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

v1.1.2

Published

dynamic display splash

Downloads

119

Readme

react-native-dynamic-splash

以中文查看
React Native dynamic launch page (advertisement page), support for Android and iOS

Installation

npm install react-native-dynamic-splash --save

Demo

| IOS | Android | | --- | ------- | | IOS | Android |

Rn installation

Android

Automatic installation

react-native link react-native-dynamic-splash

Manual installation

  • android/settings.gradle File add code
include ':react-native-dynamic-splash'
project(':react-native-dynamic-splash').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dynamic-splash/android')
  • android/app/build.gradle File add code
...
dependencies {
    ...
    compile project(':react-native-dynamic-splash')
}
...
  • android/app/src/main/java/com/example/MainApplication.java File add code
...
import com.taumu.rnDynamicSplash.DynamicSplashReactPackage;  // Import package

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 DynamicSplashReactPackage()  // Add here
            );
        }

        @Override
        protected String getJSMainModuleName() {
            return "index";
        }
    };
    ...
}

iOS

Installing via CocoaPods

  1. Added in Podfile file pod 'RNDynamicSplash', :path => '../node_modules/react-native-dynamic-splash'
  2. Then run pod install

Manual installation

  1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
  2. Go to node_modules ➜ react-native-dynamic-splash and add RNDynamicSplash.xcodeproj
  3. In XCode, in the project navigator, select your targets. Add libRNDynamicSplash.a to your project's Build Phases ➜ Link Binary With Libraries
  4. To fix 'RNDynamicSplash.h' file not found, you have to select your project/targets → Build Settings → Search Paths → Header Search Paths to add:
  • project $(SRCROOT)/../node_modules/react-native-dynamic-splash/ios recursive
  • targets $(inherited) recursive

Usage

Android

  • MainActivity.java File
...
import com.taumu.rnDynamicSplash.DynamicSplash;
import com.taumu.rnDynamicSplash.utils.Config;

public class MainActivity extends ReactActivity {
    ...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Config splashConfig = new Config();  // Splash configuration class
        // splashConfig.setImageUrl("http://custom/splash.png");
        splashConfig.setAutoHide(true);
        // splashConfig.setAutoHideTime(2000);
        // splashConfig.setLayoutResID(R.layout.custom_splash_dynamic);
        // splashConfig.setThemeResId(R.style.Custom_Splash_Theme);
        // splashConfig.setAutoDownload(false);
        // splashConfig.setSplashSavePath("/customSplashPath/");
        // splashConfig.setDynamicShow(false);
        new DynamicSplash(this, splashConfig);  // Add display splash here
        super.onCreate(savedInstanceState);
    }
    ...
}

iOS

  • AppDelegate.m File
...
#import "RNDynamicSplash.h"
#import "SplashConfig.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  [self.window makeKeyAndVisible];

  SplashConfig *config = [[SplashConfig alloc] init];  // Splash configuration class
  // config.imageUrl = @"http://custom/splash.png";
  config.autoHide = true;
  // config.autoHideTime = 1000;
  // config.dynamicShow = false;
  // config.autoDownload = false;
  // config.splashSavePath = @"custom";
  [[RNDynamicSplash alloc] initWithShow:rootView splashConfig:config];  // Add display splash here

  return YES;
}

@end
...

Configuration

| type | Field | defaultValue | setter | description | | ---- | ----- | ------------ | ------ | ----------- | | String | imageUrl | "" | setImageUrl | Download picture address | | String | splashSavePath | /splash/ | setSplashSavePath | Save image address | | int | themeResId(Android only) | R.style.DynamicSplash_Theme | setThemeResId | Use theme resource id | | int | layoutResId(Android only) | R.layout.splash_dynamic | setLayoutResId | Use layout file resource id | | boolean | autoDownload | true | setAutoDownload | Whether to download automatically | | boolean | dynamicShow | true | setDynamicShow | Whether to display the downloaded picture | | boolean | autoHide | false | setAutoHide | Whether to automatically hide | | long | autoHideTime | 3000 | setAutoHideTime | Automatically hide time |

Other instructions

  • The first time to start displaying the default image, the second time to start displaying the downloaded image again
  • Android Can use their own written resource files and topics, and the same name as the default configuration, otherwise call the set method to change the configuration, reference package resource file
  • Android doesn't set imageUrl to show resource image in layout file
  • ios does not set imageUrl to show picture of LaunchImage

Provide get request method

Can call the request to get the address of the picture

// mock json data
// {
//     splashInfo: {
//         imageUrl: "http://***.png"
//     }
// }
...
import com.taumu.rnDynamicSplash.utils.HttpUtils;

public static void getSplashImageUrl(String getApi) {
    HttpUtils.get(getApi, new HttpUtils.Callback() {
        @Override
        public void onResponse(String jsonString) {
            try {
                JSONObject jsonObject = new JSONObject(jsonString);
                JSONObject valueObject = jsonObject.getJSONObject("splashInfo");
                String imageUrl = valueObject.getString("imageUrl");
                if (!TextUtils.isEmpty(imageUrl)) {
                    Config splashConfig = new Config();
                    splashConfig.setImageUrl(imageUrl);
                    new DynamicSplash(activity, splashConfig);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}
...

API

| name | type | description | conflict | | ---- | ---- | ----------- | -------- | | hide() | function | Js control hidden splash | autoHide not set true | | downloadSplash() | function | Js control download pictures | autoDownload is set to false |

TODO

  • [x] Android version splash
  • [x] Ios version splash
  • [ ] js incoming url as image download link
  • [ ] Configuration add skip button
  • [ ] Ios rewrite using swift

Changelog

  • 1.0.*
  • 1.1.*