npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-splash-animations

v0.1.0

Published

Animated splash screen API for React Native. There are 6 different hiding animations.

Downloads

15

Readme

react-native-splash-animations

Animated splash screen API for React Native. There are 6 different hiding animations.

Before you start

This package works only with Android.

This pacage is not forked but I took a lot of example by react-native-bootsplash so some codes are totally copy-pasted from react-native-bootsplash.

Getting started

$ npm install react-native-splash-animations --save

Assets generation

To make it easy to implement splash screen I recommand to use script that creates the Android Drawable XML

$ npx generate-splash-screen

Android

  1. :warning: Skip to step 2 if you generated Android Drawable XML with script. Create Image asset of your image by leftclicking and choosing New > Image Asset

Create android/app/src/main/res/values/colors.xml and add followings

<resources>
    <color name="splash_animation_background">#FFFFFF</color>
</resources>

Create android/app/src/main/res/drawable/splashanimation.xml which looks like followings:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
    <item android:drawable="@color/your_color" />
    <item android:id="@+id/logo">
        <!--Your image asset-->
        <bitmap android:src="@mipmap/your_image_asset" android:gravity="center"/>
    </item>
</layer-list>
  1. Edit android/app/src/main/res/values/styles.xml and add
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textColor">#000000</item>
    </style>
    <!-- Add the following lines-->
    <style name="SplashTheme">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowBackground">@drawable/splashanimation</item>
    </style>

</resources>
  1. Edit android/app/src/main/AndroidManifest.xml

    <!-- ... -->

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize"
            android:exported="true"> <!-- Add this line -->
            <!-- Remove <intent-filter>-->
        </activity>
        <!-- Add following lines -->
        <activity
            android:name="com.splashanimations.SplashAnimationActivity"
            android:theme="@style/SplashTheme"
            android:launchMode="singleTask"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- ... -->
    </application>
    <!-- ... -->
  1. Edit android/app/src/main/java/com/yourprojectname/MainActivity.java
public class MainActivity extends ReactActivity {

  // ...

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Displays your splash screen
    AnimatedLoadingScreen.show(R.drawable.splashanimation, this);
    // Sets hiding animation
    AnimatedLoadingScreen.setHideAnimation(HideAnimationType.HIDE_DOWN, 1000L);
  }
}

AnimatedLoadingScreen.setHideAnimation(HideAnimationType hideAnimationType, Long duration)

By using this function, you can set different hide animations and duration of animation.

HideAnimationType:

  • NO_ANIMATION - Hides without animation
  • FADE_OUT - Hides with fade out effect
  • HIDE_LEFT - Hides by moving the screen to left side
  • HIDE_RIGHT - Hides by moving the screen to right side
  • HIDE_UP - Hides by moving the screen to up side
  • HIDE_DOWN - Hides by moving the screen to down side

Duration should be Long, so 1000L = 1s Default animation is FADE_OUT and duration 500L

Then in your React Native project, you can use hide() function to hide displayed splash screen with animation.

Example:

import React, { useEffect } from "react";
import { Text } from "react-native";
import SplashAnimations from 'react-native-splash-animations';

function App() {
  useEffect(() => {
    // After initials (e.g. fetching)
    SplashAnimations.hide();
  }, []);

  return <Text>Hello World!</Text>;
}