Skip to content

Commit

Permalink
Create new storyboard file rather than try to modify existing file. C…
Browse files Browse the repository at this point in the history
…loses #369. Reverted 2.1.6 change of using light settings for dark mode if omitted.  Fixes #368.
  • Loading branch information
jonbhanson committed Jun 5, 2022
1 parent 4b0b56f commit 34189ac
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 59 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.2.3] - (2022-June-5)
* Create new storyboard file rather than try to modify existing file. Closes [#369](https://github.com/jonbhanson/flutter_native_splash/issues/369).
* Reverted 2.1.6 change of using light settings for dark mode if omitted. Fixes [#368](https://github.com/jonbhanson/flutter_native_splash/issues/368).
## [2.2.2] - (2022-May-29)
* Corrected Android 12 color overriding color parameter. Closes [#365](https://github.com/jonbhanson/flutter_native_splash/issues/365).
* Add support for setting screen orientation in Android. Closes [#344](https://github.com/jonbhanson/flutter_native_splash/issues/344).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file.

```yaml
dependencies:
flutter_native_splash: ^2.2.2
flutter_native_splash: ^2.2.3
```
Don't forget to `flutter pub get`.
Expand Down
23 changes: 6 additions & 17 deletions lib/cli_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,18 @@ void createSplash({String? path, String? flavor}) {
void createSplashByConfig(Map<String, dynamic> config) {
// Preparing all the data for later usage
final String? image = _checkImageExists(config: config, parameter: 'image');
String? darkImage =
final String? darkImage =
_checkImageExists(config: config, parameter: 'image_dark');
final String? brandingImage =
_checkImageExists(config: config, parameter: 'branding');
String? brandingDarkImage =
final String? brandingDarkImage =
_checkImageExists(config: config, parameter: 'branding_dark');
final String? color = parseColor(config['color']);
String? darkColor = parseColor(config['color_dark']);
final String? darkColor = parseColor(config['color_dark']);
final String? backgroundImage =
_checkImageExists(config: config, parameter: 'background_image');
String? darkBackgroundImage =
final String? darkBackgroundImage =
_checkImageExists(config: config, parameter: 'background_image_dark');
if (darkImage == null && darkColor == null) {
if (image != null) {
darkImage = image;
} else {
darkColor = color;
}
brandingDarkImage = brandingImage;
darkBackgroundImage = backgroundImage;
}

final plistFiles = config['info_plist_files'] as List<String>?;
String gravity = (config['fill'] as bool? ?? false) ? 'fill' : 'center';
Expand All @@ -92,13 +83,11 @@ void createSplashByConfig(Map<String, dynamic> config) {
android12Image =
_checkImageExists(config: android12Config, parameter: 'image');
android12DarkImage =
_checkImageExists(config: android12Config, parameter: 'image_dark') ??
android12Image;
_checkImageExists(config: android12Config, parameter: 'image_dark');
android12IconBackgroundColor =
parseColor(android12Config['icon_background_color']);
darkAndroid12IconBackgroundColor =
parseColor(android12Config['icon_background_color_dark']) ??
android12IconBackgroundColor;
parseColor(android12Config['icon_background_color_dark']);
android12Color = parseColor(android12Config['color']) ?? color;
android12DarkColor = parseColor(android12Config['dark_color']) ?? darkColor;
}
Expand Down
42 changes: 3 additions & 39 deletions lib/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void _createiOSSplash({
);
}

_applyLaunchScreenStoryboard(
_createLaunchScreenStoryboard(
imagePath: imagePath,
brandingImagePath: brandingImagePath,
iosContentMode: iosContentMode,
Expand Down Expand Up @@ -206,42 +206,6 @@ void _saveImageiOS({
file.writeAsBytesSync(encodePng(newFile));
}

/// Update LaunchScreen.storyboard adding width, height and color
void _applyLaunchScreenStoryboard({
required String? imagePath,
required String iosContentMode,
String? iosBrandingContentMode,
String? brandingImagePath,
}) {
final file = File(_flavorHelper.iOSLaunchScreenStoryboardFile);

if (file.existsSync()) {
print(
'[iOS] Updating ${_flavorHelper.iOSLaunchScreenStoryboardName}.storyboard with width, and height',
);
return _updateLaunchScreenStoryboard(
imagePath: imagePath,
brandingImagePath: brandingImagePath,
iosContentMode: iosContentMode,
iosBrandingContentMode: iosBrandingContentMode,
);
} else {
print(
'[iOS] No ${_flavorHelper.iOSLaunchScreenStoryboardName}.storyboard file found in your iOS project',
);
print(
'[iOS] Creating ${_flavorHelper.iOSLaunchScreenStoryboardName}.storyboard file and adding it '
'to your iOS project',
);
return _createLaunchScreenStoryboard(
imagePath: imagePath,
brandingImagePath: brandingImagePath,
iosContentMode: iosContentMode,
iosBrandingContentMode: iosBrandingContentMode,
);
}
}

/// Updates LaunchScreen.storyboard adding splash image path
void _updateLaunchScreenStoryboard({
required String? imagePath,
Expand Down Expand Up @@ -430,8 +394,8 @@ void _updateLaunchScreenStoryboard({
void _createLaunchScreenStoryboard({
required String? imagePath,
required String iosContentMode,
String? iosBrandingContentMode,
String? brandingImagePath,
required String? iosBrandingContentMode,
required String? brandingImagePath,
}) {
final file = File(_flavorHelper.iOSLaunchScreenStoryboardFile);
file.createSync(recursive: true);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_native_splash
description: Customize Flutter's default white native splash screen with
background color and splash image. Supports dark mode, full screen, and more.
version: 2.2.2
version: 2.2.3
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
Expand All @@ -20,7 +20,7 @@ dependencies:
meta: ^1.7.0
path: ^1.8.1
universal_io: ^2.0.4
xml: ^6.0.1
xml: ^6.1.0
yaml: ^3.1.1

dev_dependencies:
Expand Down

0 comments on commit 34189ac

Please sign in to comment.