Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

improve settings ui

ammarahm-ed39229f7718e6
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js
index 416260bb3..5da05dc6b 100644
--- a/apps/mobile/src/components/header/index.js
+++ b/apps/mobile/src/components/header/index.js
@@ -13,6 +13,7 @@ export const Header = ({
hide,
showSearch,
menu,
+ verticalMenu = false,
sendHeight = e => {},
}) => {
const {colors} = useAppContext();
@@ -119,16 +120,18 @@ export const Header = ({
<Icon name={'search'} size={SIZE.xl} color={colors.icon} />
</TouchableOpacity>
</Animatable.View>
- <TouchableOpacity
- style={{
- justifyContent: 'center',
- alignItems: 'flex-end',
- height: 40,
- width: 60,
- paddingRight: 0,
- }}>
- <Icon name="more-vertical" size={SIZE.xl} color={colors.pri} />
- </TouchableOpacity>
+ {verticalMenu ? (
+ <TouchableOpacity
+ style={{
+ justifyContent: 'center',
+ alignItems: 'flex-end',
+ height: 40,
+ width: 60,
+ paddingRight: 0,
+ }}>
+ <Icon name="more-vertical" size={SIZE.xl} color={colors.pri} />
+ </TouchableOpacity>
+ ) : null}
</View>
</Animatable.View>
);
diff --git a/apps/mobile/src/views/AccountSettings/index.js b/apps/mobile/src/views/AccountSettings/index.js
index 2e7279f93..79a6a6082 100644
--- a/apps/mobile/src/views/AccountSettings/index.js
+++ b/apps/mobile/src/views/AccountSettings/index.js
@@ -104,27 +104,25 @@ export const AccountSettings = ({navigation}) => {
<FlatList
data={[
{
- name: 'Backup Notes',
- icon: 'database',
+ name: 'Backup',
},
{
name: 'My Devices',
- icon: 'tablet',
},
{
name: 'Vault',
- icon: 'shield',
},
-
{
name: 'My Subscription',
- icon: 'credit-card',
},
{
name: 'Change Password',
- icon: 'key',
+ },
+ {
+ name: 'Logout',
},
]}
+ keyExtractor={item => item.name}
renderItem={({item, index}) => (
<TouchableOpacity
activeOpacity={opacity}
@@ -145,37 +143,11 @@ export const AccountSettings = ({navigation}) => {
textAlignVertical: 'center',
color: colors.pri,
}}>
- <Icon name={item.icon} size={SIZE.md} />
- {' '} {item.name}
+ {item.name}
</Text>
</TouchableOpacity>
)}
/>
- <TouchableOpacity
- activeOpacity={opacity}
- style={{
- borderRadius: 5,
- width: '90%',
- marginHorizontal: '5%',
- paddingHorizontal: ph,
- paddingVertical: pv + 5,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- marginBottom: 10,
- backgroundColor: colors.accent,
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: 'white',
- }}>
- <Icon size={SIZE.lg} color="white" name="log-out" />
- {' '}
- Logout
- </Text>
- </TouchableOpacity>
</AnimatedSafeAreaView>
);
};
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 2eb97a980..3120276e0 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -11,7 +11,6 @@ import {COLOR_SCHEME, opacity, pv, br, SIZE, WEIGHT} from '../../common/common';
import {Search} from '../../components/SearchInput';
import {w, h, SideMenuEvent, getElevation} from '../../utils/utils';
import {Header} from '../../components/header';
-import {NavigationEvents} from 'react-navigation';
import {NotesList} from '../../components/NotesList';
import {db} from '../../../App';
import Icon from 'react-native-vector-icons/Feather';
@@ -30,7 +29,6 @@ export const Home = ({navigation}) => {
const [search, setSearch] = useState(false);
const [text, setText] = useState('');
- const [update, setUpdate] = useState(0);
const [hideHeader, setHideHeader] = useState(false);
const [margin, setMargin] = useState(180);
const [buttonHide, setButtonHide] = useState(false);
@@ -41,9 +39,6 @@ export const Home = ({navigation}) => {
let offsetY = 0;
let countUp = 1;
let countDown = 0;
- let headerHeight = 0;
- let searchHeight = 0;
- let marginSet = false;
let searchResults = null;
let allNotes = [];
@@ -55,7 +50,6 @@ export const Home = ({navigation}) => {
useEffect(() => {
if (!isFocused) return;
-
fetchNotes();
}, [isFocused]);
@@ -147,11 +141,6 @@ export const Home = ({navigation}) => {
style={{
height: '100%',
}}>
- <NavigationEvents
- onWillFocus={() => {
- setUpdate(update + 1);
- }}
- />
<Animatable.View
transition="backgroundColor"
duration={300}
@@ -162,8 +151,9 @@ export const Home = ({navigation}) => {
width: '100%',
}}>
<Header
- menu={true}
+ menu
hide={hideHeader}
+ verticalMenu
showSearch={() => {
setHideHeader(false);
countUp = 0;
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index e41819b97..537b46de1 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -7,7 +7,17 @@ import {
Dimensions,
} from 'react-native';
import NavigationService from '../../services/NavigationService';
-import {SIZE, br, ph, pv, opacity, FONT, WEIGHT} from '../../common/common';
+import {
+ SIZE,
+ br,
+ ph,
+ pv,
+ opacity,
+ FONT,
+ WEIGHT,
+ COLOR_SCHEME_DARK,
+ COLOR_SCHEME_LIGHT,
+} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
import {Header} from '../../components/header';
import {FlatList} from 'react-native-gesture-handler';
@@ -19,7 +29,7 @@ const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Settings = ({navigation}) => {
- const {colors, changeAccentColor} = useAppContext();
+ const {colors, changeAccentColor, changeColorScheme} = useAppContext();
return (
<AnimatedSafeAreaView
transition="backgroundColor"
@@ -39,66 +49,136 @@ export const Settings = ({navigation}) => {
<FlatList
data={[
{
- name: 'Sync',
- icon: 'refresh-ccw',
- switch: true,
+ name: 'General',
+ func: () => {},
+ },
+ {
+ name: 'Account',
+ func: () => {
+ NavigationService.navigate('AccountSettings');
+ },
+ },
+ {
+ name: 'Theme',
+ customComponent: (
+ <View>
+ <ScrollView
+ contentContainerStyle={{
+ flexDirection: 'row',
+ flexWrap: 'wrap',
+ marginTop: 10,
+ marginHorizontal: 20,
+ }}>
+ {[
+ '#e6194b',
+ '#3cb44b',
+ '#ffe119',
+ '#0560FF',
+ '#f58231',
+ '#911eb4',
+ '#46f0f0',
+ '#f032e6',
+ '#bcf60c',
+ '#fabebe',
+ ].map(item => (
+ <TouchableOpacity
+ onPress={() => {
+ changeAccentColor(item);
+
+ AsyncStorage.setItem('accentColor', item);
+ }}
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'flex-start',
+ alignItems: 'center',
+ marginRight: 10,
+ marginVertical: 5,
+ }}>
+ <View
+ style={{
+ width: 45,
+ height: 45,
+ backgroundColor: item,
+ borderRadius: 100,
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ {colors.accent === item ? (
+ <Icon size={SIZE.lg} color="white" name="check" />
+ ) : null}
+ </View>
+ </TouchableOpacity>
+ ))}
+ </ScrollView>
+ <TouchableOpacity
+ onPress={() => {
+ if (!colors.night) {
+ AsyncStorage.setItem(
+ 'theme',
+ JSON.stringify(COLOR_SCHEME_DARK),
+ );
+ changeColorScheme(COLOR_SCHEME_DARK);
+ } else {
+ AsyncStorage.setItem(
+ 'theme',
+ JSON.stringify(COLOR_SCHEME_LIGHT),
+ );
+
+ changeColorScheme(COLOR_SCHEME_LIGHT);
+ }
+ }}
+ activeOpacity={opacity}
+ style={{
+ width: '85%',
+ marginHorizontal: '5%',
+ paddingVertical: pv + 10,
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ }}>
+ <Text
+ style={{
+ fontSize: SIZE.sm + 1,
+ fontFamily: WEIGHT.regular,
+ textAlignVertical: 'center',
+ color: colors.pri,
+ }}>
+ Dark Mode
+ </Text>
+ <Icon
+ size={SIZE.md}
+ color={colors.night ? colors.accent : colors.icon}
+ name={colors.night ? 'toggle-right' : 'toggle-left'}
+ />
+ </TouchableOpacity>
+ </View>
+ ),
+ },
+ {
+ name: 'Terms of Service',
+ func: () => {},
},
{
- name: 'Dark Mode',
- icon: 'moon',
- switch: true,
+ name: 'Privacy Policy',
+ func: () => {},
},
{
- name: 'Sunset to Sunrise',
- icon: null,
- switch: true,
- step: true,
+ name: 'About',
+ func: () => {},
},
]}
- ListHeaderComponent={
- <View>
- <TouchableOpacity
- activeOpacity={opacity}
- onPress={() => {
- NavigationService.navigate('AccountSettings');
- }}
- style={{
- borderWidth: 1,
- borderRadius: 5,
- width: '90%',
- marginHorizontal: '5%',
- paddingHorizontal: ph,
- borderColor: colors.nav,
- paddingVertical: pv + 5,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- marginBottom: 10,
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: colors.pri,
- }}>
- My Account
- </Text>
- </TouchableOpacity>
- </View>
- }
+ keyExtractor={item => item.name}
renderItem={({item, index}) => (
<TouchableOpacity
activeOpacity={opacity}
+ onPress={item.func}
style={{
borderBottomWidth: 1,
width: item.step ? '85%' : '90%',
marginHorizontal: '5%',
borderBottomColor: colors.nav,
paddingVertical: pv + 5,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
marginLeft: item.step ? '10%' : '5%',
}}>
<Text
@@ -108,158 +188,12 @@ export const Settings = ({navigation}) => {
textAlignVertical: 'center',
color: colors.pri,
}}>
- <Icon name={item.icon} size={SIZE.md} color={colors.icon} />
- {' '} {item.name}
+ {item.name}
</Text>
- {item.switch ? (
- <Icon
- name="toggle-right"
- color={colors.icon}
- size={item.step ? SIZE.sm : SIZE.md}
- />
- ) : null}
+ {item.customComponent ? item.customComponent : null}
</TouchableOpacity>
)}
/>
-
- <View
- style={{
- borderBottomWidth: 1,
- width: '90%',
- marginHorizontal: '5%',
- borderBottomColor: colors.nav,
- paddingVertical: pv + 5,
-
- justifyContent: 'space-between',
- alignItems: 'flex-start',
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: colors.pri,
- }}>
- Accent Color
- </Text>
-
- <ScrollView
- contentContainerStyle={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- marginTop: 10,
- marginHorizontal: 20,
- }}>
- {[
- '#e6194b',
- '#3cb44b',
- '#ffe119',
- '#0560FF',
- '#f58231',
- '#911eb4',
- '#46f0f0',
- '#f032e6',
- '#bcf60c',
- '#fabebe',
- ].map(item => (
- <TouchableOpacity
- onPress={() => {
- changeAccentColor(item);
-
- AsyncStorage.setItem('accentColor', item);
- }}
- style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
- marginRight: 10,
- marginVertical: 5,
- }}>
- <View
- style={{
- width: 45,
- height: 45,
- backgroundColor: item,
- borderRadius: 100,
- justifyContent: 'center',
- alignItems: 'center',
- }}>
- {colors.accent === item ? (
- <Icon size={SIZE.lg} color="white" name="check" />
- ) : null}
- </View>
- </TouchableOpacity>
- ))}
- </ScrollView>
- </View>
-
- <TouchableOpacity
- activeOpacity={opacity}
- style={{
- borderBottomWidth: 1,
- width: '90%',
- marginHorizontal: '5%',
- borderBottomColor: colors.nav,
- paddingVertical: pv + 5,
- flexDirection: 'row',
-
- justifyContent: 'space-between',
- alignItems: 'center',
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: colors.pri,
- }}>
- Terms of Service
- </Text>
- </TouchableOpacity>
-
- <TouchableOpacity
- activeOpacity={opacity}
- style={{
- borderBottomWidth: 1,
- width: '90%',
- marginHorizontal: '5%',
- borderBottomColor: colors.nav,
- paddingVertical: pv + 5,
- flexDirection: 'row',
-
- justifyContent: 'space-between',
- alignItems: 'center',
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: colors.pri,
- }}>
- Privacy Policy
- </Text>
- </TouchableOpacity>
-
- <TouchableOpacity
- activeOpacity={opacity}
- style={{
- borderBottomWidth: 1,
- width: '90%',
- marginHorizontal: '5%',
- borderBottomColor: colors.nav,
- paddingVertical: pv + 5,
- flexDirection: 'row',
-
- justifyContent: 'space-between',
- alignItems: 'center',
- }}>
- <Text
- style={{
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- color: colors.pri,
- }}>
- About Notes.
- </Text>
- </TouchableOpacity>
</View>
</AnimatedSafeAreaView>
);