react-native-custom-splash 2.1.2 → 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 -54
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
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
AndroidConfig,
|
|
7
7
|
IOSConfig,
|
|
8
8
|
} = require('@expo/config-plugins');
|
|
9
|
-
const { withInfoPlist } = IOSConfig.Infoplist || {};
|
|
10
9
|
const path = require('path');
|
|
11
10
|
const fs = require('fs');
|
|
12
11
|
|
|
@@ -431,18 +430,6 @@ function createLaunchScreenStoryboard(hasImage, hasLogo, backgroundColor) {
|
|
|
431
430
|
* Plugin to configure iOS splash screen
|
|
432
431
|
*/
|
|
433
432
|
const withSplashScreenIOS = (config, pluginConfig) => {
|
|
434
|
-
// Step 1: Update Info.plist to use our LaunchScreen
|
|
435
|
-
config = withInfoPlist(config, (config) => {
|
|
436
|
-
// Set our LaunchScreen as the launch storyboard
|
|
437
|
-
config.modResults.UILaunchStoryboardName = 'LaunchScreen';
|
|
438
|
-
|
|
439
|
-
// Remove Expo's default splash screen configuration
|
|
440
|
-
delete config.modResults.UILaunchScreen;
|
|
441
|
-
|
|
442
|
-
return config;
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
// Step 2: Create our custom LaunchScreen.storyboard and copy images
|
|
446
433
|
config = withDangerousMod(config, [
|
|
447
434
|
'ios',
|
|
448
435
|
async (config) => {
|
|
@@ -450,67 +437,44 @@ const withSplashScreenIOS = (config, pluginConfig) => {
|
|
|
450
437
|
const iosProjectPath = config.modRequest.platformProjectRoot;
|
|
451
438
|
const projectName = config.modRequest.projectName;
|
|
452
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
|
+
|
|
453
451
|
let hasImage = false;
|
|
454
452
|
let hasLogo = false;
|
|
455
453
|
|
|
456
|
-
// Copy images to iOS assets
|
|
457
454
|
if (pluginConfig.image) {
|
|
458
|
-
hasImage = await copyImageToIOS(
|
|
459
|
-
projectRoot,
|
|
460
|
-
pluginConfig.image,
|
|
461
|
-
'splash_image',
|
|
462
|
-
iosProjectPath,
|
|
463
|
-
projectName
|
|
464
|
-
);
|
|
455
|
+
hasImage = await copyImageToIOS(projectRoot, pluginConfig.image, 'splash_image', iosProjectPath, projectName);
|
|
465
456
|
}
|
|
466
|
-
|
|
467
457
|
if (pluginConfig.logo) {
|
|
468
|
-
hasLogo = await copyImageToIOS(
|
|
469
|
-
projectRoot,
|
|
470
|
-
pluginConfig.logo,
|
|
471
|
-
'splash_logo',
|
|
472
|
-
iosProjectPath,
|
|
473
|
-
projectName
|
|
474
|
-
);
|
|
458
|
+
hasLogo = await copyImageToIOS(projectRoot, pluginConfig.logo, 'splash_logo', iosProjectPath, projectName);
|
|
475
459
|
}
|
|
476
460
|
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
iosProjectPath,
|
|
480
|
-
projectName,
|
|
481
|
-
'LaunchScreen.storyboard'
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
const storyboardContent = createLaunchScreenStoryboard(
|
|
485
|
-
hasImage,
|
|
486
|
-
hasLogo,
|
|
487
|
-
pluginConfig.backgroundColor
|
|
488
|
-
);
|
|
489
|
-
|
|
461
|
+
const launchScreenPath = path.join(iosProjectPath, projectName, 'LaunchScreen.storyboard');
|
|
462
|
+
const storyboardContent = createLaunchScreenStoryboard(hasImage, hasLogo, pluginConfig.backgroundColor);
|
|
490
463
|
fs.writeFileSync(launchScreenPath, storyboardContent);
|
|
491
464
|
|
|
492
|
-
|
|
493
|
-
const legacyPath = path.join(
|
|
494
|
-
iosProjectPath,
|
|
495
|
-
projectName,
|
|
496
|
-
'Images.xcassets',
|
|
497
|
-
'SplashScreenLegacy.imageset'
|
|
498
|
-
);
|
|
499
|
-
|
|
465
|
+
const legacyPath = path.join(iosProjectPath, projectName, 'Images.xcassets', 'SplashScreenLegacy.imageset');
|
|
500
466
|
if (fs.existsSync(legacyPath)) {
|
|
501
467
|
fs.rmSync(legacyPath, { recursive: true, force: true });
|
|
502
468
|
console.log('🗑️ Removed SplashScreenLegacy');
|
|
503
469
|
}
|
|
504
470
|
|
|
505
|
-
console.log('✅ iOS LaunchScreen
|
|
506
|
-
console.log('✅ Info.plist configured to use LaunchScreen');
|
|
507
|
-
|
|
471
|
+
console.log('✅ iOS LaunchScreen configured!');
|
|
508
472
|
return config;
|
|
509
473
|
},
|
|
510
474
|
]);
|
|
511
|
-
|
|
512
475
|
return config;
|
|
513
476
|
};
|
|
477
|
+
};
|
|
514
478
|
|
|
515
479
|
/**
|
|
516
480
|
* Main plugin export
|