A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
Merge
ammarahm-ed2ebd539a33d8
diff --cc apps/mobile/App.jsindex f2196a4d8,c46689bd0..185ad9117--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@@ -10,22 -10,19 +10,35 @@@ import {Menu} from './src/components/Meimport SideMenu from './src/components/SideMenu';import Storage from 'notes-core/api/database';import StorageInterface from './src/utils/storage';++<<<<<<< HEAD+import {useTracked, ACTIONS} from './src/provider';+import {DeviceDetectionService} from './src/utils/deviceDetection';+import {+ DialogManager,+ _recieveEvent,+ _unSubscribeEvent,+} from './src/components/DialogManager';+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';++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646export const DDS = new DeviceDetectionService();export const db = new Storage(StorageInterface);let sideMenuRef;const App = () => {++<<<<<<< HEAD+ const [state, dispatch] = useTracked();+ const {colors} = state;++=======+ const [colors, setColors] = useState(COLOR_SCHEME_LIGHT);+ // Global State++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646// Local Stateconst [sidebar, setSidebar] = useState(w * 0.3);@@@ -84,25 -71,18 +97,29 @@@}, []);useEffect(() => {- db.init().then(() => {- setInit(true);+ updateAppTheme().then(() => {+ db.init().then(() => {+ setInit(true);+ });});- }, []);+ });+ async function updateAppTheme(colors = state.colors) {+ let newColors = await getColorScheme(colors);+ dispatch({type: ACTIONS.THEME, colors: newColors});+ }+// Render-if (!init) {return <></>;}+return (++<<<<<<< HEAD+ <>++=======+ <AppProvider>++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646<Viewstyle={{width: '100%',@@@ -165,9 -145,9 +182,15 @@@</SideMenu>)}<Toast />++<<<<<<< HEAD+ <DialogManager colors={colors} />+ </View>+ </>++=======+ </View>+ <DialogManager colors={colors} />+ </AppProvider>++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646);};diff --cc apps/mobile/src/components/ActionSheetComponent/index.jsindex fdbc1442c,2e11e3c53..da9526337--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@@ -19,8 -17,10 +19,9 @@@ importimport Icon from 'react-native-vector-icons/Feather';import NavigationService from '../../services/NavigationService';import {db} from '../../../App';-import {useAppContext} from '../../provider/useAppContext';import FastStorage from 'react-native-fast-storage';- import {useTracked} from '../../provider';++ import {_recieveEvent, _unSubscribeEvent} from '../DialogManager';const w = Dimensions.get('window').width;const h = Dimensions.get('window').height;@@@ -39,13 -38,6 +39,16 @@@ export const ActionSheetComponent = (// Todo++<<<<<<< HEAD+ function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {+ let newColors = setColorScheme(colors, accent);+ StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');++ dispatch({type: ACTIONS.THEME, colors: newColors});+ }+++=======++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646const [focused, setFocused] = useState(false);const [note, setNote] = useState(itemdiff --cc apps/mobile/src/components/Dialog/index.jsindex b0904513d,22bb10a32..bf03e1ee0--- a/apps/mobile/src/components/Dialog/index.js+++ b/apps/mobile/src/components/Dialog/index.js@@@ -13,6 -13,7 +13,10 @@@ import} from '../../common/common';import Icon from 'react-native-vector-icons/Feather';import {getElevation, ToastEvent} from '../../utils/utils';++<<<<<<< HEAD++=======+++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646import {dialogActions, updateEvent} from '../DialogManager';import {db} from '../../../App';diff --cc apps/mobile/src/components/DialogManager/index.jsindex d7356be2b,71f586559..d67893199--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@@ -69,6 -58,7 +69,10 @@@ export class DialogManager extends Compsuper(props);this.actionSheet;this.opened = false;++<<<<<<< HEAD++=======+++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646this.state = {item: {},actionSheetData: {diff --cc apps/mobile/src/components/Menu/index.jsindex 5c7b58803,5c560f57d..31eee8b63--- a/apps/mobile/src/components/Menu/index.js+++ b/apps/mobile/src/components/Menu/index.js@@@ -15,18 -15,15 +15,21 @@@ importWEIGHT,COLOR_SCHEME_DARK,COLOR_SCHEME_LIGHT,+ ACCENT,+ COLOR_SCHEME,+ setColorScheme,} from '../../common/common';import Icon from 'react-native-vector-icons/Feather';-import {h} from '../../utils/utils';import {AnimatedSafeAreaView} from '../../views/Home';-import {useAppContext} from '../../provider/useAppContext';import FastStorage from 'react-native-fast-storage';++<<<<<<< HEAD+import {useTracked, ACTIONS} from '../../provider';+++=======+++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646export const Menu = ({close = () => {}, hide, update = () => {}}) => {- const [state, dispatch] = useTracked();- const {colors} = state;+ const {colors} = useAppContext();// tododiff --cc apps/mobile/src/components/NoteItem/index.jsindex 960fdeb1b,43f73d565..cbb427458--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@@ -67,7 -49,7 +67,11 @@@ export default class NoteItem extends Rupdate,index,} = this.props;++<<<<<<< HEAD+ console.log('rendering', index);++=======+ console.log('rerendering', index);++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646return (<Viewstyle={[diff --cc apps/mobile/src/provider/index.jsindex 19d3db584,0e48a8afc..92700e790--- a/apps/mobile/src/provider/index.js+++ b/apps/mobile/src/provider/index.js@@@ -32,42 -35,51 +35,85 @@@ const defaultState =warningBg: '#FEEFB3',warningText: '#9F6000',},+ selectionMode: false,+ selectedItemsList: [],};++<<<<<<< HEAD+export const ACTIONS = {+ NOTES: 'note',+ NOTEBOOKS: 'notebook',+ TRASH: 'trash',+ TAGS: 'tags',+ PINNED: 'pinned',+ FAVORITES: 'favorites',+ SELECTION_MODE: 'selectionMode',+ SELECTED_ITEMS_LIST: 'selectedItemsList',+ THEME: 'theme',+ CHANGE_THEME: 'changeTheme',+ CHANGE_ACCENT: 'changeAccent',+};++const reducer = (state, action) => {+ switch (action.type) {+ case ACTIONS.NOTES:+ console.log(action.payload);+ let notes = db.groupNotes();+ return {+ ...state,+ notes: notes,+ };+ case ACTIONS.THEME: {+ return {+ ...state,+ colors: {...action.colors},+ };+ }+ default:+ 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}- };- const useValue = () => useReducer(reducer, defaultState);+ 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 const {Provider, useTracked} = createContainer(useValue);+ export {AppProvider, AppContext};diff --cc apps/mobile/src/views/Editor/index.jsindex b40c0d7fd,fa5343a9b..66e18b384--- a/apps/mobile/src/views/Editor/index.js+++ b/apps/mobile/src/views/Editor/index.js@@@ -25,12 -25,7 +25,16 @@@ import ActionSheet from '../../componenimport {ActionSheetComponent} from '../../components/ActionSheetComponent';import {VaultDialog} from '../../components/VaultDialog';import {useIsFocused} from 'react-navigation-hooks';++<<<<<<< HEAD+import {useTracked} from '../../provider';+import {+ simpleDialogEvent,+ TEMPLATE_EXIT,+ ActionSheetEvent,+} from '../../components/DialogManager';++=======+++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646const w = Dimensions.get('window').width;const h = Dimensions.get('window').height;diff --cc apps/mobile/src/views/Home/index.jsindex acda8e6e0,8f2c731b4..1edf86c87--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@@ -47,7 -50,14 +49,18 @@@ export const Home = ({navigation}) =>// EffectsuseEffect(() => {++<<<<<<< HEAD+ dispatch({type: ACTIONS.NOTES, payload: 'hello there'});++=======+ _recieveEvent('updateEvent', () => {+ updateDB();+ });+ return () => {+ _unSubscribeEvent('updateEvent', () => {+ updateDB();+ });+ };++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646}, []);// Functionsdiff --cc apps/mobile/src/views/Settings/index.jsindex a455caa29,bcf48d549..5ac2a39c0--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@@ -24,25 -22,17 +24,29 @@@ import {useAppContext} from '../../provimport {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 [state, dispatch] = useTracked();- const {colors} = state;+ const {colors, changeAccentColor, changeColorScheme} = useAppContext();++<<<<<<< HEAD+ ///+ function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {+ let newColors = setColorScheme(colors, accent);+ StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');++=======+ //const [colors, setColors] = useState(COLOR_SCHEME_LIGHT);+ let isFocused = useIsFocused();++>>>>>>> cfee96fb230bdd33c710a5e72a80ccf2b82a8646- if (!isFocused) {- console.log('block rerender');- return <></>;+ dispatch({type: ACTIONS.THEME, colors: newColors});}++ function changeAccentColor(accentColor) {+ ACCENT.color = accentColor;+ ACCENT.shade = accentColor + '12';+ changeColorScheme();+ }+return (<Container noBottomButton={true}><View>