Skip to content

Commit 306dca3

Browse files
committed
update examples
1 parent 3d8b7ad commit 306dca3

Some content is hidden

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

44 files changed

+10734
-336
lines changed

examples/.flowconfig

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,56 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2328

2429
[options]
2530
emoji=true
2631

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

2947
munge_underscores=true
3048

3149
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'
3250

51+
module.file_ext=.js
52+
module.file_ext=.jsx
53+
module.file_ext=.json
54+
module.file_ext=.native.js
55+
3356
suppress_type=$FlowIssue
3457
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
58+
suppress_type=$FlowFixMeProps
59+
suppress_type=$FlowFixMeState
3660

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
61+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
62+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3963
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4064
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4165

42-
unsafe.enable_getters_and_setters=true
43-
4466
[version]
45-
^0.49.1
67+
^0.75.0

examples/.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ buck-out/
4646
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4747
# screenshots whenever they are needed.
4848
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5050

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

examples/App.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* SplashScreen
3+
* 启动屏
4+
* from:http://www.devio.org
5+
* Author:CrazyCodeBoy
6+
* GitHub:https://github.com/crazycodeboy
7+
8+
* @flow
9+
*/
10+
'use strict';
11+
12+
13+
import React, {Component} from 'react';
14+
import {
15+
StyleSheet,
16+
View,
17+
Text,
18+
TouchableOpacity,
19+
Linking,
20+
} from 'react-native'
21+
import SplashScreen from 'react-native-splash-screen'
22+
23+
export default class example extends Component {
24+
25+
componentDidMount() {
26+
SplashScreen.hide();
27+
}
28+
29+
30+
render() {
31+
return (
32+
<TouchableOpacity
33+
style={styles.container}
34+
onPress={(e)=> {
35+
Linking.openURL('http://www.devio.org/');
36+
}}
37+
>
38+
<View >
39+
<Text style={styles.item}>
40+
SplashScreen 启动屏
41+
</Text>
42+
<Text style={styles.item}>
43+
@:http://www.devio.org/
44+
</Text>
45+
<Text style={styles.item}>
46+
GitHub:https://github.com/crazycodeboy
47+
</Text>
48+
<Text style={styles.item}>
49+
50+
</Text>
51+
</View>
52+
</TouchableOpacity>
53+
)
54+
}
55+
56+
}
57+
58+
const styles = StyleSheet.create({
59+
container: {
60+
flex: 1,
61+
backgroundColor: '#f3f2f2',
62+
marginTop: 30
63+
},
64+
item: {
65+
fontSize: 20,
66+
},
67+
line: {
68+
flex: 1,
69+
height: 0.3,
70+
backgroundColor: 'darkgray',
71+
},
72+
})

examples/__tests__/index.android.js

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

examples/__tests__/index.ios.js

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

examples/android/app/build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import com.android.build.OutputFile
7272
* ]
7373
*/
7474

75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
7579
apply from: "../../node_modules/react-native/react.gradle"
7680

7781
/**
@@ -90,13 +94,13 @@ def enableSeparateBuildPerCPUArchitecture = false
9094
def enableProguardInReleaseBuilds = false
9195

9296
android {
93-
compileSdkVersion 23
94-
buildToolsVersion "23.0.1"
97+
compileSdkVersion rootProject.ext.compileSdkVersion
98+
buildToolsVersion rootProject.ext.buildToolsVersion
9599

96100
defaultConfig {
97101
applicationId "com.examples"
98-
minSdkVersion 16
99-
targetSdkVersion 22
102+
minSdkVersion rootProject.ext.minSdkVersion
103+
targetSdkVersion rootProject.ext.targetSdkVersion
100104
versionCode 1
101105
versionName "1.0"
102106
ndk {
@@ -135,7 +139,7 @@ android {
135139
dependencies {
136140
compile project(':react-native-splash-screen')
137141
compile fileTree(dir: "libs", include: ["*.jar"])
138-
compile "com.android.support:appcompat-v7:23.0.1"
142+
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
139143
compile "com.facebook.react:react-native:+" // From node_modules
140144
}
141145

examples/android/app/proguard-rules.pro

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,3 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18-
19-
# Disabling obfuscation is useful if you collect stack traces from production crashes
20-
# (unless you are using a system that supports de-obfuscate the stack traces).
21-
-dontobfuscate
22-
23-
# React Native
24-
25-
# Keep our interfaces so they can be used by other ProGuard rules.
26-
# See http://sourceforge.net/p/proguard/bugs/466/
27-
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28-
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29-
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
30-
31-
# Do not strip any method/class that is annotated with @DoNotStrip
32-
-keep @com.facebook.proguard.annotations.DoNotStrip class *
33-
-keep @com.facebook.common.internal.DoNotStrip class *
34-
-keepclassmembers class * {
35-
@com.facebook.proguard.annotations.DoNotStrip *;
36-
@com.facebook.common.internal.DoNotStrip *;
37-
}
38-
39-
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
40-
void set*(***);
41-
*** get*();
42-
}
43-
44-
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
45-
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
46-
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
47-
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
48-
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
49-
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
50-
51-
-dontwarn com.facebook.react.**
52-
53-
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
54-
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
55-
-dontwarn android.text.StaticLayout
56-
57-
# okhttp
58-
59-
-keepattributes Signature
60-
-keepattributes *Annotation*
61-
-keep class okhttp3.** { *; }
62-
-keep interface okhttp3.** { *; }
63-
-dontwarn okhttp3.**
64-
65-
# okio
66-
67-
-keep class sun.misc.Unsafe { *; }
68-
-dontwarn java.nio.file.*
69-
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
70-
-dontwarn okio.**
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="org.examples"
3-
android:versionCode="1"
4-
android:versionName="1.0">
2+
package="com.examples">
53

64
<uses-permission android:name="android.permission.INTERNET" />
7-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
8-
9-
<uses-sdk
10-
android:minSdkVersion="16"
11-
android:targetSdkVersion="22" />
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
126

137
<application
14-
android:name="org.examples.MainApplication"
15-
android:allowBackup="true"
16-
android:label="@string/app_name"
17-
android:icon="@mipmap/ic_launcher"
18-
android:theme="@style/AppTheme">
19-
<activity
20-
android:name="org.examples.MainActivity"
8+
android:name=".MainApplication"
9+
android:allowBackup="false"
10+
android:icon="@mipmap/ic_launcher"
2111
android:label="@string/app_name"
22-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
23-
android:windowSoftInputMode="adjustResize">
24-
<intent-filter>
25-
<action android:name="android.intent.action.MAIN" />
26-
<category android:name="android.intent.category.LAUNCHER" />
27-
</intent-filter>
28-
</activity>
29-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:name=".MainActivity"
15+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
16+
android:label="@string/app_name"
17+
android:windowSoftInputMode="adjustResize">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
3024
</application>
3125

3226
</manifest>

examples/android/app/src/main/java/org/examples/MainActivity.java renamed to examples/android/app/src/main/java/com/examples/MainActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package org.examples;
1+
package com.examples;
22

33
import android.os.Bundle;
44

5-
import org.devio.rn.splashscreen.SplashScreen;
65
import com.facebook.react.ReactActivity;
76

7+
import org.devio.rn.splashscreen.SplashScreen;
8+
89
public class MainActivity extends ReactActivity {
910

1011
/**

examples/android/app/src/main/java/org/examples/MainApplication.java renamed to examples/android/app/src/main/java/com/examples/MainApplication.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.examples;
1+
package com.examples;
22

33
import android.app.Application;
44

@@ -27,6 +27,11 @@ protected List<ReactPackage> getPackages() {
2727
new SplashScreenReactPackage()
2828
);
2929
}
30+
31+
@Override
32+
protected String getJSMainModuleName() {
33+
return "index";
34+
}
3035
};
3136

3237
@Override

0 commit comments

Comments
 (0)