Giter Site home page Giter Site logo

react-native-smart-splash-screen's Introduction

react-native-smart-splash-screen

npm npm npm npm

A smart splash screen for React Native apps, written in JS, oc and java for cross-platform support. It works on iOS and Android.

Preview

react-native-smart-splash-screen-ios-preview react-native-smart-splash-screen-android-preview

Installation

npm install react-native-smart-splash-screen --save

Notice

It can only be used greater-than-equal react-native 0.4.0 for ios, if you want to use the package less-than react-native 0.4.0, use npm install [email protected] --save

Installation (iOS)

  • Drag RCTSplashScreen.xcodeproj to your project on Xcode.

  • Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTSplashScreen.a from the Products folder inside the RCTSplashScreen.xcodeproj.

  • Look for Header Search Paths and make sure it contains $(SRCROOT)/../../../react-native/React as recursive.

  • In your project, Look for Header Search Paths and make sure it contains $(SRCROOT)/../node_modules/react-native-smart-splash-screen/ios/RCTSplashScreen/RCTSplashScreen

  • delete your project's LaunchScreen.xib

  • Drag SplashScreenResource folder to your project if you want change image, replace splash.png or add a image with your custom name

  • In AppDelegate.m


...
#import "RCTSplashScreen.h" //import interface
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                  moduleName:@"ReactNativeComponents"
                                           initialProperties:nil
                                               launchOptions:launchOptions];

//[RCTSplashScreen open:rootView];
[RCTSplashScreen open:rootView withImageNamed:@"splash"]; // activate splashscreen, imagename from LaunchScreen.xib

rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;

Installation (Android)

  • In android/settings.gradle
...
include ':react-native-smart-splashscreen'
project(':react-native-smart-splashscreen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smart-splash-screen/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    // From node_modules
    compile project(':react-native-smart-splashscreen')
}
  • Add your own drawable/splash.png to android/app/src/main/res/, it is recommended to add drawable-?dpi folders that you need.

  • in MainApplication.java

...
import com.reactnativecomponent.splashscreen.RCTSplashScreenPackage;    //import package
...
/**
 * A list of packages used by the app. If the app uses additional views
 * or modules besides the default ones, add more packages here.
 */
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RCTSplashScreenPackage()    //register Module
    );
}
...

  • in MainActivity.java
...
import com.reactnativecomponent.splashscreen.RCTSplashScreen;    //import RCTSplashScreen
...
@Override
protected void onCreate(Bundle savedInstanceState) {
    RCTSplashScreen.openSplashScreen(this);   //open splashscreen
    //RCTSplashScreen.openSplashScreen(this, true, ImageView.ScaleType.FIT_XY);   //open splashscreen fullscreen
    super.onCreate(savedInstanceState);
}
  • In android/app/**/styles.xml
...
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowIsTranslucent">true</item>
</style>
...

Full Demo

see ReactNativeComponentDemos

Usage

...
import SplashScreen from 'react-native-smart-splash-screen'
...
componentDidMount () {
     //SplashScreen.close(SplashScreen.animationType.scale, 850, 500)
     SplashScreen.close({
        animationType: SplashScreen.animationType.scale,
        duration: 850,
        delay: 500,
     })
}
...

Method

  • close(animationType, duration, delay) close splash screen with custom animation

    • animationType: determine the type of animation. enum(animationType.none, animationType.fade, animationType.scale)
    • duration: determine the duration of animation
    • delay: determine the delay of animation

react-native-smart-splash-screen's People

Contributors

abrahambotros avatar atlanteh avatar cyqresig avatar kuznetsov-online avatar mantas-janulionis avatar mcordini avatar rcugut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-smart-splash-screen's Issues

Request update to android instructions in README

Something missing from the Android instructions in the readme:

In MainActivity.java, imports section:

//import android.widget.ImageView; // uncomment if opening fullscreen
import android.os.Bundle; // required for onCreate parameter

Also, if you want to open the splash full screen, but maintain aspect ratio:

RCTSplashScreen.openSplashScreen(this, true, ImageView.ScaleType.CENTER_INSIDE);   //open splashscreen fullscreen, use CENTER_INSIDE instead of FIT_XY to maintain aspect ratio

Thanks!

Build fails on Ubuntu 14.04 x86

Up until now we ran builds in windows and everything went smoothly.
Now we started using Ubuntu and the build fails:

/home/user/Android/Sdk/build-tools/24.0.0/aapt: 5: /home/user/Android/Sdk/build-tools/24.0.0/aapt: Syntax error: end of file unexpected (expecting ")")

I've investigated the issue and it seems that the root is that your build.gradle requires build-tools 24.0.0.
If I go to node_modules/react-native-smart-splashscreen/android/build.gradle and change build-tools to 23.0.3, the build completes successfully.
You can see this SO question for reference..

Splash problems on some devices

After that, it remains on the black screen.

  • Happens usually when force-quitting the app from the app drawer.
  • Happens on Samsung Galaxy Note 4, didn't see any problems on my OPO.

Bug

[iOS] Throw 'requiresMainQueueSetup' warn

My env:

"react-native": "0.49.3",
"react-native-smart-splash-screen": "^2.3.5",

Throw warn:

Module RCTSplashScreen requires main queue setup since it overrides constantsToExport but doesn't implement `requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

Not work with RN 0.56.0

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-smart-splashscreen'.
> The SDK Build Tools revision (23.0.3) is too low for project ':react-native-smart-splashscreen'. Minimum required is 25.0.0

SplashScreen remains on the screen

I have setup the splash screen. The issue is that, after the animation. It still shows the SplashScreen.
Here's the link to the repo. https://github.com/peterlazar1993/Headway/commit/a87295b394c0485d56eeecf8b7af2c0cd6cc73ac
Any idea what's going wrong?

splash

UPDATE:

There is progress. I have the splash screen working as intended. I removed the theme line from Manifest https://github.com/peterlazar1993/Headway/commit/bb0791b77edb12bd6cf44c8c056e9cd2eab7495c

I would still like to know why the earlier issue was happening though.

Custom style splash screen ?

Thanks for build very usefull component.
Can we put some custom styling on our splash screen ? like put Text tag and some StyleSheet ?

Statusbar-issue

Is there any way to hide status-bar on splash screen in android ?

App Stuck on relaunching first time from icon in Android

Step 1 : Install app - Splash shows and close as expected
Step 2 : put app in background by pressing home button
Step : open app from launcher icon, it is stucked at splash screen.

After closing app, it works okay. Only happens on fresh install.

Android Not working on RN 0.33

  1. Cannot find the function getReactNativeHost on MainActivity.java
  2. On @Override protected ReactRootView createRootView():
    MainActivity.java:49: error: method does not override or implement a method from a supertype @Override ^
  3. MainActivity.java:81: error: cannot find symbol return super.createRootView(); ^ symbol: method createRootView()

splash设置为全屏进入首页会动一下

splash设置图片全屏,进入首页后,首页的navbar一开始被statusbar遮住一部分,然后navbar往下移,这个动画效果不太好。有解决办法嘛。我的react-native版本0.44.2,app里面的导航使用社区的react-navigation

Pressing Android back button problem

If I press Android hardware back button in my app the app properly exits, but when I reopen it (without killing it) it shows again splash screen... and it looks like app is hanged on splash screen. I guess back button causes for some reason splash screen to reappear and when app is opened next time it hangs on splash screen.

It doesn't help even if I use BackHandler.exitApp() to exit the app. Same issue persist. Any ideas how to fix?

error: cannot find symbol protected void onCreate(Bundle savedInstanceState)

:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Users\zaids\clStreet\android\app\src\main\java\com\clstreet\MainActivity.java:18: error: cannot find symbol protected void onCreate(Bundle savedInstanceState) {
^
symbol: class Bundle
location: class MainActivity
1 error
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation** failed; see the compiler error output for details.

Android this is not an activity

When running on android I get the issue when adding package to MainActivity.java

 new RCTSplashScreenPackage(this)

Will crash on error

MainApplication.java:41: error: incompatible types: <anonymous ReactNativeHost> cannot be converted to Activity
      new RCTSplashScreenPackage(this)

Support for expo kit

Current installation instructions don't allow for create react native apps that have ejected to expo kit. I figured out how to resolve the 'Header Search Paths' however the instructions for the AppDelegate.m don't sync with Expo's AppDelegate:

`- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor whiteColor];
[[ExpoKit sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
_rootViewController = [ExpoKit sharedInstance].rootViewController;
_window.rootViewController = _rootViewController;

[_rootViewController loadReactApplication];
[_window makeKeyAndVisible];

return YES;

}`

Please advise... also in the offical react native docs they now by default get you to use Expo.io so adding support for this would be amazing otherwise I can't use your plugin.

IOS installation step by step

Hey,
Can someone please explain me how to make it work on IOS step by step?
The IOS documentation here very bad.

Thanks.

how to Installation (Android)?

Hi,
I want to use react-native-smart-splash-screen for android but i can't install for RN 30.
can you show file MainApplication.java and MainApplication.java?
Or can you create a example?
Thank you very much.

On ios first open default splashscreen

On ios when I'm opening application it's open default splashscreen (even I'd put my splash.png), and when it's going to load local resources screen it does show my splash screen. Important! It's happening only with "Debug" scheme, but it works good with "Release" scheme :)

Can't get it to work on Android

undefined is not an object (evaluating _reactNativeSmartSplashScreen2.default.close)

Can you please upload a full example with the library?

Thanks!

ios 8.0 build problem

I used fastlane to build release and i got this error:

libRCTSplashScreen.a(RCTSplashScreen.o)) was built for newer iOS version (9.3) than being linked (8.0)

❌ ld: symbol(s) not found for architecture arm64

❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please help me to fix this issue.
My project needed to support iOS 8.0+

gif splash screen

Hi there,

Is it possible to add a gif splash screen with this package?

Regards

Build fails with Gradle 4.5 or 4.4.1

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-smart-splashscreen'.
> Failed to notify project evaluation listener.
> com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)

Still get white screen

i have follow the all instructions on master branch.
and build perfectly, but i still get white screen... any suggestion?

Failed to run setTimeout

react native:0.44
react native smart splash screen: 2.3.3
platform: android

setTimeout etc. will run immediately

When I add this package my react native app stops rotating on android

Hi!
Today I found an issue in my react native android project.
App rotation on android stopped work.
I discovered that it happened when I added "react-native-smart-splash-screen" package.

I created a test repo so you can easily reproduce it:
https://bitbucket.org/growappisrael/rn-test-project

On the master branch, the "react-native-smart-splash-screen" package is not installed so the rotation works.
On the "added_splash" branch the "react-native-smart-splash-screen" package is installed and the rotation does not work.

Android crash

OS: 8.0
Device: OnePlus3

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference at com.reactnativecomponent.splashscreen.RCTSplashScreen.getActivity(RCTSplashScreen.java:31) at com.reactnativecomponent.splashscreen.RCTSplashScreen.removeSplashScreen(RCTSplashScreen.java:82) at com.reactnativecomponent.splashscreen.RCTSplashScreenModule$1.run(RCTSplashScreenModule.java:56) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) at java.lang.Thread.run(Thread.java:764)

iOS wrong reference resource folder for splashScreen png

I have done everything according to manual and it works fine on both platforms. However, when I reinstall all packages with 'yarn' command on iOS I see error:

CopyPNGFile build/Build/Products/Debug-iphonesimulator/projectname.app/[email protected] /Users/.../node_modules/react-native-smart-splash-screen/ios/SplashScreenResource/[email protected]
(1 failure)

After changing png file in module folder everything is ok again, but I would like rather have reference to my asset folder that is not ignoring by git.

Any way to achieve that?

black screen

Hello I need help, I implemented the library but I have a problem, when open the app the screen is black an then run my other components as usuall.
Note: I'm using Xcode 9 and ios 11

Using splash.gif

Is this possible to use an animated file such as splash.gif instead of splash.png ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.