expo-splash-screen2 1.1.0 → 1.3.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 CHANGED
@@ -1,53 +1,37 @@
1
1
  # expo-splash-screen2
2
2
 
3
- `expo-splash-screen2` allows you to customize your app's splash screen with multiple display modes including WebView HTML, responsive background image, and fixed-width centered image. It supports dark mode and provides a seamless transition experience.
3
+ `expo-splash-screen2` allows you to customize your app's splash screen with multiple display modes including WebView HTML, .9 image, background+WebView blend mode, and icon+background color mode. It supports dark mode and provides a seamless transition experience.
4
4
 
5
- > **English** | [中文文档](./README.zh.md)
5
+ > **English** | [中文文档](./README.zh.md)
6
6
 
7
- - [⚡ Quick Start](#-quick-start)
8
- - [🚀 Features](#-features)
9
- - [📚 API](#-api)
10
- - [🗒 Examples](#-examples)
11
- - [💻 Installation](#-installation)
12
- - [Installation in managed Expo projects](#-installation-in-managed-expo-projects)
13
- - [Installation in bare React Native projects](#-installation-in-bare-react-native-projects)
14
- - [⚙️ Configuration](#️-configuration)
15
- - [WebView Mode](#webview-mode)
16
- - [ResponsiveImage Mode](#responsiveimage-mode)
17
- - [Normal Mode](#normal-mode)
18
- - [Blend Mode](#blend-mode)
19
- - [Dark Mode Support](#dark-mode-support)
20
- - [📱 Platform-Specific Details](#-platform-specific-details)
21
- - [iOS Configuration](#-ios-configuration)
22
- - [Android Configuration](#-android-configuration)
23
- - [👏 Contributing](#-contributing)
24
- - [❓ Known Issues](#-known-issues)
25
- - [📄 License](#-license)
26
- - [🏅 Hall of Fame](#-hall-of-fame)
7
+ ### Key features
27
8
 
28
- ## Quick Start
9
+ - 🎨 **Multiple Display Modes**: WebView HTML, .9 image, background+WebView blend mode, and icon+background color mode
10
+ - 🚀 **Custom Complex Splash**: Use WebView or Blend mode to create complex splash screens (privacy dialogs, animations, etc.)
11
+ - 📦 **Ready-to-Use Templates**: Complete WebView HTML template files with dev and build support
12
+ - 🎯 **Easy Integration**: Simple configuration with automatic native code generation
29
13
 
30
- Get started with `expo-splash-screen2` in minutes using WebView mode.
14
+ ### Installation
31
15
 
32
- ### Step 1: Install the Package
16
+ #### Quick Start
17
+
18
+ 1. **Install the package:**
33
19
 
34
20
  ```bash
35
21
  # Remove expo-splash-screen if installed (they are mutually exclusive)
36
22
  npm uninstall expo-splash-screen
37
23
 
38
24
  # Install expo-splash-screen2
25
+ yarn add expo-splash-screen2
26
+ # or
39
27
  npm install expo-splash-screen2
40
28
  # or
41
29
  pnpm add expo-splash-screen2
42
- # or
43
- yarn add expo-splash-screen2
44
30
  ```
45
31
 
46
- > **Note**: If you're using `pnpm` and see a warning about ignored build scripts, run `pnpm approve-builds` to allow the package to execute its postinstall script.
47
-
48
- ### Step 2: Configure app.json
32
+ > **Note**: If using `pnpm` and you see a warning about ignored build scripts, run `pnpm approve-builds`.
49
33
 
50
- Add the plugin to your `app.json` or `app.config.js` with WebView mode:
34
+ 2. **Configure `app.json`:**
51
35
 
52
36
  ```json
53
37
  {
@@ -65,966 +49,55 @@ Add the plugin to your `app.json` or `app.config.js` with WebView mode:
65
49
  }
66
50
  ```
67
51
 
68
- ### Step 3: Run Prebuild
69
-
70
- After installation, run prebuild to apply native modifications:
71
-
72
- ```bash
73
- npx expo prebuild
74
- ```
75
-
76
- ### Step 4: Use in Your App
77
-
78
- In your main component (e.g., `App.tsx`), prevent the splash screen from auto-hiding and control when to hide it:
79
-
80
- ```tsx
81
- import React, { useEffect, useState } from 'react';
82
- import { View, Text } from 'react-native';
83
- import * as SplashScreen from 'expo-splash-screen2';
84
-
85
- // Prevent native splash screen from autohiding before App component declaration
86
- SplashScreen.preventAutoHideAsync();
87
-
88
- export default function App() {
89
- const [appIsReady, setAppIsReady] = useState(false);
90
-
91
- useEffect(() => {
92
- async function prepare() {
93
- try {
94
- // Pre-load fonts, make API calls, etc.
95
- await loadFonts();
96
- await loadInitialData();
97
- } catch (e) {
98
- console.warn(e);
99
- } finally {
100
- setAppIsReady(true);
101
- await SplashScreen.hideAsync();
102
- }
103
- }
104
-
105
- prepare();
106
- }, []);
107
-
108
- if (!appIsReady) {
109
- return null;
110
- }
111
-
112
- return (
113
- <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
114
- <Text>Your App Content</Text>
115
- </View>
116
- );
117
- }
118
- ```
119
-
120
- ### Step 5: Customize Your Splash Screen HTML
121
-
122
- The plugin automatically copies the `expo-splash-web` folder to your project root. You can customize the HTML splash screen by editing files in `expo-splash-web/src/`:
52
+ 3. **Run prebuild:**
123
53
 
124
54
  ```bash
125
- # Build the splash web assets
126
- npm run build:expo-splash-web
127
-
128
- # Or run in development mode with hot reload
129
- npm run dev:expo-splash-web
130
- ```
131
-
132
- After making changes, rebuild and run prebuild again:
133
-
134
- ```bash
135
- npm run build:expo-splash-web
136
55
  npx expo prebuild
137
56
  ```
138
57
 
139
- ### That's It! 🎉
140
-
141
- Your app now has a custom WebView-based splash screen. For more advanced configurations and other display modes, see the [Configuration](#️-configuration) section below.
142
-
143
- ## 🚀 Features
144
-
145
- ### Display Modes
146
-
147
- `expo-splash-screen2` provides four splash screen modes to fit different use cases:
148
-
149
- #### `webview` Mode
150
-
151
- Display HTML content in a WebView, allowing for complex animations and interactive splash screens.
152
-
153
- - Full JavaScript/CSS support
154
- - React component support (with esbuild bundler)
155
- - Perfect for animated splash screens
156
- - JavaScript bridge for native communication
157
-
158
- #### `responsiveImage` Mode
159
-
160
- Display a full-screen background image that scales to cover the entire screen.
161
-
162
- - Supports `.9.png` (Nine-patch) format on Android
163
- - `scaleAspectFill` content mode
164
- - Best for photographic or detailed backgrounds
165
-
166
- #### `normal` Mode
167
-
168
- Display a centered image with fixed width (default 100px), maintaining aspect ratio.
169
-
170
- - Fixed width, auto height
171
- - Centered on screen with background color
172
- - **Supports dark mode** with separate image and background color
173
- - Best for logo-centric splash screens
174
-
175
- #### `blend` Mode
176
-
177
- Combine a `.9.png` background image with WebView HTML content for enhanced splash screen experience.
178
-
179
- - Uses `.9.png` image as system splash screen background
180
- - WebView container uses transparent background (recommended) for seamless transition
181
- - Full HTML/JavaScript/CSS support in WebView overlay
182
- - Perfect for achieving smooth transition from system splash to custom animated splash
183
- - Best for apps requiring both native performance and rich animations
184
-
185
- ### Dark Mode Support (Normal Mode)
186
-
187
- `expo-splash-screen2` supports per-appearance splash screens that respond to system appearance changes on iOS 13+ and Android 10+.
188
-
189
- <table>
190
- <thead><tr><td>Light Mode</td><td>Dark Mode</td></tr></thead>
191
- <tbody><tr>
192
- <td>Background: Custom color<br>Image: Light mode image</td>
193
- <td>Background: Custom dark color<br>Image: Dark mode image</td>
194
- </tr></tbody>
195
- </table>
196
-
197
- ### Cross-Platform Support
198
-
199
- - **Android**: Full support for Android 12+ system splash screen, custom activities, and seamless transitions
200
- - **iOS**: Native UIView integration, storyboard support, and smooth animations
201
-
202
- ### StatusBar Customization
203
-
204
- `expo-splash-screen2` allows customization of the StatusBar according to the [React Native StatusBar API](https://reactnative.dev/docs/statusbar). You can control StatusBar visibility, style, and background color during the splash screen display.
205
-
206
- ## 📚 API
207
-
208
- ```tsx
209
- import * as SplashScreen from 'expo-splash-screen2';
210
- ```
211
-
212
- The native splash screen that is controlled via this module autohides once the React Native-controlled view hierarchy is mounted. This means that when your app first `render`s view component, the native splash screen will hide. This default behavior can be prevented by calling [`SplashScreen.preventAutoHideAsync()`](#splashscreenpreventautohideasync) and later on [`SplashScreen.hideAsync()`](#splashscreenhideasync).
213
-
214
- ### `SplashScreen.preventAutoHideAsync()`
215
-
216
- This method makes the native splash screen stay visible until [`SplashScreen.hideAsync()`](#splashscreenhideasync) is called. This must be called before any React Native-controlled view hierarchy is rendered (either in the global scope of your main component, or when the component renders `null` at the beginning - see [Examples section](#-examples)).
217
-
218
- Preventing default autohiding might come in handy if your application needs to prepare/download some resources and/or make some API calls before first rendering some actual view hierarchy.
219
-
220
- > **Important**: It is recommended to call this in global scope without awaiting, rather than inside React components or hooks.
221
-
222
- #### Returns
223
-
224
- A `Promise` that resolves to `true` when preventing autohiding succeeded and to `false` if the native splash screen is already prevented from autohiding (for instance, if you've already called this method). `Promise` rejection most likely means that native splash screen cannot be prevented from autohiding (it's already hidden when this method was executed).
225
-
226
- ### `SplashScreen.hideAsync()`
227
-
228
- Hides the native splash screen. Only works if the native splash screen has been previously prevented from autohiding by calling [`SplashScreen.preventAutoHideAsync()`](#splashscreenpreventautohideasync) method.
229
-
230
- #### Returns
231
-
232
- A `Promise` that resolves to `true` once the splash screen becomes hidden and to `false` if the splash screen is already hidden.
233
-
234
- ## 🗒 Examples
235
-
236
- ### `SplashScreen.preventAutoHideAsync()` in global scope
237
-
238
- `App.tsx`
239
-
240
- ```tsx
241
- import React from 'react';
242
- import { StyleSheet, Text, View } from 'react-native';
243
- import * as SplashScreen from 'expo-splash-screen2';
244
-
245
- // Prevent native splash screen from autohiding before App component declaration
246
- SplashScreen.preventAutoHideAsync()
247
- .then((result) => console.log(`SplashScreen.preventAutoHideAsync() succeeded: ${result}`))
248
- .catch(console.warn); // it's good to explicitly catch and inspect any error
249
-
250
- export default class App extends React.Component {
251
- componentDidMount() {
252
- // Hides native splash screen after 2s
253
- setTimeout(async () => {
254
- await SplashScreen.hideAsync();
255
- }, 2000);
256
- }
257
-
258
- render() {
259
- return (
260
- <View style={styles.container}>
261
- <Text style={styles.text}>SplashScreen Demo! 👋</Text>
262
- </View>
263
- );
264
- }
265
- }
266
-
267
- const styles = StyleSheet.create({
268
- container: {
269
- flex: 1,
270
- alignItems: 'center',
271
- justifyContent: 'center',
272
- backgroundColor: '#aabbcc',
273
- },
274
- text: {
275
- color: 'white',
276
- fontWeight: 'bold',
277
- },
278
- });
279
- ```
280
-
281
- ### Basic Usage
58
+ 4. **Use in your app:**
282
59
 
283
60
  ```tsx
284
61
  import * as SplashScreen from 'expo-splash-screen2';
285
62
 
286
- // Prevent native splash screen from autohiding before App component declaration
63
+ // Prevent native splash screen from autohiding
287
64
  SplashScreen.preventAutoHideAsync();
288
65
 
289
66
  export default function App() {
290
- const [appIsReady, setAppIsReady] = useState(false);
291
-
292
67
  useEffect(() => {
293
- async function prepare() {
294
- try {
295
- // Pre-load fonts, make API calls, etc.
296
- await loadFonts();
297
- await loadInitialData();
298
- } catch (e) {
299
- console.warn(e);
300
- } finally {
301
- setAppIsReady(true);
302
- await SplashScreen.hideAsync();
303
- }
304
- }
305
-
306
- prepare();
307
- }, []);
308
-
309
- if (!appIsReady) {
310
- return null;
311
- }
312
-
313
- return (
314
- <View style={styles.container}>
315
- <Text>Your App Content</Text>
316
- </View>
317
- );
318
- }
319
- ```
320
-
321
- ### With Expo Router
322
-
323
- ```tsx
324
- // app/_layout.tsx
325
- import * as SplashScreen from 'expo-splash-screen2';
326
- import { useEffect } from 'react';
327
-
328
- SplashScreen.preventAutoHideAsync();
329
-
330
- export default function RootLayout() {
331
- useEffect(() => {
332
- // Hide splash screen after initial render
68
+ // Hide splash screen when ready
333
69
  SplashScreen.hideAsync();
334
70
  }, []);
335
71
 
336
- return (
337
- <Stack>
338
- <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
339
- </Stack>
340
- );
341
- }
342
- ```
343
-
344
- ### Demo
345
-
346
- See the splash screen modes in action:
347
-
348
- #### `webview` Mode
349
-
350
- Display HTML content in a WebView with full JavaScript/CSS support.
351
-
352
- <table>
353
- <thead><tr><td>Android</td><td>iOS</td></tr></thead>
354
- <tbody><tr>
355
- <td>
356
-
357
- ![WebView Android](./assets/demo/webview-a.gif)
358
-
359
- </td>
360
- <td>
361
-
362
- ![WebView iOS](./assets/demo/webview-i.gif)
363
-
364
- </td>
365
- </tr>
366
- </tbody>
367
- </table>
368
-
369
- #### `responsiveImage` Mode
370
-
371
- Display a full-screen background image that scales to cover the entire screen.
372
-
373
- <table>
374
- <thead><tr><td>Android</td><td>iOS</td></tr></thead>
375
- <tbody><tr>
376
- <td>
377
-
378
- ![ResponsiveImage Android](./assets/demo/reponsiveimg-a.gif)
379
-
380
- </td>
381
- <td>
382
-
383
- ![ResponsiveImage iOS](./assets/demo/reponsive-i.gif)
384
-
385
- </td>
386
- </tr>
387
- </tbody>
388
- </table>
389
-
390
- #### `normal` Mode
391
-
392
- Display a centered image with fixed width, maintaining aspect ratio. Supports dark mode.
393
-
394
- <table>
395
- <thead><tr><td>Android</td><td>iOS</td></tr></thead>
396
- <tbody><tr>
397
- <td>
398
-
399
- ![Normal Android](./assets/demo/normal-a.gif)
400
-
401
- </td>
402
- <td>
403
-
404
- ![Normal iOS](./assets/demo/normal-i.gif)
405
-
406
- </td>
407
- </tr>
408
- </tbody>
409
- </table>
410
-
411
- #### `blend` Mode
412
-
413
- Combine a `.9.png` background image with WebView HTML content for enhanced splash screen experience. The system splash screen uses the `.9.png` image as background, and the WebView container uses transparent background (recommended) for seamless transition.
414
-
415
- **Note**: Blend mode combines the visual appearance of `responsiveImage` mode (`.9.png` background) with the functionality of `webview` mode (HTML content overlay). This creates a smooth transition from the system splash screen to the custom animated splash screen.
416
-
417
- ## 💻 Installation
418
-
419
- ### Installation in managed Expo projects
420
-
421
- For managed Expo projects, follow the standard installation process:
422
-
423
- ```bash
424
- # Remove expo-splash-screen if installed (they are mutually exclusive)
425
- npm uninstall expo-splash-screen
426
-
427
- # Install expo-splash-screen2
428
- npm install expo-splash-screen2
429
- # or
430
- pnpm add expo-splash-screen2
431
- # or
432
- yarn add expo-splash-screen2
433
- ```
434
-
435
- > **Note**: `expo-splash-screen` and `expo-splash-screen2` are mutually exclusive. You can only use one of them in your project.
436
-
437
- ### Installation in bare React Native projects
438
-
439
- For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
440
-
441
- #### Add the package to your dependencies
442
-
443
- ```bash
444
- npm install expo-splash-screen2
445
- # or
446
- pnpm add expo-splash-screen2
447
- # or
448
- yarn add expo-splash-screen2
449
- ```
450
-
451
- #### iOS Setup
452
-
453
- Run `npx pod-install` after installing the package:
454
-
455
- ```bash
456
- npx pod-install
457
- ```
458
-
459
- #### Android Setup
460
-
461
- No additional setup required. The plugin will automatically configure Android during prebuild.
462
-
463
- ### pnpm Build Script Approval
464
-
465
- If you're using `pnpm` and encounter a warning about ignored build scripts:
466
-
467
- ```
468
- ╭ Warning ────────────────────────────────────────────────────────────────────────╮
469
- │ │
470
- │ Ignored build scripts: expo-splash-screen2, unrs-resolver. │
471
- │ Run "pnpm approve-builds" to pick which dependencies should be allowed to │
472
- │ run scripts. │
473
- ```
474
-
475
- Follow the prompt and run `pnpm approve-builds` to allow `expo-splash-screen2` to execute its postinstall script:
476
-
477
- ```bash
478
- pnpm approve-builds
479
- ```
480
-
481
- This will allow the package to run its postinstall script, which is necessary for proper setup.
482
-
483
- ### Post-installation Setup
484
-
485
- After installation, the plugin will automatically:
486
- 1. Copy `expo-splash-web` folder to your project root
487
- 2. Add build commands to your `package.json`
488
- 3. Update your `app.json` with plugin configuration
489
- 4. Remove `expo-splash-screen` dependency from `package.json`
490
-
491
- **If you're using pnpm and the postinstall script doesn't run automatically**, you can manually run the setup script:
492
-
493
- ```bash
494
- # From your project root directory
495
- node node_modules/expo-splash-screen2/scripts/setup.js
496
- ```
497
-
498
- After installation (or manual setup), run prebuild to apply native modifications:
499
-
500
- ```bash
501
- npx expo prebuild
502
- ```
503
-
504
- ## ⚙️ Configuration
505
-
506
- Add the plugin to your `app.json` or `app.config.js`:
507
-
508
- ### WebView Mode
509
-
510
- Display HTML content with full JavaScript/CSS support:
511
-
512
- ```json
513
- {
514
- "expo": {
515
- "plugins": [
516
- [
517
- "expo-splash-screen2",
518
- {
519
- "mode": "webview",
520
- "backgroundColor": "#FFFFFF"
521
- }
522
- ]
523
- ]
524
- }
525
- }
526
- ```
527
-
528
- > **Note**: For `webview` and `blend` modes, you must install `react-native-web` to build web files:
529
- > ```bash
530
- > npm install react-native-web
531
- > # or
532
- > pnpm add react-native-web
533
- > # or
534
- > yarn add react-native-web
535
- > ```
536
-
537
- #### WebView Mode Options
538
-
539
- | Option | Type | Required | Description |
540
- |--------|------|----------|-------------|
541
- | `mode` | `"webview"` | Yes | Enable WebView HTML mode |
542
- | `backgroundColor` | `string` | No | Background color (default: `#ffffff`) |
543
- | `localHtmlPath` | `string` | No | Path to custom HTML file |
544
-
545
- ### ResponsiveImage Mode
546
-
547
- Display a full-screen background image:
548
-
549
- ```json
550
- {
551
- "expo": {
552
- "plugins": [
553
- [
554
- "expo-splash-screen2",
555
- {
556
- "mode": "responsiveImage",
557
- "backgroundColor": "#FFFFFF",
558
- "image": "./assets/splash-background.png"
559
- }
560
- ]
561
- ]
562
- }
563
- }
564
- ```
565
-
566
- #### ResponsiveImage Mode Options
567
-
568
- | Option | Type | Required | Description |
569
- |--------|------|----------|-------------|
570
- | `mode` | `"responsiveImage"` | Yes | Enable responsive image mode |
571
- | `backgroundColor` | `string` | No | Background color (default: `#ffffff`) |
572
- | `image` | `string` | Yes | Path to background image (supports `.9.png`) |
573
-
574
- ### Normal Mode
575
-
576
- Display a centered image with fixed width:
577
-
578
- ```json
579
- {
580
- "expo": {
581
- "plugins": [
582
- [
583
- "expo-splash-screen2",
584
- {
585
- "mode": "normal",
586
- "backgroundColor": "#10021F",
587
- "image": "./assets/splash-icon.png",
588
- "imageWidth": 100
589
- }
590
- ]
591
- ]
592
- }
593
- }
594
- ```
595
-
596
- #### Normal Mode Options
597
-
598
- | Option | Type | Required | Description |
599
- |--------|------|----------|-------------|
600
- | `mode` | `"normal"` | Yes | Enable normal (centered image) mode |
601
- | `backgroundColor` | `string` | No | Background color (default: `#ffffff`) |
602
- | `image` | `string` | Yes | Path to splash icon image |
603
- | `imageWidth` | `number` | No | Image width in dp/pt (default: `100`) |
604
- | `dark` | `object` | No | Dark mode configuration |
605
-
606
- ### Blend Mode
607
-
608
- Combine a `.9.png` background image with WebView HTML content for enhanced splash screen experience:
609
-
610
- ```json
611
- {
612
- "expo": {
613
- "plugins": [
614
- [
615
- "expo-splash-screen2",
616
- {
617
- "mode": "blend",
618
- "image": "./assets/splash-background.9.png"
619
- }
620
- ]
621
- ]
622
- }
72
+ return <YourAppContent />;
623
73
  }
624
74
  ```
625
75
 
626
- > **Note**: For `webview` and `blend` modes, you must install `react-native-web` to build web files:
627
- > ```bash
628
- > npm install react-native-web
629
- > # or
630
- > pnpm add react-native-web
631
- > # or
632
- > yarn add react-native-web
633
- > ```
76
+ For detailed setup instructions and other modes, check out the [installation guide](./docs/installation.md).
634
77
 
635
- #### Blend Mode Options
78
+ ### Documentation
636
79
 
637
- | Option | Type | Required | Description |
638
- |--------|------|----------|-------------|
639
- | `mode` | `"blend"` | Yes | Enable blend mode (`.9.png` background + WebView) |
640
- | `image` | `string` | Yes | Path to background image (supports `.9.png`) |
641
- | `localHtmlPath` | `string` | No | Path to custom HTML file |
80
+ Full API reference and guides available at:
642
81
 
643
- **How Blend Mode Works:**
82
+ - [Installation Guide](./docs/installation.md)
83
+ - [Configuration](./docs/configuration.md)
84
+ - [API Reference](./docs/api.md)
85
+ - [Examples](./docs/examples.md)
86
+ - [Platform-Specific Details](./docs/platform-specific.md)
87
+ - [Known Issues](./docs/known-issues.md)
644
88
 
645
- - **System Splash Screen**: Uses `.9.png` image as background (Android 12+ system splash screen)
646
- - **WebView Container**: Uses transparent background (recommended) to show the system splash screen background for seamless visual continuity
647
- - **HTML Overlay**: Displays custom HTML content in WebView on top of the background
648
- - **Transition**: Smooth transition from system splash to WebView splash without visual gaps
89
+ ### Contributing
649
90
 
650
- This mode is ideal when you want:
651
- - Native performance of system splash screen
652
- - Rich animations and interactivity from HTML/WebView
653
- - Seamless visual transition between system and custom splash screens
91
+ See the [contributing guide](./CONTRIBUTING.md) to learn how to contribute to the repo and development workflow.
654
92
 
655
- ### Dark Mode Support
93
+ ### License
656
94
 
657
- Enable dark mode support in `normal` mode by adding the `dark` configuration:
658
-
659
- ```json
660
- {
661
- "expo": {
662
- "plugins": [
663
- [
664
- "expo-splash-screen2",
665
- {
666
- "mode": "normal",
667
- "backgroundColor": "#FFFFFF",
668
- "image": "./assets/splash-icon.png",
669
- "imageWidth": 100,
670
- "dark": {
671
- "backgroundColor": "#000000",
672
- "image": "./assets/splash-icon-dark.png"
673
- }
674
- }
675
- ]
676
- ]
677
- }
678
- }
679
- ```
680
-
681
- #### Dark Mode Options
682
-
683
- | Option | Type | Required | Description |
684
- |--------|------|----------|-------------|
685
- | `dark.backgroundColor` | `string` | No | Dark mode background color |
686
- | `dark.image` | `string` | No | Dark mode image (can be same as light mode) |
687
-
688
- When dark mode is enabled:
689
- - **Android**: Images are placed in `drawable/` and `drawable-night/` directories
690
- - **iOS**: App detects system appearance and switches colors/images accordingly
691
- - **Runtime switching**: Both platforms support runtime theme changes
692
-
693
- ## 📱 Platform-Specific Details
694
-
695
- ### 📱 iOS Configuration
696
-
697
- The plugin automatically:
698
-
699
- 1. Copies splash images to the iOS bundle
700
- 2. Modifies `AppDelegate.swift` to display the splash screen
701
- 3. Sets up dark mode detection using `UITraitCollection`
702
- 4. Adds `UIApplication.didBecomeActiveNotification` observer for runtime theme changes
703
-
704
- #### Resource Locations
705
-
706
- - Light mode image: `ios/{projectName}/splash-icon.{ext}`
707
- - Dark mode image: `ios/{projectName}/splash-icon-dark.{ext}`
708
-
709
- ### Manual iOS Configuration
710
-
711
- The plugin automatically handles iOS configuration, but if you need to manually configure or understand how it works, here are the details for each mode:
712
-
713
- #### WebView Mode
714
-
715
- For WebView mode, the plugin:
716
-
717
- 1. **Modifies `SplashScreen.storyboard`**: Sets background color and optional centered image
718
- 2. **Copies HTML files**: Places HTML files from `expo-splash-web/dist` or `localHtmlPath` to `ios/{projectName}/` directory
719
- 3. **Modifies `AppDelegate.swift`**: Adds code to display WebView overlay with HTML content
720
- 4. **Creates Asset Catalog**: Creates `SplashScreenBackground` colorset for background color
721
-
722
- **Manual steps** (if needed):
723
-
724
- 1. Copy HTML file to `ios/{projectName}/index.html`
725
- 2. Modify `SplashScreen.storyboard` to set background color using `SplashScreenBackground` colorset
726
- 3. Modify `AppDelegate.swift` to add WebView container code (see plugin source for template)
727
- 4. Ensure `SplashScreen.storyboard` is set as Launch Screen File in Xcode project settings
728
-
729
- #### ResponsiveImage Mode
730
-
731
- For ResponsiveImage mode, the plugin:
732
-
733
- 1. **Copies background image**: Places image file as `splash_background_image.{ext}` in `ios/{projectName}/` directory
734
- 2. **Modifies `SplashScreen.storyboard`**: Sets full-screen background image with `scaleAspectFill` content mode
735
- 3. **Modifies `AppDelegate.swift`**: Adds image container view
736
- 4. **Adds file reference**: Adds image file to Xcode project
737
-
738
- **Manual steps** (if needed):
739
-
740
- 1. Copy background image to `ios/{projectName}/splash_background_image.{ext}`
741
- 2. Modify `SplashScreen.storyboard`:
742
- - Set Image View to use `splash_background_image` image
743
- - Set Content Mode to `Aspect Fill` for full-screen coverage
744
- - Set background color (fallback)
745
- 3. Modify `AppDelegate.swift` to add image container view
746
- 4. Add image file to Xcode project file references
747
-
748
- #### Normal Mode
749
-
750
- For Normal mode, the plugin:
751
-
752
- 1. **Creates Asset Catalog imageset**: Creates `splash-icon` imageset in `Images.xcassets` (supports dark mode if configured)
753
- 2. **Creates Asset Catalog colorset**: Creates `SplashScreenBackground` colorset (supports dark mode if configured)
754
- 3. **Modifies `SplashScreen.storyboard`**: Sets background color and centered image with fixed width
755
- 4. **Modifies `AppDelegate.swift`**: Adds image container view with fixed width constraints
756
-
757
- **Manual steps** (if needed):
758
-
759
- 1. Create `splash-icon` imageset in `Images.xcassets`:
760
- - Add light mode image
761
- - If dark mode enabled, add dark mode image in `Any, Dark` appearance
762
- 2. Create `SplashScreenBackground` colorset in `Images.xcassets`:
763
- - Set light mode color
764
- - If dark mode enabled, set dark mode color in `Any, Dark` appearance
765
- 3. Modify `SplashScreen.storyboard`:
766
- - Set Image View to use `splash-icon` image
767
- - Set Content Mode to `Aspect Fit`
768
- - Set background to use `SplashScreenBackground` colorset
769
- - Add width constraint (default 100pt) to Image View
770
- 4. Modify `AppDelegate.swift` to add image container view with width constraints
771
-
772
- #### Blend Mode
773
-
774
- For Blend mode, the plugin:
775
-
776
- 1. **Copies background image**: Places `.9.png` image file as `splash_background_image.{ext}` in `ios/{projectName}/` directory
777
- 2. **Copies HTML files**: Places HTML files from `expo-splash-web/dist` or `localHtmlPath` to `ios/{projectName}/` directory
778
- 3. **Modifies `SplashScreen.storyboard`**: Sets full-screen background image with `scaleAspectFill` content mode (same as ResponsiveImage mode)
779
- 4. **Modifies `AppDelegate.swift`**: Adds WebView overlay code with transparent background (recommended)
780
-
781
- **Manual steps** (if needed):
782
-
783
- 1. Copy `.9.png` background image to `ios/{projectName}/splash_background_image.{ext}`
784
- 2. Copy HTML file to `ios/{projectName}/index.html`
785
- 3. Modify `SplashScreen.storyboard`:
786
- - Set Image View to use `splash_background_image` image
787
- - Set Content Mode to `Aspect Fill` for full-screen coverage
788
- - Set background color (fallback)
789
- 4. Modify `AppDelegate.swift`:
790
- - Add WebView container code (see plugin source for template)
791
- - Set WebView container background to transparent (recommended) for seamless transition
792
- 5. Add image and HTML files to Xcode project file references
793
-
794
- ### 🤖 Android Configuration
795
-
796
- The plugin automatically:
797
-
798
- 1. Copies splash images to Android drawable directories
799
- 2. Modifies `MainActivity.kt` to display the splash screen
800
- 3. Creates `values/colors.xml` and `values-night/colors.xml` for dark mode
801
- 4. Sets up `Configuration.UI_MODE_NIGHT_MASK` detection
802
-
803
- #### Resource Locations
804
-
805
- - Light mode image: `android/app/src/main/res/drawable/splash_icon.png`
806
- - Dark mode image: `android/app/src/main/res/drawable-night/splash_icon.png`
807
- - Light colors: `android/app/src/main/res/values/colors.xml`
808
- - Dark colors: `android/app/src/main/res/values-night/colors.xml`
809
-
810
- ### Manual Android Configuration
811
-
812
- The plugin automatically handles Android configuration, but if you need to manually configure or understand how it works, here are the details for each mode:
813
-
814
- #### WebView Mode
815
-
816
- For WebView mode, the plugin:
817
-
818
- 1. **Copies HTML file**: Places HTML file from `expo-splash-web/dist/index.html` or `localHtmlPath` to `android/app/src/main/assets/index.html`
819
- 2. **Copies icon** (optional): If `image` is configured, copies icon to `android/app/src/main/res/drawable-xxhdpi/ic_splash_icon.png`
820
- 3. **Creates CustomSplashActivity**: Generates `SplashScreen2Activity.kt` for displaying WebView
821
- 4. **Modifies AndroidManifest.xml**: Adds `SplashScreen2Activity` as launcher activity
822
- 5. **Modifies MainActivity.kt**: Adds WebView container code and methods
823
- 6. **Modifies styles.xml**: Updates `Theme.App.SplashScreen` and adds `Theme.App.MainActivity`
824
- 7. **Creates colors.xml**: Creates color resources for background color
825
- 8. **Updates build.gradle**: Adds `androidx.core:core-splashscreen` dependency
826
-
827
- **Manual steps** (if needed):
828
-
829
- 1. Copy HTML file to `android/app/src/main/assets/index.html`
830
- 2. Create `SplashScreen2Activity.kt` in `android/app/src/main/java/{packageName}/` (see plugin templates)
831
- 3. Modify `AndroidManifest.xml`:
832
- - Add `SplashScreen2Activity` as launcher activity
833
- - Set `MainActivity` theme to `Theme.App.MainActivity`
834
- 4. Modify `MainActivity.kt` to add WebView container code
835
- 5. Update `res/values/styles.xml` with splash screen themes
836
- 6. Create `res/values/colors.xml` with `splashscreen_background` color
837
- 7. Add `androidx.core:core-splashscreen:1.0.1` dependency to `build.gradle`
838
-
839
- #### ResponsiveImage Mode
840
-
841
- For ResponsiveImage mode, the plugin:
842
-
843
- 1. **Copies background image**: Places image as `splash_background_image.{ext}` in `android/app/src/main/res/drawable/` (supports `.9.png`)
844
- 2. **Updates ic_launcher_background.xml**: Modifies to show background image only
845
- 3. **Creates colors.xml**: Creates `splashscreen_background` color resource
846
- 4. **Modifies styles.xml**: Updates `Theme.App.SplashScreen` to use background image
847
- 5. **Modifies MainActivity.kt**: Adds image container view for full-screen display
848
-
849
- **Manual steps** (if needed):
850
-
851
- 1. Copy background image to `android/app/src/main/res/drawable/splash_background_image.{ext}`
852
- 2. Update `res/drawable/ic_launcher_background.xml`:
853
- ```xml
854
- <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
855
- <item android:drawable="@drawable/splash_background_image"/>
856
- </layer-list>
857
- ```
858
- 3. Create `res/values/colors.xml`:
859
- ```xml
860
- <resources>
861
- <color name="splashscreen_background">#FFFFFF</color>
862
- </resources>
863
- ```
864
- 4. Update `res/values/styles.xml`:
865
- ```xml
866
- <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
867
- <item name="android:windowBackground">@drawable/ic_launcher_background</item>
868
- </style>
869
- ```
870
- 5. Modify `MainActivity.kt` to add image container view
871
-
872
- #### Normal Mode
873
-
874
- For Normal mode, the plugin:
875
-
876
- 1. **Copies icon image**: Places image as `splash_icon.{ext}` in `android/app/src/main/res/drawable-xxhdpi/`
877
- 2. **Copies dark icon** (if dark mode enabled): Places dark image in `android/app/src/main/res/drawable-night-xxhdpi/`
878
- 3. **Creates splashscreen_logo**: Creates drawable resource for system splash screen
879
- 4. **Creates colors.xml**: Creates `splashscreen_background` color (supports dark mode in `values-night/colors.xml`)
880
- 5. **Modifies MainActivity.kt**: Adds image container view with fixed width constraints
881
-
882
- **Manual steps** (if needed):
883
-
884
- 1. Copy icon image to `android/app/src/main/res/drawable-xxhdpi/splash_icon.{ext}`
885
- 2. If dark mode enabled, copy dark icon to `android/app/src/main/res/drawable-night-xxhdpi/splash_icon.{ext}`
886
- 3. Create `res/drawable/splashscreen_logo.xml`:
887
- ```xml
888
- <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
889
- <item android:drawable="@color/splashscreen_background"/>
890
- <item>
891
- <bitmap android:gravity="center" android:src="@drawable/splash_icon"/>
892
- </item>
893
- </layer-list>
894
- ```
895
- 4. Create `res/values/colors.xml`:
896
- ```xml
897
- <resources>
898
- <color name="splashscreen_background">#FFFFFF</color>
899
- </resources>
900
- ```
901
- 5. If dark mode enabled, create `res/values-night/colors.xml`:
902
- ```xml
903
- <resources>
904
- <color name="splashscreen_background">#000000</color>
905
- </resources>
906
- ```
907
- 6. Update `res/values/styles.xml`:
908
- ```xml
909
- <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
910
- <item name="android:windowBackground">@drawable/splashscreen_logo</item>
911
- </style>
912
- ```
913
- 7. Modify `MainActivity.kt` to add image container view with fixed width (default 100dp)
914
-
915
- #### Blend Mode
916
-
917
- For Blend mode, the plugin:
918
-
919
- 1. **Copies background image**: Places `.9.png` image as `splash_background_image.{ext}` in `android/app/src/main/res/drawable/`
920
- 2. **Copies HTML file**: Places HTML file from `expo-splash-web/dist/index.html` or `localHtmlPath` to `android/app/src/main/assets/index.html`
921
- 3. **Creates CustomSplashActivity**: Generates `SplashScreen2Activity.kt` with transparent WebView container background (recommended)
922
- 4. **Modifies AndroidManifest.xml**: Adds `SplashScreen2Activity` as launcher activity, sets `MainActivity` theme to `Theme.App.SplashScreen`
923
- 5. **Modifies MainActivity.kt**: Adds WebView container code with transparent background (recommended)
924
- 6. **Modifies styles.xml**: Updates `Theme.App.SplashScreen` to use `.9.png` background image
925
- 7. **Creates colors.xml**: Creates `splashscreen_background` color resource
926
- 8. **Updates build.gradle**: Adds `androidx.core:core-splashscreen` dependency
927
-
928
- **Manual steps** (if needed):
929
-
930
- 1. Copy `.9.png` background image to `android/app/src/main/res/drawable/splash_background_image.{ext}`
931
- 2. Copy HTML file to `android/app/src/main/assets/index.html`
932
- 3. Create `SplashScreen2Activity.kt` in `android/app/src/main/java/{packageName}/`:
933
- - Set WebView container background to transparent (recommended, see plugin templates)
934
- 4. Modify `AndroidManifest.xml`:
935
- - Add `SplashScreen2Activity` as launcher activity
936
- - Set `MainActivity` theme to `Theme.App.SplashScreen` (same as splash screen theme)
937
- 5. Modify `MainActivity.kt`:
938
- - Add WebView container code
939
- - Set WebView container background to transparent (recommended) for seamless transition
940
- 6. Update `res/values/styles.xml`:
941
- ```xml
942
- <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
943
- <item name="android:windowBackground">@drawable/splash_background_image</item>
944
- </style>
945
- ```
946
- 7. Create `res/values/colors.xml`:
947
- ```xml
948
- <resources>
949
- <color name="splashscreen_background">#FFFFFF</color>
950
- </resources>
951
- ```
952
- 8. Add `androidx.core:core-splashscreen:1.0.1` dependency to `build.gradle`
953
-
954
- ### Manual Regeneration
955
-
956
- If you need to regenerate native projects with the latest plugin changes:
957
-
958
- ```bash
959
- # Clean and regenerate
960
- npx expo prebuild --clean
961
-
962
- # Or for specific platform
963
- npx expo prebuild --clean --platform android
964
- npx expo prebuild --clean --platform ios
965
- ```
966
-
967
- ## 👏 Contributing
968
-
969
- Contributions are welcome! Please feel free to submit issues and pull requests.
970
-
971
- ## ❓ Known Issues
972
-
973
- ### iOS Caching
974
-
975
- Splash screens on iOS can sometimes encounter a caching issue where the previous image will flash before showing the new image. When this occurs, try:
976
- 1. Power cycling your device
977
- 2. Uninstalling and re-installing the application
978
- 3. Running `npx expo prebuild --clean`
979
-
980
- ### Node Modules Caching
981
-
982
- If plugin changes aren't being applied, try:
983
-
984
- ```bash
985
- cd your-project
986
- rm -rf node_modules/expo-splash-screen2
987
- npm install # or pnpm install
988
- npx expo prebuild --clean
989
- ```
990
-
991
- ### Dark Mode Not Working
992
-
993
- Ensure:
994
- 1. Your `app.json` has the `dark` configuration in `normal` mode
995
- 2. You've run `npx expo prebuild --clean` after configuration changes
996
- 3. Both light and dark images exist at the specified paths
997
-
998
- ### Android 12+ System Default Splash Screen
999
-
1000
-
1001
- **Note: Android 12+ System Default Behavior**
1002
-
1003
- If your app runs on Android 12 or higher and your `targetSdkVersion` is not below 30, the system will display a default splash screen. This is the default behavior of Android and may result in two splash screens appearing (system default splash + custom splash).
1004
-
1005
- If you don't want to show the system default splash screen, you can use either of the following methods:
1006
-
1007
- **Method 1: Make the default splash transparent**
1008
-
1009
- Add the following to your Activity theme in `AndroidManifest.xml`:
1010
-
1011
- ```xml
1012
- <item name="android:windowIsTranslucent">true</item>
1013
- ```
1014
-
1015
- **Method 2: Adjust targetSdkVersion**
1016
-
1017
- Set `androidTargetSdkVersion` to 30 or lower to hide the system default splash screen.
1018
-
1019
- ## 📄 License
1020
-
1021
- This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
95
+ MIT
1022
96
 
1023
97
  This module is based on [expo-splash-screen](https://github.com/expo/expo/tree/main/packages/expo-splash-screen), which is also licensed under the MIT License.
1024
98
 
1025
- ## 🏅 Hall of Fame
99
+ ### Hall of Fame
1026
100
 
1027
101
  This module is based on a solid work from (many thanks for that 👏):
1028
102
 
1029
103
  - [expo-splash-screen](https://github.com/expo/expo/tree/main/packages/expo-splash-screen)
1030
-