|
@@ -9,7 +9,7 @@ import {
|
|
TouchableOpacity,
|
|
TouchableOpacity,
|
|
Image,
|
|
Image,
|
|
} from 'react-native';
|
|
} from 'react-native';
|
|
-import React from 'react';
|
|
|
|
|
|
+import React, { useContext, useEffect, useState } from 'react';
|
|
import { List } from 'react-native-paper';
|
|
import { List } from 'react-native-paper';
|
|
import EntypoIcon from 'react-native-vector-icons/Entypo';
|
|
import EntypoIcon from 'react-native-vector-icons/Entypo';
|
|
import { horizontalScale, moderateScale, verticalScale } from '../../constants/metrics';
|
|
import { horizontalScale, moderateScale, verticalScale } from '../../constants/metrics';
|
|
@@ -21,6 +21,8 @@ import NewscoutHomeHeader from '../../components/molecules/Header/NewscoutHomeHe
|
|
import { navigateToListViewPage, useConstructor } from '../../constants/functions';
|
|
import { navigateToListViewPage, useConstructor } from '../../constants/functions';
|
|
import { getArticlesByCategory, getCategories } from '../../api/data';
|
|
import { getArticlesByCategory, getCategories } from '../../api/data';
|
|
import { BASE_URL } from '../../api/urls';
|
|
import { BASE_URL } from '../../api/urls';
|
|
|
|
+import CustomSwitch from '../../components/atoms/Switch/CustomSwitch';
|
|
|
|
+import { ThemeContext } from '../../context/theme.context';
|
|
|
|
|
|
|
|
|
|
const SidebarPage = ({ navigation, route }) => {
|
|
const SidebarPage = ({ navigation, route }) => {
|
|
@@ -66,32 +68,39 @@ const SidebarPage = ({ navigation, route }) => {
|
|
|
|
|
|
},
|
|
},
|
|
accordionStyle: {
|
|
accordionStyle: {
|
|
- backgroundColor: colors().dominant_variant,
|
|
|
|
|
|
+ backgroundColor: colors().dominant,
|
|
borderRadius: moderateScale(8),
|
|
borderRadius: moderateScale(8),
|
|
- borderWidth: moderateScale(0),
|
|
|
|
- borderColor: colors().dominant_variant,
|
|
|
|
|
|
+ borderWidth: moderateScale(2),
|
|
|
|
+ borderColor: colors().grayShade_400,
|
|
maxHeight: verticalScale(64),
|
|
maxHeight: verticalScale(64),
|
|
},
|
|
},
|
|
accordionTextStyle: { fontFamily: fonts.type.medium, color: colors().recessive },
|
|
accordionTextStyle: { fontFamily: fonts.type.medium, color: colors().recessive },
|
|
accordionItemStyle: {
|
|
accordionItemStyle: {
|
|
backgroundColor: colors().dominant
|
|
backgroundColor: colors().dominant
|
|
},
|
|
},
|
|
- accordionItemTextStyle: {
|
|
|
|
- fontFamily: fonts.type.regular,
|
|
|
|
- color: colors().recessive
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ const theme = useContext(ThemeContext)
|
|
|
|
+ const [isDarkMode, setDarkMode] = useState(theme.state.theme === "light" ? false : true)
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (theme.state.theme === 'light') {
|
|
|
|
+ setDarkMode(false)
|
|
|
|
+ } else {
|
|
|
|
+ setDarkMode(true)
|
|
|
|
+ }
|
|
|
|
+ },[theme.state.theme])
|
|
|
|
|
|
return (
|
|
return (
|
|
<View >
|
|
<View >
|
|
<ScrollView style={{ backgroundColor: colors().dominant, minHeight: '100%' }} showsVerticalScrollIndicator={false}>
|
|
<ScrollView style={{ backgroundColor: colors().dominant, minHeight: '100%' }} showsVerticalScrollIndicator={false}>
|
|
- <NewscoutHomeHeader />
|
|
|
|
|
|
+ <NewscoutHomeHeader backButtonShown={true} onBackClick={() => navigation.toggleDrawer()} />
|
|
<View style={styles.sideBarContainer}>
|
|
<View style={styles.sideBarContainer}>
|
|
|
|
|
|
- <View style={styles.buttonContainer}>
|
|
|
|
|
|
+ {/* <View style={styles.buttonContainer}>
|
|
<CircularPrimaryBackButton onPress={() => navigation.toggleDrawer()} />
|
|
<CircularPrimaryBackButton onPress={() => navigation.toggleDrawer()} />
|
|
- </View>
|
|
|
|
|
|
+ </View> */}
|
|
|
|
|
|
|
|
|
|
<View style={styles.accordionContainer}>
|
|
<View style={styles.accordionContainer}>
|
|
@@ -104,6 +113,7 @@ const SidebarPage = ({ navigation, route }) => {
|
|
<List.Accordion
|
|
<List.Accordion
|
|
key={acc_check}
|
|
key={acc_check}
|
|
id={acc_check}
|
|
id={acc_check}
|
|
|
|
+
|
|
style={[
|
|
style={[
|
|
styles.accordionStyle,
|
|
styles.accordionStyle,
|
|
acc_check === expandedId && {
|
|
acc_check === expandedId && {
|
|
@@ -130,23 +140,16 @@ const SidebarPage = ({ navigation, route }) => {
|
|
}}
|
|
}}
|
|
left={() => (
|
|
left={() => (
|
|
<View style={{ paddingLeft: 16 }}>
|
|
<View style={{ paddingLeft: 16 }}>
|
|
- {/* <EntypoIcon
|
|
|
|
- name={item.icon}
|
|
|
|
- size={24}
|
|
|
|
- color={
|
|
|
|
- acc_check === expandedId ? colors().white : colors().recessive
|
|
|
|
- }
|
|
|
|
- /> */}
|
|
|
|
<Image
|
|
<Image
|
|
source={{ uri: BASE_URL + "/" + item.heading.icon }}
|
|
source={{ uri: BASE_URL + "/" + item.heading.icon }}
|
|
- style={{
|
|
|
|
|
|
+ style={{
|
|
height: 24,
|
|
height: 24,
|
|
width: 24,
|
|
width: 24,
|
|
- tintColor:
|
|
|
|
|
|
+ tintColor:
|
|
acc_check === expandedId ?
|
|
acc_check === expandedId ?
|
|
- colors().white :
|
|
|
|
- colors().recessive
|
|
|
|
- }}
|
|
|
|
|
|
+ colors().white :
|
|
|
|
+ colors().primaryColor
|
|
|
|
+ }}
|
|
/>
|
|
/>
|
|
</View>
|
|
</View>
|
|
)}
|
|
)}
|
|
@@ -163,13 +166,13 @@ const SidebarPage = ({ navigation, route }) => {
|
|
)}
|
|
)}
|
|
title={item.heading.name}>
|
|
title={item.heading.name}>
|
|
{item.heading.submenu.map(subTitle => (
|
|
{item.heading.submenu.map(subTitle => (
|
|
- <TouchableOpacity
|
|
|
|
|
|
+ <TouchableOpacity
|
|
onPress={
|
|
onPress={
|
|
() => {
|
|
() => {
|
|
navigation.toggleDrawer()
|
|
navigation.toggleDrawer()
|
|
- navigateToListViewPage(navigation,"category",subTitle.name)
|
|
|
|
-
|
|
|
|
- }}
|
|
|
|
|
|
+ navigateToListViewPage(navigation, "category", subTitle.name)
|
|
|
|
+
|
|
|
|
+ }}
|
|
>
|
|
>
|
|
<List.Item
|
|
<List.Item
|
|
key={`${item.title}_${subTitle.name}`}
|
|
key={`${item.title}_${subTitle.name}`}
|
|
@@ -185,8 +188,38 @@ const SidebarPage = ({ navigation, route }) => {
|
|
);
|
|
);
|
|
})}
|
|
})}
|
|
</List.AccordionGroup>
|
|
</List.AccordionGroup>
|
|
- </View>
|
|
|
|
|
|
+ <List.Item
|
|
|
|
+ style={styles.accordionStyle}
|
|
|
|
+ titleStyle={styles.accordionTextStyle}
|
|
|
|
+ title="Switch Theme"
|
|
|
|
+ left={props => <List.Icon {...props} icon="theme-light-dark" color={colors().primaryColor} />}
|
|
|
|
+ right={props => <CustomSwitch
|
|
|
|
+ onSelectSwitch={() => {
|
|
|
|
+ setDarkMode(!isDarkMode)
|
|
|
|
+ if (isDarkMode !== false){
|
|
|
|
+ theme.dispatch({ type: "LIGHTMODE" });
|
|
|
|
+ setDarkMode(false)
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ theme.dispatch({ type: "DARKMODE" });
|
|
|
|
+ setDarkMode(true)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ value={isDarkMode}
|
|
|
|
+ />}
|
|
|
|
+ />
|
|
|
|
+ <List.Item
|
|
|
|
+ style={styles.accordionStyle}
|
|
|
|
+ titleStyle={styles.accordionTextStyle}
|
|
|
|
+ title="Reader Mode"
|
|
|
|
+ left={props => <List.Icon {...props} icon="book" color={colors().primaryColor} />}
|
|
|
|
+
|
|
|
|
+ />
|
|
|
|
|
|
|
|
+ </View>
|
|
</View>
|
|
</View>
|
|
</ScrollView>
|
|
</ScrollView>
|
|
</View>
|
|
</View>
|