Skip to content

Commit c2f1e52

Browse files
Add JNI key value store + preparing for screen setup
1 parent 9d7b06a commit c2f1e52

27 files changed

+66
-41
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ buck-out/
6363
/ios/Pods/
6464

6565
src/res/config.js
66+
67+
*.hprof

android/app/build_defs.bzl

100644100755
File mode changed.

android/app/debug.keystore

100644100755
File mode changed.

android/app/proguard-rules.pro

100644100755
File mode changed.

android/app/src/debug/AndroidManifest.xml

100644100755
File mode changed.

android/app/src/debug/java/com/cargorocketapp/ReactNativeFlipper.java

100644100755
File mode changed.

android/app/src/main/java/com/cargorocketapp/MainActivity.java

100644100755
File mode changed.

android/app/src/main/java/com/cargorocketapp/MainApplication.java

100644100755
+6-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import android.app.Application;
44
import android.content.Context;
5-
// import com.ammarahmed.mmkv.RNMMKVJSIModulePackage;
5+
import com.ammarahmed.mmkv.RNMMKVJSIModulePackage;
66
import com.facebook.react.PackageList;
77
import com.facebook.react.ReactApplication;
88
import com.github.reactnativecommunity.location.RNLocationPackage;
99
import com.facebook.react.ReactInstanceManager;
10-
// import com.facebook.react.bridge.JSIModulePackage;
10+
import com.facebook.react.bridge.JSIModulePackage;
1111
import com.facebook.react.ReactNativeHost;
1212
import com.facebook.react.ReactPackage;
1313
import com.facebook.soloader.SoLoader;
@@ -38,10 +38,10 @@ protected String getJSMainModuleName() {
3838
return "index";
3939
}
4040

41-
// @Override
42-
// protected JSIModulePackage getJSIModulePackage() {
43-
// return new RNMMKVJSIModulePackage();
44-
// }
41+
@Override
42+
protected JSIModulePackage getJSIModulePackage() {
43+
return new RNMMKVJSIModulePackage();
44+
}
4545
};
4646

4747
@Override

android/app/src/main/res/mipmap-hdpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/mipmap-ldpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/mipmap-mdpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/mipmap-xhdpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png

100644100755
File mode changed.

android/app/src/main/res/playstore-icon.png

100644100755
File mode changed.

android/app/src/main/res/values/styles.xml

100644100755
File mode changed.

android/build.gradle

100644100755
File mode changed.

android/gradle.properties

100644100755
+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ MAPBOX_DOWNLOADS_TOKEN=sk.eyJ1IjoiY2FyZ29yb2NrZXQiLCJhIjoiY2tsbTRoMDg0MDVtZzJvcX
2828

2929
# Version of flipper SDK to use with React Native
3030
FLIPPER_VERSION=0.33.1
31+
32+
JAVA_TOOL_OPTIONS=-Xms4g -Xmx4g

android/gradle/wrapper/gradle-wrapper.jar

100644100755
File mode changed.

android/gradle/wrapper/gradle-wrapper.properties

100644100755
File mode changed.

android/gradlew.bat

100644100755
File mode changed.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import {AppRegistry} from 'react-native';
6-
import App from './src/App';
6+
import {App} from './src/App';
77
import {name as appName} from './app.json';
88

99
AppRegistry.registerComponent(appName, () => App);

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react-native": "0.62.2",
2525
"react-native-gesture-handler": "^1.10.3",
2626
"react-native-location": "^2.5.0",
27+
"react-native-mmkv-storage": "^0.5.4",
2728
"react-native-reanimated": "^2.0.0",
2829
"react-native-safe-area-context": "^3.2.0",
2930
"react-native-screens": "^2.18.1",

src/App.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,26 @@ import {EvaIconsPack} from '@ui-kitten/eva-icons';
1616
import * as eva from '@eva-design/eva';
1717
import {default as theme} from './res/custom-theme.json';
1818
import {Views} from './views/Views';
19+
import {UiContext} from './context/UiContext';
20+
import MMKVStorage from 'react-native-mmkv-storage';
21+
1922

2023
/**
2124
* Use any valid `name` property from eva icons (e.g `github`, or `heart-outline`)
2225
* https://akveo.github.io/eva-icons
2326
*/
2427

25-
export default () => (
26-
<>
27-
<IconRegistry icons={EvaIconsPack} />
28-
<ApplicationProvider {...eva} theme={{...eva.light, ...theme}}>
29-
<Views />
30-
</ApplicationProvider>
31-
</>
32-
);
28+
export const App = () => {
29+
const MMKV = new MMKVStorage.Loader().initialize();
30+
const [isOnBoarded, setOnBoarded] = React.useState(
31+
MMKV.getBool('isOnBoarded'),
32+
);
33+
return (
34+
<UiContext.Provider value={[isOnBoarded, setOnBoarded]}>
35+
<IconRegistry icons={EvaIconsPack} />
36+
<ApplicationProvider {...eva} theme={{...eva.light, ...theme}}>
37+
<Views />
38+
</ApplicationProvider>
39+
</UiContext.Provider>
40+
);
41+
};

src/context/UiContext.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import React from 'react';
2+
export const UiContext = React.createContext({});

src/views/StartView.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@ import React from 'react';
22
import {Button, Layout, Text, Icon} from '@ui-kitten/components';
33
import {StyleSheet} from 'react-native';
44
import Logo from '../res/images/logo.svg';
5+
import MMKVStorage from 'react-native-mmkv-storage';
6+
import {UiContext} from '../context/UiContext';
57

68
export const StartView = ({navigation}) => {
9+
const [isOnBoarded, setIsOnBoarded] = React.useContext(UiContext);
710
const shakeIconRef = React.useRef();
11+
const MMKV = new MMKVStorage.Loader().initialize();
12+
13+
const setOnBoarded = (value) => {
14+
MMKV.setBool('isOnBoarded', value, (error, result) => {
15+
if (error) {
16+
// Todo Figure out how to handle this in the future.
17+
console.error(error);
18+
return;
19+
}
20+
});
21+
setIsOnBoarded(MMKV.getBool('isOnBoarded'));
22+
};
823

924
const ChevronIcon = (props) => (
1025
<Icon
@@ -46,7 +61,8 @@ export const StartView = ({navigation}) => {
4661
accessoryLeft={ChevronIcon}
4762
onPress={() => {
4863
shakeIconRef.current.startAnimation();
49-
navigation.navigate('Content');
64+
setOnBoarded(true);
65+
// navigation.navigate('Content');
5066
}}>
5167
GO CYCLING
5268
</Button>

src/views/Views.js

+18-25
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,36 @@ import React from 'react';
22
import {NavigationContainer} from '@react-navigation/native';
33
import {createStackNavigator} from '@react-navigation/stack';
44
import {StartView} from './StartView';
5-
// import {SelectUse} from './SelectUse';
6-
// import {SelectBikes} from './SelectBikes';
5+
import {SelectUse} from './SelectUse';
6+
import {SelectBikes} from './SelectBikes';
77
import {NavigatingView} from './NavigatingView';
88
import {Content} from './content/Content';
99
import {ProjectWebView} from './ProjectWebView';
10-
// import MMKVStorage from 'react-native-mmkv-storage';
10+
import {UiContext} from '../context/UiContext';
1111

1212
const {Navigator, Screen} = createStackNavigator();
1313

1414
export const Views = () => {
15-
// async componentWillMount() {
16-
// const MMKV = new MMKVStorage.Loader().initialize();
17-
// await MMKV.setBooleanAsync('isOnBoarded', true);
18-
19-
// this.isOnBoarded = await MMKV.getStringAsync('isOnBoarded');
20-
// }
15+
console.log(React.useContext(UiContext));
16+
const [isOnBoarded, setOnBoarded] = React.useContext(UiContext);
2117

18+
// const isOnBoarded = false;
2219
return (
2320
<NavigationContainer>
2421
<Navigator headerMode="none">
25-
<Screen name="Start" component={StartView} />
26-
<Screen name="Content" component={Content} />
27-
<Screen name="Navigating" component={NavigatingView} />
28-
<Screen name="ProjectWebView" component={ProjectWebView} />
29-
{/* isOnBoarded ? (
30-
<>
31-
<Screen name="Start" component={StartView} />
32-
<Screen name="SelectUse" component={SelectUse} />
33-
<Screen name="SelectBikes" component={SelectBikes} />
34-
</>
22+
{isOnBoarded ? (
23+
<>
24+
<Screen name="Content" component={Content} />
25+
<Screen name="Navigating" component={NavigatingView} />
26+
<Screen name="ProjectWebView" component={ProjectWebView} />
27+
</>
3528
) : (
36-
<>
37-
<Screen name="Content" component={Content} />
38-
<Screen name="Navigating" component={NavigatingView} />
39-
<Screen name="ProjectWebView" component={ProjectWebView} />
40-
</>
41-
) */}
29+
<>
30+
<Screen name="Start" component={StartView} />
31+
<Screen name="SelectUse" component={SelectUse} />
32+
<Screen name="SelectBikes" component={SelectBikes} />
33+
</>
34+
)}
4235
</Navigator>
4336
</NavigationContainer>
4437
);

0 commit comments

Comments
 (0)