Skip to content

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

update state managment

ammarahm-ed652033dfe57c
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 10e658367..6906028b4 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -2,13 +2,7 @@ import React, {useState, useEffect} from 'react';
import NavigationService, {
AppContainer,
} from './src/services/NavigationService';
-import {
- StatusBar,
- View,
- DeviceEventEmitter,
- Platform,
- Animated,
-} from 'react-native';
+import {StatusBar, View, DeviceEventEmitter, Platform} from 'react-native';
import * as Animatable from 'react-native-animatable';
import {h, w} from './src/utils/utils';
import {Toast} from './src/components/Toast';
@@ -16,27 +10,22 @@ import {Menu} from './src/components/Menu';
import SideMenu from './src/components/SideMenu';
import Storage from 'notes-core/api/database';
import StorageInterface from './src/utils/storage';
-import {AppProvider} from './src/provider';
+import {Provider, useTracked} from './src/provider';
import {DeviceDetectionService} from './src/utils/deviceDetection';
-
-import {
- COLOR_SCHEME,
- onThemeUpdate,
- clearThemeUpdateListener,
-} from './src/common/common';
+import {DialogManager} from './src/components/DialogManager';
export const DDS = new DeviceDetectionService();
export const db = new Storage(StorageInterface);
let sideMenuRef;
const App = () => {
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
// Global State
- const [colors, setColors] = useState(COLOR_SCHEME);
// Local State
const [sidebar, setSidebar] = useState(w * 0.3);
- const [isIntialized, setIsInitialized] = useState(false);
-
+ const [init, setInit] = useState(false);
// Variables
// Effects
@@ -82,26 +71,17 @@ const App = () => {
useEffect(() => {
db.init().then(() => {
- setIsInitialized(true);
- });
- onThemeUpdate(() => {
- setColors({...COLOR_SCHEME});
+ setInit(true);
});
- return () => {
- clearThemeUpdateListener(() => {
- setColors({...COLOR_SCHEME});
- });
- };
}, []);
// Render
- if (!isIntialized) {
+ if (!init) {
return <></>;
}
- console.log('rerendering plain');
return (
- <AppProvider>
+ <Provider>
<View
style={{
width: '100%',
@@ -164,8 +144,14 @@ const App = () => {
</SideMenu>
)}
<Toast />
+ <DialogManager
+ colors={colors}
+ update={type => {
+ dispatch({type: type});
+ }}
+ />
</View>
- </AppProvider>
+ </Provider>
);
};
diff --git a/apps/mobile/src/components/ActionSheet/index.js b/apps/mobile/src/components/ActionSheet/index.js
index 21d9b3b3d..a6927967a 100644
--- a/apps/mobile/src/components/ActionSheet/index.js
+++ b/apps/mobile/src/components/ActionSheet/index.js
@@ -24,6 +24,13 @@ const getElevation = elevation => {
};
};
+const SUPPORTED_ORIENTATIONS = [
+ 'portrait',
+ 'portrait-upside-down',
+ 'landscape',
+ 'landscape-left',
+ 'landscape-right',
+];
export default class ActionSheet extends Component {
constructor(props) {
super(props);
@@ -32,7 +39,9 @@ export default class ActionSheet extends Component {
scrollable: false,
layoutHasCalled: false,
};
+ this.containerOpacity = new Animated.Value(0);
this.transformValue = new Animated.Value(0);
+ this.opacity = new Animated.Value(0);
this.customComponentHeight;
this.prevScroll;
this.scrollAnimationEndValue;
@@ -54,15 +63,22 @@ export default class ActionSheet extends Component {
};
_hideModal = () => {
+ let {animated, closeAnimationDuration, onClose} = this.props;
if (this.isClosing) return;
this.isClosing = true;
- Animated.timing(this.transformValue, {
- toValue: this.customComponentHeight * 2,
- duration: 300,
- useNativeDriver: true,
- }).start();
- setTimeout(() => {
+ Animated.parallel([
+ Animated.timing(this.transformValue, {
+ toValue: this.customComponentHeight * 2,
+ duration: animated ? closeAnimationDuration : 1,
+ useNativeDriver: true,
+ }),
+ ]).start(() => {
+ this.scrollViewRef.scrollTo({
+ x: 0,
+ y: 0,
+ animated: false,
+ });
this.setState(
{
modalVisible: false,
@@ -70,14 +86,22 @@ export default class ActionSheet extends Component {
() => {
this.layoutHasCalled = false;
this.isClosing = false;
- if (typeof this.props.onClose === 'function') this.props.onClose();
+ if (typeof onClose === 'function') onClose();
},
);
- }, 300);
+ });
};
_showModal = event => {
- let {gestureEnabled, bounceOffset, initialOffsetFromBottom} = this.props;
+ let {
+ gestureEnabled,
+ bounciness,
+ initialOffsetFromBottom,
+ bounceOnOpen,
+ animated,
+ defaultOverlayOpacity,
+ openAnimationDuration,
+ } = this.props;
let addFactor = deviceHeight * 0.1;
let height = event.nativeEvent.layout.height;
@@ -95,19 +119,27 @@ export default class ActionSheet extends Component {
}
return;
} else {
- this.customComponentHeight = height;
+ this.customComponentHeight = height - 100;
let scrollOffset = gestureEnabled
? this.customComponentHeight * initialOffsetFromBottom + addFactor
- : this.customComponentHeight;
+ : this.customComponentHeight + addFactor;
- this.transformValue.setValue(scrollOffset);
- this._scrollTo(scrollOffset);
+ this.scrollViewRef.scrollTo({
+ x: 0,
+ y: scrollOffset,
+ animated: false,
+ });
- Animated.spring(this.transformValue, {
- toValue: 0,
- bounciness: 8,
- useNativeDriver: true,
- }).start();
+ if (animated) {
+ this.transformValue.setValue(scrollOffset);
+ Animated.parallel([
+ Animated.spring(this.transformValue, {
+ toValue: 0,
+ bounciness: bounceOnOpen ? bounciness : 1,
+ useNativeDriver: true,
+ }).start(),
+ ]).start();
+ }
this.layoutHasCalled = true;
}
@@ -173,15 +205,13 @@ export default class ActionSheet extends Component {
render() {
let {scrollable, modalVisible} = this.state;
let {
- animationType,
- animated,
onOpen,
closeOnPressBack,
overlayColor,
- bounceOnOpen,
gestureEnabled,
elevation,
indicatorColor,
+ defaultOverlayOpacity,
children,
customStyles,
} = this.props;
@@ -189,14 +219,15 @@ export default class ActionSheet extends Component {
return (
<Modal
visible={modalVisible}
- animationType={animationType}
- animated={animated}
+ animated={true}
+ animationType="fade"
+ supportedOrientations={SUPPORTED_ORIENTATIONS}
onShow={() => onOpen}
onRequestClose={() => {
if (closeOnPressBack) this._hideModal();
}}
transparent={true}>
- <View style={[styles.parentContainer, {backgroundColor: overlayColor}]}>
+ <Animated.View style={[styles.parentContainer]}>
<KeyboardAvoidingView
style={{
width: '100%',
@@ -213,6 +244,16 @@ export default class ActionSheet extends Component {
onTouchEnd={this._onTouchEnd}
overScrollMode="always"
style={[styles.scrollview]}>
+ <Animated.View
+ style={{
+ height: '100%',
+ width: '100%',
+ opacity: defaultOverlayOpacity,
+ position: 'absolute',
+ backgroundColor: overlayColor,
+ zIndex: 1,
+ }}
+ />
<View
onTouchMove={this._onTouchMove}
onTouchStart={this._onTouchStart}
@@ -220,6 +261,7 @@ export default class ActionSheet extends Component {
style={{
height: deviceHeight * 1.1,
width: '100%',
+ zIndex: 10,
}}>
<TouchableOpacity
onPress={this._hideModal}
@@ -230,6 +272,7 @@ export default class ActionSheet extends Component {
}}
/>
</View>
+
<Animated.View
onLayout={this._showModal}
style={[
@@ -237,6 +280,7 @@ export default class ActionSheet extends Component {
customStyles,
{
...getElevation(elevation),
+ zIndex: 11,
transform: [
{
translateY: this.transformValue,
@@ -254,10 +298,20 @@ export default class ActionSheet extends Component {
) : null}
{children}
+ <View
+ style={[
+ {
+ height: 100,
+ width: '100%',
+ backgroundColor: 'white',
+ },
+ customStyles,
+ ]}
+ />
</Animated.View>
</ScrollView>
</KeyboardAvoidingView>
- </View>
+ </Animated.View>
</Modal>
);
}
@@ -266,29 +320,33 @@ export default class ActionSheet extends Component {
ActionSheet.defaultProps = {
children: <View />,
animated: true,
- animationType: 'fade',
closeOnPressBack: true,
- gestureEnabled: true,
- bounceOnOpen: true,
- bounceOffset: 20,
+ gestureEnabled: false,
+ bounceOnOpen: false,
+ bounciness: 8,
+ closeAnimationDuration: 300,
+ openAnimationDuration: 200,
springOffset: 50,
elevation: 5,
- initialOffsetFromBottom: 0.4,
+ initialOffsetFromBottom: 1,
indicatorColor: 'gray',
customStyles: {},
- overlayColor: 'rgba(0,0,0,0.3)',
+ defaultOverlayOpacity: 0.3,
+ overlayColor: 'black',
onClose: () => {},
onOpen: () => {},
};
ActionSheet.propTypes = {
children: PropTypes.node,
animated: PropTypes.bool,
- animationType: PropTypes.oneOf(['none', 'slide', 'fade']),
closeOnPressBack: PropTypes.bool,
gestureEnabled: PropTypes.bool,
bounceOnOpen: PropTypes.bool,
- bounceOffset: PropTypes.number,
+ bounciness: PropTypes.number,
springOffset: PropTypes.number,
+ defaultOverlayOpacity: PropTypes.number,
+ closeAnimationDuration: PropTypes.number,
+ openAnimationDuration: PropTypes.number,
elevation: PropTypes.number,
initialOffsetFromBottom: PropTypes.number,
indicatorColor: PropTypes.string,
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index cb3e13ee8..efe71241a 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -13,11 +13,14 @@ import {getElevation, ToastEvent} from '../../utils/utils';
import {FlatList, TextInput} from 'react-native-gesture-handler';
import {db, DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
let refs = [];
export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
const [topics, setTopics] = useState(['']);
const [title, setTitle] = useState(null);
diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.js
index f5c7da0c3..2767d5ec1 100644
--- a/apps/mobile/src/components/AddTopicDialog/index.js
+++ b/apps/mobile/src/components/AddTopicDialog/index.js
@@ -28,6 +28,7 @@ import {FlatList, TextInput} from 'react-native-gesture-handler';
import {useForceUpdate} from '../../views/ListsEditor';
import {db} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const AddTopicDialog = ({
visible,
@@ -35,7 +36,8 @@ export const AddTopicDialog = ({
notebookID,
toEdit = null,
}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
const [titleFocused, setTitleFocused] = useState(false);
let title = null;
diff --git a/apps/mobile/src/components/Container/index.js b/apps/mobile/src/components/Container/index.js
index e028a8892..069d9b9e6 100644
--- a/apps/mobile/src/components/Container/index.js
+++ b/apps/mobile/src/components/Container/index.js
@@ -19,6 +19,7 @@ import NavigationService from '../../services/NavigationService';
import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
import {DDS} from '../../../App';
+import {useTracked} from '../../provider';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView,
);
@@ -30,7 +31,8 @@ export const Container = ({
noBottomButton = false,
}) => {
// State
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
const [buttonHide, setButtonHide] = useState(false);
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 691480ca9..24f9fae69 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -15,6 +15,7 @@ import {
import Icon from 'react-native-vector-icons/Feather';
import {getElevation} from '../../utils/utils';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const Dialog = ({
title,
@@ -26,7 +27,8 @@ export const Dialog = ({
close = () => {},
positivePress = () => {},
}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
return (
<Modal
diff --git a/apps/mobile/src/components/EditorMenu/index.js b/apps/mobile/src/components/EditorMenu/index.js
index fbeed5a17..ed6d8d27f 100644
--- a/apps/mobile/src/components/EditorMenu/index.js
+++ b/apps/mobile/src/components/EditorMenu/index.js
@@ -26,6 +26,7 @@ import {AnimatedSafeAreaView} from '../../views/Home';
import {TextInput} from 'react-native-gesture-handler';
import {useAppContext} from '../../provider/useAppContext';
import {VaultDialog} from '../VaultDialog';
+import {useTracked} from '../../provider';
let tagsInputRef;
let tagsList;
@@ -38,7 +39,13 @@ export const EditorMenu = ({
note,
timestamp,
}) => {
- const {colors, changeColorScheme} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+ // Todo
+
+ const changeColorScheme = () => {};
+ ///////
+
const [unlock, setUnlock] = useState(false);
const [vaultDialog, setVaultDialog] = useState(false);
const [focused, setFocused] = useState(false);
diff --git a/apps/mobile/src/components/ListItem/index.js b/apps/mobile/src/components/ListItem/index.js
index dde1fef20..5cc859048 100644
--- a/apps/mobile/src/components/ListItem/index.js
+++ b/apps/mobile/src/components/ListItem/index.js
@@ -14,10 +14,12 @@ import Icon from 'react-native-vector-icons/Ionicons';
import {getElevation} from '../../utils/utils';
import {FlatList} from 'react-native-gesture-handler';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const ListItem = props => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
return (
<View
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 8f7a6725a..010755454 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -21,8 +21,14 @@ import {h} from '../../utils/utils';
import {AnimatedSafeAreaView} from '../../views/Home';
import {useAppContext} from '../../provider/useAppContext';
import FastStorage from 'react-native-fast-storage';
+import {useTracked} from '../../provider';
export const Menu = ({close = () => {}, hide, update = () => {}}) => {
- const {colors, changeColorScheme} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
+ // todo
+
+ const changeColorScheme = () => {};
const listItems = [
{
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index d5f66b2a3..b9e5250dd 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -27,7 +27,12 @@ export const NotebookItem = ({
customStyle,
onLongPress,
}) => {
- const {colors, updateDB} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
+ ///
+ const updateDB = () => {};
+
const [isVisible, setVisible] = useState(false);
const [addTopic, setAddTopic] = useState(false);
const [addNotebook, setAddNotebook] = useState(false);
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index 0c89fd07d..efe0e7549 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -1,22 +1,16 @@
import React, {useState, useEffect} from 'react';
-import {
- View,
- Text,
- FlatList,
- Platform,
- TouchableOpacity,
- SectionList,
-} from 'react-native';
+import {View, Text, FlatList, Platform, SectionList} from 'react-native';
import {SIZE, WEIGHT} from '../../common/common';
import NoteItem from '../NoteItem';
-import {DDS, db} from '../../../App';
-import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
-import Icon from 'react-native-vector-icons/Feather';
import {NotesPlaceHolder} from '../ListPlaceholders';
import {slideRight, slideLeft} from '../../utils/animations';
import {w} from '../../utils/utils';
import SelectionWrapper from '../SelectionWrapper';
+import ActionSheet from '../ActionSheet';
+import {ActionSheetComponent} from '../ActionSheetComponent';
+import {useTracked} from '../../provider';
+
export const NotesList = ({
notes,
onScroll,
@@ -24,234 +18,204 @@ export const NotesList = ({
isGrouped = false,
refresh = () => {},
}) => {
- const {
- colors,
- selectionMode,
- selectedItemsList,
- changeSelectionMode,
- updateSelectionList,
- pinned,
- } = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, selectedItemsList} = state;
- useEffect(() => {
- console.log(notes, pinned);
- }, [notes]);
- return isGrouped && !isSearch ? (
- <SectionList
- sections={notes}
- keyExtractor={(item, index) => item.dateCreated.toString()}
- renderSectionHeader={({section: {title}}) => (
+ ///
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
+
+ const _renderItem = ({item, index}) => (
+ <SelectionWrapper item={item}>
+ <NoteItem
+ colors={colors}
+ customStyle={{
+ width: selectionMode ? w - 74 : '100%',
+ marginHorizontal: 0,
+ }}
+ onLongPress={() => {
+ changeSelectionMode(!selectionMode);
+ updateSelectionList(item);
+ }}
+ update={() => {
+ dispatch({type: 'updateNotes'});
+ }}
+ item={item}
+ index={index}
+ />
+ </SelectionWrapper>
+ );
+
+ const _onScroll = event => {
+ if (!event) return;
+ y = event.nativeEvent.contentOffset.y;
+ onScroll(y);
+ };
+
+ const _ListHeaderComponent = (
+ <View
+ style={{
+ marginTop:
+ Platform.OS == 'ios'
+ ? notes[0] && !selectionMode
+ ? 135
+ : 135 - 60
+ : notes[0] && !selectionMode
+ ? 155
+ : 155 - 60,
+ }}>
+ {pinned && pinned.length > 0 ? (
+ <>
+ <FlatList
+ data={pinned}
+ keyExtractor={(item, index) => item.dateCreated.toString()}
+ renderItem={({item, index}) =>
+ item.type === 'note' ? (
+ <NoteItem
+ colors={colors}
+ customStyle={{
+ backgroundColor: colors.shade,
+ width: '100%',
+ paddingHorizontal: '5%',
+ paddingTop: 20,
+ marginHorizontal: 0,
+ marginBottom: 10,
+ paddingHorizontal: 12,
+ marginTop: 20,
+ borderBottomWidth: 0,
+ }}
+ pinned={true}
+ item={item}
+ index={index}
+ />
+ ) : null
+ }
+ />
+ </>
+ ) : null}
+ </View>
+ );
+
+ const _ListFooterComponent = notes[0] ? (
+ <View
+ style={{
+ height: 150,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Text
+ style={{
+ color: colors.navbg,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}>
+ - End -
+ </Text>
+ </View>
+ ) : null;
+
+ const _ListEmptyComponent =
+ pinned && pinned.length > 0 ? null : (
+ <View
+ style={{
+ height: '80%',
+ width: '100%',
+ alignItems: 'center',
+ alignSelf: 'center',
+ justifyContent: 'center',
+ opacity: 0.8,
+ }}>
+ <NotesPlaceHolder animation={slideRight} colors={colors} />
+ <NotesPlaceHolder animation={slideLeft} colors={colors} />
+ <NotesPlaceHolder animation={slideRight} colors={colors} />
<Text
style={{
- fontFamily: WEIGHT.bold,
- fontSize: SIZE.sm,
- color: colors.accent,
- paddingHorizontal: 12,
- width: '100%',
- alignSelf: 'center',
- marginTop: 15,
- paddingBottom: 5,
+ color: colors.icon,
+ fontSize: SIZE.md,
+ fontFamily: WEIGHT.regular,
+ marginTop: 20,
}}>
- {title}
+ Notes you write will appear here.
</Text>
- )}
- onScroll={event => {
- y = event.nativeEvent.contentOffset.y;
- onScroll(y);
- }}
- ListEmptyComponent={
- pinned && pinned.length > 0 ? null : (
- <View
- style={{
- height: '80%',
- width: '100%',
- alignItems: 'center',
- alignSelf: 'center',
- justifyContent: 'center',
- opacity: 0.8,
- }}>
- <NotesPlaceHolder animation={slideRight} colors={colors} />
- <NotesPlaceHolder animation={slideLeft} colors={colors} />
- <NotesPlaceHolder animation={slideRight} colors={colors} />
- <Text
- style={{
- color: colors.icon,
- fontSize: SIZE.md,
- fontFamily: WEIGHT.regular,
- marginTop: 20,
- }}>
- Notes you write will appear here.
- </Text>
- <Text
- style={{
- fontSize: SIZE.sm,
- color: colors.icon,
- marginTop: 20,
- }}>
- No notes found
- </Text>
- </View>
- )
- }
- ListHeaderComponent={
- <View
+ <Text
style={{
- marginTop:
- Platform.OS == 'ios'
- ? notes[0] && !selectionMode
- ? 135
- : 135 - 60
- : notes[0] && !selectionMode
- ? 155
- : 155 - 60,
+ fontSize: SIZE.sm,
+ color: colors.icon,
+ marginTop: 20,
}}>
- {pinned && pinned.length > 0 ? (
- <>
- <FlatList
- data={pinned}
- keyExtractor={(item, index) => item.dateCreated.toString()}
- renderItem={({item, index}) =>
- item.type === 'note' ? (
- <NoteItem
- customStyle={{
- backgroundColor: colors.shade,
- width: '100%',
- paddingHorizontal: '5%',
- paddingTop: 20,
- marginHorizontal: 0,
- marginBottom: 10,
- paddingHorizontal: 12,
- marginTop: 20,
- borderBottomWidth: 0,
- }}
- pinned={true}
- item={item}
- index={index}
- />
- ) : null
- }
- />
- </>
- ) : null}
- </View>
- }
+ No notes found
+ </Text>
+ </View>
+ );
+
+ const _renderSectionHeader = ({section: {title}}) => (
+ <Text
+ style={{
+ fontFamily: WEIGHT.bold,
+ fontSize: SIZE.sm,
+ color: colors.accent,
+ paddingHorizontal: 12,
+ width: '100%',
+ alignSelf: 'center',
+ marginTop: 15,
+ paddingBottom: 5,
+ }}>
+ {title}
+ </Text>
+ );
+
+ const _ListHeaderComponent_S = (
+ <View
+ style={{
+ marginTop:
+ Platform.OS == 'ios'
+ ? notes[0]
+ ? 135
+ : 135 - 60
+ : notes[0]
+ ? 155
+ : 155 - 60,
+ }}></View>
+ );
+
+ const _listKeyExtractor = (item, index) => item.dateCreated.toString();
+
+ return isGrouped && !isSearch ? (
+ <SectionList
+ sections={notes}
+ keyExtractor={_listKeyExtractor}
+ renderSectionHeader={_renderSectionHeader}
+ onScroll={_onScroll}
+ ListEmptyComponent={_ListEmptyComponent}
+ ListHeaderComponent={_ListHeaderComponent}
contentContainerStyle={{
width: '100%',
alignSelf: 'center',
+ minHeight: '100%',
+ }}
+ style={{
height: '100%',
}}
- ListFooterComponent={
- notes[0] ? (
- <View
- style={{
- height: 150,
- alignItems: 'center',
- justifyContent: 'center',
- }}>
- <Text
- style={{
- color: colors.navbg,
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- }}>
- - End -
- </Text>
- </View>
- ) : null
- }
- renderItem={({item, index}) => (
- <SelectionWrapper item={item}>
- <NoteItem
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- onLongPress={() => {
- changeSelectionMode(!selectionMode);
- updateSelectionList(item);
- }}
- item={item}
- index={index}
- />
- </SelectionWrapper>
- )}
+ removeClippedSubviews={true}
+ ListFooterComponent={_ListFooterComponent}
+ renderItem={_renderItem}
/>
) : (
<FlatList
data={notes}
- //keyExtractor={(item, index) => item.dateCreated.toString()}
- ListFooterComponent={
- <View
- style={{
- height: 150,
- alignItems: 'center',
- justifyContent: 'center',
- }}>
- <Text
- style={{
- color: colors.navbg,
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- }}>
- - End -
- </Text>
- </View>
- }
- onScroll={event => {
- y = event.nativeEvent.contentOffset.y;
- onScroll(y);
- }}
- ListHeaderComponent={
- <View
- style={{
- marginTop:
- Platform.OS == 'ios'
- ? notes[0]
- ? 135
- : 135 - 60
- : notes[0]
- ? 155
- : 155 - 60,
- }}></View>
- }
+ keyExtractor={_listKeyExtractor}
+ ListFooterComponent={_ListFooterComponent}
+ onScroll={_onScroll}
+ ListHeaderComponent={_ListHeaderComponent_S}
contentContainerStyle={{
width: '100%',
alignSelf: 'center',
+ minHeight: '100%',
+ }}
+ style={{
height: '100%',
}}
- ListFooterComponent={
- <View
- style={{
- height: 150,
- alignItems: 'center',
- justifyContent: 'center',
- }}>
- <Text
- style={{
- color: colors.navbg,
- fontSize: SIZE.sm,
- fontFamily: WEIGHT.regular,
- }}>
- - End -
- </Text>
- </View>
- }
- renderItem={({item, index}) => (
- <SelectionWrapper item={item}>
- <NoteItem
- customStyle={{
- width: selectionMode ? w - 74 : '100%',
- marginHorizontal: 0,
- }}
- onLongPress={() => {
- changeSelectionMode(!selectionMode);
- updateSelectionList(item);
- }}
- item={item}
- index={index}
- />
- </SelectionWrapper>
- )}
+ renderItem={_renderItem}
/>
);
};
diff --git a/apps/mobile/src/components/SearchInput/index.js b/apps/mobile/src/components/SearchInput/index.js
index 8c70621f9..5a31bb32d 100644
--- a/apps/mobile/src/components/SearchInput/index.js
+++ b/apps/mobile/src/components/SearchInput/index.js
@@ -15,8 +15,11 @@ import {getElevation, w} from '../../utils/utils';
import * as Animatable from 'react-native-animatable';
import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const Search = props => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
const [focus, setFocus] = useState(false);
const inputRef = createRef();
diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.js
index 8b11072a9..0f7ad6e0e 100644
--- a/apps/mobile/src/components/SelectionHeader/index.js
+++ b/apps/mobile/src/components/SelectionHeader/index.js
@@ -5,6 +5,7 @@ import {w} from '../../utils/utils';
import Icon from 'react-native-vector-icons/Feather';
import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView,
@@ -12,12 +13,13 @@ export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
export const SelectionHeader = ({navigation}) => {
// State
- const {
- colors,
- selectionMode,
- selectedItemsList,
- changeSelectionMode,
- } = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, selectedItemsList} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
// Render
diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.js
index 9249a5fbd..bbe61bb53 100644
--- a/apps/mobile/src/components/SelectionWrapper/index.js
+++ b/apps/mobile/src/components/SelectionWrapper/index.js
@@ -3,10 +3,16 @@ import {View, TouchableOpacity} from 'react-native';
import {SIZE} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
import {w} from '../../utils/utils';
-import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
const SelectionWrapper = ({children, item}) => {
- const {colors, selectedItemsList, selectionMode} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, selectedItemsList} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
return (
<View
style={{
@@ -14,6 +20,7 @@ const SelectionWrapper = ({children, item}) => {
justifyContent: 'space-between',
alignItems: 'center',
width: w - 24,
+
marginHorizontal: 12,
}}>
<TouchableOpacity
@@ -24,6 +31,7 @@ const SelectionWrapper = ({children, item}) => {
justifyContent: 'center',
alignItems: 'flex-start',
display: selectionMode ? 'flex' : 'none',
+ opacity: selectionMode ? 1 : 0,
}}>
<View
style={{
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.js
index f6ca90438..14756a825 100644
--- a/apps/mobile/src/components/Toast/index.js
+++ b/apps/mobile/src/components/Toast/index.js
@@ -12,12 +12,15 @@ import Icon from 'react-native-vector-icons/Feather';
import * as Animatable from 'react-native-animatable';
import {h, w} from '../../utils/utils';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
const AnimatedTouchableOpacity = Animatable.createAnimatableComponent(
TouchableOpacity,
);
export const Toast = () => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
const [toast, setToast] = useState(false);
const [message, setMessage] = useState([]);
const [data, setData] = useState([]);
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index 337c5e3f4..49dacf948 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -8,6 +8,7 @@ import {db} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
import {getElevation} from '../../utils/utils';
import NavigationService from '../../services/NavigationService';
+import {useTracked} from '../../provider';
let refs = [];
@@ -20,7 +21,9 @@ export const VaultDialog = ({
perm = false,
timestamp = null,
}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
const [hidden, setHidden] = useState(false);
let password = null;
return (
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js
index a65d42743..75ec2b986 100644
--- a/apps/mobile/src/components/header/index.js
+++ b/apps/mobile/src/components/header/index.js
@@ -7,6 +7,7 @@ import * as Animatable from 'react-native-animatable';
import NavigationService from '../../services/NavigationService';
import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
let isOpen = false;
export const Header = ({
heading,
@@ -17,7 +18,8 @@ export const Header = ({
verticalMenu = false,
sendHeight = e => {},
}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
return (
<Animatable.View
diff --git a/apps/mobile/src/views/AccountSettings/index.js b/apps/mobile/src/views/AccountSettings/index.js
index 57095c7ad..10df3ec27 100644
--- a/apps/mobile/src/views/AccountSettings/index.js
+++ b/apps/mobile/src/views/AccountSettings/index.js
@@ -4,9 +4,11 @@ import {SIZE, pv, opacity, WEIGHT} from '../../common/common';
import {Header} from '../../components/header';
import {AnimatedSafeAreaView} from '../Home';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const AccountSettings = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
return (
<AnimatedSafeAreaView
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 7444d2d27..887c22ab7 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -3,7 +3,6 @@ import {
View,
Platform,
Linking,
- DeviceEventEmitter,
KeyboardAvoidingView,
Dimensions,
TextInput,
@@ -19,29 +18,31 @@ import {SideMenuEvent, getElevation, ToastEvent} from '../../utils/utils';
import {Dialog} from '../../components/Dialog';
import {DDS} from '../../../App';
import * as Animatable from 'react-native-animatable';
-import SideMenu from 'react-native-side-menu';
import {EditorMenu} from '../../components/EditorMenu';
import {AnimatedSafeAreaView} from '../Home';
import {useAppContext} from '../../provider/useAppContext';
import ActionSheet from '../../components/ActionSheet';
import {ActionSheetComponent} from '../../components/ActionSheetComponent';
import {VaultDialog} from '../../components/VaultDialog';
-import NavigationService from '../../services/NavigationService';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
+let titleRef;
+let EditorWebView;
+let note = {};
var timestamp = null;
var content = null;
var title = null;
-let titleRef;
-let EditorWebView;
let timer = null;
-let note = {};
-
const Editor = ({navigation}) => {
// Global State
- const {colors, updateDB} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
+ ///
+ const updateDB = () => {};
// Local State
@@ -116,20 +117,31 @@ const Editor = ({navigation}) => {
locked: note.locked,
};
setNoteProps({...props});
+ console.log(JSON.stringify(note.content.delta));
- post(JSON.stringify(note.content.delta));
- setTimeout(() => {
- title = note.title;
- titleRef.setNativeProps({
- text: title,
- });
- timestamp = note.dateCreated;
- content = note.content;
- }, 200);
+ if (JSON.stringify(note.content.delta) === JSON.stringify({})) {
+ console.log('i run');
+ post(`{"ops":[{"insert":"${note.content.text}"}]}`);
+ } else {
+ post(JSON.stringify(note.content.delta));
+ }
+
+ title = note.title;
+ titleRef.setNativeProps({
+ text: title,
+ });
+ timestamp = note.dateCreated;
+ content = note.content;
};
const onTitleTextChange = value => {
title = value;
+ clearTimeout(timer);
+ timer = null;
+ timer = setTimeout(() => {
+ saveNote(noteProps, true);
+ console.log('saved');
+ }, 1000);
};
const onMenuHide = () => {
diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js
index c57511167..1628f3146 100644
--- a/apps/mobile/src/views/Favorites/index.js
+++ b/apps/mobile/src/views/Favorites/index.js
@@ -10,17 +10,15 @@ import {NotebookItem} from '../../components/NotebookItem';
import {FavoritesPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
export const Favorites = ({navigation}) => {
// Global State
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, selectedItemsList, favorites} = state;
- const {
- colors,
- favorites,
- selectionMode,
- changeSelectionMode,
- updateSelectionList,
- } = useAppContext();
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
// Local State
const [text, setText] = useState('');
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 2333d9c3f..0ff5b4a61 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -14,17 +14,17 @@ import SelectionHeader from '../../components/SelectionHeader';
import SelectionWrapper from '../../components/SelectionWrapper';
import {w} from '../../utils/utils';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
export const Folders = ({navigation}) => {
- const {
- colors,
- notebooks,
- pinned,
- updateDB,
- selectionMode,
- changeSelectionMode,
- updateSelectionList,
- } = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, notebooks} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
+
const [addNotebook, setAddNotebook] = useState(false);
const [hideHeader, setHideHeader] = useState(false);
diff --git a/apps/mobile/src/views/ForgotPassword/index.js b/apps/mobile/src/views/ForgotPassword/index.js
index 1b9c94588..5dd8dbd89 100644
--- a/apps/mobile/src/views/ForgotPassword/index.js
+++ b/apps/mobile/src/views/ForgotPassword/index.js
@@ -33,9 +33,16 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header';
import {useForceUpdate} from '../ListsEditor';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const ForgotPassword = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, selectedItemsList} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
useEffect(() => {
DeviceEventEmitter.emit('hide');
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 2c14c8175..70fce7cff 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -12,17 +12,30 @@ import {DDS} from '../../../App';
import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
+
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView,
);
+let intervals;
+let counter = 0;
export const Home = ({navigation}) => {
// State
- const {colors, setMenuOpen, selectionMode, notes} = useAppContext();
+
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, notes} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
+
const [text, setText] = useState('');
const [hideHeader, setHideHeader] = useState(false);
const [keyword, setKeyword] = useState('');
const [searchResults, setSearchResults] = useState([]);
+
// Variables
let isFocused = useIsFocused();
@@ -34,7 +47,7 @@ export const Home = ({navigation}) => {
// Effects
useEffect(() => {
- DDS.isTab ? setMenuOpen() : null;
+ dispatch({type: 'updateNotes', boo: 'hoo'});
}, []);
// Functions
@@ -89,72 +102,67 @@ export const Home = ({navigation}) => {
offsetY = y;
};
- if (!isFocused) {
- console.log('block rerender');
- return <></>;
- } else {
- // Render
- console.log('rerendering home');
- return (
- <Container
- bottomButtonText="Add a new note"
- bottomButtonOnPress={() => {
- SideMenuEvent.close();
- SideMenuEvent.disable();
- NavigationService.navigate('Editor');
+ // Render
+
+ return (
+ <Container
+ bottomButtonText="Add a new note"
+ bottomButtonOnPress={() => {
+ SideMenuEvent.close();
+ SideMenuEvent.disable();
+ NavigationService.navigate('Editor');
+ }}>
+ <SelectionHeader />
+ <Animatable.View
+ transition={['backgroundColor', 'opacity', 'height']}
+ duration={300}
+ style={{
+ position: 'absolute',
+ backgroundColor: colors.bg,
+ zIndex: 10,
+ height: selectionMode ? 0 : null,
+ opacity: selectionMode ? 0 : 1,
+ width: '100%',
}}>
- <SelectionHeader />
- <Animatable.View
- transition={['backgroundColor', 'opacity', 'height']}
- duration={300}
- style={{
- position: 'absolute',
- backgroundColor: colors.bg,
- zIndex: 10,
- height: selectionMode ? 0 : null,
- opacity: selectionMode ? 0 : 1,
- width: '100%',
- }}>
- <Header
- menu
+ <Header
+ menu
+ hide={hideHeader}
+ verticalMenu
+ showSearch={() => {
+ setHideHeader(false);
+ countUp = 0;
+ countDown = 0;
+ }}
+ colors={colors}
+ heading={'Home'}
+ canGoBack={false}
+ customIcon="menu"
+ />
+
+ {notes[0] ? (
+ <Search
+ clear={() => setText('')}
hide={hideHeader}
- verticalMenu
- showSearch={() => {
- setHideHeader(false);
- countUp = 0;
- countDown = 0;
- }}
- colors={colors}
- heading="Home"
- canGoBack={false}
- customIcon="menu"
+ onChangeText={onChangeText}
+ onSubmitEditing={onSubmitEditing}
+ placeholder="Search your notes"
+ onBlur={onBlur}
+ onFocus={onFocus}
+ clearSearch={clearSearch}
+ value={text}
/>
-
- {notes[0] ? (
- <Search
- clear={() => setText('')}
- hide={hideHeader}
- onChangeText={onChangeText}
- onSubmitEditing={onSubmitEditing}
- placeholder="Search your notes"
- onBlur={onBlur}
- onFocus={onFocus}
- clearSearch={clearSearch}
- value={text}
- />
- ) : null}
- </Animatable.View>
-
- <NotesList
- isGrouped={true}
- onScroll={onScroll}
- isSearch={searchResults.length > 0 ? true : false}
- notes={searchResults.length > 0 ? searchResults : notes}
- keyword={keyword}
- />
- </Container>
- );
- }
+ ) : null}
+ </Animatable.View>
+
+ <NotesList
+ isGrouped={true}
+ onScroll={onScroll}
+ isSearch={searchResults.length > 0 ? true : false}
+ notes={searchResults.length > 0 ? searchResults : notes}
+ keyword={keyword}
+ />
+ </Container>
+ );
};
Home.navigationOptions = {
diff --git a/apps/mobile/src/views/Lists/index.js b/apps/mobile/src/views/Lists/index.js
index 05b970ab9..95e7f1bf0 100644
--- a/apps/mobile/src/views/Lists/index.js
+++ b/apps/mobile/src/views/Lists/index.js
@@ -24,12 +24,14 @@ import Icon from 'react-native-vector-icons/Ionicons';
import {Reminder} from '../../components/Reminder';
import {ListItem} from '../../components/ListItem';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Lists = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
return (
<SafeAreaView>
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
index 39be4d9c8..350a0b79e 100644
--- a/apps/mobile/src/views/Login/index.js
+++ b/apps/mobile/src/views/Login/index.js
@@ -14,8 +14,11 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header';
import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const Login = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
useEffect(() => {
DeviceEventEmitter.emit('hide');
return () => {
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 755557866..718fae194 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -9,9 +9,16 @@ import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container';
+import {useTracked} from '../../provider';
export const Notebook = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, selectedItemsList} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
const params = navigation.state.params;
const [hideHeader, setHideHeader] = useState(false);
const [buttonHide, setButtonHide] = useState(false);
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 6f93d2078..c6221b0d2 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -7,9 +7,16 @@ import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
export const Notes = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, pinned, selectedItemsList} = state;
+
+ ///
+ const updateDB = () => {};
+ const updateSelectionList = () => {};
+ const changeSelectionMode = () => {};
const [hideHeader, setHideHeader] = useState(false);
const [margin, setMargin] = useState(200);
const [buttonHide, setButtonHide] = useState(false);
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 181907ff0..5dafb16de 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -22,8 +22,14 @@ import {useAppContext} from '../../provider/useAppContext';
import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container';
import FastStorage from 'react-native-fast-storage';
+import {useTracked} from '../../provider';
export const Settings = ({navigation}) => {
- const {colors, changeAccentColor, changeColorScheme} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+
+ ///
+ const changeAccentColor = () => {};
+ const changeColorScheme = () => {};
//const [colors, setColors] = useState(COLOR_SCHEME_LIGHT);
let isFocused = useIsFocused();
@@ -77,6 +83,7 @@ export const Settings = ({navigation}) => {
'#fabebe',
].map(item => (
<TouchableOpacity
+ key={item}
onPress={() => {
changeAccentColor(item);
@@ -165,6 +172,7 @@ export const Settings = ({navigation}) => {
keyExtractor={item => item.name}
renderItem={({item, index}) => (
<TouchableOpacity
+ key={item.name}
activeOpacity={opacity}
onPress={item.func}
style={{
diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js
index f608f4c43..bc9830bf3 100644
--- a/apps/mobile/src/views/Signup/index.js
+++ b/apps/mobile/src/views/Signup/index.js
@@ -12,9 +12,11 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header';
import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext';
+import {useTracked} from '../../provider';
export const Signup = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
useEffect(() => {
DeviceEventEmitter.emit('hide');
return () => {
diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js
index e075abd1f..2d14fd705 100644
--- a/apps/mobile/src/views/Tags/index.js
+++ b/apps/mobile/src/views/Tags/index.js
@@ -5,11 +5,13 @@ import {SIZE, pv, WEIGHT} from '../../common/common';
import {Header} from '../../components/header';
import {useAppContext} from '../../provider/useAppContext';
import {TagsPlaceHolder} from '../../components/ListPlaceholders';
+import {useTracked} from '../../provider';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Tags = ({navigation}) => {
- const {colors} = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
let isFocused = useIsFocused();
if (!isFocused) {
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index 4bfade850..d7d03c9dc 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -13,16 +13,15 @@ import {TrashPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader';
import {useIsFocused} from 'react-navigation-hooks';
+import {useTracked} from '../../provider';
export const Trash = ({navigation}) => {
- const {
- colors,
- trash,
- updateDB,
- selectionMode,
- changeSelectionMode,
- updateSelectionList,
- } = useAppContext();
+ const [state, dispatch] = useTracked();
+ const {colors, selectionMode, trash} = state;
+
+ const updateDB = () => {};
+ const changeSelectionMode = () => {};
+ const updateSelectionList = () => {};
const [dialog, setDialog] = useState(false);
let isFocused = useIsFocused();