Skip to content

Commit 2a869af

Browse files
committed
working on example home page
1 parent 845d046 commit 2a869af

File tree

9 files changed

+92
-103
lines changed

9 files changed

+92
-103
lines changed

.prettierrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,8 @@ apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
44

5-
/**
6-
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7-
* and bundleReleaseJsAndAssets).
8-
* These basically call `react-native bundle` with the correct arguments during the Android build
9-
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10-
* bundle directly from the development server. Below you can see all the possible configurations
11-
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12-
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13-
*
14-
* project.ext.react = [
15-
* // the name of the generated asset file containing your JS bundle
16-
* bundleAssetName: "index.android.bundle",
17-
*
18-
* // the entry file for bundle generation. If none specified and
19-
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20-
* // default. Can be overridden with ENTRY_FILE environment variable.
21-
* entryFile: "index.android.js",
22-
*
23-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
24-
* bundleCommand: "ram-bundle",
25-
*
26-
* // whether to bundle JS and assets in debug mode
27-
* bundleInDebug: false,
28-
*
29-
* // whether to bundle JS and assets in release mode
30-
* bundleInRelease: true,
31-
*
32-
* // whether to bundle JS and assets in another build variant (if configured).
33-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34-
* // The configuration property can be in the following formats
35-
* // 'bundleIn${productFlavor}${buildType}'
36-
* // 'bundleIn${buildType}'
37-
* // bundleInFreeDebug: true,
38-
* // bundleInPaidRelease: true,
39-
* // bundleInBeta: true,
40-
*
41-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
42-
* // for example: to disable dev mode in the staging build type (if configured)
43-
* devDisabledInStaging: true,
44-
* // The configuration property can be in the following formats
45-
* // 'devDisabledIn${productFlavor}${buildType}'
46-
* // 'devDisabledIn${buildType}'
47-
*
48-
* // the root of your project, i.e. where "package.json" lives
49-
* root: "../../",
50-
*
51-
* // where to put the JS bundle asset in debug mode
52-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53-
*
54-
* // where to put the JS bundle asset in release mode
55-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56-
*
57-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
58-
* // require('./image.png')), in debug mode
59-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60-
*
61-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
62-
* // require('./image.png')), in release mode
63-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64-
*
65-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
68-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69-
* // for example, you might want to remove it from here.
70-
* inputExcludes: ["android/**", "ios/**"],
71-
*
72-
* // override which node gets called and with what additional arguments
73-
* nodeExecutableAndArgs: ["node"],
74-
*
75-
* // supply additional arguments to the packager
76-
* extraPackagerArgs: []
77-
* ]
78-
*/
79-
805
project.ext.react = [
81-
enableHermes: false, // clean and rebuild if changing
6+
enableHermes: true, // clean and rebuild if changing
827
]
838

849
apply from: "../../node_modules/react-native/react.gradle"

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.example;
22

33
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactActivityDelegate;
5+
import com.facebook.react.ReactRootView;
6+
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
47

58
public class MainActivity extends ReactActivity {
69

@@ -12,4 +15,14 @@ public class MainActivity extends ReactActivity {
1215
protected String getMainComponentName() {
1316
return "example";
1417
}
18+
19+
@Override
20+
protected ReactActivityDelegate createReactActivityDelegate() {
21+
return new ReactActivityDelegate(this, getMainComponentName()) {
22+
@Override
23+
protected ReactRootView createRootView() {
24+
return new RNGestureHandlerEnabledRootView(MainActivity.this);
25+
}
26+
};
27+
}
1528
}

example/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/**
2-
* @format
3-
*/
1+
import 'react-native-gesture-handler';
42

5-
import {AppRegistry} from 'react-native';
6-
import App from './src/pages/Homes/Home';
7-
import {name as appName} from './app.json';
3+
import { AppRegistry } from 'react-native';
4+
5+
import App from './src/routes';
6+
7+
import { name as appName } from './app.json';
88

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

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"babel-jest": "^26.1.0",
3333
"eslint": "^7.5.0",
3434
"eslint-config-airbnb": "^18.2.0",
35+
"eslint-config-prettier": "^6.11.0",
3536
"eslint-import-resolver-typescript": "^2.0.0",
3637
"eslint-plugin-import": "^2.22.0",
3738
"eslint-plugin-jsx-a11y": "^6.3.1",

example/src/pages/Home/index.tsx

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,61 @@
1-
import React, { useCallback } from 'react'
2-
import {View, Button} from 'react-native'
3-
import SInfo from 'react-native-sensitive-info'
1+
import React, { useCallback } from 'react';
2+
import { View, Button, Alert } from 'react-native';
3+
import SInfo from 'react-native-sensitive-info';
44

55
const Home: React.FC = () => {
6-
const handleAddItemOnPress = useCallback(() => {
7-
SInfo.setItem('key1', 'value1', {
8-
sharedPreferencesName: 'exampleApp',
9-
keychainService: 'exampleApp'
10-
})
11-
},[])
12-
13-
return (
14-
<View>
15-
<Button title="Add Item" onPress={handleAddItemOnPress} />
16-
</View>
17-
);
18-
}
6+
const handleAddUsingSetItemOnPress = useCallback(() => {
7+
SInfo.setItem('key1', 'value1', {
8+
sharedPreferencesName: 'exampleApp',
9+
keychainService: 'exampleApp',
10+
});
11+
}, []);
12+
13+
const handleSetItemUsingTouchIDOnPress = useCallback(async () => {
14+
try {
15+
const deviceHasSensor = await SInfo.isSensorAvailable();
16+
17+
if (!deviceHasSensor) {
18+
return Alert.alert('No sensor found');
19+
}
20+
21+
SInfo.setItem('touchIdItem', 'dataStoredUsingTouchId', {
22+
// touchID: true,
23+
showModal: true
24+
});
25+
} catch (ex) {
26+
console.log(ex.message);
27+
}
28+
}, []);
29+
30+
/**
31+
* @BUG when triggering this function iOS emulator crashes. Need to investigate
32+
*/
33+
const getTouchIDItem = useCallback(async () => {
34+
const deviceHasSensor = await SInfo.isSensorAvailable();
35+
36+
if (!deviceHasSensor) {
37+
return Alert.alert('No sensor found');
38+
}
39+
40+
SInfo.getItem('touchIdItem', {
41+
touchID: true,
42+
showModal: true
43+
});
44+
}, []);
45+
46+
return (
47+
<View>
48+
<Button
49+
title="Add item using setItem"
50+
onPress={handleAddUsingSetItemOnPress}
51+
/>
52+
<Button
53+
title="Add item using TouchID"
54+
onPress={handleSetItemUsingTouchIDOnPress}
55+
/>
56+
57+
<Button title="Get TouchID Data" onPress={getTouchIDItem} />
58+
</View>
59+
);
60+
};
1961
export default Home;
File renamed without changes.

example/yalc.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "v1",
33
"packages": {
44
"react-native-sensitive-info": {
5-
"signature": "7da6a228c3431c0df8527e02eb77f9d3",
5+
"signature": "425b7d38ece20a9a95f0880f94414ee1",
66
"file": true
77
}
88
}

example/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,13 @@ eslint-config-airbnb@^18.2.0:
26462646
object.assign "^4.1.0"
26472647
object.entries "^1.1.2"
26482648

2649+
eslint-config-prettier@^6.11.0:
2650+
version "6.11.0"
2651+
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1"
2652+
integrity sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA==
2653+
dependencies:
2654+
get-stdin "^6.0.0"
2655+
26492656
eslint-import-resolver-node@^0.3.3:
26502657
version "0.3.4"
26512658
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717"
@@ -3239,6 +3246,11 @@ get-package-type@^0.1.0:
32393246
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
32403247
integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==
32413248

3249+
get-stdin@^6.0.0:
3250+
version "6.0.0"
3251+
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
3252+
integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==
3253+
32423254
get-stream@^4.0.0:
32433255
version "4.1.0"
32443256
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5"

0 commit comments

Comments
 (0)