diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f47491..54ff009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ +##[2.2.4] - (2022-July-03) +* Added parameters for platform-specific images. Closes [#375](https://github.com/jonbhanson/flutter_native_splash/issues/375). +* Remove black status bar which appeared on Android devices with a notch. Fixes [#311](https://github.com/jonbhanson/flutter_native_splash/issues/311). ##[2.2.3+1] - (2022-June-12) * Updated readme. - ## [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). - ## [2.2.1] - (2022-May-22) * Updated dependencies. Closes [#358](https://github.com/jonbhanson/flutter_native_splash/issues/358). * Added Android 12 background color support. Closes [#357](https://github.com/jonbhanson/flutter_native_splash/issues/357). diff --git a/README.md b/README.md index f3ab6ed..5775192 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file. ```yaml dependencies: - flutter_native_splash: ^2.2.3+1 + flutter_native_splash: ^2.2.4 ``` Don't forget to `flutter pub get`. @@ -100,7 +100,26 @@ flutter_native_splash: #android: false #ios: false #web: false - + + # Platform specific images can be specified with the following parameters, which will override + # the respective image parameter. You may specify all, selected, or none of these parameters: + #image_andriod: assets/splash-andriod.png + #image_dark_android: assets/splash-invert-android.png + #image_ios: assets/splash-ios.png + #image_dark_ios: assets/splash-invert-ios.png + #image_web: assets/splash-web.png + #image_dark_web: assets/splash-invert-web.png + #background_image_android: "assets/background-android.png" + #background_image_dark_android: "assets/dark-background-android.png" + #background_image_ios: "assets/background-ios.png" + #background_image_dark_ios: "assets/dark-background-ios.png" + #background_image_web: "assets/background-web.png" + #background_image_dark_web: "assets/dark-background-web.png" + #branding_andriod: assets/brand-android.png + #branding_dark_android: assets/dart_dark-android.png + #branding_ios: assets/brand-ios.png + #branding_dark_ios: assets/dart_dark-ios.png + # The position of the splash image can be set with android_gravity, ios_content_mode, and # web_image_mode parameters. All default to center. # diff --git a/lib/android.dart b/lib/android.dart index 28fa9af..ca23e5c 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -381,6 +381,12 @@ Future _updateStylesFile({ value: fullScreen.toString(), ); + replaceElement( + launchTheme: launchTheme, + name: 'android:windowLayoutInDisplayCutoutMode', + value: 'shortEdges', + ); + // In Android 12, the color must be set directly in the styles.xml if (android12BackgroundColor != null) { replaceElement( diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 2c675c2..129c3d2 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -38,7 +38,6 @@ void createSplash({String? path, String? flavor}) { _flavorHelper = _FlavorHelper(flavor); final config = getConfig(configFile: path); - _checkConfig(config); createSplashByConfig(config); } @@ -46,18 +45,50 @@ void createSplash({String? path, String? flavor}) { void createSplashByConfig(Map config) { // Preparing all the data for later usage final String? image = _checkImageExists(config: config, parameter: 'image'); + final String? imageAndroid = + _checkImageExists(config: config, parameter: 'image_android'); + final String? imageIos = + _checkImageExists(config: config, parameter: 'image_ios'); + final String? imageWeb = + _checkImageExists(config: config, parameter: 'image_web'); final String? darkImage = _checkImageExists(config: config, parameter: 'image_dark'); + final String? darkImageAndroid = + _checkImageExists(config: config, parameter: 'image_dark_android'); + final String? darkImageIos = + _checkImageExists(config: config, parameter: 'image_dark_ios'); + final String? darkImageWeb = + _checkImageExists(config: config, parameter: 'image_dark_web'); final String? brandingImage = _checkImageExists(config: config, parameter: 'branding'); + final String? brandingImageAndroid = + _checkImageExists(config: config, parameter: 'branding_android'); + final String? brandingImageIos = + _checkImageExists(config: config, parameter: 'branding_ios'); final String? brandingDarkImage = _checkImageExists(config: config, parameter: 'branding_dark'); + final String? brandingDarkImageAndroid = + _checkImageExists(config: config, parameter: 'branding_dark_android'); + final String? brandingDarkImageIos = + _checkImageExists(config: config, parameter: 'branding_dark_ios'); final String? color = parseColor(config['color']); final String? darkColor = parseColor(config['color_dark']); final String? backgroundImage = _checkImageExists(config: config, parameter: 'background_image'); + final String? backgroundImageAndroid = + _checkImageExists(config: config, parameter: 'background_android'); + final String? backgroundImageIos = + _checkImageExists(config: config, parameter: 'background_ios'); + final String? backgroundImageWeb = + _checkImageExists(config: config, parameter: 'background_web'); final String? darkBackgroundImage = _checkImageExists(config: config, parameter: 'background_image_dark'); + final String? darkBackgroundImageAndroid = _checkImageExists( + config: config, parameter: 'background_image_dark_android'); + final String? darkBackgroundImageIos = + _checkImageExists(config: config, parameter: 'background_image_dark_ios'); + final String? darkBackgroundImageWeb = + _checkImageExists(config: config, parameter: 'background_image_dark_web'); final plistFiles = config['info_plist_files'] as List?; String gravity = (config['fill'] as bool? ?? false) ? 'fill' : 'center'; @@ -95,16 +126,16 @@ void createSplashByConfig(Map config) { if (!config.containsKey('android') || config['android'] as bool) { if (Directory('android').existsSync()) { _createAndroidSplash( - imagePath: image, - darkImagePath: darkImage, - brandingImagePath: brandingImage, - brandingDarkImagePath: brandingDarkImage, + imagePath: imageAndroid ?? image, + darkImagePath: darkImageAndroid ?? darkImage, + brandingImagePath: brandingImageAndroid ?? brandingImage, + brandingDarkImagePath: brandingDarkImageAndroid ?? brandingDarkImage, android12ImagePath: android12Image, android12DarkImagePath: android12DarkImage, android12IconBackgroundColor: android12IconBackgroundColor, darkAndroid12IconBackgroundColor: darkAndroid12IconBackgroundColor, - backgroundImage: backgroundImage, - darkBackgroundImage: darkBackgroundImage, + backgroundImage: backgroundImageAndroid ?? backgroundImage, + darkBackgroundImage: darkBackgroundImageAndroid ?? darkBackgroundImage, color: android12Color ?? color, darkColor: android12DarkColor ?? darkColor, gravity: gravity, @@ -122,12 +153,12 @@ void createSplashByConfig(Map config) { if (!config.containsKey('ios') || config['ios'] as bool) { if (Directory('ios').existsSync()) { _createiOSSplash( - imagePath: image, - darkImagePath: darkImage, - backgroundImage: backgroundImage, - darkBackgroundImage: darkBackgroundImage, - brandingImagePath: brandingImage, - brandingDarkImagePath: brandingDarkImage, + imagePath: imageIos ?? image, + darkImagePath: darkImageIos ?? darkImage, + backgroundImage: backgroundImageIos ?? backgroundImage, + darkBackgroundImage: darkBackgroundImageIos ?? darkBackgroundImage, + brandingImagePath: brandingImageIos ?? brandingImage, + brandingDarkImagePath: brandingDarkImageIos ?? brandingDarkImage, color: color, darkColor: darkColor, plistFiles: plistFiles, @@ -143,10 +174,10 @@ void createSplashByConfig(Map config) { if (!config.containsKey('web') || config['web'] as bool) { if (Directory('web').existsSync()) { _createWebSplash( - imagePath: image, - darkImagePath: darkImage, - backgroundImage: backgroundImage, - darkBackgroundImage: darkBackgroundImage, + imagePath: imageWeb ?? image, + darkImagePath: darkImageWeb ?? darkImage, + backgroundImage: backgroundImageWeb ?? backgroundImage, + darkBackgroundImage: darkBackgroundImageWeb ?? darkBackgroundImage, color: color, darkColor: darkColor, imageMode: webImageMode, @@ -283,53 +314,6 @@ Map _yamlToMap(YamlMap yamlMap) { return map; } -/// Validates if the mix and match of different setup values are not conflicting with each other. -/// If they do, the developer will get a message where the issue is. -void _checkConfig(Map config) { - if (config.containsKey('color') && config.containsKey('background_image')) { - print( - 'Your `flutter_native_splash` section cannot not contain both a ' - '`color` and `background_image`.', - ); - exit(1); - } - - if (!config.containsKey('color') && !config.containsKey('background_image')) { - print( - 'Your `flutter_native_splash` section does not contain a `color` or ' - '`background_image`.', - ); - exit(1); - } - - if (config.containsKey('color_dark') && - config.containsKey('background_image_dark')) { - print( - 'Your `flutter_native_splash` section cannot not contain both a ' - '`color_dark` and `background_image_dark`.', - ); - exit(1); - } - - if (config.containsKey('image_dark') && - !config.containsKey('color_dark') && - !config.containsKey('background_image_dark')) { - print( - 'Your `flutter_native_splash` section contains `image_dark` but ' - 'does not contain a `color_dark` or a `background_image_dark`.', - ); - exit(1); - } - - if (config.containsKey('branding_dark') && !config.containsKey('branding')) { - print( - 'Your `flutter_native_splash` section contains `branding_dark` but ' - 'does not contain a `branding`.', - ); - exit(1); - } -} - @visibleForTesting String? parseColor(dynamic color) { dynamic colorValue = color; diff --git a/pubspec.yaml b/pubspec.yaml index 9798e4d..1a8f354 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.3+1 +version: 2.2.4 homepage: https://github.com/jonbhanson/flutter_native_splash environment: