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
delete old settings files
ammarahm-edc3dc06424060
diff --git a/apps/mobile/src/screens/settings/appearance.js b/apps/mobile/src/screens/settings/appearance.jsindex fa9649413..3a005c355 100644--- a/apps/mobile/src/screens/settings/appearance.js+++ b/apps/mobile/src/screens/settings/appearance.js@@ -1,9 +1,8 @@import React, { useRef, useState } from 'react';-import { Appearance, TouchableOpacity, View } from 'react-native';+import { View } from 'react-native';import { ScrollView } from 'react-native-gesture-handler';import Menu, { MenuItem } from 'react-native-reanimated-material-menu';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 { DDS } from '../../services/device-detection';@@ -12,205 +11,10 @@ import PremiumService from '../../services/premium';import SettingsService from '../../services/settings';import { useSettingStore } from '../../stores/stores';import { useThemeStore } from '../../stores/theme';-import { ACCENT, COLOR_SCHEME, setAccentColor, setColorScheme } from '../../utils/color-scheme';-import {- getColorScheme,- hexToRGBA,- RGB_Linear_Shade,- switchAccentColor,- toggleDarkMode-} from '../../utils/color-scheme/utils';+import { hexToRGBA, RGB_Linear_Shade, switchAccentColor } from '../../utils/color-scheme/utils';import { MenuItemsList } from '../../utils/constants';import { tabBarRef } from '../../utils/global-refs';import { pv, SIZE } from '../../utils/size';-import { CustomButton } from './button';-import SectionHeader from './section-header';--const SettingsAppearanceSection = () => {- const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const [collapsed, setCollapsed] = useState(true);- const menuRef = useRef();-- const switchTheme = async () => {- if (SettingsService.get().useSystemTheme) {- await SettingsService.set({ useSystemTheme: false });- } else {- await SettingsService.set({- useSystemTheme: !SettingsService.get().useSystemTheme,- theme: {- ...SettingsService.get().theme,- dark: Appearance.getColorScheme() === 'dark'- }- });- getColorScheme();- }- };-- const pitchBlack = async () => {- await SettingsService.set({ pitchBlack: !SettingsService.get().pitchBlack });- getColorScheme();- };-- return (- <>- <SectionHeader collapsed={collapsed} setCollapsed={setCollapsed} title="Appearance" />-- {collapsed ? null : (- <>- <View- style={{- paddingHorizontal: 12,- marginTop: 5- }}- >- <Paragraph- size={SIZE.md}- style={{- textAlignVertical: 'center'- }}- >- Accent color- </Paragraph>- <Paragraph size={SIZE.sm} color={colors.icon}>- Change the accent color of the app.- </Paragraph>- </View>-- <AccentColorPicker />-- <CustomButton- title="Use system theme"- tagline="Automatically switch to dark mode when the system theme changes."- onPress={switchTheme}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={settings.useSystemTheme}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={switchTheme}- />- }- />-- <CustomButton- title="Pitch black"- tagline="Save battery while using the app with pitch black dark mode on amoled displays"- onPress={pitchBlack}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={settings.pitchBlack}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={pitchBlack}- />- }- />-- {/* <CustomButton- title="Reduce animations"- tagline="Enable this to reduce animations in the app."- onPress={reduceAnimations}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={settings.reduceAnimations}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={reduceAnimations}- />- }- /> */}-- <CustomButton- title="Dark mode"- tagline="Switch on dark mode at night to protect your eyes."- onPress={toggleDarkMode}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={colors.night}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={toggleDarkMode}- />- }- />-- <CustomButton- title="Homepage"- tagline={'Default screen to open on app startup '}- onPress={async () => {- await PremiumService.verify(menuRef.current?.show);- }}- customComponent={- <Menu- ref={menuRef}- animationDuration={200}- style={{- borderRadius: 5,- backgroundColor: colors.bg- }}- button={- <TouchableOpacity- onPress={async () => {- await PremiumService.verify(menuRef.current?.show);- }}- style={{- flexDirection: 'row',- alignItems: 'center'- }}- >- <Paragraph>{settings.homepage}</Paragraph>- <Icon color={colors.icon} name="menu-down" size={SIZE.md} />- </TouchableOpacity>- }- >- {MenuItemsList.slice(0, MenuItemsList.length - 1).map(- item =>- item.name !== 'Monographs' && (- <MenuItem- key={item.name}- onPress={async () => {- menuRef.current?.hide();- await SettingsService.set({ homepage: item.name });- ToastEvent.show({- heading: 'Homepage set to ' + item.name,- message: 'Restart the app for changes to take effect.',- type: 'success'- });- }}- style={{- backgroundColor:- settings.homepage === item.name ? colors.nav : 'transparent'- }}- textStyle={{- fontSize: SIZE.md,- color: settings.homepage === item.name ? colors.accent : colors.pri- }}- >- {item.name}- </MenuItem>- )- )}- </Menu>- }- />- </>- )}- </>- );-};export const HomagePageSelector = () => {const colors = useThemeStore(state => state.colors);@@ -381,5 +185,3 @@ export const AccentColorPicker = ({ settings = true, wrap = false }) => {</ScrollView>);};--export default SettingsAppearanceSection;diff --git a/apps/mobile/src/screens/settings/backuprestore.js b/apps/mobile/src/screens/settings/backuprestore.jsindex 0d5aa8d14..94dc4b0d3 100644--- a/apps/mobile/src/screens/settings/backuprestore.js+++ b/apps/mobile/src/screens/settings/backuprestore.js@@ -1,205 +1,12 @@-import React, { useState } from 'react';+import React from 'react';import { Platform, TouchableOpacity, View } from 'react-native';-import ToggleSwitch from 'toggle-switch-react-native';-import Seperator from '../../components/ui/seperator';import Paragraph from '../../components/ui/typography/paragraph';import Backup from '../../services/backup';-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';import PremiumService from '../../services/premium';import SettingsService from '../../services/settings';import { useSettingStore, useUserStore } from '../../stores/stores';import { useThemeStore } from '../../stores/theme';-import { eCloseProgressDialog, eOpenLoginDialog, eOpenRestoreDialog } from '../../utils/events';-import { openLinkInBrowser } from '../../utils/functions';import { SIZE } from '../../utils/size';-import { sleep } from '../../utils/time';-import { CustomButton } from './button';-import { verifyUser } from './functions';-import SectionHeader from './section-header';--const SettingsBackupAndRestore = ({ isSheet }) => {- const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const user = useUserStore(state => state.user);- const [collapsed, setCollapsed] = useState(isSheet ? false : true);- const backupDirectoryAndroid = settings.backupDirectoryAndroid;-- const optItems = isSheet- ? []- : [- {- name: 'Restore backup',- func: async () => {- if (!user || !user?.email) {- ToastEvent.show({- heading: 'Login required',- message: 'Please log in to your account to restore backup',- type: 'error',- context: 'global'- });- return;- }- if (isSheet) {- eSendEvent(eCloseProgressDialog);- await sleep(300);- }- eSendEvent(eOpenRestoreDialog);- },- desc: 'Restore backup from phone storage.'- },- {- name: 'Import notes from other note apps',- desc: 'Get all your notes in one place with Notesnook Importer.',- func: async () => {- if (isSheet) {- eSendEvent(eCloseProgressDialog);- await sleep(300);- }- presentSheet({- title: 'Notesnook Importer',- icon: 'import',- action: async () => {- try {- await openLinkInBrowser('https://importer.notesnook.com', colors);- } catch (e) {}- },- actionText: 'Go to Notesnook Importer',- learnMore: 'Learn how this works',- learnMorePress: async () => {- try {- await openLinkInBrowser(- 'https://docs.notesnook.com/importing/notesnook-importer/',- colors- );- } catch (e) {}- },- paragraph:- 'Now you can import your notes from all the popular note taking apps. Go to https://importer.notesnook.com to import your notes.'- });- },- new: true- }- ];-- if (Platform.OS === 'android' && !isSheet) {- optItems.push({- name: backupDirectoryAndroid ? 'Change backups directory' : 'Select backups directory',- func: async () => {- let dir;- try {- let dir = await Backup.checkBackupDirExists(true);- } catch (e) {- } finally {- if (!dir) {- ToastEvent.show({- heading: 'No directory selected',- type: 'error'- });- }- }- },- desc: backupDirectoryAndroid ? backupDirectoryAndroid.name : 'No backup directory selected'- });- }-- const backupItemsList = [- {- name: 'Backup now',- func: async () => {- if (isSheet) {- eSendEvent(eCloseProgressDialog);- await sleep(300);- }- if (!user) {- await Backup.run(true);- return;- }- verifyUser(null, () => Backup.run(true));- },- desc: 'Backup your data to phone storage'- },- ...optItems- ];-- const toggleEncryptedBackups = async () => {- if (!user) {- ToastEvent.show({- heading: 'Login required to enable encryption',- type: 'error',- func: () => {- eSendEvent(eOpenLoginDialog);- },- actionText: 'Login'- });- return;- }- await SettingsService.set({ encryptedBackup: !settings.encryptedBackup });- };-- return (- <>- {!isSheet && (- <SectionHeader collapsed={collapsed} setCollapsed={setCollapsed} title="Backup & restore" />- )}-- {!collapsed && (- <>- {backupItemsList.map(item => (- <CustomButton- key={item.name}- title={item.name}- tagline={item.desc}- onPress={item.func}- />- ))}-- <View- style={{- width: '100%',- marginHorizontal: 0,- paddingHorizontal: 12,- flexShrink: 1,- paddingVertical: 10- }}- >- <Paragraph- size={SIZE.md}- style={{- textAlignVertical: 'center',- maxWidth: '100%'- }}- >- Automatic backups- </Paragraph>- <Paragraph color={colors.icon} size={SIZE.sm}>- Backup your data once every week or daily automatically.- </Paragraph>- <Seperator half />- <AutomaticBackupsSelector />- </View>-- {!isSheet && (- <CustomButton- title="Backup encryption"- tagline="Encrypt all your backups."- onPress={toggleEncryptedBackups}- customComponent={- <ToggleSwitch- isOn={settings.encryptedBackup}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={toggleEncryptedBackups}- />- }- />- )}- </>- )}- </>- );-};export const AutomaticBackupsSelector = () => {const colors = useThemeStore(state => state.colors);@@ -280,5 +87,3 @@ export const AutomaticBackupsSelector = () => {</View>);};--export default SettingsBackupAndRestore;diff --git a/apps/mobile/src/screens/settings/button.js b/apps/mobile/src/screens/settings/button.jsdeleted file mode 100644index 94776bffc..000000000--- a/apps/mobile/src/screens/settings/button.js+++ /dev/null@@ -1,53 +0,0 @@-import React from 'react';-import { View } from 'react-native';-import { PressableButton } from '../../components/ui/pressable';-import Paragraph from '../../components/ui/typography/paragraph';-import { useThemeStore } from '../../stores/theme';-import { SIZE } from '../../utils/size';--export const CustomButton = ({ title, tagline, customComponent, onPress, color = null }) => {- const colors = useThemeStore(state => state.colors);- return (- <PressableButton- onPress={onPress}- customStyle={{- minHeight: 50,- justifyContent: 'space-between',- alignItems: 'center',- paddingHorizontal: 12,- paddingVertical: 12,- width: '100%',- borderRadius: 0,- flexDirection: 'row'- }}- >- <View- style={{- flexShrink: 1- }}- >- <Paragraph- size={SIZE.md}- color={color || colors.pri}- style={{- textAlignVertical: 'center',- flexWrap: 'wrap'- }}- >- {title}- </Paragraph>- <Paragraph- style={{- flexWrap: 'wrap',- paddingRight: 10- }}- size={SIZE.sm}- color={colors.icon}- >- {tagline}- </Paragraph>- </View>- {customComponent ? customComponent : null}- </PressableButton>- );-};diff --git a/apps/mobile/src/screens/settings/developeroptions.js b/apps/mobile/src/screens/settings/developeroptions.jsdeleted file mode 100644index 5ee77ca3e..000000000--- a/apps/mobile/src/screens/settings/developeroptions.js+++ /dev/null@@ -1,63 +0,0 @@-import React, { useState } from 'react';-import ToggleSwitch from 'toggle-switch-react-native';-import { useThemeStore } from '../../stores/theme';-import { useSettingStore } from '../../stores/stores';-import SettingsService from '../../services/settings';-import { CustomButton } from './button';-import SectionHeader from './section-header';--const SettingsDeveloperOptions = ({ isSheet }) => {- const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const [collapsed, setCollapsed] = useState(isSheet ? false : true);-- const toggleDevMode = () => {- SettingsService.set({ devMode: !settings.devMode });- };-- const devModeList = [- {- name: 'Enable debug mode',- func: toggleDevMode,- desc: 'Show debug options on items',- customComponent: (- <ToggleSwitch- isOn={settings.devMode}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={toggleDevMode}- />- )- }- ];-- return (- <>- {!isSheet && (- <SectionHeader- collapsed={collapsed}- setCollapsed={setCollapsed}- title="Developer options"- />- )}-- {!collapsed && (- <>- {devModeList.map(item => (- <CustomButton- key={item.name}- title={item.name}- tagline={item.desc}- onPress={item.func}- customComponent={item.customComponent}- />- ))}- </>- )}- </>- );-};--export default SettingsDeveloperOptions;diff --git a/apps/mobile/src/screens/settings/general.js b/apps/mobile/src/screens/settings/general.jsdeleted file mode 100644index 37445b4d0..000000000--- a/apps/mobile/src/screens/settings/general.js+++ /dev/null@@ -1,64 +0,0 @@-import React, { useState } from 'react';-import ToggleSwitch from 'toggle-switch-react-native';-import { useThemeStore } from '../../stores/theme';-import { useSettingStore } from '../../stores/stores';-import Notifications from '../../services/notifications';-import SettingsService from '../../services/settings';-import { CustomButton } from './button';-import SectionHeader from './section-header';--export const SettingsGeneralOptions = ({ isSheet }) => {- const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const [collapsed, setCollapsed] = useState(isSheet ? false : true);- const toggleNotifNotes = () => {- if (settings.notifNotes) {- Notifications.unpinQuickNote();- } else {- Notifications.pinQuickNote();- }- SettingsService.set({ notifNotes: !settings.notifNotes });- };-- const generalList = [- {- name: 'Notes in notifications',- func: toggleNotifNotes,- desc: 'Add quick notes from notifications without opening the app.',- customComponent: (- <ToggleSwitch- isOn={settings.notifNotes}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={toggleNotifNotes}- />- )- }- ];-- return (- <>- {!isSheet && (- <SectionHeader collapsed={collapsed} setCollapsed={setCollapsed} title="General" />- )}-- {!collapsed && (- <>- {generalList.map(item => (- <CustomButton- key={item.name}- title={item.name}- tagline={item.desc}- onPress={item.func}- customComponent={item.customComponent}- />- ))}- </>- )}- </>- );-};--export default SettingsGeneralOptions;diff --git a/apps/mobile/src/screens/settings/logout.js b/apps/mobile/src/screens/settings/logout.jsdeleted file mode 100644index 1b74bc858..000000000--- a/apps/mobile/src/screens/settings/logout.js+++ /dev/null@@ -1,190 +0,0 @@-import React, { useState } from 'react';-import { View } from 'react-native';-import AnimatedProgress from 'react-native-reanimated-progress-bar';-import BaseDialog from '../../components/dialog/base-dialog';-import { presentDialog } from '../../components/dialog/functions';-import { PressableButton } from '../../components/ui/pressable';-import Heading from '../../components/ui/typography/heading';-import Paragraph from '../../components/ui/typography/paragraph';-import { useThemeStore } from '../../stores/theme';-import { useUserStore } from '../../stores/stores';-import BiometricService from '../../services/biometrics';-import { eSendEvent, ToastEvent } from '../../services/event-manager';-import { db } from '../../utils/database';-import { SIZE } from '../../utils/size';-import Storage from '../../utils/database/storage';-import { sleep } from '../../utils/time';-import SettingsService from '../../services/settings';-import { eCloseSimpleDialog } from '../../utils/events';--const AccoutLogoutSection = () => {- const colors = useThemeStore(state => state.colors);- const user = useUserStore(state => state.user);- const [loading, setLoading] = useState(false);-- return !user ? null : (- <>- {loading && (- <BaseDialog visible={true}>- <View- style={{- width: '100%',- height: '100%',- backgroundColor: colors.bg,- justifyContent: 'center',- alignItems: 'center'- }}- >- <Heading color={colors.pri} size={SIZE.lg}>- Logging out- </Heading>- <Paragraph color={colors.icon}>- Please wait while we log out and clear app data.- </Paragraph>- <View- style={{- flexDirection: 'row',- height: 10,- width: 100,- marginTop: 15- }}- >- <AnimatedProgress fill={colors.accent} total={8} current={8} />- </View>- </View>- </BaseDialog>- )}-- {[- {- name: 'Logout',- func: async () => {- presentDialog({- title: 'Logout',- paragraph: 'Clear all your data and reset the app.',- positiveText: 'Logout',- positivePress: async () => {- try {- eSendEvent(eCloseSimpleDialog);- setLoading(true);- await sleep(10);- await db.user.logout();- await BiometricService.resetCredentials();- await SettingsService.set({- introCompleted: true- });- setLoading(false);- } catch (e) {- setLoading(false);- }- }- });- }- }- ].map((item, index) => (- <PressableButton- onPress={item.func}- key={item.name}- type="gray"- customStyle={{- height: 50,- borderTopWidth: index === 0 ? 1 : 0,- borderTopColor: colors.nav,- width: '100%',- alignItems: 'flex-start',- paddingHorizontal: 12,- marginTop: index === 0 ? 25 : 0,- borderRadius: 0- }}- >- <Heading- color={item.name === 'Logout' ? colors.pri : colors.red}- style={{- fontSize: SIZE.md- }}- >- {item.name}- </Heading>- </PressableButton>- ))}-- <PressableButton- onPress={() => {- presentDialog({- title: 'Delete account',- paragraphColor: colors.red,- paragraph:- 'All your data will be removed permanantly. Make sure you have saved backup of your notes. This action is IRREVERSIBLE.',- positiveType: 'errorShade',- input: true,- inputPlaceholder: 'Enter account password',- positiveText: 'Delete',- positivePress: async value => {- try {- let verified = await db.user.verifyPassword(value);- if (verified) {- setLoading(true);- await db.user.deleteUser(value);- await BiometricService.resetCredentials();- SettingsService.set({- introCompleted: true- });- setLoading(false);- } else {- setLoading(false);- ToastEvent.show({- heading: 'Incorrect password',- message: 'The account password you entered is incorrect',- type: 'error',- context: 'global'- });- }- } catch (e) {- console.log(e);- setLoading(false);- ToastEvent.show({- heading: 'Failed to delete account',- message: e.message,- type: 'error',- context: 'global'- });- }- }- });- }}- type="error"- customStyle={{- borderWidth: 1,- borderRadius: 5,- paddingVertical: 10,- width: '95%',- alignItems: 'flex-start',- paddingHorizontal: 12,- marginTop: 25,- borderColor: colors.red- }}- >- <Heading- color={colors.red}- style={{- fontSize: SIZE.md- }}- >- Delete account- </Heading>- <Paragraph- style={{- flexWrap: 'wrap',- flexBasis: 1- }}- color={colors.red}- >- Your account will be deleted and all your data will be removed permanantly. Make sure you- have saved backup of your notes. This action is IRREVERSIBLE.- </Paragraph>- </PressableButton>- </>- );-};--export default AccoutLogoutSection;diff --git a/apps/mobile/src/screens/settings/privacy.js b/apps/mobile/src/screens/settings/privacy.jsdeleted file mode 100644index 9d47b1e3c..000000000--- a/apps/mobile/src/screens/settings/privacy.js+++ /dev/null@@ -1,221 +0,0 @@-import React, { useCallback, useEffect, useState } from 'react';-import { Platform } from 'react-native';-import { enabled } from 'react-native-privacy-snapshot';-import ToggleSwitch from 'toggle-switch-react-native';-import { useThemeStore } from '../../stores/theme';-import { useSettingStore, useUserStore } from '../../stores/stores';-import BiometricService from '../../services/biometrics';-import { eSubscribeEvent, eUnSubscribeEvent, openVault } from '../../services/event-manager';-import PremiumService from '../../services/premium';-import SettingsService from '../../services/settings';-import { AndroidModule, InteractionManager } from '../../utils';-import { db } from '../../utils/database';-import AppLock from './app-lock';-import { CustomButton } from './button';-import SectionHeader from './section-header';--const SettingsPrivacyAndSecurity = () => {- const colors = useThemeStore(state => state.colors);- const settings = useSettingStore(state => state.settings);- const [collapsed, setCollapsed] = useState(true);- const user = useUserStore(state => state.user);- const [vaultStatus, setVaultStatus] = React.useState({- exists: false,- biometryEnrolled: false,- isBiometryAvailable: false- });-- const checkVaultStatus = useCallback(() => {- InteractionManager.runAfterInteractions(() => {- db.vault.exists().then(async r => {- let available = await BiometricService.isBiometryAvailable();- let fingerprint = await BiometricService.hasInternetCredentials();- console.log(available);- setVaultStatus({- exists: r,- biometryEnrolled: fingerprint,- isBiometryAvailable: available ? true : false- });- });- });- }, [collapsed]);-- useEffect(() => {- checkVaultStatus();- eSubscribeEvent('vaultUpdated', () => checkVaultStatus());- return () => {- eUnSubscribeEvent('vaultUpdated', () => checkVaultStatus());- };- }, [collapsed]);-- const toggleBiometricUnlocking = () => {- openVault({- item: {},- fingerprintAccess: !vaultStatus.biometryEnrolled,- revokeFingerprintAccess: vaultStatus.biometryEnrolled,- novault: true,- title: vaultStatus.biometryEnrolled- ? 'Revoke biometric unlocking'- : 'Enable biometery unlock',- description: vaultStatus.biometryEnrolled- ? 'Disable biometric unlocking for notes in vault'- : 'Enable biometric unlocking for notes in vault'- });- };-- return (- <>- <SectionHeader collapsed={collapsed} setCollapsed={setCollapsed} title="Privacy & security" />- {collapsed ? null : (- <>- <CustomButton- key="telemetry"- title="Enable telemetry"- tagline="Help improve Notesnook by sending completely anonymized private analytics and bug reports."- onPress={() => {- SettingsService.set({ telemetry: !settings.telemetry });- }}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={settings.telemetry}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={isOn => {- SettingsService.set({ telemetry: isOn });- }}- />- }- />-- <CustomButton- key="privacyMode"- title="Privacy mode"- tagline="Hide app contents when you switch to other apps. This will also disable screenshot taking in the app."- onPress={() => {- Platform.OS === 'android'- ? AndroidModule.setSecureMode(!settings.privacyScreen)- : enabled(true);-- SettingsService.set({ privacyScreen: !settings.privacyScreen });- }}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={settings.privacyScreen}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={isOn => {- Platform.OS === 'android' ? AndroidModule.setSecureMode(isOn) : enabled(true);- SettingsService.set({ privacyScreen: isOn });- }}- />- }- />-- {user || vaultStatus.isBiometryAvailable ? (- <CustomButton- key="appLock"- title="App lock"- tagline="Require biometrics to access your notes."- onPress={() => {- AppLock.present();- }}- maxWidth="90%"- />- ) : null}-- {vaultStatus.exists ? (- <>- {vaultStatus.isBiometryAvailable ? (- <CustomButton- key="fingerprintVaultUnlock"- title="Vault biometrics unlock"- tagline="Access notes in vault using biometrics"- onPress={toggleBiometricUnlocking}- maxWidth="90%"- customComponent={- <ToggleSwitch- isOn={vaultStatus.biometryEnrolled}- onColor={colors.accent}- offColor={colors.icon}- size="small"- animationSpeed={150}- onToggle={toggleBiometricUnlocking}- />- }- />- ) : null}- <CustomButton- key="changeVaultPassword"- title="Change vault password"- tagline="Setup a new password for the vault"- onPress={() => {- openVault({- item: {},- changePassword: true,- novault: true,- title: 'Change vault password',- description: 'Set a new password for your vault.'- });- }}- />- <CustomButton- key="clearVault"- title="Clear vault"- tagline="Unlock all locked notes and clear vault."- onPress={() => {- openVault({- item: {},- clearVault: true,- novault: true,- title: 'Clear vault',- description:- 'Enter vault password to unlock and remove all notes from the vault.'- });- }}- />-- <CustomButton- key="deleteVault"- title="Delete vault"- tagline="Delete vault (and optionally remove all notes)."- onPress={() => {- openVault({- item: {},- deleteVault: true,- novault: true,- title: 'Delete vault',- description: 'Enter your account password to delete your vault.'- });- }}- />- </>- ) : (- <CustomButton- key="createVault"- title="Create vault"- tagline="Secure your notes by adding the to the vault."- onPress={() => {- PremiumService.verify(() => {- openVault({- item: {},- novault: false,- title: 'Create vault',- description: 'Set a password to create vault and lock notes.'- });- });- }}- />- )}- </>- )}- </>- );-};--export default SettingsPrivacyAndSecurity;diff --git a/apps/mobile/src/screens/settings/sectionheader.js b/apps/mobile/src/screens/settings/sectionheader.jsdeleted file mode 100644index d887f99e0..000000000--- a/apps/mobile/src/screens/settings/sectionheader.js+++ /dev/null@@ -1,53 +0,0 @@-import React from 'react';-import { TouchableOpacity } from 'react-native';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import Heading from '../../components/ui/typography/heading';-import Paragraph from '../../components/ui/typography/paragraph';-import { useThemeStore } from '../../stores/theme';-import layoutmanager from '../../utils/layout-manager';-import { SIZE } from '../../utils/size';--const SectionHeader = ({ title, collapsed, setCollapsed }) => {- const colors = useThemeStore(state => state.colors);-- return (- <TouchableOpacity- activeOpacity={0.9}- onPress={() => {- layoutmanager.withAnimation(200);- setCollapsed(!collapsed);- }}- style={{- height: 50,- paddingHorizontal: 0,- justifyContent: 'space-between',- flexDirection: 'row',- alignItems: 'center',- width: '95%',- alignSelf: 'center',- marginBottom: 5,- marginTop: 5,- borderBottomWidth: 1,- borderBottomColor: colors.nav- }}- >- {collapsed ? (- <Paragraph size={SIZE.md + 1} color={collapsed ? colors.icon : colors.accent}>- {title}- </Paragraph>- ) : (- <Heading size={SIZE.md + 1} color={colors.accent}>- {title}- </Heading>- )}-- <Icon- name={collapsed ? 'chevron-down' : 'chevron-up'}- color={collapsed ? colors.icon : colors.accent}- size={SIZE.lg}- />- </TouchableOpacity>- );-};--export default SectionHeader;diff --git a/apps/mobile/src/screens/settings/sectionitem.tsx b/apps/mobile/src/screens/settings/sectionitem.tsxindex 868941756..f777851ee 100644--- a/apps/mobile/src/screens/settings/sectionitem.tsx+++ b/apps/mobile/src/screens/settings/sectionitem.tsx@@ -1,121 +1,19 @@import { NavigationProp, StackActions, useNavigation } from '@react-navigation/native';-import dayjs from 'dayjs';import React, { ReactElement } from 'react';-import { Linking, Platform, View } from 'react-native';+import { View } from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import ToggleSwitch from 'toggle-switch-react-native';-import { Button } from '../../components/ui/button';import { PressableButton } from '../../components/ui/pressable';import Seperator from '../../components/ui/seperator';import Paragraph from '../../components/ui/typography/paragraph';-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';-import PremiumService from '../../services/premium';import SettingsService from '../../services/settings';-import { useSettingStore, useUserStore } from '../../stores/stores';+import { useSettingStore } from '../../stores/stores';import { useThemeStore } from '../../stores/theme';-import { SUBSCRIPTION_PROVIDER, SUBSCRIPTION_STATUS } from '../../utils/constants';-import { eOpenPremiumDialog } from '../../utils/events';-import { usePricing } from '../../utils/hooks/use-pricing';import { SIZE } from '../../utils/size';import { AccentColorPicker, HomagePageSelector } from './appearance';import { AutomaticBackupsSelector } from './backup-restore';+import { Subscription } from './subscription';import { RouteParams, SettingSection } from './types';-import { getTimeLeft } from './user-section';--const Subscription = () => {- const user: any = useUserStore(state => state.user);- const monthlyPlan = usePricing('monthly');- const colors = useThemeStore(state => state.colors);- const isNotPro =- user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&- user.subscription?.type !== SUBSCRIPTION_STATUS.BETA;-- const manageSubscription = () => {- if (!user.isEmailConfirmed) {- PremiumService.showVerifyEmailDialog();- return;- }- if (- user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&- Platform.OS === 'android'- ) {- if (user.subscription?.provider === 3) {- ToastEvent.show({- heading: 'Subscribed on web',- message: 'Open your web browser to manage your subscription.',- type: 'success'- });- return;- }- Linking.openURL('https://play.google.com/store/account/subscriptions');-- /**- *- * Platform.OS === 'ios'- ? 'https://apps.apple.com/account/subscriptions'- : 'https://play.google.com/store/account/subscriptions'- */- } else {- eSendEvent(eOpenPremiumDialog);- }- };-- return (- <View>- {isNotPro ? (- <Button- height={35}- style={{- borderRadius: 100,- paddingHorizontal: 16,- alignSelf: 'flex-start'- }}- fontSize={SIZE.sm}- type="accent"- onPress={manageSubscription}- title={- !user.isEmailConfirmed- ? 'Confirm your email'- : user.subscription?.provider === 3 &&- user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED- ? 'Manage subscription from desktop app'- : user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&- Platform.OS === 'android'- ? `Resubscribe from Google Playstore`- : user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED- ? `Resubscribe to Pro (${monthlyPlan?.product?.localizedPrice} / mo)`- : `Get Pro (${monthlyPlan?.product?.localizedPrice} / mo)`- }- />- ) : null}-- {user?.subscription?.provider &&- user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&- user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC &&- SUBSCRIPTION_PROVIDER[user?.subscription?.provider] ? (- <Button- title={SUBSCRIPTION_PROVIDER[user?.subscription?.provider]?.title}- onPress={() => {- presentSheet({- title: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].title,- paragraph: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].desc- });- }}- style={{- alignSelf: 'flex-start',- paddingHorizontal: 0- }}- fontSize={SIZE.sm}- textStyle={{- fontWeight: 'normal'- }}- height={30}- type="transparent"- />- ) : null}- </View>- );-};const components: { [name: string]: ReactElement } = {colorpicker: <AccentColorPicker wrap={true} />,diff --git a/apps/mobile/src/screens/settings/subscription.js b/apps/mobile/src/screens/settings/subscription.jsnew file mode 100644index 000000000..4acae9342--- /dev/null+++ b/apps/mobile/src/screens/settings/subscription.js@@ -0,0 +1,106 @@+import React from 'react';+import { Linking, Platform, View } from 'react-native';+import { Button } from '../../components/ui/button';+import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';+import PremiumService from '../../services/premium';+import { useUserStore } from '../../stores/stores';+import { useThemeStore } from '../../stores/theme';+import { SUBSCRIPTION_PROVIDER, SUBSCRIPTION_STATUS } from '../../utils/constants';+import { eOpenPremiumDialog } from '../../utils/events';+import { usePricing } from '../../utils/hooks/use-pricing';+import { SIZE } from '../../utils/size';++export const Subscription = () => {+ const user: any = useUserStore(state => state.user);+ const monthlyPlan = usePricing('monthly');+ const colors = useThemeStore(state => state.colors);+ const isNotPro =+ user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&+ user.subscription?.type !== SUBSCRIPTION_STATUS.BETA;++ const manageSubscription = () => {+ if (!user.isEmailConfirmed) {+ PremiumService.showVerifyEmailDialog();+ return;+ }+ if (+ user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&+ Platform.OS === 'android'+ ) {+ if (user.subscription?.provider === 3) {+ ToastEvent.show({+ heading: 'Subscribed on web',+ message: 'Open your web browser to manage your subscription.',+ type: 'success'+ });+ return;+ }+ Linking.openURL('https://play.google.com/store/account/subscriptions');++ /**+ *+ * Platform.OS === 'ios'+ ? 'https://apps.apple.com/account/subscriptions'+ : 'https://play.google.com/store/account/subscriptions'+ */+ } else {+ eSendEvent(eOpenPremiumDialog);+ }+ };++ return (+ <View>+ {isNotPro ? (+ <Button+ height={35}+ style={{+ borderRadius: 100,+ paddingHorizontal: 16,+ alignSelf: 'flex-start'+ }}+ fontSize={SIZE.sm}+ type="accent"+ onPress={manageSubscription}+ title={+ !user.isEmailConfirmed+ ? 'Confirm your email'+ : user.subscription?.provider === 3 &&+ user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED+ ? 'Manage subscription from desktop app'+ : user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&+ Platform.OS === 'android'+ ? `Resubscribe from Google Playstore`+ : user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED+ ? `Resubscribe to Pro (${monthlyPlan?.product?.localizedPrice} / mo)`+ : `Get Pro (${monthlyPlan?.product?.localizedPrice} / mo)`+ }+ />+ ) : null}++ {user?.subscription?.provider &&+ user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&+ user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC &&+ SUBSCRIPTION_PROVIDER[user?.subscription?.provider] ? (+ <Button+ title={SUBSCRIPTION_PROVIDER[user?.subscription?.provider]?.title}+ onPress={() => {+ presentSheet({+ title: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].title,+ paragraph: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].desc+ });+ }}+ style={{+ alignSelf: 'flex-start',+ paddingHorizontal: 0+ }}+ fontSize={SIZE.sm}+ textStyle={{+ fontWeight: 'normal'+ }}+ height={30}+ type="transparent"+ />+ ) : null}+ </View>+ );+};