Skip to content

Commit

Permalink
publish v2.0.0
Browse files Browse the repository at this point in the history
Update iOS RN header paths
  • Loading branch information
crazycodeboy committed Jan 16, 2017
1 parent 148f86c commit fec4d94
Show file tree
Hide file tree
Showing 57 changed files with 592 additions and 257 deletions.
51 changes: 39 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# react-native-splash-screen

**[![](http://www.devio.org/io/sb/lang/chinese.svg)](https://github.com/crazycodeboy/react-native-splash-screen/blob/master/README.zh.md) | [原理解析](https://github.com/crazycodeboy/RNStudyNotes/blob/master/React%20Native%20%E9%97%AE%E9%A2%98%E5%8F%8A%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%90%88%E9%9B%86/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B.md)**
**[ ![语言 中文](https://img.shields.io/badge/语言-中文-feb252.svg)](https://github.com/crazycodeboy/GitHubPopular/blob/master/README.zh.md) | [原理解析](https://github.com/crazycodeboy/RNStudyNotes/blob/master/React%20Native%20%E9%97%AE%E9%A2%98%E5%8F%8A%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%90%88%E9%9B%86/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B.md)**


A splash screen for react-native, hide when application loaded ,it works on iOS and Android.

## Content

- [Installation](#installation)
- [Demo](#demo)
- [Examples](#examples)
- [Getting started](#getting-started)
- [API](#api)
- [Contribution](#contribution)
- [Changes](#changes)

## Changes
React Native>=4.0 to use [v2.+](https://github.com/crazycodeboy/react-native-splash-screen/releases) ,and React Native<4.0 to use [v1.0.9](https://github.com/crazycodeboy/react-native-splash-screen/releases/tag/v1.0.9)

## Examples
* [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)

![react-native-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-iOS.gif)



## Installation

Expand Down Expand Up @@ -76,6 +88,9 @@ public class MainApplication extends Application implements ReactApplication {
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
2. Go to `node_modules``react-native-splash-screen` and add `SplashScreen.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libSplashScreen.a` to your project's `Build Phases``Link Binary With Libraries`
4. To fix `'SplashScreen.h' file not found`, you have to select your project → Build Settings → Search Paths → Header Search Paths to add:

`$(SRCROOT)/../node_modules/react-native-splash-screen/ios`



Expand Down Expand Up @@ -125,19 +140,13 @@ You should add following code to AppDelegate.m for keeping launch image:

```
## Demo
* [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)
![react-native-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-iOS.gif)
## Getting started
Import `react-native-splash-screen` in your JS file.
`import SplashScreen from 'react-native-splash-screen'`
**Android:**
### Android:
Add a file called launch_screen.xml in the layout as the splash screen.
Expand All @@ -149,14 +158,32 @@ Add a file called launch_screen.xml in the layout as the splash screen.
android:background="@drawable/launch_screen">
</LinearLayout>
```
**Learn more to see [examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)**
**Optional steps:**
You can also via the following steps to set the window transparent.
open `android/app/src/main/res/values/styles.xml`, to add `<item name="android:windowIsTranslucent">true</item>`,like this :
```xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!--设置透明背景-->
+ <item name="android:windowIsTranslucent">true</item>
</style>
</resources>
```

**Learn more to see [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/Examples)**


**iOS**
### iOS

iOS can be used to customize your startup screen via LaunchImage or LaunchScreen.xib.

**Learn more to see [examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)**
**Learn more to see [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)**

Then you can use it like this:

Expand Down
43 changes: 37 additions & 6 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# react-native-splash-screen

**[![](http://www.devio.org/io/sb/lang/english.svg)](https://github.com/crazycodeboy/react-native-splash-screen) | [原理解析](https://github.com/crazycodeboy/RNStudyNotes/blob/master/React%20Native%20%E9%97%AE%E9%A2%98%E5%8F%8A%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%90%88%E9%9B%86/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B.md)**
**[ ![language English](https://img.shields.io/badge/language-English-feb252.svg)](https://github.com/crazycodeboy/GitHubPopular/) | [原理解析](https://github.com/crazycodeboy/RNStudyNotes/blob/master/React%20Native%20%E9%97%AE%E9%A2%98%E5%8F%8A%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%90%88%E9%9B%86/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B/React%20Native%20%E5%90%AF%E5%8A%A8%E7%99%BD%E5%B1%8F%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%95%99%E7%A8%8B.md)**


React Native启动屏,解决iOS,Android启动白屏问题,支持Android和iOS。
Expand All @@ -12,6 +12,19 @@ React Native启动屏,解决iOS,Android启动白屏问题,支持Android和
- [使用说明](#使用说明)
- [API](#api)
- [贡献](#贡献)
- [改变](#改变)

## 演示
* [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)

![react-native-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-iOS.gif)


## 改变

如果你项目的React Native>=4.0请使用[v2.+](https://github.com/crazycodeboy/react-native-splash-screen/releases),
如果<4.0请使用[v1.0.9](https://github.com/crazycodeboy/react-native-splash-screen/releases/tag/v1.0.9)

## 安装说明

Expand Down Expand Up @@ -85,7 +98,12 @@ public class MainApplication extends Application implements ReactApplication {
2.`SplashScreen.xcodeproj`添加到你的项目中,`node_modules``react-native-splash-screen``SplashScreen.xcodeproj`

3. 在XCode中打开`Build Phases``Link Binary With Libraries``libSplashScreen.a` 添加到你的项目中。
4. 如果在使用过过程中出现 `'SplashScreen.h' file not found`问题,你可以下面的代码添加到Header Search Paths中,步骤如下:


选择你的项目,TARGET → Build Settings → Search Paths → Header Search Paths 添加:

`$(SRCROOT)/../node_modules/react-native-splash-screen/ios`


### 第三步(配置):
Expand Down Expand Up @@ -129,11 +147,6 @@ public class MainActivity extends ReactActivity {

```
## 演示
* [Examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)
![react-native-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/master/examples/Screenshots/react-native-splash-screen-iOS.gif)
## 使用说明
Expand All @@ -155,6 +168,24 @@ public class MainActivity extends ReactActivity {
</LinearLayout>
```
**另外:**
你也可以启用app主题透明选项来解决在APP启动时因主题原因导致的短暂白屏的问题,具体步骤如下:
打开 `android/app/src/main/res/values/styles.xml`文件,添加 `<item name="android:windowIsTranslucent">true</item>`,如下 :
```xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!--设置透明背景-->
+ <item name="android:windowIsTranslucent">true</item>
</style>
</resources>
```


**更详细的介绍,可以查看 [examples](https://github.com/crazycodeboy/react-native-splash-screen/tree/master/examples)**

**iOS**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import java.lang.ref.WeakReference;
/**
* SplashScreen
* 出自:http://www.cboy.me
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Eamil:[email protected]
* Email:[email protected]
*/
public class SplashScreen {
private static Dialog mSplashDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import com.facebook.react.bridge.ReactMethod;

/**
* SplashScreenModule
* 出自:http://www.cboy.me
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Eamil:[email protected]
* Email:[email protected]
*/
public class SplashScreenModule extends ReactContextBaseJavaModule{
public SplashScreenModule(ReactApplicationContext reactContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import java.util.List;

/**
* SplashScreenReactPackage
* 出自:http://www.cboy.me
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Eamil:[email protected]
* Email:[email protected]
*/
public class SplashScreenReactPackage implements ReactPackage {

Expand Down
3 changes: 3 additions & 0 deletions examples/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
34 changes: 10 additions & 24 deletions examples/.flowconfig
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
[ignore]

# We fork some components by platform.
; We fork some components by platform
.*/*[.]android.js

# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Ignore malformed json
.*/node_modules/y18n/test/.*\.json

# Ignore the website subdir
<PROJECT_ROOT>/website/.*

# Ignore BUCK generated dirs
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*

[include]

Expand All @@ -34,25 +24,21 @@ flow/
[options]
module.system=haste

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
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'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
^0.30.0
^0.36.0
1 change: 1 addition & 0 deletions examples/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
18 changes: 15 additions & 3 deletions examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ DerivedData
*.xcuserstate
project.xcworkspace

# Android/IJ
# Android/IntelliJ
#
*.iml
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
Expand All @@ -38,4 +39,15 @@ npm-debug.log
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
Binary file removed examples/Screenshots/China.png
Binary file not shown.
Binary file modified examples/Screenshots/react-native-splash-screen-Android.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Screenshots/react-native-splash-screen-iOS.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions examples/__tests__/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import Index from '../index.android.js';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
12 changes: 12 additions & 0 deletions examples/__tests__/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import Index from '../index.ios.js';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
4 changes: 2 additions & 2 deletions examples/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
from configurations.compile
into 'libs'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

import com.cboy.rn.splashscreen.SplashScreen;
import com.facebook.react.ReactActivity;

/**
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Email:[email protected]
*/
public class MainActivity extends ReactActivity {

/**
Expand All @@ -22,4 +29,3 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}

Loading

0 comments on commit fec4d94

Please sign in to comment.