Skip to content

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

ui: remove flatlist & assign keys to list items.

ammarahm-ed070ac5aba514
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index b97b19509..e94a8a8cf 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -5,7 +5,6 @@ import {
Text,
TouchableOpacity,
Platform,
- FlatList,
StatusBar,
} from 'react-native';
import NavigationService from '../../services/NavigationService';
@@ -26,6 +25,68 @@ import {useAppContext} from '../../provider/useAppContext';
export const Menu = ({close = () => {}, hide, update = () => {}}) => {
const {colors, changeColorScheme} = useAppContext();
+ const listItems = [
+ {
+ name: 'Home',
+ icon: 'home',
+ func: () => NavigationService.push('Home'),
+ close: true,
+ },
+
+ {
+ name: 'Notebooks',
+ icon: 'book',
+ func: () =>
+ NavigationService.push('Folders', {
+ title: 'Notebooks',
+ canGoBack: false,
+ }),
+ close: true,
+ },
+ {
+ name: 'Lists',
+ icon: 'list',
+ func: () => NavigationService.push('Lists'),
+ close: true,
+ },
+ {
+ name: 'Favorites',
+ icon: 'star',
+ func: () => NavigationService.push('Favorites'),
+ close: true,
+ },
+
+ {
+ name: 'Dark Mode',
+ icon: 'moon',
+ func: () => {
+ if (!colors.night) {
+ AsyncStorage.setItem('theme', JSON.stringify(COLOR_SCHEME_DARK));
+ changeColorScheme(COLOR_SCHEME_DARK);
+ } else {
+ AsyncStorage.setItem('theme', JSON.stringify(COLOR_SCHEME_LIGHT));
+
+ changeColorScheme(COLOR_SCHEME_LIGHT);
+ }
+ },
+ switch: true,
+ on: colors.night ? true : false,
+ close: false,
+ },
+ {
+ name: 'Trash',
+ icon: 'trash',
+ func: () => NavigationService.push('Trash'),
+ close: true,
+ },
+ {
+ name: 'Settings',
+ icon: 'settings',
+ func: () => NavigationService.push('Settings'),
+ close: true,
+ },
+ ];
+
return (
<AnimatedSafeAreaView
transition="backgroundColor"
@@ -48,77 +109,10 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
contentContainerStyle={{minHeight: '80%'}}
showsVerticalScrollIndicator={false}>
<View>
- <FlatList
- data={[
- {
- name: 'Home',
- icon: 'home',
- func: () => NavigationService.push('Home'),
- close: true,
- },
-
- {
- name: 'Notebooks',
- icon: 'book',
- func: () =>
- NavigationService.push('Folders', {
- title: 'Notebooks',
- canGoBack: false,
- }),
- close: true,
- },
- {
- name: 'Lists',
- icon: 'list',
- func: () => NavigationService.push('Lists'),
- close: true,
- },
- {
- name: 'Favorites',
- icon: 'star',
- func: () => NavigationService.push('Favorites'),
- close: true,
- },
-
- {
- name: 'Dark Mode',
- icon: 'moon',
- func: () => {
- if (!colors.night) {
- AsyncStorage.setItem(
- 'theme',
- JSON.stringify(COLOR_SCHEME_DARK),
- );
- changeColorScheme(COLOR_SCHEME_DARK);
- } else {
- AsyncStorage.setItem(
- 'theme',
- JSON.stringify(COLOR_SCHEME_LIGHT),
- );
-
- changeColorScheme(COLOR_SCHEME_LIGHT);
- }
- },
- switch: true,
- on: colors.night ? true : false,
- close: false,
- },
- {
- name: 'Trash',
- icon: 'trash',
- func: () => NavigationService.push('Trash'),
- close: true,
- },
- {
- name: 'Settings',
- icon: 'settings',
- func: () => NavigationService.push('Settings'),
- close: true,
- },
- ]}
- keyExtractor={(item, index) => item.name}
- renderItem={({item, index}) => (
+ <View>
+ {listItems.map(item => (
<TouchableOpacity
+ key={item.name}
activeOpacity={opacity / 2}
onPress={() => {
item.close === false ? null : close();
@@ -166,8 +160,8 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
undefined
)}
</TouchableOpacity>
- )}
- />
+ ))}
+ </View>
<TouchableOpacity
activeOpacity={opacity / 2}
@@ -226,6 +220,7 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
'water',
].map(item => (
<TouchableOpacity
+ key={item}
activeOpacity={opacity / 2}
onPress={() => {
close();
@@ -262,6 +257,7 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
{['red', 'yellow', 'green', 'blue', 'purple', 'orange', 'gray'].map(
item => (
<TouchableOpacity
+ key={item}
activeOpacity={opacity / 2}
style={{
flexDirection: 'row',