Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
uradev0123 committed May 21, 2018
2 parents 43666e2 + 1b590fc commit 64e01cd
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 32 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ For React Native >= 0.47.0 use [v3.+](https://github.com/crazycodeboy/react-nati
## 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)
![react-native-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-iOS.gif)



Expand All @@ -45,7 +45,7 @@ Run `npm i react-native-splash-screen --save`

**Android:**

1. In your android/settings.gradle file, make the following additions:
1. In your `android/settings.gradle` file, make the following additions:
```java
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
Expand Down Expand Up @@ -134,9 +134,10 @@ Update `AppDelegate.m` with the following additions:


```obj-c

#import "AppDelegate.h"
#import "RCTRootView.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "SplashScreen.h" // here

@implementation AppDelegate
Expand Down Expand Up @@ -181,7 +182,7 @@ You can create splash screens in the following folders:
* `drawable-xxhdpi`
* `drawable-xxxhdpi`

To modify the status bar color, you can add a color called primary_dark in color.xml
Add a color called `primary_dark` in `app/src/main/res/values/color.xml`

```
<?xml version="1.0" encoding="utf-8"?>
Expand Down Expand Up @@ -233,12 +234,12 @@ Create a style definition for this in `android/app/src/main/res/values/colors.xm

Change your `show` method to include your custom style:
```java
SplashScreen.show(this, false, R.style.SplashScreenTheme);
SplashScreen.show(this, R.style.SplashScreenTheme);
```

### iOS

Customize your splash screen via LaunchImage or LaunchScreen.xib,
Customize your splash screen via `LaunchImage` or `LaunchScreen.xib`,

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

Expand Down Expand Up @@ -275,4 +276,4 @@ Pull requests are welcome. If you want to change the API or do something big it

---

**MIT Licensed**
**[MIT Licensed](https://github.com/crazycodeboy/react-native-splash-screen/blob/master/LICENSE)**
11 changes: 6 additions & 5 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ React Native启动屏,解决iOS,Android启动白屏问题,支持Android和
## 演示
* [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-splash-screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-Android.gif)
![react-native-splash-screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-iOS.gif)


## 改变
Expand Down Expand Up @@ -134,10 +134,11 @@ public class MainActivity extends ReactActivity {


```obj-c

#import "AppDelegate.h"
#import "RCTRootView.h"
#import "SplashScreen.h" // here

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "SplashScreen.h" // 添加这一句

@implementation AppDelegate

Expand Down
4 changes: 1 addition & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
package="org.devio.rn.splashscreen">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
android:label="@string/app_name">

</application>

Expand Down
15 changes: 5 additions & 10 deletions android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,20 @@
* Email:crazycodeboy@gmail.com
*/
public class SplashScreen {
private static int NULL_ID = 0;
private static Dialog mSplashDialog;
private static WeakReference<Activity> mActivity;

/**
* 打开启动屏
*/
public static void show(final Activity activity, final boolean fullScreen, final int themeResId) {
public static void show(final Activity activity, final int themeResId) {
if (activity == null) return;
mActivity = new WeakReference<Activity>(activity);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!activity.isFinishing()) {

mSplashDialog = new Dialog(
activity,
themeResId != NULL_ID ? themeResId
: fullScreen ? R.style.SplashScreen_Fullscreen
: R.style.SplashScreen_SplashTheme
);
mSplashDialog = new Dialog(activity, themeResId);
mSplashDialog.setContentView(R.layout.launch_screen);
mSplashDialog.setCancelable(false);

Expand All @@ -50,7 +43,9 @@ public void run() {
* 打开启动屏
*/
public static void show(final Activity activity, final boolean fullScreen) {
show(activity, fullScreen, 0);
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;

show(activity, resourceId);
}

/**
Expand Down
21 changes: 16 additions & 5 deletions examples/android/app/src/main/res/layout/launch_screen.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/launch_screen">

</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/black">

<LinearLayout
android:layout_width="350dip"
android:layout_height="450dip"
android:layout_centerInParent="true"
android:background="@drawable/launch_screen"
android:orientation="vertical"
android:padding="30dip"
>
</LinearLayout>
</RelativeLayout>
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module "react-native-splash-screen" {
export default class SplashScreen {
static hide(): void;
static show(): void;
}
}

0 comments on commit 64e01cd

Please sign in to comment.