Skip to content

Commit 01b220c

Browse files
committed
rewrite reactnative example
1 parent 7b6e6bb commit 01b220c

File tree

65 files changed

+31388
-1826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+31388
-1826
lines changed

examples/reactnative/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

examples/reactnative/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

examples/reactnative/.flowconfig

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,62 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; Flow doesn't support platforms
12+
.*/Libraries/Utilities/LoadingView.js
1513

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
14+
.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$
1815

19-
; Ignore metro
20-
.*/node_modules/metro/.*
16+
[untyped]
17+
.*/node_modules/@react-native-community/cli/.*/.*
2118

2219
[include]
2320

2421
[libs]
25-
node_modules/react-native/Libraries/react-native/react-native-interface.js
22+
node_modules/react-native/interface.js
2623
node_modules/react-native/flow/
2724

2825
[options]
2926
emoji=true
3027

31-
esproposal.optional_chaining=enable
32-
esproposal.nullish_coalescing=enable
33-
34-
module.system=haste
35-
module.system.haste.use_name_reducers=true
36-
# get basename
37-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38-
# strip .js or .js.flow suffix
39-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40-
# strip .ios suffix
41-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44-
module.system.haste.paths.blacklist=.*/__tests__/.*
45-
module.system.haste.paths.blacklist=.*/__mocks__/.*
46-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
48-
49-
munge_underscores=true
28+
exact_by_default=true
5029

51-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
30+
format.bracket_spacing=false
5231

5332
module.file_ext=.js
54-
module.file_ext=.jsx
5533
module.file_ext=.json
56-
module.file_ext=.native.js
34+
module.file_ext=.ios.js
35+
36+
munge_underscores=true
37+
38+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
39+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
5740

5841
suppress_type=$FlowIssue
5942
suppress_type=$FlowFixMe
6043
suppress_type=$FlowFixMeProps
6144
suppress_type=$FlowFixMeState
6245

63-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
66-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
46+
[lints]
47+
sketchy-null-number=warn
48+
sketchy-null-mixed=warn
49+
sketchy-number=warn
50+
untyped-type-import=warn
51+
nonstrict-import=warn
52+
deprecated-type=warn
53+
unsafe-getters-setters=warn
54+
unnecessary-invariant=warn
55+
56+
[strict]
57+
deprecated-type
58+
nonstrict-import
59+
sketchy-null
60+
unclear-type
61+
unsafe-getters-setters
62+
untyped-import
63+
untyped-type-import
6764

6865
[version]
69-
^0.92.0
66+
^0.182.0

examples/reactnative/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/reactnative/.gitignore

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
23+
ios/.xcode.env.local
2424

2525
# Android/IntelliJ
2626
#
@@ -29,6 +29,8 @@ build/
2929
.gradle
3030
local.properties
3131
*.iml
32+
*.hprof
33+
.cxx/
3234

3335
# node.js
3436
#
@@ -40,6 +42,7 @@ yarn-error.log
4042
buck-out/
4143
\.buckd/
4244
*.keystore
45+
!debug.keystore
4346

4447
# fastlane
4548
#
@@ -48,11 +51,14 @@ buck-out/
4851
# For more information about the recommended setup visit:
4952
# https://docs.fastlane.tools/best-practices/source-control/
5053

51-
*/fastlane/report.xml
52-
*/fastlane/Preview.html
53-
*/fastlane/screenshots
54+
**/fastlane/report.xml
55+
**/fastlane/Preview.html
56+
**/fastlane/screenshots
57+
**/fastlane/test_output
5458

5559
# Bundle artifact
5660
*.jsbundle
5761

58-
package-lock.json
62+
# Ruby / CocoaPods
63+
/ios/Pods/
64+
/vendor/bundle/

examples/reactnative/.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

examples/reactnative/.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

examples/reactnative/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

examples/reactnative/App.js

Lines changed: 122 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,130 @@
1-
import React, { Component } from 'react';
2-
import { Linking, StyleSheet, Text, View } from 'react-native';
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow strict-local
7+
*/
8+
9+
import React, {useState, useEffect} from 'react';
10+
import type {Node} from 'react';
11+
import {
12+
SafeAreaView,
13+
ScrollView,
14+
StatusBar,
15+
StyleSheet,
16+
Text,
17+
useColorScheme,
18+
View,
19+
} from 'react-native';
320
import VersionCheck from 'react-native-version-check';
421

22+
import {Colors, Header} from 'react-native/Libraries/NewAppScreen';
23+
24+
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
25+
* LTI update could not be added via codemod */
26+
const Section = ({children, title}): Node => {
27+
const isDarkMode = useColorScheme() === 'dark';
28+
return (
29+
<View style={styles.sectionContainer}>
30+
<Text
31+
style={[
32+
styles.sectionTitle,
33+
{
34+
color: isDarkMode ? Colors.white : Colors.black,
35+
},
36+
]}
37+
>
38+
{title}
39+
</Text>
40+
<Text
41+
style={[
42+
styles.sectionDescription,
43+
{
44+
color: isDarkMode ? Colors.light : Colors.dark,
45+
},
46+
]}
47+
>
48+
{children}
49+
</Text>
50+
</View>
51+
);
52+
};
53+
54+
const App: () => Node = () => {
55+
const [currentVersion, setCurrentVersion] = useState(null);
56+
const [latestVersion, setLatestVersion] = useState(null);
57+
const [isNeeded, setIsNeeded] = useState(false);
58+
const [storeUrl, setStoreUrl] = useState('');
59+
60+
useEffect(() => {
61+
VersionCheck.needUpdate({
62+
latestVersion: '1.0.0',
63+
}).then(res => {
64+
console.log(res);
65+
const {currentVersion, latestVersion, isNeeded} = res;
66+
setCurrentVersion(currentVersion);
67+
setLatestVersion(latestVersion);
68+
setIsNeeded(isNeeded);
69+
});
70+
71+
VersionCheck.getStoreUrl({appID: '364709193', country: 'KR'}).then(
72+
storeUrl => {
73+
console.log(storeUrl);
74+
setStoreUrl(storeUrl);
75+
},
76+
);
77+
}, []);
78+
79+
const isDarkMode = useColorScheme() === 'dark';
80+
81+
const backgroundStyle = {
82+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
83+
};
84+
85+
return (
86+
<SafeAreaView style={backgroundStyle}>
87+
<StatusBar
88+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
89+
backgroundColor={backgroundStyle.backgroundColor}
90+
/>
91+
<ScrollView
92+
contentInsetAdjustmentBehavior="automatic"
93+
style={backgroundStyle}
94+
>
95+
<Header />
96+
<View
97+
style={{
98+
backgroundColor: isDarkMode ? Colors.black : Colors.white,
99+
}}
100+
>
101+
<Section title="Current Version">{currentVersion}</Section>
102+
<Section title="Latest Version">{latestVersion}</Section>
103+
<Section title="Is update needed?">{String(isNeeded)}</Section>
104+
<Section title="Store Url">{String(storeUrl)}</Section>
105+
</View>
106+
</ScrollView>
107+
</SafeAreaView>
108+
);
109+
};
110+
5111
const styles = StyleSheet.create({
6-
container: {
7-
flex: 1,
8-
justifyContent: 'center',
9-
alignItems: 'center',
10-
backgroundColor: '#F5FCFF',
112+
sectionContainer: {
113+
marginTop: 32,
114+
paddingHorizontal: 24,
11115
},
12-
text: {
13-
fontSize: 20,
14-
textAlign: 'center',
15-
margin: 10,
116+
sectionTitle: {
117+
fontSize: 24,
118+
fontWeight: '600',
16119
},
17-
linkText: {
18-
color: 'blue',
120+
sectionDescription: {
121+
marginTop: 8,
122+
fontSize: 18,
123+
fontWeight: '400',
124+
},
125+
highlight: {
126+
fontWeight: '700',
19127
},
20128
});
21129

22-
export default class example extends Component {
23-
state = {
24-
currentVersion: null,
25-
latestVersion: null,
26-
isNeeded: false,
27-
storeUrl: '',
28-
};
29-
componentDidMount() {
30-
VersionCheck.needUpdate({
31-
latestVersion: '1.0.0',
32-
}).then(res => this.setState(res));
33-
34-
VersionCheck.getStoreUrl({ appID: '364709193' }).then(res => {
35-
//App Store ID for iBooks.
36-
this.setState({ storeUrl: res });
37-
});
38-
}
39-
render() {
40-
return (
41-
<View style={styles.container}>
42-
<Text style={styles.text}>
43-
Current Version: {this.state.currentVersion}
44-
</Text>
45-
<Text style={styles.text}>
46-
Latest Version: {this.state.latestVersion}
47-
</Text>
48-
<Text style={styles.text}>
49-
Is update needed?: {String(this.state.isNeeded)}
50-
</Text>
51-
<View>
52-
<Text style={styles.text}>Store Url:</Text>
53-
<Text
54-
style={[styles.text, styles.linkText]}
55-
onPress={() => Linking.openURL(this.state.storeUrl)}
56-
>
57-
{String(this.state.storeUrl)}
58-
</Text>
59-
</View>
60-
</View>
61-
);
62-
}
63-
}
130+
export default App;

examples/reactnative/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.5'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

0 commit comments

Comments
 (0)