Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5 - Bye AndroidX, dark mode + brand image support, useHideAnimation hook, etc. #475

Merged
merged 56 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a99254c
Initial v5 commit
zoontek Aug 6, 2023
36923bf
Unify function declarations
zoontek Aug 6, 2023
55b7254
Add obfuscator command
zoontek Aug 7, 2023
e1aab70
Improve addon loading system
zoontek Aug 7, 2023
81500f8
Update migration guide
zoontek Aug 7, 2023
21323f2
Update README.md
zoontek Aug 7, 2023
27d6850
Update README.md
zoontek Aug 8, 2023
784eca9
Update migration list
zoontek Aug 8, 2023
4d80c6c
Add missing line
zoontek Aug 8, 2023
e7850a5
Fix typo
zoontek Aug 8, 2023
a42eb69
Add methods descriptions
zoontek Aug 8, 2023
7294a50
Update useHideAnimation type documentation
zoontek Aug 8, 2023
e2727b7
Update README.md
zoontek Aug 8, 2023
72426ff
Remove duplicate lines
zoontek Aug 8, 2023
049f358
Update prepack script
zoontek Aug 8, 2023
4d60ca9
Fix node minimum version
zoontek Aug 8, 2023
1e95371
Bump version number
zoontek Aug 8, 2023
0a1b8cb
Add npmignore
zoontek Aug 8, 2023
633c67c
Don't include RNBootSplash.res
zoontek Aug 8, 2023
bba88b0
adds missing update to splash theme name (#476)
AaronWitter Aug 8, 2023
7a76f06
Fix image aspect ratio on Safari mobile
zoontek Aug 8, 2023
fb8232c
Add a node version check
zoontek Aug 9, 2023
a464332
Use files instead of multiple npmignore
zoontek Aug 10, 2023
fd9496b
5.0.0-beta.2
zoontek Aug 10, 2023
b9b3ea0
Improve JSON writing
zoontek Aug 11, 2023
1c4c7f2
Add detect-indent + xml-formatter
zoontek Aug 11, 2023
a00ab3f
Align brand to the maximum bottom (looks better on web)
zoontek Aug 12, 2023
87f92a5
Bump to 5.0.0-beta.3
zoontek Aug 12, 2023
268366d
Revert "Align brand to the maximum bottom (looks better on web)"
zoontek Aug 12, 2023
9a8432d
Ignore brand bottom value on web only
zoontek Aug 12, 2023
edb1e24
Don't read previous indent when writing json
zoontek Aug 12, 2023
e20e6c7
Minify xml to make regex matching more resilient
zoontek Aug 12, 2023
05eb955
Bump to 5.0.0-beta.4
zoontek Aug 12, 2023
916374b
Add webpack to the example app
zoontek Aug 12, 2023
ca20a51
Add web implementation
zoontek Aug 12, 2023
b2accba
Add html modification (raster image)
zoontek Aug 13, 2023
a499806
Add support for SVG web asset
zoontek Aug 13, 2023
0f2df09
Support dark mode on web
zoontek Aug 14, 2023
1ba116d
Set --platforms as first option
zoontek Aug 14, 2023
40f9d1a
Allow exiting the app on back press
zoontek Aug 14, 2023
d62258d
Fix navigation bar color in example
zoontek Aug 14, 2023
a4e4dc5
5.0.0-rc.0
zoontek Aug 14, 2023
341d0d8
Add react-native-web-image-loader for the web example
zoontek Aug 14, 2023
641d320
Update dependencies
zoontek Aug 21, 2023
99e012d
Add Android 5.0 support
zoontek Aug 21, 2023
b8a4c0a
Add xml version
zoontek Aug 21, 2023
23cce51
Use transparent system bars colors in a similar way as react-native-bars
zoontek Aug 21, 2023
0a9d6d8
5.0.0-rc.1
zoontek Aug 21, 2023
0d048d8
Allow different separators (even if help mention commas)
zoontek Aug 21, 2023
6591110
Remove transparent system bars by default
zoontek Aug 21, 2023
5244f12
Add Theme.BootSplash.EdgeToEdge
zoontek Aug 21, 2023
ad5fa9c
5.0.0-rc.2
zoontek Aug 21, 2023
ba8c2de
Add useHideAnimation mock
zoontek Aug 21, 2023
d0ba2ac
Add web in CLI generator screenshot
zoontek Aug 21, 2023
7616284
Add a FAQ
zoontek Aug 21, 2023
d0aab4c
5.0.0
zoontek Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
example/
dist/
react-native.config.js
.eslintrc.js
46 changes: 46 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const path = require("path");

module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react-hooks"],

extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],

parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},

env: {
es2022: true,
},

rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",

"@typescript-eslint/ban-ts-comment": [
"error",
{ "ts-check": true, "ts-expect-error": false },
],
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", ignoreRestSiblings: true },
],

"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
},
};
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,5 @@ example/vendor/bundle/
# Bob
dist/

# OCaml / Reason
**/.merlin
**/lib/bs
**/lib/ocaml
*.bs.js
.bsb.lock
# CLI paid addon
src/addon
164 changes: 40 additions & 124 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,151 +1,67 @@
# Migration from v3
# Migration from v4

## What's new

- The drop of Android < 6 and iOS < 11 (Android 5 is _possible_ but only displays the background color)
- A switch to [AndroidX splashscreen library](https://developer.android.com/jetpack/androidx/releases/core#core-splashscreen-1.0.0) to fully support Android 12
- The removal of the `show` method
- The `hide` method cannot reject anymore
- The switch to `RCTRootView` only on iOS (removed usage of `UIViewController`)
- An integration with [react-native-bars](https://github.com/zoontek/react-native-bars) for fully transparent system bars on Android
- Brand image support
- Dark mode support 🌚
- A new hook, `useHideAnimation`, allowing you to easily animate all splash screen elements using `Animated` or `react-native-reanimated`. Create something nicer than a simple fade πŸš€
- An improved CLI generator, now able to edit / output **57** files (light and dark logos + light and dark brand images, config files…for all pixel densities!). Note that the new options require a [license key πŸ”‘](https://zoontek.gumroad.com/l/bootsplash-generator)

## Code modifications
## What else?

For `android/build.gradle`:
- [AndroidX SplashScreen library](https://developer.android.com/jetpack/androidx/releases/core#core-splashscreen-1.0.0) has been replaced in order to solve a lot of known issues with it ([#381](https://github.com/zoontek/react-native-bootsplash/issues/381), [#418](https://github.com/zoontek/react-native-bootsplash/issues/418), [#440](https://github.com/zoontek/react-native-bootsplash/issues/440), [#456](https://github.com/zoontek/react-native-bootsplash/issues/456), etc). `react-native-bootsplash` now uses its own polyfill, compatible with Android 5+ (without any degraded mode).
- Android generated assets has been migrated from `mipmap-*` directories to `drawable-*` ones.
- To avoid conflicts, Android provided theme / properties has been renamed `Theme.BootSplash` / `Theme.BootSplash.EdgeToEdge`, `bootSplashBackground`, `bootSplashLogo`, `bootSplashBrand` and `postBootSplashTheme`.
- The `duration` argument has been removed from `fade()` options.
- `getVisibilityStatus()` has been replaced with `isVisible()` (which returns a `Promise<boolean>`). The `transitioning` does not exists anymore (when the splash screen is fading, it stays `visible` until complete disappearance).
- The CLI now output a `bootsplash_manifest.json` file to share image sizes + colors with the JS thread (used by `useHideAnimation`).
- `--assets-path` CLI option has been renamed `--assets-output`.
- React native < 0.70 support has been dropped, iOS < 12.4 support too.
- ReScript support has been removed as I don't know how to write bindings for it. Feels free to open a PR to add it back.

```diff
buildscript {
ext {
- buildToolsVersion = "30.0.2"
- minSdkVersion = 21
- compileSdkVersion = 30
- targetSdkVersion = 30
+ buildToolsVersion = "31.0.0"
+ minSdkVersion = 23
+ compileSdkVersion = 31
+ targetSdkVersion = 31
}
## How to update

// …
```
πŸ‘‰ First, run the CLI to generate assets in updated locations!<br>
It will also update your `BootSplash.storyboard`, the only change to perform on iOS.

### Android

For `android/app/build.gradle`:
1. Delete all `android/app/src/main/res/mipmap-*/bootsplash_logo.png` files.

2. Edit your `android/app/build.gradle` file:

```diff
// …

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
+ implementation("androidx.core:core-splashscreen:1.0.0")
- implementation("androidx.core:core-splashscreen:1.0.0")
```

For `android/app/src/main/res/values/styles.xml`:
3. Edit your `values/styles.xml` file:

```diff
<resources>

<!-- … -->

- <!-- BootTheme should inherit from AppTheme -->
- <style name="BootTheme" parent="AppTheme">
- <!-- set bootsplash.xml as background -->
- <item name="android:background">@drawable/bootsplash</item>
- </style>

+ <!-- BootTheme should inherit from Theme.SplashScreen -->
+ <style name="BootTheme" parent="Theme.SplashScreen">
+ <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
+ <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
+ <item name="postSplashScreenTheme">@style/AppTheme</item>
+ </style>

</resources>
- <!-- BootTheme should inherit from Theme.SplashScreen -->
+ <!-- BootTheme should inherit from Theme.BootSplash or Theme.BootSplash.EdgeToEdge -->
- <style name="BootTheme" parent="Theme.SplashScreen">
+ <style name="BootTheme" parent="Theme.BootSplash">
- <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
+ <item name="bootSplashBackground">@color/bootsplash_background</item>
- <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
+ <item name="bootSplashLogo">@drawable/bootsplash_logo</item>
- <item name="postSplashScreenTheme">@style/AppTheme</item>
+ <item name="postBootSplashTheme">@style/AppTheme</item>
</style>
```

For `android/app/src/main/AndroidManifest.xml`:
4. Edit your `MainActivity.java` file:

```diff
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rnbootsplashexample">

<uses-permission android:name="android.permission.INTERNET" />

<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">
+ android:theme="@style/BootTheme">

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
</activity>

- <activity
- android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
- android:theme="@style/BootTheme"
- android:launchMode="singleTask">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
</application>
</manifest>
```

For `android/app/src/main/java/com/yourprojectname/MainActivity.java`:

```diff
import android.os.Bundle;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {

// …

@Override
protected void onCreate(Bundle savedInstanceState) {
+ RNBootSplash.init(this);
super.onCreate(savedInstanceState); // or super.onCreate(null) with react-native-screens
- RNBootSplash.init(R.drawable.bootsplash, this);
- RNBootSplash.init(this);
+ RNBootSplash.init(this, R.style.BootTheme);
super.onCreate(savedInstanceState);
}

public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}

@Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
}
}
```

## Generated files

You **must** re-generate your assets.

- You can delete `android/app/src/main/res/drawable/bootsplash.xml` (now unused).
- All Android related assets now include padding.
Loading