From 401e8da666c02560b4bdc98ffebb6e29d84030c5 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sun, 6 Sep 2020 16:10:34 +0500 Subject: [PATCH] migrate to latest mmkv storage --- apps/mobile/App.js | 3 +- .../AppIcon.appiconset/Contents.json | 15 +++++++ apps/mobile/ios/Notesnook/Info.plist | 8 +++- apps/mobile/ios/Podfile.lock | 20 +++++++--- apps/mobile/src/common/common.js | 2 +- .../components/ActionSheetComponent/index.js | 5 ++- apps/mobile/src/components/Menu/index.js | 5 ++- apps/mobile/src/components/header/index.js | 39 +++++++------------ apps/mobile/src/utils/storage.js | 4 +- apps/mobile/src/utils/utils.js | 3 +- apps/mobile/src/views/Home/index.js | 13 ++++++- apps/mobile/src/views/Settings/index.js | 3 +- 12 files changed, 78 insertions(+), 42 deletions(-) diff --git a/apps/mobile/App.js b/apps/mobile/App.js index 63fad2fe0..456276397 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -1,5 +1,4 @@ import React, {useEffect, useState} from 'react'; -import MMKV from 'react-native-mmkv-storage'; import Orientation from 'react-native-orientation'; import {SafeAreaProvider} from 'react-native-safe-area-context'; import {getColorScheme, scale, updateSize} from './src/common/common'; @@ -10,6 +9,8 @@ import {eSubscribeEvent, eUnSubscribeEvent} from './src/services/eventManager'; import {eDispatchAction, eStartSyncer, eResetApp} from './src/services/events'; import {db, DDS, ToastEvent} from './src/utils/utils'; import {useNetInfo} from '@react-native-community/netinfo'; +import RNHTMLtoPDF from 'react-native-html-to-pdf'; +import { MMKV } from './src/utils/storage'; const App = () => { const [state, dispatch] = useTracked(); diff --git a/apps/mobile/ios/Notesnook/Images.xcassets/AppIcon.appiconset/Contents.json b/apps/mobile/ios/Notesnook/Images.xcassets/AppIcon.appiconset/Contents.json index 118c98f74..19882d568 100644 --- a/apps/mobile/ios/Notesnook/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/apps/mobile/ios/Notesnook/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -29,6 +39,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/apps/mobile/ios/Notesnook/Info.plist b/apps/mobile/ios/Notesnook/Info.plist index d74b2f1da..b6121042c 100644 --- a/apps/mobile/ios/Notesnook/Info.plist +++ b/apps/mobile/ios/Notesnook/Info.plist @@ -24,6 +24,8 @@ 1 LSRequiresIPhoneOS + LSSupportsOpeningDocumentsInPlace + NSAppTransportSecurity NSAllowsArbitraryLoads @@ -39,7 +41,7 @@ NSLocationWhenInUseUsageDescription - UIAppFonts + UIAppFonts DMSerifText-Regular.ttf DMSans-Regular.ttf @@ -52,6 +54,8 @@ Quicksand-Bold.ttf Quicksand-Light.ttf + UIFileSharingEnabled + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities @@ -64,6 +68,8 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UISupportsDocumentBrowser + UIViewControllerBasedStatusBarAppearance diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock index 8dba6cdff..36c9ba83f 100644 --- a/apps/mobile/ios/Podfile.lock +++ b/apps/mobile/ios/Podfile.lock @@ -68,7 +68,9 @@ PODS: - DoubleConversion - glog - glog (0.3.5) - - MMKV (1.0.24) + - MMKV (1.2.2): + - MMKVCore (~> 1.2.2) + - MMKVCore (1.2.2) - OpenSSL-Universal (1.0.2.19): - OpenSSL-Universal/Static (= 1.0.2.19) - OpenSSL-Universal/Static (1.0.2.19) @@ -240,8 +242,10 @@ PODS: - React-jsinspector (0.63.2) - react-native-get-random-values (1.4.0): - React - - react-native-mmkv-storage (0.2.2): - - MMKV (= 1.0.24) + - react-native-html-to-pdf (0.8.0): + - React + - react-native-mmkv-storage (0.3.7): + - MMKV (= 1.2.2) - React - react-native-netinfo (5.9.6): - React @@ -374,6 +378,7 @@ DEPENDENCIES: - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) + - react-native-html-to-pdf (from `../node_modules/react-native-html-to-pdf`) - react-native-mmkv-storage (from `../node_modules/react-native-mmkv-storage`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-orientation (from `../node_modules/react-native-orientation`) @@ -415,6 +420,7 @@ SPEC REPOS: - Flipper-RSocket - FlipperKit - MMKV + - MMKVCore - OpenSSL-Universal - YogaKit @@ -451,6 +457,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsinspector" react-native-get-random-values: :path: "../node_modules/react-native-get-random-values" + react-native-html-to-pdf: + :path: "../node_modules/react-native-html-to-pdf" react-native-mmkv-storage: :path: "../node_modules/react-native-mmkv-storage" react-native-netinfo: @@ -521,7 +529,8 @@ SPEC CHECKSUMS: FlipperKit: bc68102cd4952a258a23c9c1b316c7bec1fecf83 Folly: b73c3869541e86821df3c387eb0af5f65addfab4 glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 - MMKV: 758b2edee46b08bdd958db4169191afb9a6d4ebd + MMKV: b14909757d8b70e2aa89ff1c6d56a7b239e10a29 + MMKVCore: 6225324fe5006026bc86ef8641d567e00c6582f3 OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 RCTRequired: f13f25e7b12f925f1f6a6a8c69d929a03c0129fe RCTTypeSafety: 44982c5c8e43ff4141eb519a8ddc88059acd1f3a @@ -534,7 +543,8 @@ SPEC CHECKSUMS: React-jsiexecutor: 8ca588cc921e70590820ce72b8789b02c67cce38 React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606 react-native-get-random-values: 2b7500cdb68066aba87cdccd97067c29e16ffe95 - react-native-mmkv-storage: 4f85ac485ff25ad5b9f7b3c6cd4c8bb067b1028c + react-native-html-to-pdf: 1d1199917f56a98377d431bce84c2f275e48eb71 + react-native-mmkv-storage: 023a9c501f7430319138a94889fc53691b93d73d react-native-netinfo: 38a1e0b3e89b48e4b5833ed475d8df5f049f6f90 react-native-orientation: f1caf84d65f1a4fd4511a18f2b924e634ad7a628 react-native-safe-area-context: eb91fe1fb3f7b87d9c30a7f0808407d8569d539d diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js index 3579cbfbc..2c8fab22d 100755 --- a/apps/mobile/src/common/common.js +++ b/apps/mobile/src/common/common.js @@ -1,5 +1,4 @@ import { Dimensions, PixelRatio, StatusBar, Platform } from 'react-native'; -import MMKV from 'react-native-mmkv-storage'; import { eSendEvent, eSubscribeEvent, @@ -7,6 +6,7 @@ import { } from '../services/eventManager'; import { eThemeUpdated } from '../services/events'; import { DDS } from '../utils/utils'; +import { MMKV } from '../utils/storage'; export const scale = { fontScale: 1, diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js index fe173e77f..f105c3e10 100644 --- a/apps/mobile/src/components/ActionSheetComponent/index.js +++ b/apps/mobile/src/components/ActionSheetComponent/index.js @@ -8,7 +8,7 @@ import { View, KeyboardAvoidingView, } from 'react-native'; -import MMKV from 'react-native-mmkv-storage'; + import Share from 'react-native-share'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { @@ -30,6 +30,7 @@ import {timeConverter, ToastEvent, DDS, db} from '../../utils/utils'; import {openVault, eSendEvent} from '../../services/eventManager'; import {refreshNotesPage, eOpenPremiumDialog} from '../../services/events'; import {PremiumTag} from '../Premium/PremiumTag'; +import { MMKV } from '../../utils/storage'; const w = Dimensions.get('window').width; const h = Dimensions.get('window').height; @@ -286,7 +287,7 @@ export const ActionSheetComponent = ({ icon: 'theme-light-dark', func: () => { if (!colors.night) { - MMKV.setStringAsync('theme', JSON.stringify({night: true})); + MMKV .setStringAsync('theme', JSON.stringify({night: true})); changeColorScheme(COLOR_SCHEME_DARK); } else { MMKV.setStringAsync('theme', JSON.stringify({night: false})); diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js index 0630e16a6..4f148abad 100644 --- a/apps/mobile/src/components/Menu/index.js +++ b/apps/mobile/src/components/Menu/index.js @@ -8,7 +8,7 @@ import { View, } from 'react-native'; import {createAnimatableComponent} from 'react-native-animatable'; -import MMKV from 'react-native-mmkv-storage'; + import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { ACCENT, @@ -28,6 +28,7 @@ import {ColorSection} from './ColorSection'; import {MenuListItem} from './MenuListItem'; import {TagsSection} from './TagsSection'; import {UserSection} from './UserSection'; +import { MMKV } from '../../utils/storage'; const AnimatedSafeAreaView = createAnimatableComponent(SafeAreaView); @@ -85,7 +86,7 @@ export const Menu = ({ icon: 'theme-light-dark', func: () => { if (!colors.night) { - MMKV.setStringAsync('theme', JSON.stringify({night: true})); + MMKV .setStringAsync('theme', JSON.stringify({night: true})); changeColorScheme(COLOR_SCHEME_DARK); } else { MMKV.setStringAsync('theme', JSON.stringify({night: false})); diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js index b8b7e5ab0..f8a3a7e9c 100644 --- a/apps/mobile/src/components/header/index.js +++ b/apps/mobile/src/components/header/index.js @@ -27,11 +27,11 @@ import {moveNoteHideEvent} from '../DialogManager/recievers'; import {HeaderMenu} from './HeaderMenu'; import {HeaderTitle} from './HeaderTitle'; let offsetY = 0; -let timeout = null +let timeout = null; function useForceUpdate() { const [, setTick] = useState(0); const update = useCallback(() => { - setTick(tick => tick + 1); + setTick((tick) => tick + 1); }, []); return update; } @@ -53,38 +53,32 @@ export const Header = ({showSearch, root}) => { const insets = useSafeArea(); const forceUpdate = useForceUpdate(); - - const onScroll = y => { + const onScroll = (y) => { if (searchResults.results.length > 0) return; if (y < 30) { setHideHeader(false); - offsetY = y + offsetY = y; } if (y > offsetY) { if (y - offsetY < 100) return; clearTimeout(timeout); - timeout = null + timeout = null; timeout = setTimeout(() => { setHideHeader(true); - },300); - offsetY = y + }, 300); + offsetY = y; } else { if (offsetY - y < 50) return; clearTimeout(timeout); - timeout = null + timeout = null; timeout = setTimeout(() => { setHideHeader(false); - },300); - offsetY = y - + }, 300); + offsetY = y; } - }; - - - - const _setModalNavigator = value => { + const _setModalNavigator = (value) => { if (root) return; forceUpdate(); setIsModalNavigator(value); @@ -118,7 +112,7 @@ export const Header = ({showSearch, root}) => { alignItems: 'center', paddingHorizontal: 12, width: '100%', - backgroundColor:colors.bg + backgroundColor: colors.bg, }}> { size={SIZE.xxxl - 3} /> - ) : ( - undefined - )} + ) : undefined} {headerState.menu && !DDS.isTab ? ( { }}> - ) : ( - undefined - )} + ) : undefined} + { const [state, dispatch] = useTracked(); const {notes} = state; @@ -54,7 +54,16 @@ export const Home = ({route, navigation}) => { type: ACTIONS.CONTAINER_BOTTOM_BUTTON, state: { bottomButtonText: 'Create a new note', - bottomButtonOnPress: () => { + bottomButtonOnPress: async () => { + let res = await RNHTMLtoPDF.convert({ + html: '

Custom converted PDF Document

', + fileName: 'test', + base64: false, + directory:"Documents" + + }); + console.log(res); + return; if (DDS.isTab) { eSendEvent(eOnLoadNote, {type: 'new'}); } else { diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js index fb86fcd86..cc2d26f18 100644 --- a/apps/mobile/src/views/Settings/index.js +++ b/apps/mobile/src/views/Settings/index.js @@ -2,7 +2,7 @@ import { useIsFocused } from '@react-navigation/native'; import React, { useEffect, useState } from 'react'; import { Clipboard, Linking, Modal, Platform, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native'; import * as Animatable from 'react-native-animatable'; -import MMKV from 'react-native-mmkv-storage'; + import QRCode from 'react-native-qrcode-generator'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { ACCENT, COLOR_SCHEME, COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT, opacity, ph, pv, setColorScheme, SIZE, WEIGHT } from '../../common/common'; @@ -13,6 +13,7 @@ import { eSendEvent } from '../../services/eventManager'; import { eOpenLoginDialog, eResetApp } from '../../services/events'; import NavigationService from '../../services/NavigationService'; import { db, DDS, setSetting, ToastEvent, w } from '../../utils/utils'; +import { MMKV } from '../../utils/storage'; export const Settings = ({route, navigation}) => { const [state, dispatch] = useTracked();