react-native-bootsplash 4.7.4 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -107
- package/RNBootSplash.podspec +11 -11
- package/android/.npmignore +11 -0
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +3 -2
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +49 -0
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +157 -87
- package/android/src/main/res/anim/bootsplash_fade_in.xml +7 -0
- package/android/src/main/res/anim/bootsplash_fade_out.xml +7 -0
- package/android/src/main/res/drawable/compat_splash_screen.xml +19 -0
- package/android/src/main/res/values/attrs.xml +8 -0
- package/android/src/main/res/values/public.xml +7 -0
- package/android/src/main/res/values/styles.xml +29 -0
- package/android/src/main/res/values-v31/styles.xml +7 -0
- package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +11 -4
- package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +13 -4
- package/dist/commonjs/NativeRNBootSplash.js.map +1 -1
- package/dist/commonjs/addon/index.js +3 -0
- package/dist/commonjs/addon/index.js.map +1 -0
- package/dist/commonjs/generate.js +289 -194
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +115 -7
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/NativeRNBootSplash.js.map +1 -1
- package/dist/module/addon/index.js +3 -0
- package/dist/module/addon/index.js.map +1 -0
- package/dist/module/generate.js +287 -195
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +113 -6
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/NativeRNBootSplash.d.ts +6 -3
- package/dist/typescript/NativeRNBootSplash.d.ts.map +1 -1
- package/dist/typescript/addon/index.d.ts +3 -0
- package/dist/typescript/addon/index.d.ts.map +1 -0
- package/dist/typescript/generate.d.ts +47 -14
- package/dist/typescript/generate.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +33 -5
- package/dist/typescript/index.d.ts.map +1 -1
- package/example/android/app/debug.keystore +0 -0
- package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/.travis/compile +351 -0
- package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
- package/ios/.DS_Store +0 -0
- package/ios/.npmignore +8 -0
- package/ios/RNBootSplash.mm +101 -95
- package/package.json +22 -15
- package/react-native.config.js +74 -76
- package/src/.DS_Store +0 -0
- package/src/.npmignore +1 -0
- package/src/NativeRNBootSplash.ts +3 -4
- package/src/addon/index.ts +788 -0
- package/src/generate.ts +457 -232
- package/src/index.ts +205 -8
- package/RNBootSplash.res +0 -29
- package/bsconfig.json +0 -14
package/src/index.ts
CHANGED
|
@@ -1,18 +1,215 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ImageProps,
|
|
4
|
+
ImageRequireSource,
|
|
5
|
+
Platform,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
ViewProps,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
useColorScheme,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
import NativeModule from "./NativeRNBootSplash";
|
|
2
12
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
13
|
+
export type Config = {
|
|
14
|
+
fade?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type Manifest = {
|
|
18
|
+
background: string;
|
|
19
|
+
darkBackground?: string;
|
|
20
|
+
logo: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
brand?: {
|
|
25
|
+
bottom: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type UseHideAnimationConfig = {
|
|
32
|
+
manifest: Manifest;
|
|
33
|
+
|
|
34
|
+
logo: ImageRequireSource;
|
|
35
|
+
darkLogo?: ImageRequireSource;
|
|
36
|
+
brand?: ImageRequireSource;
|
|
37
|
+
darkBrand?: ImageRequireSource;
|
|
38
|
+
|
|
39
|
+
animate: () => void;
|
|
40
|
+
|
|
41
|
+
statusBarTranslucent?: boolean;
|
|
42
|
+
navigationBarTranslucent?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type UseHideAnimation = {
|
|
46
|
+
container: ViewProps;
|
|
47
|
+
logo: ImageProps;
|
|
48
|
+
brand?: ImageProps;
|
|
49
|
+
};
|
|
5
50
|
|
|
6
51
|
export function hide(config: Config = {}): Promise<void> {
|
|
7
|
-
const { fade = false
|
|
8
|
-
return NativeModule.hide(fade
|
|
52
|
+
const { fade = false } = config;
|
|
53
|
+
return NativeModule.hide(fade).then(() => {});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function isVisible(): Promise<boolean> {
|
|
57
|
+
return NativeModule.isVisible();
|
|
9
58
|
}
|
|
10
59
|
|
|
11
|
-
export function
|
|
12
|
-
|
|
60
|
+
export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
61
|
+
const {
|
|
62
|
+
manifest,
|
|
63
|
+
|
|
64
|
+
logo: logoSrc,
|
|
65
|
+
darkLogo: darkLogoSrc,
|
|
66
|
+
brand: brandSrc,
|
|
67
|
+
darkBrand: darkBrandSrc,
|
|
68
|
+
|
|
69
|
+
animate,
|
|
70
|
+
|
|
71
|
+
statusBarTranslucent = false,
|
|
72
|
+
navigationBarTranslucent = false,
|
|
73
|
+
} = config;
|
|
74
|
+
|
|
75
|
+
const hasBrand = manifest.brand != null && brandSrc != null;
|
|
76
|
+
const logoWidth = manifest.logo.width;
|
|
77
|
+
const logoHeight = manifest.logo.height;
|
|
78
|
+
const brandBottom = manifest.brand?.bottom;
|
|
79
|
+
const brandWidth = manifest.brand?.width;
|
|
80
|
+
const brandHeight = manifest.brand?.height;
|
|
81
|
+
|
|
82
|
+
const colorScheme = useColorScheme();
|
|
83
|
+
|
|
84
|
+
const backgroundColor: string =
|
|
85
|
+
colorScheme === "dark" && manifest.darkBackground != null
|
|
86
|
+
? manifest.darkBackground
|
|
87
|
+
: manifest.background;
|
|
88
|
+
|
|
89
|
+
const logoFinalSrc: ImageRequireSource =
|
|
90
|
+
colorScheme === "dark" && darkLogoSrc != null ? darkLogoSrc : logoSrc;
|
|
91
|
+
|
|
92
|
+
const brandFinalSrc: ImageRequireSource | undefined = hasBrand
|
|
93
|
+
? colorScheme === "dark" && darkBrandSrc != null
|
|
94
|
+
? darkBrandSrc
|
|
95
|
+
: brandSrc
|
|
96
|
+
: undefined;
|
|
97
|
+
|
|
98
|
+
const animateFn = useRef(animate);
|
|
99
|
+
const layoutReady = useRef(false);
|
|
100
|
+
const logoReady = useRef(false);
|
|
101
|
+
const brandReady = useRef(!hasBrand);
|
|
102
|
+
const animateHasBeenCalled = useRef(false);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
animateFn.current = animate;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const maybeRunAnimate = useCallback(() => {
|
|
109
|
+
if (
|
|
110
|
+
layoutReady.current &&
|
|
111
|
+
logoReady.current &&
|
|
112
|
+
brandReady.current &&
|
|
113
|
+
!animateHasBeenCalled.current
|
|
114
|
+
) {
|
|
115
|
+
animateHasBeenCalled.current = true;
|
|
116
|
+
|
|
117
|
+
hide({ fade: false })
|
|
118
|
+
.then(() => animateFn.current())
|
|
119
|
+
.catch(() => {});
|
|
120
|
+
}
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return useMemo<UseHideAnimation>(() => {
|
|
124
|
+
const containerStyle: ViewStyle = {
|
|
125
|
+
...StyleSheet.absoluteFillObject,
|
|
126
|
+
backgroundColor,
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
justifyContent: "center",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const container: ViewProps = {
|
|
132
|
+
style: containerStyle,
|
|
133
|
+
onLayout: () => {
|
|
134
|
+
layoutReady.current = true;
|
|
135
|
+
maybeRunAnimate();
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const logo: ImageProps = {
|
|
140
|
+
fadeDuration: 0,
|
|
141
|
+
resizeMode: "contain",
|
|
142
|
+
source: logoFinalSrc,
|
|
143
|
+
style: {
|
|
144
|
+
width: logoWidth,
|
|
145
|
+
height: logoHeight,
|
|
146
|
+
},
|
|
147
|
+
onLoadEnd: () => {
|
|
148
|
+
logoReady.current = true;
|
|
149
|
+
maybeRunAnimate();
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const brand: ImageProps | undefined =
|
|
154
|
+
brandFinalSrc != null
|
|
155
|
+
? {
|
|
156
|
+
fadeDuration: 0,
|
|
157
|
+
resizeMode: "contain",
|
|
158
|
+
source: brandFinalSrc,
|
|
159
|
+
style: {
|
|
160
|
+
position: "absolute",
|
|
161
|
+
bottom: brandBottom,
|
|
162
|
+
width: brandWidth,
|
|
163
|
+
height: brandHeight,
|
|
164
|
+
},
|
|
165
|
+
onLoadEnd: () => {
|
|
166
|
+
brandReady.current = true;
|
|
167
|
+
maybeRunAnimate();
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
: undefined;
|
|
171
|
+
|
|
172
|
+
if (Platform.OS !== "android") {
|
|
173
|
+
return { container, logo, brand };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const { statusBarHeight, navigationBarHeight } =
|
|
177
|
+
NativeModule.getConstants();
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
container: {
|
|
181
|
+
...container,
|
|
182
|
+
style: {
|
|
183
|
+
...containerStyle,
|
|
184
|
+
marginTop: statusBarTranslucent ? undefined : -statusBarHeight,
|
|
185
|
+
marginBottom: navigationBarTranslucent
|
|
186
|
+
? undefined
|
|
187
|
+
: -navigationBarHeight,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
logo,
|
|
191
|
+
brand,
|
|
192
|
+
};
|
|
193
|
+
}, [
|
|
194
|
+
maybeRunAnimate,
|
|
195
|
+
|
|
196
|
+
logoWidth,
|
|
197
|
+
logoHeight,
|
|
198
|
+
brandBottom,
|
|
199
|
+
brandWidth,
|
|
200
|
+
brandHeight,
|
|
201
|
+
|
|
202
|
+
backgroundColor,
|
|
203
|
+
logoFinalSrc,
|
|
204
|
+
brandFinalSrc,
|
|
205
|
+
|
|
206
|
+
statusBarTranslucent,
|
|
207
|
+
navigationBarTranslucent,
|
|
208
|
+
]);
|
|
13
209
|
}
|
|
14
210
|
|
|
15
211
|
export default {
|
|
16
212
|
hide,
|
|
17
|
-
|
|
213
|
+
isVisible,
|
|
214
|
+
useHideAnimation,
|
|
18
215
|
};
|
package/RNBootSplash.res
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
type config = {fade: bool}
|
|
2
|
-
|
|
3
|
-
@module("react-native-bootsplash") @scope("default")
|
|
4
|
-
external hide: config => Js.Promise.t<unit> = "hide"
|
|
5
|
-
|
|
6
|
-
// Note that this binding requires BuckleScript >= 8.2.0
|
|
7
|
-
type visibilityStatus = [#visible | #hidden | #transitioning]
|
|
8
|
-
|
|
9
|
-
@module("react-native-bootsplash") @scope("default")
|
|
10
|
-
external getVisibilityStatus: unit => Js.Promise.t<visibilityStatus> = "getVisibilityStatus"
|
|
11
|
-
/*
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```rescript
|
|
15
|
-
RNBootSplash.hide({fade: true})->ignore
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Or
|
|
19
|
-
|
|
20
|
-
```rescript
|
|
21
|
-
RNBootSplash.hide({fade: true})->Js.Promise.then_(() => {
|
|
22
|
-
Js.log("RN BootSplash: fading is over")
|
|
23
|
-
Js.Promise.resolve()
|
|
24
|
-
}, _)->Js.Promise.catch(error => {
|
|
25
|
-
Js.log(("RN BootSplash: cannot hide splash", error))
|
|
26
|
-
Js.Promise.resolve()
|
|
27
|
-
}, _)->ignore
|
|
28
|
-
```
|
|
29
|
-
*/
|