This commit is contained in:
ammarahm-ed
2020-01-17 21:26:01 +05:00
parent 29f55e19c2
commit 6a256686f7
33 changed files with 146 additions and 234 deletions

View File

@@ -10,7 +10,6 @@ import {Menu} from './src/components/Menu';
import SideMenu from './src/components/SideMenu'; import SideMenu from './src/components/SideMenu';
import Storage from 'notes-core/api/database'; import Storage from 'notes-core/api/database';
import StorageInterface from './src/utils/storage'; import StorageInterface from './src/utils/storage';
<<<<<<< HEAD
import {useTracked, ACTIONS} from './src/provider'; import {useTracked, ACTIONS} from './src/provider';
import {DeviceDetectionService} from './src/utils/deviceDetection'; import {DeviceDetectionService} from './src/utils/deviceDetection';
import { import {
@@ -19,26 +18,14 @@ import {
_unSubscribeEvent, _unSubscribeEvent,
} from './src/components/DialogManager'; } from './src/components/DialogManager';
import {getColorScheme} from './src/common/common'; import {getColorScheme} from './src/common/common';
=======
import {DeviceDetectionService} from './src/utils/deviceDetection';
import {DialogManager} from './src/components/DialogManager';
import {useAppContext} from './src/provider/useAppContext';
import {AppProvider} from './src/provider';
import {COLOR_SCHEME_LIGHT} from './src/common/common';
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
export const DDS = new DeviceDetectionService(); export const DDS = new DeviceDetectionService();
export const db = new Storage(StorageInterface); export const db = new Storage(StorageInterface);
let sideMenuRef; let sideMenuRef;
const App = () => { const App = () => {
<<<<<<< HEAD
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors} = state; const {colors} = state;
=======
const [colors, setColors] = useState(COLOR_SCHEME_LIGHT);
// Global State
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
// Local State // Local State
const [sidebar, setSidebar] = useState(w * 0.3); const [sidebar, setSidebar] = useState(w * 0.3);
@@ -102,7 +89,7 @@ const App = () => {
setInit(true); setInit(true);
}); });
}); });
}); }, []);
async function updateAppTheme(colors = state.colors) { async function updateAppTheme(colors = state.colors) {
let newColors = await getColorScheme(colors); let newColors = await getColorScheme(colors);
@@ -110,16 +97,12 @@ const App = () => {
} }
// Render // Render
if (!init) { if (!init) {
return <></>; return <></>;
} }
return ( return (
<<<<<<< HEAD
<> <>
=======
<AppProvider>
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
<View <View
style={{ style={{
width: '100%', width: '100%',
@@ -182,15 +165,9 @@ const App = () => {
</SideMenu> </SideMenu>
)} )}
<Toast /> <Toast />
<<<<<<< HEAD
<DialogManager colors={colors} /> <DialogManager colors={colors} />
</View> </View>
</> </>
=======
</View>
<DialogManager colors={colors} />
</AppProvider>
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
); );
}; };

View File

@@ -5,5 +5,15 @@
import {AppRegistry} from 'react-native'; import {AppRegistry} from 'react-native';
import App, {db} from './App'; import App, {db} from './App';
import {name as appName} from './app.json'; import {name as appName} from './app.json';
import React, {useEffect} from 'react';
import {Provider} from './src/provider';
AppRegistry.registerComponent(appName, () => App); const AppProvider = () => {
return (
<Provider>
<App />
</Provider>
);
};
AppRegistry.registerComponent(appName, () => AppProvider);

View File

@@ -20,8 +20,7 @@ import Icon from 'react-native-vector-icons/Feather';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {db} from '../../../App'; import {db} from '../../../App';
import FastStorage from 'react-native-fast-storage'; import FastStorage from 'react-native-fast-storage';
import {useTracked} from '../../provider';
import {_recieveEvent, _unSubscribeEvent} from '../DialogManager';
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
@@ -35,11 +34,11 @@ export const ActionSheetComponent = ({
rowItems = [], rowItems = [],
columnItems = [], columnItems = [],
}) => { }) => {
const {colors, updateDB, changeColorScheme} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
// Todo // Todo
<<<<<<< HEAD
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) { function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent); let newColors = setColorScheme(colors, accent);
StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content'); StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');
@@ -47,8 +46,6 @@ export const ActionSheetComponent = ({
dispatch({type: ACTIONS.THEME, colors: newColors}); dispatch({type: ACTIONS.THEME, colors: newColors});
} }
=======
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
const [focused, setFocused] = useState(false); const [focused, setFocused] = useState(false);
const [note, setNote] = useState( const [note, setNote] = useState(
item item
@@ -163,7 +160,7 @@ export const ActionSheetComponent = ({
} }
} }
updateDB(); dispatch({type: type});
setNote({...toAdd}); setNote({...toAdd});
}; };

View File

@@ -13,12 +13,13 @@ import {getElevation, ToastEvent} from '../../utils/utils';
import {FlatList, TextInput} from 'react-native-gesture-handler'; import {FlatList, TextInput} from 'react-native-gesture-handler';
import {db, DDS} from '../../../App'; import {db, DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
let refs = []; let refs = [];
export const AddNotebookDialog = ({visible, close, toEdit = null}) => { export const AddNotebookDialog = ({visible, close, toEdit = null}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
const [topics, setTopics] = useState(['']); const [topics, setTopics] = useState(['']);
const [title, setTitle] = useState(null); const [title, setTitle] = useState(null);

View File

@@ -28,7 +28,7 @@ import {FlatList, TextInput} from 'react-native-gesture-handler';
import {useForceUpdate} from '../../views/ListsEditor'; import {useForceUpdate} from '../../views/ListsEditor';
import {db} from '../../../App'; import {db} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const AddTopicDialog = ({ export const AddTopicDialog = ({
visible, visible,
@@ -36,7 +36,8 @@ export const AddTopicDialog = ({
notebookID, notebookID,
toEdit = null, toEdit = null,
}) => { }) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
const [titleFocused, setTitleFocused] = useState(false); const [titleFocused, setTitleFocused] = useState(false);
let title = null; let title = null;

View File

@@ -19,7 +19,7 @@ import NavigationService from '../../services/NavigationService';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import {useTracked} from '../../provider';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent( export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView, SafeAreaView,
); );
@@ -31,7 +31,8 @@ export const Container = ({
noBottomButton = false, noBottomButton = false,
}) => { }) => {
// State // State
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
const [buttonHide, setButtonHide] = useState(false); const [buttonHide, setButtonHide] = useState(false);

View File

@@ -13,10 +13,6 @@ import {
} from '../../common/common'; } from '../../common/common';
import Icon from 'react-native-vector-icons/Feather'; import Icon from 'react-native-vector-icons/Feather';
import {getElevation, ToastEvent} from '../../utils/utils'; import {getElevation, ToastEvent} from '../../utils/utils';
<<<<<<< HEAD
=======
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
import {dialogActions, updateEvent} from '../DialogManager'; import {dialogActions, updateEvent} from '../DialogManager';
import {db} from '../../../App'; import {db} from '../../../App';

View File

@@ -69,10 +69,6 @@ export class DialogManager extends Component {
super(props); super(props);
this.actionSheet; this.actionSheet;
this.opened = false; this.opened = false;
<<<<<<< HEAD
=======
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
this.state = { this.state = {
item: {}, item: {},
actionSheetData: { actionSheetData: {

View File

@@ -26,7 +26,7 @@ import {AnimatedSafeAreaView} from '../../views/Home';
import {TextInput} from 'react-native-gesture-handler'; import {TextInput} from 'react-native-gesture-handler';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {VaultDialog} from '../VaultDialog'; import {VaultDialog} from '../VaultDialog';
import {useTracked} from '../../provider';
let tagsInputRef; let tagsInputRef;
let tagsList; let tagsList;
@@ -39,9 +39,11 @@ export const EditorMenu = ({
note, note,
timestamp, timestamp,
}) => { }) => {
const {colors, changeColorScheme} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
// Todo // Todo
const changeColorScheme = () => {};
/////// ///////
const [unlock, setUnlock] = useState(false); const [unlock, setUnlock] = useState(false);

View File

@@ -14,11 +14,12 @@ import Icon from 'react-native-vector-icons/Ionicons';
import {getElevation} from '../../utils/utils'; import {getElevation} from '../../utils/utils';
import {FlatList} from 'react-native-gesture-handler'; import {FlatList} from 'react-native-gesture-handler';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
export const ListItem = props => { export const ListItem = props => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
return ( return (
<View <View

View File

@@ -25,7 +25,8 @@ import FastStorage from 'react-native-fast-storage';
import {useTracked, ACTIONS} from '../../provider'; import {useTracked, ACTIONS} from '../../provider';
export const Menu = ({close = () => {}, hide, update = () => {}}) => { export const Menu = ({close = () => {}, hide, update = () => {}}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
// todo // todo

View File

@@ -67,11 +67,7 @@ export default class NoteItem extends React.Component {
update, update,
index, index,
} = this.props; } = this.props;
<<<<<<< HEAD
console.log('rendering', index); console.log('rendering', index);
=======
console.log('rerendering', index);
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
return ( return (
<View <View
style={[ style={[

View File

@@ -27,9 +27,11 @@ export const NotebookItem = ({
customStyle, customStyle,
onLongPress, onLongPress,
}) => { }) => {
const {colors, updateDB} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
/// ///
const updateDB = () => {};
const [isVisible, setVisible] = useState(false); const [isVisible, setVisible] = useState(false);
const [addTopic, setAddTopic] = useState(false); const [addTopic, setAddTopic] = useState(false);

View File

@@ -15,9 +15,10 @@ import {getElevation, w} from '../../utils/utils';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const Search = props => { export const Search = props => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
const [focus, setFocus] = useState(false); const [focus, setFocus] = useState(false);

View File

@@ -5,7 +5,7 @@ import {w} from '../../utils/utils';
import Icon from 'react-native-vector-icons/Feather'; import Icon from 'react-native-vector-icons/Feather';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent( export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView, SafeAreaView,
@@ -13,14 +13,13 @@ export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
export const SelectionHeader = ({navigation}) => { export const SelectionHeader = ({navigation}) => {
// State // State
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, selectedItemsList} = state;
selectionMode,
selectedItemsList, ///
updateDB, const updateDB = () => {};
updateSelectionList, const updateSelectionList = () => {};
changeSelectionMode, const changeSelectionMode = () => {};
} = useAppContext();
// Render // Render

View File

@@ -3,18 +3,16 @@ import {View, TouchableOpacity} from 'react-native';
import {SIZE} from '../../common/common'; import {SIZE} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather'; import Icon from 'react-native-vector-icons/Feather';
import {w} from '../../utils/utils'; import {w} from '../../utils/utils';
import {useAppContext} from '../../provider/useAppContext'; import {useTracked} from '../../provider';
const SelectionWrapper = ({children, item}) => { const SelectionWrapper = ({children, item}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, selectedItemsList} = state;
selectionMode,
selectedItemsList,
updateDB,
updateSelectionList,
changeSelectionMode,
} = useAppContext();
///
const updateDB = () => {};
const updateSelectionList = () => {};
const changeSelectionMode = () => {};
return ( return (
<View <View
style={{ style={{

View File

@@ -12,13 +12,14 @@ import Icon from 'react-native-vector-icons/Feather';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import {h, w} from '../../utils/utils'; import {h, w} from '../../utils/utils';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
const AnimatedTouchableOpacity = Animatable.createAnimatableComponent( const AnimatedTouchableOpacity = Animatable.createAnimatableComponent(
TouchableOpacity, TouchableOpacity,
); );
export const Toast = () => { export const Toast = () => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
const [toast, setToast] = useState(false); const [toast, setToast] = useState(false);
const [message, setMessage] = useState([]); const [message, setMessage] = useState([]);

View File

@@ -7,7 +7,7 @@ import * as Animatable from 'react-native-animatable';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
let isOpen = false; let isOpen = false;
export const Header = ({ export const Header = ({
heading, heading,
@@ -18,7 +18,8 @@ export const Header = ({
verticalMenu = false, verticalMenu = false,
sendHeight = e => {}, sendHeight = e => {},
}) => { }) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
return ( return (
<Animatable.View <Animatable.View

View File

@@ -1,9 +1,6 @@
import React, {createContext, useEffect, useState} from 'react'; import React, {useReducer} from 'react';
import {View, Text} from 'react-native';
import {useImmer} from 'use-immer';
import {DDS, db} from '../../App'; import {DDS, db} from '../../App';
import {getColorScheme} from '../common/common'; import {createContainer} from 'react-tracked';
const defaultState = { const defaultState = {
isMenuOpen: { isMenuOpen: {
current: false, current: false,
@@ -35,11 +32,8 @@ const defaultState = {
warningBg: '#FEEFB3', warningBg: '#FEEFB3',
warningText: '#9F6000', warningText: '#9F6000',
}, },
selectionMode: false,
selectedItemsList: [],
}; };
<<<<<<< HEAD
export const ACTIONS = { export const ACTIONS = {
NOTES: 'note', NOTES: 'note',
NOTEBOOKS: 'notebook', NOTEBOOKS: 'notebook',
@@ -71,49 +65,9 @@ const reducer = (state, action) => {
} }
default: default:
throw new Error('unknown action type'); throw new Error('unknown action type');
=======
const AppContext = createContext([defaultState, function() {}]);
const AppProvider = ({children}) => {
const [state, dispatch] = useImmer({...defaultState});
const [loading, setLoading] = useState(true);
async function init() {
let newColors = await getColorScheme();
dispatch(draft => {
draft.colors = {...newColors};
draft.notes = db.groupNotes();
draft.notebooks = db.getNotebooks();
draft.trash = db.getTrash();
draft.favorites = db.getFavorites();
draft.pinned = db.getPinned();
});
setLoading(false);
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
} }
useEffect(() => {
init();
}, []);
return (
<AppContext.Provider value={[state, dispatch]}>
{loading ? (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center',
}}>
<Text>Loading...</Text>
</View>
) : (
children
)}
</AppContext.Provider>
);
}; };
export {AppProvider, AppContext}; const useValue = () => useReducer(reducer, defaultState);
export const {Provider, useTracked} = createContainer(useValue);

View File

@@ -4,10 +4,11 @@ import {SIZE, pv, opacity, WEIGHT} from '../../common/common';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
import {AnimatedSafeAreaView} from '../Home'; import {AnimatedSafeAreaView} from '../Home';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const AccountSettings = ({navigation}) => { export const AccountSettings = ({navigation}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
return ( return (
<AnimatedSafeAreaView <AnimatedSafeAreaView

View File

@@ -25,16 +25,12 @@ import ActionSheet from '../../components/ActionSheet';
import {ActionSheetComponent} from '../../components/ActionSheetComponent'; import {ActionSheetComponent} from '../../components/ActionSheetComponent';
import {VaultDialog} from '../../components/VaultDialog'; import {VaultDialog} from '../../components/VaultDialog';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
<<<<<<< HEAD
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import { import {
simpleDialogEvent, simpleDialogEvent,
TEMPLATE_EXIT, TEMPLATE_EXIT,
ActionSheetEvent, ActionSheetEvent,
} from '../../components/DialogManager'; } from '../../components/DialogManager';
=======
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
@@ -47,7 +43,11 @@ var title = null;
let timer = null; let timer = null;
const Editor = ({navigation}) => { const Editor = ({navigation}) => {
// Global State // Global State
const {colors, updateDB} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
///
const updateDB = () => {};
// Local State // Local State

View File

@@ -10,17 +10,15 @@ import {NotebookItem} from '../../components/NotebookItem';
import {FavoritesPlaceHolder} from '../../components/ListPlaceholders'; import {FavoritesPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container'; import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import {useTracked} from '../../provider';
export const Favorites = ({navigation}) => { export const Favorites = ({navigation}) => {
// Global State // Global State
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, pinned, selectedItemsList, favorites} = state;
selectionMode,
favorites, const updateSelectionList = () => {};
updateSelectionList, const changeSelectionMode = () => {};
changeSelectionMode,
} = useAppContext();
// Local State // Local State
const [text, setText] = useState(''); const [text, setText] = useState('');

View File

@@ -14,18 +14,16 @@ import SelectionHeader from '../../components/SelectionHeader';
import SelectionWrapper from '../../components/SelectionWrapper'; import SelectionWrapper from '../../components/SelectionWrapper';
import {w} from '../../utils/utils'; import {w} from '../../utils/utils';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import {useTracked} from '../../provider';
export const Folders = ({navigation}) => { export const Folders = ({navigation}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, pinned, notebooks} = state;
selectionMode,
pinned, ///
notebooks, const updateDB = () => {};
updateDB, const updateSelectionList = () => {};
updateSelectionList, const changeSelectionMode = () => {};
changeSelectionMode,
} = useAppContext();
const [addNotebook, setAddNotebook] = useState(false); const [addNotebook, setAddNotebook] = useState(false);
const [hideHeader, setHideHeader] = useState(false); const [hideHeader, setHideHeader] = useState(false);

View File

@@ -33,17 +33,16 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
import {useForceUpdate} from '../ListsEditor'; import {useForceUpdate} from '../ListsEditor';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const ForgotPassword = ({navigation}) => { export const ForgotPassword = ({navigation}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, pinned, selectedItemsList} = state;
updateDB,
updateSelectionList,
changeSelectionMode,
} = useAppContext();
/// ///
const updateDB = () => {};
const updateSelectionList = () => {};
const changeSelectionMode = () => {};
useEffect(() => { useEffect(() => {
DeviceEventEmitter.emit('hide'); DeviceEventEmitter.emit('hide');

View File

@@ -1,5 +1,5 @@
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {SafeAreaView, Text} from 'react-native'; import {SafeAreaView} from 'react-native';
import {Search} from '../../components/SearchInput'; import {Search} from '../../components/SearchInput';
import {w, h, SideMenuEvent, ToastEvent} from '../../utils/utils'; import {w, h, SideMenuEvent, ToastEvent} from '../../utils/utils';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
@@ -11,28 +11,26 @@ import {useAppContext} from '../../provider/useAppContext';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import Container from '../../components/Container'; import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader'; import SelectionHeader from '../../components/SelectionHeader';
import {useIsFocused, useFocusEffect} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import { import {useTracked, ACTIONS} from '../../provider';
_recieveEvent, import {_recieveEvent, _unSubscribeEvent} from '../../components/DialogManager';
_unSubscribeEvent,
updateEvent,
} from '../../components/DialogManager';
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent( export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView, SafeAreaView,
); );
let intervals;
let counter = 0;
export const Home = ({navigation}) => { export const Home = ({navigation}) => {
// State // State
const {
colors, const [state, dispatch] = useTracked();
selectionMode, const {colors, selectionMode, notes} = state;
pinned,
notes, ///
updateDB, const updateDB = () => {};
updateSelectionList, const updateSelectionList = () => {};
changeSelectionMode, const changeSelectionMode = () => {};
} = useAppContext();
const [text, setText] = useState(''); const [text, setText] = useState('');
const [hideHeader, setHideHeader] = useState(false); const [hideHeader, setHideHeader] = useState(false);
@@ -49,18 +47,7 @@ export const Home = ({navigation}) => {
// Effects // Effects
useEffect(() => { useEffect(() => {
<<<<<<< HEAD
dispatch({type: ACTIONS.NOTES, payload: 'hello there'}); dispatch({type: ACTIONS.NOTES, payload: 'hello there'});
=======
_recieveEvent('updateEvent', () => {
updateDB();
});
return () => {
_unSubscribeEvent('updateEvent', () => {
updateDB();
});
};
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
}, []); }, []);
// Functions // Functions
@@ -116,7 +103,7 @@ export const Home = ({navigation}) => {
}; };
// Render // Render
console.log('rerender');
return ( return (
<Container <Container
bottomButtonText="Add a new note" bottomButtonText="Add a new note"
@@ -143,7 +130,6 @@ export const Home = ({navigation}) => {
hide={hideHeader} hide={hideHeader}
verticalMenu verticalMenu
showSearch={() => { showSearch={() => {
let counter = updateCounter;
setHideHeader(false); setHideHeader(false);
countUp = 0; countUp = 0;
countDown = 0; countDown = 0;

View File

@@ -24,13 +24,14 @@ import Icon from 'react-native-vector-icons/Ionicons';
import {Reminder} from '../../components/Reminder'; import {Reminder} from '../../components/Reminder';
import {ListItem} from '../../components/ListItem'; import {ListItem} from '../../components/ListItem';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
export const Lists = ({navigation}) => { export const Lists = ({navigation}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
return ( return (
<SafeAreaView> <SafeAreaView>

View File

@@ -14,9 +14,10 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const Login = ({navigation}) => { export const Login = ({navigation}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
useEffect(() => { useEffect(() => {
DeviceEventEmitter.emit('hide'); DeviceEventEmitter.emit('hide');

View File

@@ -9,17 +9,16 @@ import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container'; import Container from '../../components/Container';
import {useTracked} from '../../provider';
export const Notebook = ({navigation}) => { export const Notebook = ({navigation}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, pinned, selectedItemsList} = state;
selectionMode,
updateDB,
updateSelectionList,
changeSelectionMode,
} = useAppContext();
///
const updateDB = () => {};
const updateSelectionList = () => {};
const changeSelectionMode = () => {};
const params = navigation.state.params; const params = navigation.state.params;
const [hideHeader, setHideHeader] = useState(false); const [hideHeader, setHideHeader] = useState(false);
const [buttonHide, setButtonHide] = useState(false); const [buttonHide, setButtonHide] = useState(false);

View File

@@ -7,17 +7,16 @@ import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import Container from '../../components/Container'; import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import {useTracked} from '../../provider';
export const Notes = ({navigation}) => { export const Notes = ({navigation}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, pinned, selectedItemsList} = state;
selectionMode,
updateDB,
updateSelectionList,
changeSelectionMode,
} = useAppContext();
///
const updateDB = () => {};
const updateSelectionList = () => {};
const changeSelectionMode = () => {};
const [hideHeader, setHideHeader] = useState(false); const [hideHeader, setHideHeader] = useState(false);
const [margin, setMargin] = useState(200); const [margin, setMargin] = useState(200);
const [buttonHide, setButtonHide] = useState(false); const [buttonHide, setButtonHide] = useState(false);

View File

@@ -24,19 +24,15 @@ import {useAppContext} from '../../provider/useAppContext';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container'; import Container from '../../components/Container';
import FastStorage from 'react-native-fast-storage'; import FastStorage from 'react-native-fast-storage';
import {useTracked} from '../../provider';
export const Settings = ({navigation}) => { export const Settings = ({navigation}) => {
const {colors, changeAccentColor, changeColorScheme} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
<<<<<<< HEAD
/// ///
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) { function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent); let newColors = setColorScheme(colors, accent);
StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content'); StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');
=======
//const [colors, setColors] = useState(COLOR_SCHEME_LIGHT);
let isFocused = useIsFocused();
>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646
dispatch({type: ACTIONS.THEME, colors: newColors}); dispatch({type: ACTIONS.THEME, colors: newColors});
} }

View File

@@ -12,10 +12,11 @@ import {NavigationEvents} from 'react-navigation';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
import {DDS} from '../../../App'; import {DDS} from '../../../App';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {useTracked} from '../../provider';
export const Signup = ({navigation}) => { export const Signup = ({navigation}) => {
const {colors} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
useEffect(() => { useEffect(() => {
DeviceEventEmitter.emit('hide'); DeviceEventEmitter.emit('hide');
return () => { return () => {

View File

@@ -5,13 +5,13 @@ import {SIZE, pv, WEIGHT} from '../../common/common';
import {Header} from '../../components/header'; import {Header} from '../../components/header';
import {useAppContext} from '../../provider/useAppContext'; import {useAppContext} from '../../provider/useAppContext';
import {TagsPlaceHolder} from '../../components/ListPlaceholders'; import {TagsPlaceHolder} from '../../components/ListPlaceholders';
import {useTracked} from '../../provider';
const w = Dimensions.get('window').width; const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height; const h = Dimensions.get('window').height;
export const Tags = ({navigation}) => { export const Tags = ({navigation}) => {
const {colors, tags} = useAppContext(); const [state, dispatch] = useTracked();
const {colors} = state;
let isFocused = useIsFocused(); let isFocused = useIsFocused();
if (!isFocused) { if (!isFocused) {

View File

@@ -13,17 +13,15 @@ import {TrashPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container'; import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader'; import SelectionHeader from '../../components/SelectionHeader';
import {useIsFocused} from 'react-navigation-hooks'; import {useIsFocused} from 'react-navigation-hooks';
import {useTracked} from '../../provider';
export const Trash = ({navigation}) => { export const Trash = ({navigation}) => {
const { const [state, dispatch] = useTracked();
colors, const {colors, selectionMode, trash} = state;
selectionMode,
updateDB, const updateDB = () => {};
updateSelectionList, const changeSelectionMode = () => {};
changeSelectionMode, const updateSelectionList = () => {};
trash,
} = useAppContext();
const [dialog, setDialog] = useState(false); const [dialog, setDialog] = useState(false);
let isFocused = useIsFocused(); let isFocused = useIsFocused();