Skip to content

Commit

Permalink
Use Theme.Light.NoTitleBar. Fixes #402. Correct android spelling in r…
Browse files Browse the repository at this point in the history
…eadme. Thanks Muhammad for PR #407. Use html parser. Thanks OutdatedGuy for PR #396. Separate branding property for Android 12. Closes #405.
  • Loading branch information
jonbhanson committed Aug 21, 2022
1 parent 68da2c4 commit 017020f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## [2.2.8] - (2022-Aug-21)
- Use Theme.Light.NoTitleBar. Fixes [#402](https://github.com/jonbhanson/flutter_native_splash/issues/402).
- Correct android spelling in readme. Thanks [Muhammad](https://github.com/itsahmed-dev) for [PR #407](https://github.com/jonbhanson/flutter_native_splash/pull/407).
- Use html parser. Thanks [OutdatedGuy](https://github.com/OutdatedGuy) for [PR #396](https://github.com/jonbhanson/flutter_native_splash/pull/396).
- Separate branding property for Android 12. Closes [#405](https://github.com/jonbhanson/flutter_native_splash/issues/405).

## [2.2.7] - (2022-July-31)

- Remove branding on Android 12 if branding is not specified. Fixes [#399](https://github.com/jonbhanson/flutter_native_splash/issues/399).
Expand Down
12 changes: 8 additions & 4 deletions README.md
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.7
flutter_native_splash: ^2.2.8
```

Don't forget to `flutter pub get`.
Expand Down Expand Up @@ -52,7 +52,8 @@ flutter_native_splash:
#image: assets/splash.png

# The branding property allows you to specify an image used as branding in the splash screen.
# It must be a png file. It is supported for Android < v12, iOS and the Web.
# It must be a png file. It is supported for Android, iOS and the Web. For Android 12,
# see the Android 12 section below.
#branding: assets/dart.png

# To position the branding image at the bottom of the screen you can use bottom, bottomRight,
Expand Down Expand Up @@ -88,8 +89,11 @@ flutter_native_splash:
# App icon background color.
#icon_background_color: "#111111"

# The image_dark parameter and icon_background_color_dark set the image and icon background
# color when the device is in dark mode. If they are not specified, the app will use the
# The branding property allows you to specify an image used as branding in the splash screen.
#branding: assets/dart.png

# The image_dark, color_dark, icon_background_color_dark, and branding_dark set values that
# apply when the device is in dark mode. If they are not specified, the app will use the
# parameters from above.
#image_dark: assets/android12splash-invert.png
#color_dark: "#042a49"
Expand Down
6 changes: 4 additions & 2 deletions lib/android.dart
Expand Up @@ -63,6 +63,8 @@ void _createAndroidSplash({
required String? android12IconBackgroundColor,
required String? darkAndroid12IconBackgroundColor,
required String? screenOrientation,
String? android12BrandingImagePath,
String? android12DarkBrandingImagePath,
}) {
if (imagePath != null) {
_applyImageAndroid(imagePath: imagePath);
Expand Down Expand Up @@ -170,7 +172,7 @@ void _createAndroidSplash({
android12BackgroundColor: android12BackgroundColor,
android12ImagePath: android12ImagePath,
android12IconBackgroundColor: android12IconBackgroundColor,
android12BrandingImagePath: brandingImagePath,
android12BrandingImagePath: android12BrandingImagePath,
);

if (android12DarkBackgroundColor != null ||
Expand All @@ -184,7 +186,7 @@ void _createAndroidSplash({
android12BackgroundColor: android12DarkBackgroundColor,
android12ImagePath: android12DarkImagePath,
android12IconBackgroundColor: darkAndroid12IconBackgroundColor,
android12BrandingImagePath: brandingDarkImagePath,
android12BrandingImagePath: android12DarkBrandingImagePath,
);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/cli_commands.dart
Expand Up @@ -115,6 +115,8 @@ void createSplashByConfig(Map<String, dynamic> config) {
String? darkAndroid12IconBackgroundColor;
String? android12Color;
String? android12DarkColor;
String? android12BrandingImage;
String? android12DarkBrandingImage;

if (config['android_12'] != null) {
final android12Config = config['android_12'] as Map<String, dynamic>;
Expand All @@ -128,6 +130,10 @@ void createSplashByConfig(Map<String, dynamic> config) {
parseColor(android12Config['icon_background_color_dark']);
android12Color = parseColor(android12Config['color']) ?? color;
android12DarkColor = parseColor(android12Config['color_dark']) ?? darkColor;
android12BrandingImage =
_checkImageExists(config: android12Config, parameter: 'branding');
android12DarkBrandingImage =
_checkImageExists(config: android12Config, parameter: 'branding_dark');
}

if (!config.containsKey('android') || config['android'] as bool) {
Expand All @@ -141,6 +147,8 @@ void createSplashByConfig(Map<String, dynamic> config) {
android12DarkImagePath: android12DarkImage,
android12IconBackgroundColor: android12IconBackgroundColor,
darkAndroid12IconBackgroundColor: darkAndroid12IconBackgroundColor,
android12BrandingImagePath: android12BrandingImage,
android12DarkBrandingImagePath: android12DarkBrandingImage,
backgroundImage: backgroundImageAndroid ?? backgroundImage,
darkBackgroundImage: darkBackgroundImageAndroid ?? darkBackgroundImage,
color: android12Color ?? color,
Expand Down
16 changes: 8 additions & 8 deletions lib/templates.dart
Expand Up @@ -26,20 +26,20 @@ const String _androidLaunchBackgroundXml = '''
const String _androidStylesXml = '''
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
''';
Expand All @@ -50,15 +50,15 @@ const String _androidStylesNightXml = '''
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
Expand Down
2 changes: 1 addition & 1 deletion 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.7
version: 2.2.8
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
Expand Down

0 comments on commit 017020f

Please sign in to comment.