Skip to content

Commit

Permalink
redux implementation done
Browse files Browse the repository at this point in the history
  • Loading branch information
TomarJatin committed Oct 21, 2023
1 parent 6958acd commit b37ceb3
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 246 deletions.
6 changes: 0 additions & 6 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
Inter_300Light,
} from "@expo-google-fonts/inter";
import Route from "./navigation/home";
import { ThemeProvider } from "./contexts/ThemeContext";
import { Provider } from "react-redux";
import store from "./redux/store";
import { SaveForLaterProvider } from "./contexts/SaveForLaterContext";
import { SettingsProvider } from "./contexts/SettingsContext";
import "expo-dev-client";

function App() {
Expand All @@ -32,13 +30,9 @@ function App() {

return (
<Provider store={store}>
<ThemeProvider>
<SaveForLaterProvider>
<SettingsProvider>
<Route />
</SettingsProvider>
</SaveForLaterProvider>
</ThemeProvider>
</Provider>
);
}
Expand Down
5 changes: 2 additions & 3 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { View, Text, Dimensions, TouchableOpacity } from "react-native";
import { Entypo } from "@expo/vector-icons";
import { MaterialIcons } from '@expo/vector-icons';
import { FontAwesome } from '@expo/vector-icons';
import { FontAwesome5 } from '@expo/vector-icons';
import { useSelector } from "react-redux";
import { FontSize, color } from "../GlobalStyles";

import { useNavigation } from "@react-navigation/core";
import { ThemeContext } from "../contexts/ThemeContext";

export default function Navbar(props: { nav: string }) {
const navigation = useNavigation();
const {theme} = useContext(ThemeContext);
const theme = useSelector((state: any) => state.theme.theme);
const Color = color(theme);

return (
Expand Down
10 changes: 4 additions & 6 deletions components/Topbar.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React, { useContext } from "react";
import React from "react";
import { Text, View } from "react-native";
import { Image } from "expo-image";
import { ThemeContext } from "../contexts/ThemeContext";
import { icons } from "../styles/Icon";
import { FontSize, color } from "../GlobalStyles";
import { useNavigation } from "@react-navigation/core";
import { useSelector } from "react-redux";
import { TouchableOpacity } from "react-native-gesture-handler";
import { translations } from "../translations/main";
import { SettingsContext } from "../contexts/SettingsContext";
import { Feather } from '@expo/vector-icons';

export default function Topbar() {
const {theme} = useContext(ThemeContext);
const {language} = useContext(SettingsContext);
const theme = useSelector((state: any) => state.theme.theme);
const language = useSelector((state: any) => state.settings.language);
const Color = color(theme);
const Icons = icons(theme);
const navigation = useNavigation();
Expand Down
94 changes: 0 additions & 94 deletions contexts/SettingsContext.js

This file was deleted.

58 changes: 0 additions & 58 deletions contexts/ThemeContext.js

This file was deleted.

31 changes: 0 additions & 31 deletions contexts/VerseContext.js

This file was deleted.

56 changes: 53 additions & 3 deletions redux/slices/SettingsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,61 @@ const settingsSlice = createSlice({
initialState: {
language: "english",
commentryOn: true,
wordMeaningOn: true,
wordMeaningOn: false,
translationOn: true,
transliteration: true,
authorsList: [],
allTranslationsAuthors: [],
authorsList: [
{
author_name: "Swami Adidevananda",
language: "english",
},
{
author_name: "Swami Gambirananda",
language: "english",
},
{
author_name: "Swami Sivananda",
language: "english",
},
{
author_name: "Dr. S. Sankaranarayan",
language: "english",
},
{
author_name: "Shri Purohit Swami",
language: "english",
},
],
allTranslationsAuthors: [
{
author_name: "Swami Adidevananda",
language: "english",
},
{
author_name: "Swami Gambirananda",
language: "english",
},
{
author_name: "Swami Ramsukhdas",
language: "hindi",
},
{
author_name: "Swami Tejomayananda",
language: "hindi",
},
{
author_name: "Swami Sivananda",
language: "english",
},
{
author_name: "Dr. S. Sankaranarayan",
language: "english",
},
{
author_name: "Shri Purohit Swami",
language: "english",
},
],
},
reducers: {
setLanguage(state, action) {
Expand Down
4 changes: 2 additions & 2 deletions screens/AudioBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import Navbar from "../components/Navbar";
import { ThemeContext } from "../contexts/ThemeContext";
import { useSelector } from "react-redux";
import { FontSize, color } from "../GlobalStyles";
import { Audio } from "expo-av";
import storage from "@react-native-firebase/storage";
Expand All @@ -29,7 +29,7 @@ export default function AudioBook({ navigation }) {
const [currentPosition, setCurrentPosition] = useState<number | null>(null);
const [totalDuration, setTotalDuration] = useState<number | null>(null);
const [sliderValue, setSliderValue] = useState(0);
const { theme } = useContext(ThemeContext);
const theme = useSelector((state: any) => state.theme.theme);
const Color = color(theme);

useEffect(() => {
Expand Down
6 changes: 2 additions & 4 deletions screens/Bookmarked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ import React, { useContext } from 'react';
import { View, Text, FlatList, TouchableOpacity, Dimensions } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import Navbar from "../components/Navbar";
import { ThemeContext } from "../contexts/ThemeContext";
import { FontSize, color } from "../GlobalStyles";
import { Image } from "expo-image";
import { SaveForLaterContext } from '../contexts/SaveForLaterContext';
import { SettingsContext } from '../contexts/SettingsContext';
import { translations } from "../translations/main";
import { Entypo } from '@expo/vector-icons';
import { useDispatch, useSelector } from "react-redux";
import { setSelectedChapter } from "../redux/slices/ChapterSlice";
import { setSelectedVerse } from "../redux/slices/VerseSlice";

export default function Bookmarked({navigation}) {
const { theme } = useContext(ThemeContext);
const theme = useSelector((state: any) => state.theme.theme);
const dispatch = useDispatch();
const {saveForLater} = useContext(SaveForLaterContext);
const {language} = useContext(SettingsContext);
const language = useSelector((state: any) => state.settings.language);
const Color = color(theme);

const handleSetSelectedChapter = (chapter: any) => {
Expand Down
Loading

0 comments on commit b37ceb3

Please sign in to comment.