ui improvements

This commit is contained in:
ammarahm-ed
2020-11-16 09:42:50 +05:00
parent b5759d3061
commit f24c0a11ce

View File

@@ -2,12 +2,10 @@ import React, { createRef, useCallback, useEffect } from 'react';
import { import {
Appearance, Appearance,
Linking, Linking,
ScrollView, ScrollView,
Text, Text,
TouchableOpacity, TouchableOpacity,
View View,
} from 'react-native'; } from 'react-native';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import Menu, {MenuItem} from 'react-native-reanimated-material-menu'; import Menu, {MenuItem} from 'react-native-reanimated-material-menu';
@@ -23,13 +21,19 @@ import { DDS } from '../../services/DeviceDetection';
import {eSendEvent, ToastEvent} from '../../services/EventManager'; import {eSendEvent, ToastEvent} from '../../services/EventManager';
import NavigationService from '../../services/Navigation'; import NavigationService from '../../services/Navigation';
import PremiumService from '../../services/PremiumService'; import PremiumService from '../../services/PremiumService';
import { dWidth, MenuItemsList, setSetting } from '../../utils'; import {
dWidth,
MenuItemsList,
setSetting,
SUBSCRIPTION_STATUS,
SUBSCRIPTION_STATUS_STRINGS,
} from '../../utils';
import { import {
ACCENT, ACCENT,
COLOR_SCHEME, COLOR_SCHEME,
COLOR_SCHEME_DARK, COLOR_SCHEME_DARK,
COLOR_SCHEME_LIGHT, COLOR_SCHEME_LIGHT,
setColorScheme setColorScheme,
} from '../../utils/Colors'; } from '../../utils/Colors';
import {hexToRGBA, RGB_Linear_Shade} from '../../utils/ColorUtils'; import {hexToRGBA, RGB_Linear_Shade} from '../../utils/ColorUtils';
import {db} from '../../utils/DB'; import {db} from '../../utils/DB';
@@ -42,7 +46,7 @@ import {
eOpenRestoreDialog, eOpenRestoreDialog,
eResetApp, eResetApp,
eScrollEvent, eScrollEvent,
eUpdateSearchState eUpdateSearchState,
} from '../../utils/Events'; } from '../../utils/Events';
import {MMKV} from '../../utils/mmkv'; import {MMKV} from '../../utils/mmkv';
import {opacity, pv, SIZE, WEIGHT} from '../../utils/SizeUtils'; import {opacity, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
@@ -89,6 +93,7 @@ export const Settings = ({navigation}) => {
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log(user);
navigation.addListener('focus', onFocus); navigation.addListener('focus', onFocus);
return () => { return () => {
eSendEvent(eScrollEvent, {name: 'Settings', type: 'back'}); eSendEvent(eScrollEvent, {name: 'Settings', type: 'back'});
@@ -102,7 +107,7 @@ export const Settings = ({navigation}) => {
let diff = d2.getTime() - d1.getTime(); let diff = d2.getTime() - d1.getTime();
diff = (diff / (1000 * 3600 * 24)).toFixed(0); diff = (diff / (1000 * 3600 * 24)).toFixed(0);
return diff; return diff < 0 ? 0 : diff;
}; };
const SectionHeader = ({title}) => ( const SectionHeader = ({title}) => (
@@ -172,13 +177,14 @@ export const Settings = ({navigation}) => {
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
paddingHorizontal: 12, paddingHorizontal: 12,
paddingVertical: 6,
width: '100%', width: '100%',
borderRadius: 0, borderRadius: 0,
flexDirection: 'row', flexDirection: 'row',
}}> }}>
<Text <Text
style={{ style={{
fontSize: SIZE.md, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
textAlignVertical: 'center', textAlignVertical: 'center',
color: colors.pri, color: colors.pri,
@@ -225,11 +231,8 @@ export const Settings = ({navigation}) => {
style={{ style={{
alignSelf: 'center', alignSelf: 'center',
width: '100%', width: '100%',
marginBottom: pv,
marginTop: pv,
borderRadius: 5, borderRadius: 5,
padding: 10, paddingVertical: 12,
backgroundColor: colors.shade,
}}> }}>
<View <View
style={{ style={{
@@ -243,11 +246,23 @@ export const Settings = ({navigation}) => {
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
}}> }}>
<View
style={{
borderWidth: 1,
borderRadius: 100,
borderColor: colors.accent,
width: 20,
height: 20,
alignItems: 'center',
justifyContent: 'center',
}}>
<Icon <Icon
size={SIZE.md} size={SIZE.md}
color={colors.accent} color={colors.accent}
name="account-outline" name="account-outline"
/> />
</View>
<Text <Text
style={{ style={{
color: colors.heading, color: colors.heading,
@@ -268,10 +283,10 @@ export const Settings = ({navigation}) => {
<Text <Text
style={{ style={{
color: colors.accent, color: colors.accent,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.bold,
fontSize: SIZE.xs, fontSize: SIZE.sm,
}}> }}>
{user.subscription.status === 1 ? 'Trial' : 'Pro'} {SUBSCRIPTION_STATUS_STRINGS[user.subscription.status]}
</Text> </Text>
</View> </View>
</View> </View>
@@ -285,7 +300,7 @@ export const Settings = ({navigation}) => {
? colors.pri ? colors.pri
: colors.errorText, : colors.errorText,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
fontSize: SIZE.xxl, fontSize: SIZE.lg,
}}> }}>
{getTimeLeft(parseInt(user.subscription.expiry)) + {getTimeLeft(parseInt(user.subscription.expiry)) +
' Days Remaining'}{' '} ' Days Remaining'}{' '}
@@ -310,8 +325,10 @@ export const Settings = ({navigation}) => {
eSendEvent(eOpenPremiumDialog); eSendEvent(eOpenPremiumDialog);
}} }}
width="100%" width="100%"
fontSize={SIZE.md}
title="Get Notesnook Pro" title="Get Notesnook Pro"
height={40} height={50}
type="accent"
/> />
</View> </View>
</View> </View>
@@ -323,7 +340,7 @@ export const Settings = ({navigation}) => {
eSendEvent(eOpenRecoveryKeyDialog); eSendEvent(eOpenRecoveryKeyDialog);
}, },
desc: desc:
'Save your recovery key. If you lose your password, you can recover your data using your recovery key.', 'If you lose your password, you can recover your data using your recovery key.',
}, },
{ {
name: 'Logout', name: 'Logout',
@@ -359,7 +376,7 @@ export const Settings = ({navigation}) => {
}} }}
activeOpacity={opacity / 2} activeOpacity={opacity / 2}
customStyle={{ customStyle={{
paddingVertical: pv + 5, paddingVertical: 12,
width: '100%', width: '100%',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
@@ -394,6 +411,8 @@ export const Settings = ({navigation}) => {
<Text <Text
style={{ style={{
color: colors.accent, color: colors.accent,
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
}}> }}>
Login to sync notes. Login to sync notes.
</Text> </Text>
@@ -422,11 +441,10 @@ export const Settings = ({navigation}) => {
<Text <Text
style={{ style={{
fontSize: SIZE.md, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
textAlignVertical: 'center', textAlignVertical: 'center',
color: colors.pri, color: colors.pri,
marginTop: pv + 5,
paddingHorizontal: 12, paddingHorizontal: 12,
}}> }}>
Accent Color{'\n'} Accent Color{'\n'}
@@ -630,6 +648,7 @@ export const Settings = ({navigation}) => {
}> }>
{MenuItemsList.slice(0, MenuItemsList.length - 1).map((item) => ( {MenuItemsList.slice(0, MenuItemsList.length - 1).map((item) => (
<MenuItem <MenuItem
key={item.title}
onPress={async () => { onPress={async () => {
await setSetting(settings, 'homepage', item.name); await setSetting(settings, 'homepage', item.name);
}} }}
@@ -666,7 +685,7 @@ export const Settings = ({navigation}) => {
}}> }}>
<Text <Text
style={{ style={{
fontSize: SIZE.md, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
textAlignVertical: 'center', textAlignVertical: 'center',
color: colors.pri, color: colors.pri,
@@ -786,7 +805,7 @@ export const Settings = ({navigation}) => {
}}> }}>
<Text <Text
style={{ style={{
fontSize: SIZE.md, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
textAlignVertical: 'center', textAlignVertical: 'center',
color: colors.pri, color: colors.pri,