react-native-custom-splash 2.1.1 → 2.1.3
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/package.json +1 -1
- package/plugin/src/index.js +18 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-custom-splash",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "A custom splash screen module for React Native with native iOS and Android support, fully compatible with Expo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
package/plugin/src/index.js
CHANGED
|
@@ -430,18 +430,6 @@ function createLaunchScreenStoryboard(hasImage, hasLogo, backgroundColor) {
|
|
|
430
430
|
* Plugin to configure iOS splash screen
|
|
431
431
|
*/
|
|
432
432
|
const withSplashScreenIOS = (config, pluginConfig) => {
|
|
433
|
-
// Step 1: Update Info.plist to use our LaunchScreen
|
|
434
|
-
config = IOSConfig.InfoPlist.withInfoPlist(config, (config) => {
|
|
435
|
-
// Set our LaunchScreen as the launch storyboard
|
|
436
|
-
config.modResults.UILaunchStoryboardName = 'LaunchScreen';
|
|
437
|
-
|
|
438
|
-
// Remove Expo's default splash screen configuration
|
|
439
|
-
delete config.modResults.UILaunchScreen;
|
|
440
|
-
|
|
441
|
-
return config;
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// Step 2: Create our custom LaunchScreen.storyboard and copy images
|
|
445
433
|
config = withDangerousMod(config, [
|
|
446
434
|
'ios',
|
|
447
435
|
async (config) => {
|
|
@@ -449,67 +437,44 @@ const withSplashScreenIOS = (config, pluginConfig) => {
|
|
|
449
437
|
const iosProjectPath = config.modRequest.platformProjectRoot;
|
|
450
438
|
const projectName = config.modRequest.projectName;
|
|
451
439
|
|
|
440
|
+
// Step 1: Update Info.plist
|
|
441
|
+
const infoPlistPath = path.join(iosProjectPath, projectName, 'Info.plist');
|
|
442
|
+
if (fs.existsSync(infoPlistPath)) {
|
|
443
|
+
let infoPlist = fs.readFileSync(infoPlistPath, 'utf8');
|
|
444
|
+
if (!infoPlist.includes('<key>UILaunchStoryboardName</key>')) {
|
|
445
|
+
infoPlist = infoPlist.replace('</dict>\n</plist>', '\t<key>UILaunchStoryboardName</key>\n\t<string>LaunchScreen</string>\n</dict>\n</plist>');
|
|
446
|
+
}
|
|
447
|
+
infoPlist = infoPlist.replace(/<key>UILaunchScreen<\/key>[\s\S]*?<\/dict>/g, '');
|
|
448
|
+
fs.writeFileSync(infoPlistPath, infoPlist);
|
|
449
|
+
}
|
|
450
|
+
|
|
452
451
|
let hasImage = false;
|
|
453
452
|
let hasLogo = false;
|
|
454
453
|
|
|
455
|
-
// Copy images to iOS assets
|
|
456
454
|
if (pluginConfig.image) {
|
|
457
|
-
hasImage = await copyImageToIOS(
|
|
458
|
-
projectRoot,
|
|
459
|
-
pluginConfig.image,
|
|
460
|
-
'splash_image',
|
|
461
|
-
iosProjectPath,
|
|
462
|
-
projectName
|
|
463
|
-
);
|
|
455
|
+
hasImage = await copyImageToIOS(projectRoot, pluginConfig.image, 'splash_image', iosProjectPath, projectName);
|
|
464
456
|
}
|
|
465
|
-
|
|
466
457
|
if (pluginConfig.logo) {
|
|
467
|
-
hasLogo = await copyImageToIOS(
|
|
468
|
-
projectRoot,
|
|
469
|
-
pluginConfig.logo,
|
|
470
|
-
'splash_logo',
|
|
471
|
-
iosProjectPath,
|
|
472
|
-
projectName
|
|
473
|
-
);
|
|
458
|
+
hasLogo = await copyImageToIOS(projectRoot, pluginConfig.logo, 'splash_logo', iosProjectPath, projectName);
|
|
474
459
|
}
|
|
475
460
|
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
iosProjectPath,
|
|
479
|
-
projectName,
|
|
480
|
-
'LaunchScreen.storyboard'
|
|
481
|
-
);
|
|
482
|
-
|
|
483
|
-
const storyboardContent = createLaunchScreenStoryboard(
|
|
484
|
-
hasImage,
|
|
485
|
-
hasLogo,
|
|
486
|
-
pluginConfig.backgroundColor
|
|
487
|
-
);
|
|
488
|
-
|
|
461
|
+
const launchScreenPath = path.join(iosProjectPath, projectName, 'LaunchScreen.storyboard');
|
|
462
|
+
const storyboardContent = createLaunchScreenStoryboard(hasImage, hasLogo, pluginConfig.backgroundColor);
|
|
489
463
|
fs.writeFileSync(launchScreenPath, storyboardContent);
|
|
490
464
|
|
|
491
|
-
|
|
492
|
-
const legacyPath = path.join(
|
|
493
|
-
iosProjectPath,
|
|
494
|
-
projectName,
|
|
495
|
-
'Images.xcassets',
|
|
496
|
-
'SplashScreenLegacy.imageset'
|
|
497
|
-
);
|
|
498
|
-
|
|
465
|
+
const legacyPath = path.join(iosProjectPath, projectName, 'Images.xcassets', 'SplashScreenLegacy.imageset');
|
|
499
466
|
if (fs.existsSync(legacyPath)) {
|
|
500
467
|
fs.rmSync(legacyPath, { recursive: true, force: true });
|
|
501
468
|
console.log('🗑️ Removed SplashScreenLegacy');
|
|
502
469
|
}
|
|
503
470
|
|
|
504
|
-
console.log('✅ iOS LaunchScreen
|
|
505
|
-
console.log('✅ Info.plist configured to use LaunchScreen');
|
|
506
|
-
|
|
471
|
+
console.log('✅ iOS LaunchScreen configured!');
|
|
507
472
|
return config;
|
|
508
473
|
},
|
|
509
474
|
]);
|
|
510
|
-
|
|
511
475
|
return config;
|
|
512
476
|
};
|
|
477
|
+
};
|
|
513
478
|
|
|
514
479
|
/**
|
|
515
480
|
* Main plugin export
|