All Projects → HwangTaehyun → react-native-lottie-splash-screen

HwangTaehyun / react-native-lottie-splash-screen

Licence: MIT license
⚡ Lottie splash screen for your react native app!

Programming Languages

java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
swift
15916 projects
ruby
36898 projects - #4 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-native-lottie-splash-screen

SplashScreenExample
How to implement a Splash Screen in ReactNative
Stars: ✭ 14 (-88.71%)
Mutual labels:  splash-screen, splashscreen
weather-icons
Free to use animated weather icons.
Stars: ✭ 341 (+175%)
Mutual labels:  lottie, lottie-animation
SplashScreen
A demo project showcasing different methods to create splash screen in Android and discusses the details in the companion Medium article.
Stars: ✭ 37 (-70.16%)
Mutual labels:  splash-screen, splashscreen
Splashy
Splash screen library for Android
Stars: ✭ 112 (-9.68%)
Mutual labels:  splash-screen, splashscreen
DarkModeSplashScreen
A sample app for iOS and Android written in Xamarin.Forms showing how to implement a Splash Page for Dark Mode
Stars: ✭ 28 (-77.42%)
Mutual labels:  splash-screen, splashscreen
React Native Splash Screen
A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
Stars: ✭ 5,038 (+3962.9%)
Mutual labels:  splash-screen, splashscreen
react-native-animated-loader
🍭 A React Native Loader Component which uses Airbnb's Lottie for beautiful loader animations.
Stars: ✭ 165 (+33.06%)
Mutual labels:  lottie, lottie-animation
retropiesplashscreen
Splashscreen Randomizer for Retropie!
Stars: ✭ 19 (-84.68%)
Mutual labels:  splash-screen
LoginAndRegistrationWithSocialMedia
Created a Project to design login screen, registration screen, login with google ,slider navigation drawer,dashboard screen login with Facebook using Flutter
Stars: ✭ 82 (-33.87%)
Mutual labels:  splashscreen
Compose-ToDo
A fully functional Android TODO app built entirely with Kotlin and Jetpack Compose
Stars: ✭ 130 (+4.84%)
Mutual labels:  lottie
space empires
Space Themed Turn-Based Strategy Game developed in Flutter
Stars: ✭ 60 (-51.61%)
Mutual labels:  lottie
DailyFeed
iOS client for newsapi.org
Stars: ✭ 128 (+3.23%)
Mutual labels:  lottie
app-intro-lottie-expo
App Intro component with Expo, styled-components and Lottie
Stars: ✭ 46 (-62.9%)
Mutual labels:  lottie
svelte-lottie-player
Lottie Player component for Svelte
Stars: ✭ 90 (-27.42%)
Mutual labels:  lottie
vue-splash
splash plugin for vue js
Stars: ✭ 120 (-3.23%)
Mutual labels:  splash-screen
CarLens-iOS
CarLens - Recognize and Collect Cars
Stars: ✭ 124 (+0%)
Mutual labels:  lottie
Dads
*BA DUM TSSS*
Stars: ✭ 240 (+93.55%)
Mutual labels:  lottie
My Android Garage
A quick reference guide for Android development.
Stars: ✭ 66 (-46.77%)
Mutual labels:  lottie-animation
AnimateViewLibrary
Developing easy to use any animation set for splash screen or any other views in your Android application. Easy to use, so you can animate your whole app just using this library
Stars: ✭ 19 (-84.68%)
Mutual labels:  splash-screen
FlightBookingApp
Xamarin.Forms goodlooking UI sample using the new SwipeView.
Stars: ✭ 26 (-79.03%)
Mutual labels:  lottie

react-native-lottie-splash-screen

Download PRs Welcome react-native-lottie-splash-screen release License MIT

Fork of react-native-splash-screen and add implement for animation splash screen using airbnb lottie files.

Works on IOS and Android.

Content

Examples

You can run examples in this project

react-native-lottie-splash-screen-Android react-native-lottie-splash-screen-iOS

Installation

First step(Download):

Run yarn add [email protected] react-native-lottie-splash-screen

Second step(Plugin Installation):

React Native v0.60+

The package is automatically linked when building the app. All you need to do is:

cd ios && pod install

For android, the package will be linked automatically on build.

For React Native version 0.59 or older

React Native <= v0.59

react-native link react-native-lottie-splash-screen

If you don't want to use the methods above, you can always do Manual installation.

Manual installation

Android:

  1. In your android/settings.gradle file, make the following additions:
include ':react-native-lottie-splash-screen'
project(':react-native-lottie-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-lottie-splash-screen/android')
  1. In your android/app/build.gradle file, add the :react-native-lottie-splash-screen project as a compile-time dependency:
...
dependencies {
    ...
    implementation project(':react-native-lottie-splash-screen')
}
  1. Update the MainApplication.java file to use react-native-lottie-splash-screen via the following changes:
// react-native-lottie-splash-screen >= 0.3.1
import org.devio.rn.splashscreen.SplashScreenReactPackage;
// react-native-lottie-splash-screen < 0.3.1
import com.cboy.rn.splashscreen.SplashScreenReactPackage;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
            new SplashScreenReactPackage()  //here
            );
        }
    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }
}

iOS:

  1. cd ios
  2. run pod install

OR

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]

  2. Go to node_modulesreact-native-lottie-splash-screen and add SplashScreen.xcodeproj

  3. In XCode, in the project navigator, select your project. Add libSplashScreen.a to your project's Build PhasesLink Binary With Libraries

  4. 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

Third step(Plugin Configuration):

Android:

Update the MainActivity.java to use react-native-lottie-splash-screen via the following changes:

import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen; // here
import android.os.Bundle;

public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this, R.id.lottie); // here
    SplashScreen.setAnimationFinished(true); // If you want the animation dialog to be forced to close when hide is called, use this code
    super.onCreate(savedInstanceState);
    // ...other code
  }
}

iOS:

  1. Create Dynamic.Swift with the following contents:
import UIKit
import Foundation
import Lottie

@objc class Dynamic: NSObject {

  @objc func createAnimationView(rootView: UIView, lottieName: String) -> AnimationView {
    let animationView = AnimationView(name: lottieName)
    animationView.frame = rootView.frame
    animationView.center = rootView.center
    animationView.backgroundColor = UIColor.white;
    return animationView;
  }

  @objc func play(animationView: AnimationView) {
    animationView.play(
      completion: { (success) in
        RNSplashScreen.setAnimationFinished(true)
      }
    );
  }
}
  1. Create [your-project-name]-Bridging-Header.h with the following contents:
//  HyperMoney-Bridging-Header.h

#ifndef HyperMoney_Bridging_Header_h
#define HyperMoney_Bridging_Header_h

#import "RNSplashScreen.h" // here

#endif /* HyperMoney_Bridging_Header_h */
  1. To use swift file in AppDelegate.m, follow next step.

https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c

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:

  1. Update AppDelegate.m with the following additions:
#import "AppDelegate.h"

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

#import "HyperMoney-Swift.h" // here, change project name to yours

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  // ...other code

  /* here */
  UIViewController *rootViewController = [UIViewController new];

  rootViewController.view = rootView;

  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  Dynamic *t = [Dynamic new];
  UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"loading"]; // change lottieName to your lottie files name
  animationUIView.backgroundColor = [UIColor whiteColor]; // change backgroundColor

  // 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];

  /* here */

  return YES;
}

Getting started

Import react-native-lottie-splash-screen in your JS file.

import SplashScreen from 'react-native-lottie-splash-screen'

Android:

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:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
  >
    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/lottie"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:lottie_rawRes="@raw/loading"
        app:lottie_autoPlay="true"
        app:lottie_loop="false"
        />
</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

iOS

Drag your lottie files to Xcode Project. Click Finish. That's all.

Usage

Use like so:

When the app is finished loading, hide the LottieSplashScreen.

The contents of the App.js may be the following:

import React, { useEffect } from "react";
import LottieSplashScreen from "react-native-lottie-splash-screen";
import RootNavigator from "@navi/RootNavigator";

const App = () => {
  useEffect(() => {
    LottieSplashScreen.hide(); // here
  }, []);
  return <RootNavigator />;
};

export default App;

API

Method Type Optional Description
hide() function false Close lottie splash screen

Contribution

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.


MIT Licensed

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].