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-app-splash

v1.0.2

Published

React Native splash screen library: programmatically show/hide for Android & iOS.

Downloads

14

Readme

react-native-app-splash

Download

React Native app splash library: programmatically show/hide for Android & iOS.

Content

Installation

First Step(Download):

$ npm install --save react-native-app-splash
$ yarn add react-native-app-splash

Manual Installation(If Needed)

Android:

  1. In your android/settings.gradle file, make the following additions:
include ':react-native-app-splash'   
project(':react-native-app-splash').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-app-splash/android')
  1. In your android/app/build.gradle file, add the :react-native-app-splash project as a compile-time dependency:
...
dependencies {
    ...
    implementation project(':react-native-app-splash')
}

iOS:

  1. cd ios
  2. run pod install

Second Step(Plugin Configuration):

Android:

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

java:

import android.os.Bundle; // here
import com.appsplash.AppSplash; // here

public class MainActivity extends ReactActivity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        AppSplash.show(this);  // here
        super.onCreate(null) // to fix Fragment constructor caused an exception
    }
    // ...other code
}

kotlin:

import android.os.Bundle; // here
import com.appsplash.AppSplash; // here

class MainActivity : ReactActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        AppSplash.show(this)
        super.onCreate(null) // to fix Fragment constructor caused an exception
    }
    // ...other code
}

iOS:

Update AppDelegate.m with the following additions:

obj-c:

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import "AppSplash.h"  // here

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ...other code
    [super application:application didFinishLaunchingWithOptions:launchOptions];
    [AppSplash show];  // here
    return YES;
}

@end

// ...other code

Getting started

Android:

Create a file called app_splash.xml in app/src/main/res/layout (create the layout-folder if it doesn't exist). The contents of the file should be the following:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/_dialog_parent"
    android:layout_width="match_parent"
    android:background="@android:color/white"
    android:layout_height="match_parent">

      <ImageView
        android:id="@+id/_dialog_imageview"
        android:layout_width="match_parent"
        android:src="@drawable/app_splash"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_height="match_parent"
        tools:ignore="ContentDescription" />

</RelativeLayout>

Customize your launch screen by creating a app_splash.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 app splashs in the following folders:

  • drawable-ldpi
  • drawable-mdpi
  • drawable-hdpi
  • drawable-xhdpi
  • drawable-xxhdpi
  • drawable-xxxhdpi

Optional steps:

If you want the app splash to be full screen, Change your show method.

java/kotlin:

AppSplash.show(this, true)

iOS

Customize your app splash via LaunchScreen.storyboard or LaunchScreen.xib

Usage

Use like so:

import AppSplash from 'react-native-app-splash';

const App = () => {

    React.useEffect(() => {
        // do the needed action while app splash is shown
        // After having done action hide the app splash
        AppSplash?.hide()  
    }, [])

}
export default App;

API

| Method | Type | Optional | Description | | ------------------------------------------------------- | -------- | -------- | -------------------------------- | | show() | function | false | Open App Splash (Native Method ) | | show(final Activity activity, final boolean fullScreen) | function | false | Open App Splash (Native Method ) | | hide() | function | false | Close App Splash |

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.

MIT Licensed