Gathering detailed insights and metrics for react-native-lottie-splash-screen
Gathering detailed insights and metrics for react-native-lottie-splash-screen
Gathering detailed insights and metrics for react-native-lottie-splash-screen
Gathering detailed insights and metrics for react-native-lottie-splash-screen
expo-splash-screen
Provides a module to allow keeping the native Splash Screen visible until you choose to hide it.
react-native-splash-screen
A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
lottie-web
After Effects plugin for exporting animations to SVG + JavaScript or canvas + JavaScript
lottie-react-native
React Native bindings for Lottie
npm install react-native-lottie-splash-screen
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
222 Stars
222 Commits
62 Forks
5 Watching
5 Branches
50 Contributors
Updated on 18 Nov 2024
Java (53.09%)
Objective-C (32.68%)
Swift (6.11%)
Ruby (5.43%)
JavaScript (2.69%)
Cumulative downloads
Total Downloads
Last day
17.2%
1,163
Compared to previous day
Last week
-8.2%
5,702
Compared to previous week
Last month
1%
26,423
Compared to previous month
Last year
-8.2%
356,176
Compared to previous year
2
1
Fork of react-native-splash-screen and add implement for animation splash screen using airbnb lottie files.
Works on IOS and Android.
You can run examples in this project
Run yarn add lottie-ios@3.2.3 react-native-lottie-splash-screen
The package is automatically linked when building the app. All you need to do is:
1cd ios && pod install
For android, the package will be linked automatically on build.
1react-native link react-native-lottie-splash-screen
If you don't want to use the methods above, you can always do Manual installation.
Android:
android/settings.gradle
file, make the following additions:1include ':react-native-lottie-splash-screen' 2project(':react-native-lottie-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-lottie-splash-screen/android')
:react-native-lottie-splash-screen
project as a compile-time dependency:1... 2dependencies { 3 ... 4 implementation project(':react-native-lottie-splash-screen') 5}
react-native-lottie-splash-screen
via the following changes:1// react-native-lottie-splash-screen >= 0.3.1 2import org.devio.rn.splashscreen.SplashScreenReactPackage; 3// react-native-lottie-splash-screen < 0.3.1 4import com.cboy.rn.splashscreen.SplashScreenReactPackage; 5 6public class MainApplication extends Application implements ReactApplication { 7 8 private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 9 @Override 10 public boolean getUseDeveloperSupport() { 11 return BuildConfig.DEBUG; 12 } 13 14 @Override 15 protected List<ReactPackage> getPackages() { 16 return Arrays.<ReactPackage>asList( 17 new MainReactPackage(), 18 new SplashScreenReactPackage() //here 19 ); 20 } 21 }; 22 23 @Override 24 public ReactNativeHost getReactNativeHost() { 25 return mReactNativeHost; 26 } 27}
iOS:
cd ios
run pod install
OR
In XCode, in the project navigator, right click Libraries
➜ Add Files to [your project's name]
Go to node_modules
➜ react-native-lottie-splash-screen
and add SplashScreen.xcodeproj
In XCode, in the project navigator, select your project. Add libSplashScreen.a
to your project's Build Phases
➜ Link Binary With Libraries
To fix 'RNSplashScreen.h' file not found
, you have to select your project → Build Settings → Search Paths → Header Search Paths to add:
$(SRCROOT)/../node_modules/react-native-lottie-splash-screen/ios
Android:
Update the MainActivity.java
to use react-native-lottie-splash-screen
via the following changes:
1import android.os.Bundle; 2import com.facebook.react.ReactActivity; 3import org.devio.rn.splashscreen.SplashScreen; // here 4import android.os.Bundle; 5 6public class MainActivity extends ReactActivity { 7 @Override 8 protected void onCreate(Bundle savedInstanceState) { 9 SplashScreen.show(this, R.id.lottie); // here 10 SplashScreen.setAnimationFinished(true); // If you want the animation dialog to be forced to close when hide is called, use this code 11 super.onCreate(savedInstanceState); 12 // ...other code 13 } 14}
iOS:
Dynamic.swift
with the following contents:1import UIKit
2import Foundation
3import Lottie
4
5@objc class Dynamic: NSObject {
6
7 @objc func createAnimationView(rootView: UIView, lottieName: String) -> AnimationView {
8 let animationView = AnimationView(name: lottieName)
9 animationView.frame = rootView.frame
10 animationView.center = rootView.center
11 animationView.backgroundColor = UIColor.white;
12 return animationView;
13 }
14
15 @objc func play(animationView: AnimationView) {
16 animationView.play(
17 completion: { (success) in
18 RNSplashScreen.setAnimationFinished(true)
19 }
20 );
21 }
22}
[your-project-name]-Bridging-Header.h
with the following contents:1// HyperMoney-Bridging-Header.h 2 3#ifndef HyperMoney_Bridging_Header_h 4#define HyperMoney_Bridging_Header_h 5 6#import "RNSplashScreen.h" // here 7 8#endif /* HyperMoney_Bridging_Header_h */ 9
Import Swift code into Objective-C within the same framework:
Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to Yes.
Import the Swift code from that framework target into any Objective-C .m file within that target using this syntax and substituting the appropriate names:
AppDelegate.mm
with the following additions: (for react-native@0.71 proceed to 4.1)1 2#import "AppDelegate.h" 3 4#import <React/RCTBridge.h> 5#import <React/RCTBundleURLProvider.h> 6#import <React/RCTRootView.h> 7#import "RNSplashScreen.h" // here 8 9#import "HyperMoney-Swift.h" // here, change project name to yours 10 11@implementation AppDelegate 12 13- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14{ 15 16 // ...other code 17 18 /* here */ 19 UIViewController *rootViewController = [UIViewController new]; 20 21 rootViewController.view = rootView; 22 23 self.window.rootViewController = rootViewController; 24 [self.window makeKeyAndVisible]; 25 26 Dynamic *t = [Dynamic new]; 27 UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"loading"]; // change lottieName to your lottie files name 28 animationUIView.backgroundColor = [UIColor whiteColor]; // change backgroundColor 29 30 // register LottieSplashScreen to RNSplashScreen 31 [RNSplashScreen showLottieSplash:animationUIView inRootView:rootView]; 32 33 // casting UIView type to AnimationView type 34 AnimationView *animationView = (AnimationView *) animationUIView; 35 36 // play 37 [t playWithAnimationView:animationView]; 38 39 // If you want the animation layout to be forced to remove when hide is called, use this code 40 [RNSplashScreen setAnimationFinished:true]; 41 42 /* here */ 43 44 return YES; 45}
4.1 For React-Native version 0.71, in AppDelegate.mm
rootView is no longer here. We need access to the rootView.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"YOUR_PROJECT_NAME";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
// return [super application:application didFinishLaunchingWithOptions:launchOptions]; //This will be assigned as success instead
BOOL success = [super application:application didFinishLaunchingWithOptions:launchOptions];
if (success) {
//This is where we will put the logic to get access to rootview
UIView *rootView = self.window.rootViewController.view;
rootView.backgroundColor = [UIColor whiteColor]; // change with your desired backgroundColor
Dynamic *t = [Dynamic new];
UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"logo_animated"]; // change lottieName to your lottie files name
// register LottieSplashScreen to RNSplashScreen
[RNSplashScreen showLottieSplash:animationUIView inRootView:rootView];
// casting UIView type to AnimationView type
AnimationView *animationView = (AnimationView *) animationUIView;
// play
[t playWithAnimationView:animationView];
// If you want the animation layout to be forced to remove when hide is called, use this code
[RNSplashScreen setAnimationFinished:true];
}
return success;
}
4.2 If your AppDelegate.swift
is in swift
:
let rootViewController = UIViewController()
rootViewController.view = rootView
rootWindow.rootViewController = rootViewController
rootWindow.makeKeyAndVisible()
// start
let t = Dynamic()
let animationUIView: UIView = t.createAnimationView(rootView: rootView, lottieName:"Your_lottie_animation")
RNSplashScreen.showLottieSplash(animationUIView, inRootView: rootView)
animationUIView.frame = rootView.frame
t.play(animationView: animationUIView as! AnimationView)
RNSplashScreen.setAnimationFinished(true)
// end
return true
Import react-native-lottie-splash-screen
in your JS file.
import SplashScreen from 'react-native-lottie-splash-screen'
Create a file called launch_screen.xml
in app/src/main/res/layout
(create the layout
-folder if it doesn't exist). Next, locate your lottie files in app/src/main/res/raw
(loading.json in this example). The contents of the file should be the following:
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 tools:context=".MainActivity" 6 android:orientation="vertical" 7 android:layout_width="match_parent" 8 android:layout_height="match_parent" 9 android:background="@color/white" 10 > 11 <com.airbnb.lottie.LottieAnimationView 12 android:id="@+id/lottie" 13 android:layout_width="match_parent" 14 android:layout_height="match_parent" 15 app:lottie_rawRes="@raw/loading" 16 app:lottie_autoPlay="true" 17 app:lottie_loop="false" 18 /> 19</LinearLayout>
Customize your launch screen by creating a launch_screen.png
-file and placing it in an appropriate drawable
-folder. Android automatically scales drawable, so you do not necessarily need to provide images for all phone densities.
You can create splash screens in the following folders:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
Drag your lottie files to Xcode Project. Click Finish. That's all.
It's really annoying to resolve issues with expo bare workflow because I do not use this 🥲. But a lot of developers want to use this project to expo bare workflow. So, If you managed to this, please star and share this project! That's a really big energy to me! :rocket::rocket::rocket:
"Cannot find 'RNSplashScreen' in scope - Build iOS error" issue in Dynamic.swift #
1#import "RNSplashScreen.h" // here 2#import "ExpoModulesCore-Swift.h" // here 3#import "ExpoLSSTestApp-Swift.h" // here, change project name to yours
1"build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'" 2j
Use like so:
When the app is finished loading, hide the LottieSplashScreen.
The contents of the App.js may be the following:
1import React, { useEffect } from "react"; 2import LottieSplashScreen from "react-native-lottie-splash-screen"; 3import RootNavigator from "@navi/RootNavigator"; 4 5const App = () => { 6 useEffect(() => { 7 LottieSplashScreen.hide(); // here 8 }, []); 9 return <RootNavigator />; 10}; 11 12export default App;
Method | Type | Optional | Description |
---|---|---|---|
hide() | function | false | Close lottie splash screen |
I open-source almost everything I can and try to reply to everyone needing help using these projects. Obviously, this takes time. You can use this service for free.
However, if you are using this project and are happy with it or just want to encourage me to continue creating stuff, there are a few ways you can do it:
Thanks! :heart:
Issues are welcome. Please add a screenshot of you bug and a code snippet. Quickest way to solve issue is to reproduce it in one of the examples.
Pull requests are welcome. If you want to change the API or do something big it is best to create an issue and discuss it first.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/16 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More