migrate to latest mmkv storage

This commit is contained in:
ammarahm-ed
2020-09-06 16:10:34 +05:00
parent ee03318301
commit 401e8da666
12 changed files with 78 additions and 42 deletions

View File

@@ -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();

View File

@@ -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" : {

View File

@@ -24,6 +24,8 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
@@ -52,6 +54,8 @@
<string>Quicksand-Bold.ttf</string>
<string>Quicksand-Light.ttf</string>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
@@ -64,6 +68,8 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>

View File

@@ -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

View File

@@ -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,

View File

@@ -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}));

View File

@@ -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}));

View File

@@ -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,
}}>
<Animatable.View
transition={['opacity']}
@@ -191,9 +185,7 @@ export const Header = ({showSearch, root}) => {
size={SIZE.xxxl - 3}
/>
</TouchableOpacity>
) : (
undefined
)}
) : undefined}
{headerState.menu && !DDS.isTab ? (
<TouchableOpacity
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
@@ -208,12 +200,11 @@ export const Header = ({showSearch, root}) => {
}}>
<Icon color={colors.pri} name={'menu'} size={SIZE.xxxl} />
</TouchableOpacity>
) : (
undefined
)}
) : undefined}
<HeaderTitle root={root} />
</View>
<View
style={{
flexDirection: 'row',

View File

@@ -1,6 +1,8 @@
import MMKV from 'react-native-mmkv-storage';
import MMKVStorage from 'react-native-mmkv-storage';
import Sodium from 'react-native-sodium';
export const MMKV = new MMKVStorage.Loader().initialize();
async function read(key, isArray = false) {
let data;
if (isArray) {

View File

@@ -6,8 +6,7 @@ import {
eHideToast,
} from '../services/events';
import { DeviceDetectionService } from './deviceDetection';
import StorageInterface from './storage';
import MMKV from 'react-native-mmkv-storage';
import StorageInterface, { MMKV } from './storage';
import { updateEvent } from '../components/DialogManager/recievers';
import { ACTIONS } from '../provider/actions';
export const DDS = new DeviceDetectionService();

View File

@@ -9,7 +9,7 @@ import {eOnLoadNote, eScrollEvent} from '../../services/events';
import {openEditorAnimation} from '../../utils/animations';
import {DDS} from '../../utils/utils';
import {Placeholder} from '../../components/ListPlaceholders';
import RNHTMLtoPDF from 'react-native-html-to-pdf';
export const Home = ({route, navigation}) => {
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: '<h1>Custom converted PDF Document</h1>',
fileName: 'test',
base64: false,
directory:"Documents"
});
console.log(res);
return;
if (DDS.isTab) {
eSendEvent(eOnLoadNote, {type: 'new'});
} else {

View File

@@ -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();