Skip to content

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

redesign user section in menu

ammarahm-ed10d8d648c5e3
diff --git a/apps/mobile/src/components/Menu/UserSection.js b/apps/mobile/src/components/Menu/UserSection.js
index 1e5e7911a..34f4e123f 100644
--- a/apps/mobile/src/components/Menu/UserSection.js
+++ b/apps/mobile/src/components/Menu/UserSection.js
@@ -3,7 +3,7 @@ import {
ActivityIndicator,
Platform,
TouchableOpacity,
- View,
+ View
} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -14,6 +14,7 @@ import {eSendEvent, ToastEvent} from '../../services/EventManager';
import Sync from '../../services/Sync';
import {eOpenLoginDialog} from '../../utils/Events';
import {SIZE} from '../../utils/SizeUtils';
+import {PressableButton} from '../PressableButton';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
import {TimeSince} from './TimeSince';
@@ -33,100 +34,86 @@ export const UserSection = () => {
style={{
width: '100%',
alignSelf: 'center',
- backgroundColor: colors.nav,
- paddingBottom: Platform.OS === 'ios' ? insets.bottom / 2 : null,
+ paddingBottom: Platform.OS === 'ios' ? insets.bottom / 2 : null
}}>
<View
style={{
- flexDirection: deviceMode !== 'mobile' ? 'column' : 'row',
+ flexDirection: 'row',
justifyContent: 'space-between',
- alignItems: deviceMode !== 'mobile' ? 'flex-start' : 'center',
- paddingRight: 8,
- paddingLeft: 8,
+ alignItems: 'center',
+ paddingRight: 12,
+ paddingLeft: 12
}}>
- <TouchableOpacity
- activeOpacity={0.8}
- onPress={() => {
+ <PressableButton
+ onPress={async () => {
if (user) {
- ToastEvent.show({
- heading: 'Logged in as ' + user?.email,
- type: 'success',
- context: 'global',
- });
+ await Sync.run();
} else {
eSendEvent(eOpenLoginDialog);
}
}}
- style={{
+ type="gray"
+ customStyle={{
flexDirection: 'row',
- alignItems: 'center',
- paddingVertical: deviceMode !== 'mobile' ? 5 : 10,
- paddingTop: 10,
+ justifyContent: 'flex-start',
+ padding: 12,
+ borderBottomRightRadius: 0,
+ borderBottomLeftRadius: 0
}}>
- <Icon
+ <View
style={{
- marginRight: 5,
- }}
- name="checkbox-blank-circle"
- size={10}
- color={!user ? colors.red : colors.green}
- />
-
- <View>
- <Heading size={SIZE.sm} color={colors.heading}>
- {!user ? 'Not logged in' : 'Logged in'}
- </Heading>
-
- {!user && (
- <Paragraph
- style={{
- maxWidth: deviceMode !== 'mobile' ? '96%' : '100%',
- }}
- color={colors.icon}>
- Login to encrypt and sync your notes.
- </Paragraph>
- )}
- </View>
- </TouchableOpacity>
-
- {user && (
- <TouchableOpacity
- activeOpacity={0.8}
- onPress={async () => await Sync.run()}
- style={{
- flexDirection: 'row',
- alignItems: 'center',
- paddingVertical: deviceMode !== 'mobile' ? 0 : 10,
- paddingBottom: 10,
- justifyContent: 'space-between',
- width: deviceMode !== 'mobile' ? '100%' : null,
+ flexShrink: 1,
+ flexGrow: 1
}}>
- <Paragraph
+ <Heading
style={{
- marginRight: 5,
+ flexWrap: 'wrap'
}}
- size={SIZE.sm}
- color={syncing ? colors.accent : colors.icon}>
- {syncing ? 'Syncing' : 'Synced '}
-
- {!syncing ? (
+ size={SIZE.xs}
+ color={colors.icon}>
+ {!user ? (
+ 'You are not logged in'
+ ) : !syncing ? (
lastSynced && lastSynced !== 'Never' ? (
- <TimeSince
- style={{fontSize: SIZE.sm, color: colors.icon}}
- time={lastSynced}
- />
+ <>
+ Last synced{' '}
+ <TimeSince
+ style={{fontSize: SIZE.xs, color: colors.icon}}
+ time={lastSynced}
+ />
+ </>
) : (
'never'
)
- ) : null}
+ ) : (
+ 'Syncing your notes'
+ )}{' '}
+ <Icon
+ name="checkbox-blank-circle"
+ size={9}
+ color={!user ? colors.red : colors.green}
+ />
+ </Heading>
+
+ <Paragraph
+ style={{
+ flexWrap: 'wrap'
+ }}
+ color={colors.heading}>
+ {!user
+ ? 'Login to sync your notes.'
+ : 'Tap here to sync your notes.'}
</Paragraph>
- {syncing ? (
- <ActivityIndicator size={SIZE.md} color={colors.accent} />
+ </View>
+
+ {user ? (
+ syncing ? (
+ <ActivityIndicator size={SIZE.lg} color={colors.accent} />
) : (
- <Icon color={colors.accent} name="sync" size={SIZE.md} />
- )}
- </TouchableOpacity>
- )}
+ <Icon color={colors.accent} name="sync" size={SIZE.lg} />
+ )
+ ) : null}
+ </PressableButton>
</View>
</View>
);