From c4af3a5fa8b0699b972803367f059467b861e5f2 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Thu, 20 Jun 2024 22:09:12 +0800 Subject: [PATCH 01/12] fix: add space 24 for image branding --- lib/templates.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/templates.dart b/lib/templates.dart index ce45978..312788a 100644 --- a/lib/templates.dart +++ b/lib/templates.dart @@ -386,21 +386,21 @@ const String _iOSLaunchBackgroundConstraints = ''' const String _iOSBrandingCenterBottomConstraints = ''' - + '''; const String _iOSBrandingLeftBottomConstraints = ''' - + '''; const String _iOSBrandingRightBottomConstraints = ''' - + '''; From 9e500ecc4e1cbaa9fe9dcce5559e531e3122168f Mon Sep 17 00:00:00 2001 From: Lzyct Date: Thu, 20 Jun 2024 23:18:14 +0800 Subject: [PATCH 02/12] fix: add space 24 for image branding android --- lib/templates.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates.dart b/lib/templates.dart index 312788a..8ff67f1 100644 --- a/lib/templates.dart +++ b/lib/templates.dart @@ -9,7 +9,7 @@ const String _androidLaunchItemXml = ''' '''; const String _androidBrandingItemXml = ''' - + '''; From ca945102b42ee3ddba76d5d7cc3dc2a8fc75a7b1 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 12:39:47 +0800 Subject: [PATCH 03/12] feat: support adjust branding bottom padding for iOS --- lib/cli_commands.dart | 8 ++++++++ lib/ios.dart | 7 +++++++ lib/templates.dart | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 6d94cf7..1672f6e 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -64,10 +64,14 @@ void _createSplashByConfig(Map config) { _checkImageExists(config: config, parameter: _Parameter.darkImageWeb); final String? brandingImage = _checkImageExists(config: config, parameter: _Parameter.brandingImage); + final String? brandingBottomPadding = _checkImageExists( + config: config, parameter: _Parameter.brandingBottomPadding); final String? brandingImageAndroid = _checkImageExists( config: config, parameter: _Parameter.brandingImageAndroid); final String? brandingImageIos = _checkImageExists(config: config, parameter: _Parameter.brandingImageIos); + final String? brandingBottomPaddingIos = _checkImageExists( + config: config, parameter: _Parameter.brandingBottomPaddingIos); final String? brandingImageWeb = _checkImageExists(config: config, parameter: _Parameter.brandingImageWeb); final String? brandingDarkImage = _checkImageExists( @@ -189,6 +193,8 @@ void _createSplashByConfig(Map config) { darkBackgroundImage: darkBackgroundImageIos ?? darkBackgroundImage, brandingImagePath: brandingImageIos ?? brandingImage, brandingDarkImagePath: brandingDarkImageIos ?? brandingDarkImage, + brandingBottomPadding: + brandingBottomPaddingIos ?? brandingBottomPadding, color: colorIos ?? color, darkColor: darkColorIos ?? darkColor, plistFiles: plistFiles, @@ -420,8 +426,10 @@ class _Parameter { static const brandingDarkImageWeb = 'branding_dark_web'; static const brandingGravity = 'branding_mode'; static const brandingImage = 'branding'; + static const brandingBottomPadding = 'branding_bottom_padding'; static const brandingImageAndroid = 'branding_android'; static const brandingImageIos = 'branding_ios'; + static const brandingBottomPaddingIos = 'branding_bottom_padding_ios'; static const brandingImageWeb = 'branding_web'; static const color = 'color'; static const colorAndroid = "color_android"; diff --git a/lib/ios.dart b/lib/ios.dart index 2a12c0a..76dc0de 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -55,6 +55,7 @@ void _createiOSSplash({ required String? imagePath, required String? darkImagePath, String? brandingImagePath, + String? brandingBottomPadding, String? brandingDarkImagePath, required String? color, required String? darkColor, @@ -141,6 +142,7 @@ void _createiOSSplash({ brandingImagePath: brandingImagePath, iosContentMode: iosContentMode, iosBrandingContentMode: iosBrandingContentMode, + brandingBottomPadding: brandingBottomPadding, ); _createBackground( colorString: color, @@ -209,6 +211,7 @@ void _updateLaunchScreenStoryboard({ required String? imagePath, required String iosContentMode, String? brandingImagePath, + String? brandingBottomPadding, String? iosBrandingContentMode, }) { String? iosBrandingContentModeValue = iosBrandingContentMode; @@ -376,6 +379,8 @@ void _updateLaunchScreenStoryboard({ } final element = view.getElement('constraints'); + toParse.replaceAll("{bottom_padding}", brandingBottomPadding ?? "0"); + final doc = XmlDocument.parse(toParse).rootElement.copy(); if (doc.firstChild != null) { print('[iOS] updating constraints with splash branding'); @@ -396,6 +401,7 @@ void _createLaunchScreenStoryboard({ required String iosContentMode, required String? iosBrandingContentMode, required String? brandingImagePath, + required String? brandingBottomPadding, }) { final file = File(_flavorHelper.iOSLaunchScreenStoryboardFile); file.createSync(recursive: true); @@ -404,6 +410,7 @@ void _createLaunchScreenStoryboard({ return _updateLaunchScreenStoryboard( imagePath: imagePath, brandingImagePath: brandingImagePath, + brandingBottomPadding: brandingBottomPadding, iosContentMode: iosContentMode, iosBrandingContentMode: iosBrandingContentMode, ); diff --git a/lib/templates.dart b/lib/templates.dart index 8ff67f1..f363100 100644 --- a/lib/templates.dart +++ b/lib/templates.dart @@ -386,21 +386,21 @@ const String _iOSLaunchBackgroundConstraints = ''' const String _iOSBrandingCenterBottomConstraints = ''' - + '''; const String _iOSBrandingLeftBottomConstraints = ''' - + '''; const String _iOSBrandingRightBottomConstraints = ''' - + '''; From 017bc1d072011a09cba4502293b429d28b3b4b6f Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:31:48 +0800 Subject: [PATCH 04/12] feat: support adjust branding bottom padding for iOS --- lib/cli_commands.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 1672f6e..de07906 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -475,8 +475,10 @@ class _Parameter { brandingDarkImageWeb, brandingGravity, brandingImage, + brandingBottomPadding, brandingImageAndroid, brandingImageIos, + brandingBottomPaddingIos, brandingImageWeb, color, colorAndroid, From 7126c1ad21b6cd10ffeb09b3be0db5ed13db65d0 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:35:28 +0800 Subject: [PATCH 05/12] fix: resolve when receive data branding bottomPadding --- lib/cli_commands.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index de07906..303c60f 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -64,14 +64,14 @@ void _createSplashByConfig(Map config) { _checkImageExists(config: config, parameter: _Parameter.darkImageWeb); final String? brandingImage = _checkImageExists(config: config, parameter: _Parameter.brandingImage); - final String? brandingBottomPadding = _checkImageExists( - config: config, parameter: _Parameter.brandingBottomPadding); + final String? brandingBottomPadding = + config[_Parameter.brandingBottomPadding]?.toString(); final String? brandingImageAndroid = _checkImageExists( config: config, parameter: _Parameter.brandingImageAndroid); final String? brandingImageIos = _checkImageExists(config: config, parameter: _Parameter.brandingImageIos); - final String? brandingBottomPaddingIos = _checkImageExists( - config: config, parameter: _Parameter.brandingBottomPaddingIos); + final String? brandingBottomPaddingIos = + config[_Parameter.brandingBottomPaddingIos]?.toString(); final String? brandingImageWeb = _checkImageExists(config: config, parameter: _Parameter.brandingImageWeb); final String? brandingDarkImage = _checkImageExists( From bcf2450b26846682f7f6ffebd22a663afb0cc430 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:43:17 +0800 Subject: [PATCH 06/12] fix: resolve when receive data branding bottomPadding --- lib/ios.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ios.dart b/lib/ios.dart index 76dc0de..061c0df 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -381,6 +381,8 @@ void _updateLaunchScreenStoryboard({ toParse.replaceAll("{bottom_padding}", brandingBottomPadding ?? "0"); + print('toParse: $toParse'); + final doc = XmlDocument.parse(toParse).rootElement.copy(); if (doc.firstChild != null) { print('[iOS] updating constraints with splash branding'); From fac9e58b8ee4807898df6957445b1b43c1e8c3dc Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:47:31 +0800 Subject: [PATCH 07/12] fix: resolve when receive data branding bottomPadding --- lib/ios.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ios.dart b/lib/ios.dart index 061c0df..c80c789 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -379,11 +379,10 @@ void _updateLaunchScreenStoryboard({ } final element = view.getElement('constraints'); - toParse.replaceAll("{bottom_padding}", brandingBottomPadding ?? "0"); - - print('toParse: $toParse'); - - final doc = XmlDocument.parse(toParse).rootElement.copy(); + final toParseBottomPadding = + toParse.replaceAll("{bottom_padding}", brandingBottomPadding ?? "0"); + print("[iOS] branding bottom padding: $brandingBottomPadding"); + final doc = XmlDocument.parse(toParseBottomPadding).rootElement.copy(); if (doc.firstChild != null) { print('[iOS] updating constraints with splash branding'); for (final v in doc.children) { From b271c48240df4ce9223af3f004a3c5835ab9da8d Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:57:27 +0800 Subject: [PATCH 08/12] feat: support adjust branding bottom padding for Android --- lib/android.dart | 11 ++++++++++- lib/templates.dart | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/android.dart b/lib/android.dart index ad47078..012ff8b 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -56,6 +56,7 @@ void _createAndroidSplash({ required String? android12BackgroundColor, required String? android12DarkBackgroundColor, required String? brandingImagePath, + required String? brandingBottomPadding, required String? brandingDarkImagePath, required String? color, required String? darkColor, @@ -138,6 +139,7 @@ void _createAndroidSplash({ showImage: imagePath != null, showBranding: brandingImagePath != null, brandingGravity: brandingGravity, + brandingBottomPadding: brandingBottomPadding, ); if (darkColor != null || darkBackgroundImage != null) { @@ -147,6 +149,7 @@ void _createAndroidSplash({ showImage: imagePath != null, showBranding: brandingImagePath != null, brandingGravity: brandingGravity, + brandingBottomPadding: brandingBottomPadding, ); } @@ -157,6 +160,7 @@ void _createAndroidSplash({ showImage: imagePath != null, showBranding: brandingImagePath != null, brandingGravity: brandingGravity, + brandingBottomPadding: brandingBottomPadding, ); if (darkColor != null || darkBackgroundImage != null) { _applyLaunchBackgroundXml( @@ -166,6 +170,7 @@ void _createAndroidSplash({ showImage: imagePath != null, showBranding: brandingImagePath != null, brandingGravity: brandingGravity, + brandingBottomPadding: brandingBottomPadding, ); } } @@ -304,6 +309,7 @@ void _applyLaunchBackgroundXml({ required String gravity, required bool showImage, bool showBranding = false, + String? brandingBottomPadding, String brandingGravity = 'bottom', }) { String brandingGravityValue = brandingGravity; @@ -325,8 +331,11 @@ void _applyLaunchBackgroundXml({ if (showBranding && gravity != brandingGravityValue) { //add branding when splash image and branding image are not at the same position + final androidRandingItemXml = _androidBrandingItemXml.replaceAll( + "{bottom_padding}", brandingBottomPadding ?? "0"); + print('[Android] branding bottom padding: ${brandingBottomPadding ?? "0"}'); final brandingItem = - XmlDocument.parse(_androidBrandingItemXml).rootElement.copy(); + XmlDocument.parse(androidRandingItemXml).rootElement.copy(); if (brandingGravityValue == 'bottomRight') { brandingGravityValue = 'bottom|right'; } else if (brandingGravityValue == 'bottomLeft') { diff --git a/lib/templates.dart b/lib/templates.dart index f363100..0695a92 100644 --- a/lib/templates.dart +++ b/lib/templates.dart @@ -9,7 +9,7 @@ const String _androidLaunchItemXml = ''' '''; const String _androidBrandingItemXml = ''' - + '''; From 7d0debfada6cc6e301c925396aa58b30beeb4cb5 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 13:57:44 +0800 Subject: [PATCH 09/12] chore: update log for iOS --- lib/ios.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ios.dart b/lib/ios.dart index c80c789..efb6277 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -381,7 +381,7 @@ void _updateLaunchScreenStoryboard({ final toParseBottomPadding = toParse.replaceAll("{bottom_padding}", brandingBottomPadding ?? "0"); - print("[iOS] branding bottom padding: $brandingBottomPadding"); + print("[iOS] branding bottom padding: ${brandingBottomPadding ?? "0"}"); final doc = XmlDocument.parse(toParseBottomPadding).rootElement.copy(); if (doc.firstChild != null) { print('[iOS] updating constraints with splash branding'); From f11896d823ed31bb576071b5d8b7f611bf249041 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 14:06:01 +0800 Subject: [PATCH 10/12] fix: resolve when receive data branding bottomPadding --- lib/cli_commands.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 303c60f..49fcc6f 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -68,6 +68,8 @@ void _createSplashByConfig(Map config) { config[_Parameter.brandingBottomPadding]?.toString(); final String? brandingImageAndroid = _checkImageExists( config: config, parameter: _Parameter.brandingImageAndroid); + final String? brandingBottomPaddingAndroid = + config[_Parameter.brandingBottomPaddingAndroid]?.toString(); final String? brandingImageIos = _checkImageExists(config: config, parameter: _Parameter.brandingImageIos); final String? brandingBottomPaddingIos = @@ -159,6 +161,8 @@ void _createSplashByConfig(Map config) { imagePath: imageAndroid ?? image, darkImagePath: darkImageAndroid ?? darkImage, brandingImagePath: brandingImageAndroid ?? brandingImage, + brandingBottomPadding: + brandingBottomPaddingAndroid ?? brandingBottomPadding, brandingDarkImagePath: brandingDarkImageAndroid ?? brandingDarkImage, backgroundImage: backgroundImageAndroid ?? backgroundImage, darkBackgroundImage: darkBackgroundImageAndroid ?? darkBackgroundImage, @@ -428,6 +432,7 @@ class _Parameter { static const brandingImage = 'branding'; static const brandingBottomPadding = 'branding_bottom_padding'; static const brandingImageAndroid = 'branding_android'; + static const brandingBottomPaddingAndroid = 'branding_bottom_padding_android'; static const brandingImageIos = 'branding_ios'; static const brandingBottomPaddingIos = 'branding_bottom_padding_ios'; static const brandingImageWeb = 'branding_web'; @@ -479,6 +484,7 @@ class _Parameter { brandingImageAndroid, brandingImageIos, brandingBottomPaddingIos, + brandingBottomPaddingAndroid, brandingImageWeb, color, colorAndroid, From d8f6eeb3cb0738b0dd872e84f0e07b675faea617 Mon Sep 17 00:00:00 2001 From: Lzyct Date: Sun, 23 Jun 2024 14:08:08 +0800 Subject: [PATCH 11/12] docs: update README.md to support adjust branding bottom padding --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 6e74765..7fec351 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,9 @@ flutter_native_splash: # To position the branding image at the bottom of the screen you can use bottom, bottomRight, # and bottomLeft. The default values is bottom if not specified or specified something else. #branding_mode: bottom + + # Set the branding padding from the bottom of the screen. The default value is 0 + # branding_bottom_padding: 24 # The color_dark, background_image_dark, image_dark, branding_dark are parameters that set the background # and image when the device is in dark mode. If they are not specified, the app will use the @@ -130,8 +133,10 @@ flutter_native_splash: #background_image_web: "assets/background-web.png" #background_image_dark_web: "assets/dark-background-web.png" #branding_android: assets/brand-android.png + #branding_bottom_padding_android: 24 #branding_dark_android: assets/dart_dark-android.png #branding_ios: assets/brand-ios.png + #branding_bottom_padding_ios: 24 #branding_dark_ios: assets/dart_dark-ios.png #branding_web: assets/brand-web.gif #branding_dark_web: assets/dart_dark-web.gif @@ -289,6 +294,7 @@ flutter_native_splash: color: "#ffffff" image: assets/logo-acceptance.png branding: assets/branding-acceptance.png + branding_bottom_padding: 24 color_dark: "#121212" image_dark: assets/logo-acceptance.png branding_dark: assets/branding-acceptance.png @@ -306,6 +312,7 @@ flutter_native_splash: color: "#ffffff" image: assets/logo-production.png branding: assets/branding-production.png + branding_bottom_padding: 24 color_dark: "#121212" image_dark: assets/logo-production.png branding_dark: assets/branding-production.png From 1bf27ebb5c5dbc960b7e1afd1ce9feb9cf7976ec Mon Sep 17 00:00:00 2001 From: Lzyct Date: Thu, 27 Jun 2024 11:08:53 +0800 Subject: [PATCH 12/12] fix: typo from androidRandingItemXml to androidBrandingItemXml --- lib/android.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/android.dart b/lib/android.dart index 012ff8b..bd10441 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -331,11 +331,11 @@ void _applyLaunchBackgroundXml({ if (showBranding && gravity != brandingGravityValue) { //add branding when splash image and branding image are not at the same position - final androidRandingItemXml = _androidBrandingItemXml.replaceAll( + final androidBrandingItemXml = _androidBrandingItemXml.replaceAll( "{bottom_padding}", brandingBottomPadding ?? "0"); print('[Android] branding bottom padding: ${brandingBottomPadding ?? "0"}'); final brandingItem = - XmlDocument.parse(androidRandingItemXml).rootElement.copy(); + XmlDocument.parse(androidBrandingItemXml).rootElement.copy(); if (brandingGravityValue == 'bottomRight') { brandingGravityValue = 'bottom|right'; } else if (brandingGravityValue == 'bottomLeft') {