A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
layout basic settings
ammarahm-ed6ad63e2d3447
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.jsindex 5a2a62d33..bda375480 100644--- a/apps/mobile/src/components/header/index.js+++ b/apps/mobile/src/components/header/index.js@@ -1,18 +1,15 @@import React, { useEffect, useState } from 'react';import { Platform, StyleSheet, View } from 'react-native';import { useSafeAreaInsets } from 'react-native-safe-area-context';-import { useThemeStore } from '../../stores/theme';import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';-import SearchService from '../../services/search';+import { useThemeStore } from '../../stores/theme';import { eScrollEvent } from '../../utils/events';-import { IconButton } from '../ui/icon-button';-import { SearchInput } from '../SearchInput';import { LeftMenus } from './left-menus';import { RightMenus } from './right-menus';import { Title } from './title';export const Header = React.memo(- ({ root, title, screen, isBack, color, action, rightButtons, notebook }) => {+ ({ root, title, screen, isBack, color, action, rightButtons, notebook, onBackPress }) => {const colors = useThemeStore(state => state.colors);const insets = useSafeAreaInsets();const [hide, setHide] = useState(true);@@ -48,7 +45,7 @@ export const Header = React.memo(]}><View style={styles.leftBtnContainer}>- <LeftMenus headerMenuState={!isBack} currentScreen={screen} />+ <LeftMenus onBackPress={onBackPress} headerMenuState={!isBack} currentScreen={screen} /><Titlenotebook={notebook}diff --git a/apps/mobile/src/components/header/leftmenus.js b/apps/mobile/src/components/header/leftmenus.jsindex 8a374c2f0..e7a9f3803 100644--- a/apps/mobile/src/components/header/leftmenus.js+++ b/apps/mobile/src/components/header/leftmenus.js@@ -6,11 +6,12 @@ import { DDS } from '../../services/device-detection';import Navigation from '../../services/navigation';import { IconButton } from '../ui/icon-button';-export const LeftMenus = ({ currentScreen, headerMenuState }) => {+export const LeftMenus = ({ currentScreen, headerMenuState, onBackPress }) => {const colors = useThemeStore(state => state.colors);const deviceMode = useSettingStore(state => state.deviceMode);const onLeftButtonPress = () => {+ if (onBackPress) return onBackPress();if (headerMenuState) {Navigation.openDrawer();return;diff --git a/apps/mobile/src/components/header/rightmenus.js b/apps/mobile/src/components/header/rightmenus.jsindex 28f8d6752..9e657ef36 100644--- a/apps/mobile/src/components/header/rightmenus.js+++ b/apps/mobile/src/components/header/rightmenus.js@@ -15,7 +15,7 @@ export const RightMenus = ({ currentScreen, action, rightButtons }) => {const menuRef = useRef();return (<View style={styles.rightBtnContainer}>- {currentScreen !== 'Settings' ? (+ {!currentScreen.startsWith('Settings') ? (<IconButtononPress={async () => {Navigation.navigate('Search', {diff --git a/apps/mobile/src/components/sidemenu/index.js b/apps/mobile/src/components/sidemenu/index.jsindex 616cb820e..fde61a0a4 100644--- a/apps/mobile/src/components/sidemenu/index.js+++ b/apps/mobile/src/components/sidemenu/index.js@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';import { FlatList, View } from 'react-native';import { useSafeAreaInsets } from 'react-native-safe-area-context';import { notesnook } from '../../../e2e/test.ids';+import Settings from '../../screens/settings';import { DDS } from '../../services/device-detection';import { eSendEvent } from '../../services/event-manager';import { useSettingStore, useUserStore } from '../../stores/stores';diff --git a/apps/mobile/src/components/sidemenu/menuitem.js b/apps/mobile/src/components/sidemenu/menuitem.jsindex 28f310433..1007b64d3 100644--- a/apps/mobile/src/components/sidemenu/menuitem.js+++ b/apps/mobile/src/components/sidemenu/menuitem.js@@ -19,6 +19,7 @@ export const MenuItem = React.memo(const _onPress = event => {if (item.func) {+ console.log('item.func called');item.func();} else {Navigation.navigate(diff --git a/apps/mobile/src/navigation/navigationstack.js b/apps/mobile/src/navigation/navigationstack.jsindex 4d515727b..2d5b87842 100644--- a/apps/mobile/src/navigation/navigationstack.js+++ b/apps/mobile/src/navigation/navigationstack.js@@ -83,8 +83,8 @@ export const NavigationStack = React.memo(<Stack.Screen name="NotesPage" component={Notes} /><Stack.Screen name="Tags" component={Tags} /><Stack.Screen name="Notebook" component={Notebook} />- <Stack.Screen name="Settings" component={Settings} /><Stack.Screen name="Search" component={Search} />+ <Stack.Screen name="Settings" component={Settings} /></Stack.Navigator>) : null}</NavigationContainer>diff --git a/apps/mobile/src/navigation/tabsholder.js b/apps/mobile/src/navigation/tabsholder.jsindex fda0c77ba..0539dcfa5 100644--- a/apps/mobile/src/navigation/tabsholder.js+++ b/apps/mobile/src/navigation/tabsholder.js@@ -26,6 +26,7 @@ import { editorRef, tabBarRef } from '../utils/global-refs';import { hideAllTooltips } from '../utils/hooks/use-tooltip';import { sleep } from '../utils/time';import { NavigationStack } from './navigation-stack';+import Settings from '../screens/settings';let layoutTimer = null;@@ -335,6 +336,7 @@ export const TabsHolder = React.memo(><StatusBar animated={true} barStyle={colors.night ? 'light-content' : 'dark-content'} /><NavigationBar barStyle={colors.night ? 'light-content' : 'dark-content'} />+{deviceMode ? (<Tabsref={tabBarRef}diff --git a/apps/mobile/src/screens/settings/appearance.js b/apps/mobile/src/screens/settings/appearance.jsindex e01cb1ffc..2ffb23410 100644--- a/apps/mobile/src/screens/settings/appearance.js+++ b/apps/mobile/src/screens/settings/appearance.js@@ -212,7 +212,7 @@ const SettingsAppearanceSection = () => {);};-export const AccentColorPicker = ({ settings = true }) => {+export const AccentColorPicker = ({ settings = true, wrap = false }) => {const colors = useThemeStore(state => state.colors);function changeAccentColor(color) {switchAccentColor(color);@@ -234,9 +234,9 @@ export const AccentColorPicker = ({ settings = true }) => {borderRadius: 5,padding: 5,marginTop: 10,- marginBottom: pv + 5,+ marginBottom: wrap ? 0 : pv + 5,width: '100%',- paddingHorizontal: 12,+ paddingHorizontal: wrap ? 0 : 12,maxWidth: settings ? null : '100%'}}scrollEnabled={true}@@ -244,7 +244,10 @@ export const AccentColorPicker = ({ settings = true }) => {contentContainerStyle={{alignSelf: 'center',flexDirection: 'row',- flexWrap: 'wrap'+ flexWrap: 'wrap',+ maxWidth: wrap ? '100%' : null,+ alignContent: wrap && 'flex-start',+ justifyContent: wrap && 'flex-start'}}>{[diff --git a/apps/mobile/src/screens/settings/group.tsx b/apps/mobile/src/screens/settings/group.tsxnew file mode 100644index 000000000..ca8e8467b--- /dev/null+++ b/apps/mobile/src/screens/settings/group.tsx@@ -0,0 +1,31 @@+import { NativeStackScreenProps } from '@react-navigation/native-stack';+import React from 'react';+import { FlatList, View } from 'react-native';+import { ContainerHeader } from '../../components/container/containerheader';+import { Header } from '../../components/header';+import { SectionItem } from './section-item';+import { RouteParams, SettingSection } from './types';++const Group = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettingsGroup'>) => {+ const renderItem = ({ item, index }: { item: SettingSection; index: number }) => (+ <SectionItem item={item} />+ );++ return (+ <View>+ <ContainerHeader>+ <Header title={route.params.name} isBack={true} screen={route.name} />+ </ContainerHeader>++ {route.params.sections ? (+ <FlatList+ data={route.params.sections}+ keyExtractor={(item, index) => item.name || index.toString()}+ renderItem={renderItem}+ />+ ) : null}+ </View>+ );+};++export default Group;diff --git a/apps/mobile/src/screens/settings/home.tsx b/apps/mobile/src/screens/settings/home.tsxnew file mode 100644index 000000000..b330f5931--- /dev/null+++ b/apps/mobile/src/screens/settings/home.tsx@@ -0,0 +1,218 @@+import { NativeStackScreenProps } from '@react-navigation/native-stack';+import React from 'react';+import { FlatList, Linking, View } from 'react-native';+import { APP_VERSION } from '../../../version';+import { ContainerHeader } from '../../components/container/containerheader';+import { Header } from '../../components/header';+import { Issue } from '../../components/sheets/github/issue';+import { presentSheet } from '../../services/event-manager';+import { useSettingStore } from '../../stores/stores';+import { useThemeStore } from '../../stores/theme';+import { openLinkInBrowser } from '../../utils/functions';+import { SectionGroup } from './section-group';+import { RouteParams, SettingSection } from './types';+const format = (ver: number) => {+ let parts = ver.toString().split('');+ return `v${parts[0]}.${parts[1]}.${parts[2]?.startsWith('0') ? '' : parts[2]}${+ !parts[3] ? '' : parts[3]+ } `;+};++const groups: SettingSection[] = [+ {+ name: 'Customize',+ sections: [+ {+ type: 'screen',+ name: 'Theme',+ description: 'Change app look and feel',+ icon: 'shape',+ sections: [+ {+ type: 'component',+ name: 'Accent color',+ description: 'Pick the color that matches your mood',+ component: 'colorpicker'+ },+ {+ type: 'switch',+ name: 'Follow system theme',+ description: 'Automatically switch to dark mode when system theme changes',+ property: 'useSystemTheme',+ icon: 'circle-half'+ },+ {+ type: 'switch',+ name: 'Dark mode',+ description: 'Strain your eyes no more at night',+ property: 'theme',+ icon: 'brightness-6',+ modifer: () => {+ let current = { ...useSettingStore.getState().settings.theme };+ current.dark = !current.dark;+ return {+ theme: current+ };+ },+ getter: () => useSettingStore.getState().settings.theme.dark+ },+ {+ type: 'switch',+ name: 'Pitch black',+ description: 'Save battery on device with amoled screen at night.',+ property: 'pitchBlack',+ icon: 'brightness-1'+ }+ ]+ },+ {+ type: 'screen',+ name: 'Behaviour',+ description: 'Change app homepage'+ }+ ]+ },+ {+ name: 'Privacy and security',+ sections: [+ {+ type: 'switch',+ name: 'Telemetry',+ icon: 'radar',+ description:+ 'Contribute towards a better Notesnook. All tracking information is anonymous.',+ property: 'telemetry'+ },+ {+ type: 'screen',+ name: 'Vault'+ },+ {+ type: 'screen',+ name: 'App lock'+ }+ ]+ }+];++const Home = ({ navigation }: NativeStackScreenProps<RouteParams, 'SettingsHome'>) => {+ const colors = useThemeStore(state => state.colors);++ const otherItems = [+ {+ name: 'Terms of service',+ func: async () => {+ try {+ await openLinkInBrowser('https://notesnook.com/tos', colors);+ } catch (e) {}+ },+ desc: 'Read our terms of service'+ },+ {+ name: 'Privacy policy',+ func: async () => {+ try {+ await openLinkInBrowser('https://notesnook.com/privacy', colors);+ } catch (e) {}+ },+ desc: 'Read our privacy policy'+ },+ {+ name: `Report an issue`,+ func: async () => {+ presentSheet({+ component: <Issue />+ });+ },+ desc: `Faced an issue or have a suggestion? Click here to create a bug report`+ },+ {+ name: 'Join our Telegram group',+ desc: "We are on telegram, let's talk",+ func: () => {+ Linking.openURL('https://t.me/notesnook').catch(console.log);+ }+ },+ {+ name: 'Join our Discord community',+ func: async () => {+ presentSheet({+ title: 'Join our Discord Community',+ iconColor: 'discord',+ paragraph: 'We are not ghosts, chat with us and share your experience.',+ valueArray: [+ 'Talk with us anytime.',+ 'Follow the development process',+ 'Give suggestions and report issues.',+ 'Get early access to new features',+ 'Meet other people using Notesnook'+ ],+ icon: 'discord',+ action: async () => {+ try {+ Linking.openURL('https://discord.gg/zQBK97EE22').catch(console.log);+ } catch (e) {}+ },+ actionText: 'Join Now'+ });+ },+ desc: 'We are not ghosts, chat with us and share your experience.'+ },+ {+ name: 'Download on desktop',+ func: async () => {+ try {+ await openLinkInBrowser('https://notesnook.com', colors);+ } catch (e) {}+ },+ desc: 'Notesnook app can be downloaded on all platforms'+ },+ {+ name: 'Documentation',+ func: async () => {+ try {+ await openLinkInBrowser('https://docs.notesnook.com', colors);+ } catch (e) {}+ },+ desc: 'Learn about every feature and how it works.'+ },+ {+ name: 'Roadmap',+ func: async () => {+ try {+ await openLinkInBrowser('https://docs.notesnook.com/roadmap/', colors);+ } catch (e) {}+ },+ desc: 'See what the future of Notesnook is going to be like.'+ },+ {+ name: 'About Notesnook',+ func: async () => {+ try {+ await openLinkInBrowser('https://notesnook.com', colors);+ } catch (e) {}+ },+ desc: format(APP_VERSION)+ }+ ];++ const renderItem = ({ item, index }: { item: SettingSection; index: number }) => (+ <SectionGroup item={item} />+ );++ return (+ <View>+ <ContainerHeader>+ <Header title="Settings" isBack={true} screen="Settings" />+ </ContainerHeader>++ <FlatList+ data={groups}+ keyExtractor={(item, index) => item.name || index.toString()}+ renderItem={renderItem}+ />+ </View>+ );+};++export default Home;diff --git a/apps/mobile/src/screens/settings/index.js b/apps/mobile/src/screens/settings/index.jsindex fb115de8d..129c3fce4 100644--- a/apps/mobile/src/screens/settings/index.js+++ b/apps/mobile/src/screens/settings/index.js@@ -1,300 +1,55 @@-import React, { useCallback, useEffect, useState } from 'react';-import { Linking, Platform, ScrollView, View } from 'react-native';-import { APP_VERSION } from '../../../version';-import { Button as MButton } from '../../components/ui/button/index';-import { ContainerHeader } from '../../components/container/containerheader';-import { Issue } from '../../components/sheets/github/issue';-import { Header as TopHeader } from '../../components/header/index';-import Seperator from '../../components/ui/seperator';-import Paragraph from '../../components/ui/typography/paragraph';+import { createNativeStackNavigator } from '@react-navigation/native-stack';+import React from 'react';import { useThemeStore } from '../../stores/theme';-import { eSendEvent, presentSheet } from '../../services/event-manager';-import Navigation from '../../services/navigation';-import { InteractionManager } from '../../utils';-import { STORE_LINK } from '../../utils/constants';-import { eScrollEvent, eUpdateSearchState } from '../../utils/events';-import { openLinkInBrowser } from '../../utils/functions';-import SettingsAppearanceSection from './appearance';-import SettingsBackupAndRestore from './backup-restore';-import { CustomButton } from './button';-import SettingsDeveloperOptions from './developeroptions';-import SettingsGeneralOptions from './general';-import AccoutLogoutSection from './logout';-import SettingsPrivacyAndSecurity from './privacy';-import SectionHeader from './section-header';-import SettingsUserSection from './user-section';-import TwoFactorAuth from './2fa';+import Group from './group';+import Home from './home';-const format = ver => {- let parts = ver.toString().split('');- return `v${parts[0]}.${parts[1]}.${parts[2]?.startsWith('0') ? '' : parts[2]}${- !parts[3] ? '' : parts[3]- } `;-};+const SettingsStack = createNativeStackNavigator();-export const Settings = ({ navigation }) => {+export const Settings = () => {const colors = useThemeStore(state => state.colors);- const [collapsed, setCollapsed] = useState(false);-- let pageIsLoaded = false;-- const onFocus = useCallback(() => {- eSendEvent(eUpdateSearchState, {- placeholder: '',- data: [],- noSearch: true,- type: '',- color: null- });-- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }- Navigation.setHeaderState(- 'Settings',- {- menu: true- },- {- heading: 'Settings',- id: 'settings_navigation'- }- );- }, []);-- // const checkAppUpdateAvailable = async () => {- // try {- // const version = await checkVersion();- // if (!version.needsUpdate) {- // ToastEvent.show({- // heading: 'You are on the latest version',- // type: 'success'- // });- // return false;- // }- // presentSheet({- // noIcon: true,- // noProgess: true,- // component: ref => <Update version={version} fwdRef={ref} />- // });- // return true;- // } catch (e) {- // ToastEvent.show({- // heading: 'You are on the latest version',- // type: 'success'- // });- // return false;- // }- // };-- useEffect(() => {- InteractionManager.runAfterInteractions(() => {- navigation.addListener('focus', onFocus);- });-- return () => {- pageIsLoaded = false;- navigation.removeListener('focus', onFocus);- };- }, []);-- const otherItems = [- {- name: 'Terms of service',- func: async () => {- try {- await openLinkInBrowser('https://notesnook.com/tos', colors);- } catch (e) {}- },- desc: 'Read our terms of service'- },- {- name: 'Privacy policy',- func: async () => {- try {- await openLinkInBrowser('https://notesnook.com/privacy', colors);- } catch (e) {}- },- desc: 'Read our privacy policy'- },- {- name: `Report an issue`,- func: async () => {- presentSheet({- component: <Issue />- });- },- desc: `Faced an issue or have a suggestion? Click here to create a bug report`- },- {- name: 'Join our Telegram group',- desc: "We are on telegram, let's talk",- func: () => {- Linking.openURL('https://t.me/notesnook').catch(console.log);- }- },- {- name: 'Join our Discord community',- func: async () => {- presentSheet({- title: 'Join our Discord Community',- iconColor: 'discord',- paragraph: 'We are not ghosts, chat with us and share your experience.',- valueArray: [- 'Talk with us anytime.',- 'Follow the development process',- 'Give suggestions and report issues.',- 'Get early access to new features',- 'Meet other people using Notesnook'- ],- icon: 'discord',- action: async () => {- try {- Linking.openURL('https://discord.gg/zQBK97EE22').catch(console.log);- } catch (e) {}- },- actionText: 'Join Now'- });- },- desc: 'We are not ghosts, chat with us and share your experience.'- },- {- name: 'Download on desktop',- func: async () => {- try {- await openLinkInBrowser('https://notesnook.com', colors);- } catch (e) {}- },- desc: 'Notesnook app can be downloaded on all platforms'- },- {- name: 'Documentation',- func: async () => {- try {- await openLinkInBrowser('https://docs.notesnook.com', colors);- } catch (e) {}- },- desc: 'Learn about every feature and how it works.'- },- {- name: 'Roadmap',- func: async () => {- try {- await openLinkInBrowser('https://docs.notesnook.com/roadmap/', colors);- } catch (e) {}- },- desc: 'See what the future of Notesnook is going to be like.'- },- {- name: 'About Notesnook',- func: async () => {- try {- await openLinkInBrowser('https://notesnook.com', colors);- } catch (e) {}- },- desc: format(APP_VERSION)- }- ];-return (- <>- <ContainerHeader>- <TopHeader title="Settings" isBack={false} screen="Settings" />- </ContainerHeader>- <View- style={{- height: '100%',+ <SettingsStack.Navigator+ initialRouteName="SettingsHome"+ screenOptions={{+ animation: 'none',+ headerShown: false,+ contentStyle: {backgroundColor: colors.bg- }}- >- <ScrollView- onScroll={e =>- eSendEvent(eScrollEvent, {- y: e.nativeEvent.contentOffset.y,- screen: 'Settings'- })- }- testID="scrollview"- scrollEventThrottle={1}- style={{- paddingHorizontal: 0- }}- >- <SettingsUserSection />-- <SettingsAppearanceSection />-- {Platform.OS === 'android' ? <SettingsGeneralOptions /> : null}-- <SettingsPrivacyAndSecurity />-- <SettingsBackupAndRestore />-- <SettingsDeveloperOptions />-- <SectionHeader collapsed={collapsed} setCollapsed={setCollapsed} title="Other" />-- {!collapsed && (- <>- <View- style={{- borderRadius: 5,- paddingVertical: 10,- width: '95%',- alignItems: 'center',- paddingHorizontal: 12,- marginTop: 10,- backgroundColor: colors.nav,- alignSelf: 'center'- }}- >- <Paragraph- style={{- flexWrap: 'wrap',- flexBasis: 1,- textAlign: 'center'- }}- color={colors.pri}- >- It took us a year to bring Notesnook to you. Help us make it better by rating it- on {Platform.OS === 'ios' ? 'Appstore' : 'Playstore'}- </Paragraph>- <Seperator />- <MButton- type="accent"- width="100%"- title={`Rate us on ${Platform.OS === 'ios' ? 'Appstore' : 'Playstore'}`}- onPress={async () => {- try {- await Linking.openURL(STORE_LINK);- } catch (e) {}- }}- />- </View>+ }+ }}+ >+ <SettingsStack.Screen name="SettingsHome" component={Home} />+ <SettingsStack.Screen name="SettingsGroup" component={Group} />+ </SettingsStack.Navigator>+ );+};- {otherItems.map(item => (- <CustomButton- key={item.name}- title={item.name}- tagline={item.desc}- onPress={item.func}- />- ))}- </>- )}+export default Settings;- <AccoutLogoutSection />+/**+ *+ *+ *<Viewstyle={{- height: 400+ height: '100%',+ backgroundColor: colors.bg}}- />- </ScrollView>- </View>- </>- );-};--export default Settings;+ >+ <ScrollView+ onScroll={e =>+ eSendEvent(eScrollEvent, {+ y: e.nativeEvent.contentOffset.y,+ screen: 'Settings'+ })+ }+ testID="scrollview"+ scrollEventThrottle={1}+ style={{+ paddingHorizontal: 0+ }}+ ></ScrollView>+ </View>+ */diff --git a/apps/mobile/src/screens/settings/sectiongroup.tsx b/apps/mobile/src/screens/settings/sectiongroup.tsxnew file mode 100644index 000000000..3b02459da--- /dev/null+++ b/apps/mobile/src/screens/settings/sectiongroup.tsx@@ -0,0 +1,34 @@+import React from 'react';+import { View } from 'react-native';+import Heading from '../../components/ui/typography/heading';+import { useThemeStore } from '../../stores/theme';+import { SIZE } from '../../utils/size';+import { SectionItem } from './section-item';+import { SettingSection } from './types';++export const SectionGroup = ({ item }: { item: SettingSection }) => {+ const colors = useThemeStore(state => state.colors);+ return (+ <View+ style={{+ marginVertical: item.sections ? 10 : 0+ }}+ >+ {item.name && item.sections ? (+ <Heading+ style={{+ paddingHorizontal: 12+ }}+ color={colors.icon}+ size={SIZE.sm}+ >+ {item.name}+ </Heading>+ ) : null}++ {item.sections?.map(item => (+ <SectionItem key={item.name} item={item} />+ ))}+ </View>+ );+};diff --git a/apps/mobile/src/screens/settings/sectionitem.tsx b/apps/mobile/src/screens/settings/sectionitem.tsxnew file mode 100644index 000000000..707badc61--- /dev/null+++ b/apps/mobile/src/screens/settings/sectionitem.tsx@@ -0,0 +1,104 @@+import { NavigationProp, useNavigation } from '@react-navigation/native';+import React, { ReactElement } from 'react';+import { View } from 'react-native';+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import ToggleSwitch from 'toggle-switch-react-native';+import { PressableButton } from '../../components/ui/pressable';+import Paragraph from '../../components/ui/typography/paragraph';+import SettingsService from '../../services/settings';+import { useSettingStore } from '../../stores/stores';+import { useThemeStore } from '../../stores/theme';+import { SIZE } from '../../utils/size';+import { AccentColorPicker } from './appearance';+import { RouteParams, SettingSection } from './types';++const components: { [name: string]: ReactElement } = {+ colorpicker: <AccentColorPicker wrap={true} />+};++export const SectionItem = ({ item }: { item: SettingSection }) => {+ const colors = useThemeStore(state => state.colors);+ const settings = useSettingStore(state => state.settings);+ const navigation = useNavigation<NavigationProp<RouteParams>>();++ const onChangeSettings = () => {+ if (!item.property) return;+ SettingsService.set(+ item.modifer+ ? item.modifer(item.property)+ : {+ [item.property]: !settings[item.property]+ }+ );+ };+ return (+ <PressableButton+ key={item.name}+ disabled={item.type === 'component'}+ customStyle={{+ width: '100%',+ alignItems: 'center',+ padding: 12,+ flexDirection: 'row',+ justifyContent: 'space-between',+ paddingVertical: 20+ }}+ onPress={() => {+ switch (item.type) {+ case 'screen':+ navigation.navigate('SettingsGroup', item);+ break;+ case 'switch':+ onChangeSettings();+ break;+ }+ }}+ >+ <View+ style={{+ flexDirection: 'row',+ flexShrink: 1+ }}+ >+ <View+ style={{+ width: 40,+ height: 40,+ justifyContent: 'center',+ alignItems: 'center',+ marginRight: 12,+ backgroundColor: item.component === 'colorpicker' ? colors.accent : undefined,+ borderRadius: 100+ }}+ >+ {!!item.icon && <Icon name={item.icon} size={30} />}+ </View>++ <View+ style={{+ flexShrink: 1,+ paddingRight: item.type === 'switch' ? 10 : 0+ }}+ >+ <Paragraph color={colors.heading} size={SIZE.md + 1}>+ {item.name}+ </Paragraph>+ <Paragraph size={SIZE.sm}>{item.description}</Paragraph>++ {!!item.component && components[item.component]}+ </View>+ </View>++ {item.type === 'switch' && item.property && (+ <ToggleSwitch+ isOn={item.getter ? item.getter(item.property) : settings[item.property]}+ onColor={colors.accent}+ offColor={colors.icon}+ size="small"+ animationSpeed={150}+ onToggle={onChangeSettings}+ />+ )}+ </PressableButton>+ );+};diff --git a/apps/mobile/src/screens/settings/types.ts b/apps/mobile/src/screens/settings/types.tsnew file mode 100644index 000000000..8ffac7dcf--- /dev/null+++ b/apps/mobile/src/screens/settings/types.ts@@ -0,0 +1,23 @@+import { Settings } from '../../stores/interfaces';++export type SettingSection = {+ type?: 'screen' | 'switch' | 'component';+ name?: string;+ description?: string;+ icon?: string;+ property?: keyof Settings;+ sections?: SettingSection[];+ component?: string;+ modifer?: (property: keyof Settings) => Partial<Settings>;+ getter?: (property: keyof Settings) => any;+};++export type SettingsGroup = {+ name: string;+ sections: SettingSection[];+};++export type RouteParams = {+ SettingsHome: undefined;+ SettingsGroup: SettingSection;+};diff --git a/apps/mobile/src/stores/interfaces.ts b/apps/mobile/src/stores/interfaces.tsindex 1f82a9644..07920e2ab 100644--- a/apps/mobile/src/stores/interfaces.ts+++ b/apps/mobile/src/stores/interfaces.ts@@ -81,7 +81,7 @@ export type Settings = {recoveryKeySaved?: boolean;theme: {accent: string;- dark: false;+ dark: boolean;};backupDirectoryAndroid?: FileType | null;showBackupCompleteSheet: boolean;