Skip to content

Commit 4e6dff1

Browse files
committed
add examples
1 parent 0f9c0f9 commit 4e6dff1

Some content is hidden

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

43 files changed

+2196
-4
lines changed

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class MainApplication extends Application implements ReactApplication {
5656
protected List<ReactPackage> getPackages() {
5757
return Arrays.<ReactPackage>asList(
5858
new MainReactPackage(),
59-
new SplashScreenReactPackage()
59+
new SplashScreenReactPackage() //here
6060
);
6161
}
6262
};
@@ -68,22 +68,55 @@ public class MainApplication extends Application implements ReactApplication {
6868
}
6969
```
7070

71+
**iOS:**
72+
73+
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
74+
2. Go to `node_modules``react-native-launch-image` and add `SplashScreen.xcodeproj`
75+
3. In XCode, in the project navigator, select your project. Add `libSplashScreen.a` to your project's `Build Phases``Link Binary With Libraries`
76+
4. Run your project (`Cmd+R`).
77+
7178

7279
### Third step(Plugin Configuration):
7380

81+
**Android:**
82+
7483
Update the MainActivity.java file to use `react-native-splash-screen` via the following changes:
7584

7685
```java
7786
public class MainActivity extends ReactActivity {
7887
@Override
7988
protected void onCreate(Bundle savedInstanceState) {
80-
SplashScreen.show(this);
89+
SplashScreen.show(this); // here
8190
super.onCreate(savedInstanceState);
8291
}
83-
...
92+
// ...other code
8493
}
8594
```
8695

96+
**iOS:**
97+
98+
You should add following code to AppDelegate.m for keeping launch image:
99+
100+
101+
```obj-c
102+
103+
#import "AppDelegate.h"
104+
#import "RCTRootView.h"
105+
#import "SplashScreen.h" // here
106+
107+
@implementation AppDelegate
108+
109+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
110+
{
111+
// ...other code
112+
113+
[SplashScreen show]; // here
114+
return YES;
115+
}
116+
117+
@end
118+
119+
```
87120
88121
## Demo
89122
* [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)
@@ -96,6 +129,8 @@ Import `react-native-splash-screen` in your JS file.
96129
97130
`import SplashScreen from 'react-native-splash-screen'`
98131
132+
**Android:**
133+
99134
Add a file called launch_screen.xml in the layout as the splash screen.
100135
101136
```
@@ -108,7 +143,6 @@ Add a file called launch_screen.xml in the layout as the splash screen.
108143
```
109144
110145
111-
112146
Then you can use it like this:
113147
114148
```JavaScript

examples/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

examples/.flowconfig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*[.]android.js
5+
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
8+
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
11+
12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
14+
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
17+
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
20+
21+
# Ignore duplicate module providers
22+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
.*/Libraries/react-native/ReactNative.js
25+
.*/node_modules/jest-runtime/build/__tests__/.*
26+
27+
[include]
28+
29+
[libs]
30+
node_modules/react-native/Libraries/react-native/react-native-interface.js
31+
node_modules/react-native/flow
32+
flow/
33+
34+
[options]
35+
module.system=haste
36+
37+
esproposal.class_static_fields=enable
38+
esproposal.class_instance_fields=enable
39+
40+
experimental.strict_type_args=true
41+
42+
munge_underscores=true
43+
44+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
45+
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'
46+
47+
suppress_type=$FlowIssue
48+
suppress_type=$FlowFixMe
49+
suppress_type=$FixMe
50+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
54+
55+
unsafe.enable_getters_and_setters=true
56+
57+
[version]
58+
^0.30.0

examples/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IJ
26+
#
27+
*.iml
28+
.idea
29+
.gradle
30+
local.properties
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
android/keystores/debug.keystore

examples/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
392 KB
Loading
91.6 KB
Loading

examples/android/app/BUCK

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import re
2+
3+
# To learn about Buck see [Docs](https://buckbuild.com/).
4+
# To run your application with Buck:
5+
# - install Buck
6+
# - `npm start` - to start the packager
7+
# - `cd android`
8+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
9+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10+
# - `buck install -r android/app` - compile, install and run application
11+
#
12+
13+
lib_deps = []
14+
for jarfile in glob(['libs/*.jar']):
15+
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16+
lib_deps.append(':' + name)
17+
prebuilt_jar(
18+
name = name,
19+
binary_jar = jarfile,
20+
)
21+
22+
for aarfile in glob(['libs/*.aar']):
23+
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24+
lib_deps.append(':' + name)
25+
android_prebuilt_aar(
26+
name = name,
27+
aar = aarfile,
28+
)
29+
30+
android_library(
31+
name = 'all-libs',
32+
exported_deps = lib_deps
33+
)
34+
35+
android_library(
36+
name = 'app-code',
37+
srcs = glob([
38+
'src/main/java/**/*.java',
39+
]),
40+
deps = [
41+
':all-libs',
42+
':build_config',
43+
':res',
44+
],
45+
)
46+
47+
android_build_config(
48+
name = 'build_config',
49+
package = 'com.examples',
50+
)
51+
52+
android_resource(
53+
name = 'res',
54+
res = 'src/main/res',
55+
package = 'com.examples',
56+
)
57+
58+
android_binary(
59+
name = 'app',
60+
package_type = 'debug',
61+
manifest = 'src/main/AndroidManifest.xml',
62+
keystore = '//android/keystores:debug',
63+
deps = [
64+
':app-code',
65+
],
66+
)

0 commit comments

Comments
 (0)