update menu

This commit is contained in:
ammarahm-ed
2020-12-19 15:20:41 +05:00
parent 69e3211baf
commit 93a03e0aba
8 changed files with 158 additions and 109 deletions

View File

@@ -1,5 +1,5 @@
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {Dimensions, Platform, View} from 'react-native'; import {Dimensions, View} from 'react-native';
import ScrollableTabView from 'react-native-scrollable-tab-view'; import ScrollableTabView from 'react-native-scrollable-tab-view';
import {notesnook} from './e2e/test.ids'; import {notesnook} from './e2e/test.ids';
import ContextMenu from './src/components/ContextMenu'; import ContextMenu from './src/components/ContextMenu';
@@ -190,7 +190,7 @@ const AppStack = React.memo(
}); });
setWidthHeight(size); setWidthHeight(size);
console.log(size,"SIZES") console.log(size, 'SIZES');
DDS.setSize(size); DDS.setSize(size);
if (DDS.isLargeTablet()) { if (DDS.isLargeTablet()) {
setDeviceMode('tablet', size); setDeviceMode('tablet', size);

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import {notesnook} from '../../../e2e/test.ids'; import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import { DDS } from '../../services/DeviceDetection';
import Navigation from '../../services/Navigation'; import Navigation from '../../services/Navigation';
import SettingsService from '../../services/SettingsService'; import SettingsService from '../../services/SettingsService';
import {SIZE} from '../../utils/SizeUtils'; import {SIZE} from '../../utils/SizeUtils';
@@ -19,7 +20,9 @@ export const HeaderLeftMenu = () => {
}; };
return ( return (
<> <>
{deviceMode === 'mobile' || currentScreen === 'search' ? ( {deviceMode === 'mobile' ||
currentScreen === 'search' ||
!headerMenuState ? (
<ActionIcon <ActionIcon
testID={notesnook.ids.default.header.buttons.left} testID={notesnook.ids.default.header.buttons.left}
customStyle={{ customStyle={{
@@ -29,12 +32,11 @@ export const HeaderLeftMenu = () => {
width: 40, width: 40,
borderRadius: 100, borderRadius: 100,
marginLeft: -5, marginLeft: -5,
marginRight: 25, marginRight:DDS.isLargeTablet()? 10 : 25,
}} }}
onPress={onLeftButtonPress} onPress={onLeftButtonPress}
onLongPress={() => { onLongPress={() => {
Navigation.popToTop(); Navigation.popToTop();
}} }}
name={!headerMenuState ? 'arrow-left' : 'menu'} name={!headerMenuState ? 'arrow-left' : 'menu'}
size={SIZE.xxxl} size={SIZE.xxxl}

View File

@@ -41,7 +41,7 @@ export const HeaderRightMenu = () => {
type="shade" type="shade"
style={{ style={{
marginLeft: 20, marginLeft: 20,
width: 60, width: 50,
height: 35, height: 35,
}} }}
/> />

View File

@@ -8,14 +8,16 @@ import {
eUnSubscribeEvent, eUnSubscribeEvent,
} from '../../services/EventManager'; } from '../../services/EventManager';
import Navigation from '../../services/Navigation'; import Navigation from '../../services/Navigation';
import {getElevation} from '../../utils';
import {COLORS_NOTE} from '../../utils/Colors'; import {COLORS_NOTE} from '../../utils/Colors';
import {db} from '../../utils/DB'; import {db} from '../../utils/DB';
import {refreshNotesPage} from '../../utils/Events'; import {refreshNotesPage} from '../../utils/Events';
import {SIZE} from '../../utils/SizeUtils'; import {SIZE} from '../../utils/SizeUtils';
import {PressableButton} from '../PressableButton'; import {PressableButton} from '../PressableButton';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
export const ColorSection = ({noTextMode}) => { export const ColorSection = () => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colorNotes, loading} = state; const {colorNotes, loading} = state;
@@ -25,16 +27,9 @@ export const ColorSection = ({noTextMode}) => {
} }
}, [loading]); }, [loading]);
return ( return colorNotes.map((item, index) => (
<View
style={{
width: '100%',
}}>
{colorNotes.map((item, index) => (
<ColorItem key={item.id} item={item} index={index} /> <ColorItem key={item.id} item={item} index={index} />
))} ));
</View>
);
}; };
const ColorItem = ({item, index}) => { const ColorItem = ({item, index}) => {
@@ -43,7 +38,9 @@ const ColorItem = ({item, index}) => {
const [headerTextState, setHeaderTextState] = useState(null); const [headerTextState, setHeaderTextState] = useState(null);
const onHeaderStateChange = (event) => { const onHeaderStateChange = (event) => {
if (event.id === item.name) { console.log(event);
if (event.id === item.id) {
console.log('here');
setHeaderTextState(event); setHeaderTextState(event);
} else { } else {
setHeaderTextState(null); setHeaderTextState(null);
@@ -75,28 +72,30 @@ const ColorItem = ({item, index}) => {
return ( return (
<PressableButton <PressableButton
customColor={ customColor="transparent"
headerTextState?.id === item.id && item.type === headerTextState?.type
? COLORS_NOTE[item.title]
: 'transparent'
}
customSelectedColor={COLORS_NOTE[item.title]} customSelectedColor={COLORS_NOTE[item.title]}
customAlpha={!colors.night ? -0.02 : 0.02} customAlpha={!colors.night ? -0.02 : 0.02}
customOpacity={0.12} customOpacity={0.12}
onPress={() => onPress(item)} onPress={() => onPress(item)}
customStyle={{ customStyle={{
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
width: '100%', width: '100%',
alignSelf: 'center',
borderRadius: 0, borderRadius: 0,
paddingHorizontal: 10, flexDirection: 'row',
height: 50, paddingHorizontal: 8,
justifyContent: 'space-between',
alignItems: 'center',
height: 40,
}}> }}>
<View <View
style={{ style={{
width: 35, flexDirection: 'row',
height: 35, alignItems: 'center',
}}>
<View
style={{
width: 30,
height: 30,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'flex-start', alignItems: 'flex-start',
}}> }}>
@@ -111,18 +110,29 @@ const ColorItem = ({item, index}) => {
}} }}
/> />
</View> </View>
{headerTextState?.id === item.id ? (
<View <Heading color={COLORS_NOTE[item.title.toLowerCase()]} size={SIZE.md}>
style={{ {item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
flexDirection: 'row', </Heading>
justifyContent: 'space-between', ) : (
alignItems: 'center',
width: '85%',
}}>
<Paragraph color={colors.heading} size={SIZE.md}> <Paragraph color={colors.heading} size={SIZE.md}>
{item.title.slice(0, 1).toUpperCase() + item.title.slice(1)} {item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
</Paragraph> </Paragraph>
)}
</View> </View>
<View
style={{
backgroundColor:
headerTextState?.id === item.id
? COLORS_NOTE[item.title.toLowerCase()]
: 'transparent',
width: 7,
height: 7,
borderRadius: 100,
...getElevation(5),
}}
/>
</PressableButton> </PressableButton>
); );
}; };

View File

@@ -4,8 +4,10 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager'; import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
import Navigation from '../../services/Navigation'; import Navigation from '../../services/Navigation';
import {getElevation} from '../../utils';
import {SIZE} from '../../utils/SizeUtils'; import {SIZE} from '../../utils/SizeUtils';
import {PressableButton} from '../PressableButton'; import {PressableButton} from '../PressableButton';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph'; import Paragraph from '../Typography/Paragraph';
export const MenuListItem = ({item, index, noTextMode, testID}) => { export const MenuListItem = ({item, index, noTextMode, testID}) => {
@@ -53,20 +55,16 @@ export const MenuListItem = ({item, index, noTextMode, testID}) => {
testID={testID} testID={testID}
key={item.name + index} key={item.name + index}
onPress={_onPress} onPress={_onPress}
type={ type="transparent"
headerTextState?.id === item.name.toLowerCase() + '_navigation'
? 'shade'
: 'transparent'
}
customStyle={{ customStyle={{
width: noTextMode ? 50 : '100%', width: '100%',
alignSelf: 'center', alignSelf: 'center',
borderRadius: 0, borderRadius: 0,
flexDirection: 'row', flexDirection: 'row',
paddingHorizontal: noTextMode ? 0 : 8, paddingHorizontal: 8,
justifyContent: noTextMode ? 'center' : 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
height: 50, height: 40,
}}> }}>
<View <View
style={{ style={{
@@ -75,24 +73,43 @@ export const MenuListItem = ({item, index, noTextMode, testID}) => {
}}> }}>
<Icon <Icon
style={{ style={{
minWidth: noTextMode ? null : 35, minWidth: 30,
textAlignVertical: 'center', textAlignVertical: 'center',
textAlign: noTextMode ? 'center' : 'left', textAlign: 'left',
}} }}
name={item.icon} name={item.icon}
color={colors.accent} color={colors.accent}
size={SIZE.md} size={SIZE.md}
/> />
{noTextMode ? null : <Paragraph size={SIZE.md}>{item.name}</Paragraph>} {headerTextState?.id === item.name.toLowerCase() + '_navigation' ? (
<Heading color={colors.accent} size={SIZE.md}>
{item.name}
</Heading>
) : (
<Paragraph size={SIZE.md}>{item.name}</Paragraph>
)}
</View> </View>
{item.switch && !noTextMode ? ( {item.switch ? (
<Icon <Icon
size={SIZE.lg} size={SIZE.lg}
color={item.on ? colors.accent : colors.icon} color={item.on ? colors.accent : colors.icon}
name={item.on ? 'toggle-switch' : 'toggle-switch-off'} name={item.on ? 'toggle-switch' : 'toggle-switch-off'}
/> />
) : undefined} ) : (
<View
style={{
backgroundColor:
headerTextState?.id === item.name.toLowerCase() + '_navigation'
? colors.accent
: 'transparent',
width: 7,
height: 7,
borderRadius: 100,
...getElevation(5),
}}
/>
)}
</PressableButton> </PressableButton>
); );
}; };

View File

@@ -89,7 +89,7 @@ export const TagsSection = () => {
<View <View
style={{ style={{
flexGrow: 1, flexGrow: 1,
minHeight:"40%", minHeight: '40%',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
paddingHorizontal: '10%', paddingHorizontal: '10%',
@@ -101,8 +101,8 @@ export const TagsSection = () => {
style={{textAlign: 'center'}} style={{textAlign: 'center'}}
color={colors.icon} color={colors.icon}
size={SIZE.xs}> size={SIZE.xs}>
You have not pinned anything yet. You can pin notebooks, topics and tags You have not pinned anything yet. You can pin notebooks, topics
here. and tags here.
</Paragraph> </Paragraph>
</View> </View>
} }
@@ -122,7 +122,7 @@ const PinItem = ({item, index, onPress}) => {
const [headerTextState, setHeaderTextState] = useState(null); const [headerTextState, setHeaderTextState] = useState(null);
const onHeaderStateChange = (event) => { const onHeaderStateChange = (event) => {
if (event?.id === item.name) { if (event?.id === item.id) {
setHeaderTextState(event); setHeaderTextState(event);
} else { } else {
setHeaderTextState(null); setHeaderTextState(null);
@@ -163,26 +163,27 @@ const PinItem = ({item, index, onPress}) => {
</BaseDialog> </BaseDialog>
)} )}
<PressableButton <PressableButton
type={ type="transparent"
headerTextState?.id === item.id && headerTextState?.type === item.type
? 'shade'
: 'transparent'
}
onLongPress={() => setVisible(true)} onLongPress={() => setVisible(true)}
onPress={() => onPress(item)} onPress={() => onPress(item)}
customStyle={{ customStyle={{
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'flex-start', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
width: '100%', width: '100%',
borderRadius: 0, borderRadius: 0,
paddingHorizontal: 10, paddingHorizontal: 10,
minHeight: 50, minHeight: 40,
}}> }}>
<View <View
style={{ style={{
width: 35, flexDirection: 'row',
height: 35, alignItems: 'center',
}}>
<View
style={{
width: 30,
height: 30,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'flex-start', alignItems: 'flex-start',
}}> }}>
@@ -202,12 +203,16 @@ const PinItem = ({item, index, onPress}) => {
<View <View
style={{ style={{
alignItems: 'flex-start', alignItems: 'flex-start',
width: '85%',
}}> }}>
<Paragraph size={SIZE.md} color={colors.heading}> {headerTextState?.id === item.id ? (
<Heading color={colors.heading} size={SIZE.md}>
{item.title}
</Heading>
) : (
<Paragraph color={colors.heading} size={SIZE.md}>
{item.title} {item.title}
</Paragraph> </Paragraph>
)}
<Paragraph <Paragraph
style={{marginTop: 2.5}} style={{marginTop: 2.5}}
size={SIZE.xs} size={SIZE.xs}
@@ -219,6 +224,18 @@ const PinItem = ({item, index, onPress}) => {
: null} : null}
</Paragraph> </Paragraph>
</View> </View>
</View>
<View
style={{
backgroundColor:
headerTextState?.id === item.id ? colors.accent : 'transparent',
width: 7,
height: 7,
borderRadius: 100,
...getElevation(5),
}}
/>
</PressableButton> </PressableButton>
</> </>
); );

View File

@@ -185,7 +185,10 @@ const SimpleList = ({
alignItems: 'center', alignItems: 'center',
}}> }}>
<Heading>{placeholderData.heading}</Heading> <Heading>{placeholderData.heading}</Heading>
<Paragraph color={colors.icon}> <Paragraph style={{
textAlign:'center',
width:"80%"
}} color={colors.icon}>
{loading ? placeholderData.loading : placeholderData.paragraph} {loading ? placeholderData.loading : placeholderData.paragraph}
</Paragraph> </Paragraph>
<Seperator /> <Seperator />

View File

@@ -78,7 +78,7 @@ export const Trash = ({route, navigation}) => {
type="trash" type="trash"
focused={() => navigation.isFocused()} focused={() => navigation.isFocused()}
placeholderData={{ placeholderData={{
heading: 'Your Trash', heading: 'Trash',
paragraph: paragraph:
'Items in the trash will be permanently deleted after 7 days.', 'Items in the trash will be permanently deleted after 7 days.',
button: null, button: null,