Skip to content

Commit

Permalink
Use light settings for dark mode if dark mode settings are omitted. A…
Browse files Browse the repository at this point in the history
…dd ALT tag for web. Fixes #339.
  • Loading branch information
jonbhanson committed Apr 17, 2022
1 parent f6b77fe commit 74fb046
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.1.6] - (2022-Apr-17)
* Use light settings for dark mode if dark mode settings are omitted.
* Add ALT tag for web. Fixes [#339](https://github.com/jonbhanson/flutter_native_splash/issues/339).
## [2.1.5] - (2022-Apr-10)
* Thanks [Yousef](https://github.com/YDA93) for [PR #332](https://github.com/jonbhanson/flutter_native_splash/pull/332) adding stricter lint rules and [zuboje](https://github.com/zuboje) for [PR #334](https://github.com/jonbhanson/flutter_native_splash/pull/334) adding deprecated message.
## [2.1.3+1] - (2022-Apr-03)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file.

```yaml
dependencies:
flutter_native_splash: ^2.1.5
flutter_native_splash: ^2.1.6
```

Don't forget to `flutter pub get`.
Expand Down
24 changes: 18 additions & 6 deletions lib/cli_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ void createSplash({String? path}) {
/// Create splash screens for Android and iOS based on a config argument
void createSplashByConfig(Map<String, dynamic> config) {
final String? image = _checkImageExists(config: config, parameter: 'image');
final String? darkImage =
String? darkImage =
_checkImageExists(config: config, parameter: 'image_dark');
final String? brandingImage =
_checkImageExists(config: config, parameter: 'branding');
final String? brandingDarkImage =
String? brandingDarkImage =
_checkImageExists(config: config, parameter: 'branding_dark');
final String? color = parseColor(config['color']);
final String? darkColor = parseColor(config['color_dark']);
String? darkColor = parseColor(config['color_dark']);
final String? backgroundImage =
_checkImageExists(config: config, parameter: 'background_image');
final String? darkBackgroundImage =
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';
if (config['android_gravity'] != null) {
Expand All @@ -57,11 +67,13 @@ void createSplashByConfig(Map<String, dynamic> config) {
android12Image =
_checkImageExists(config: android12Config, parameter: 'image');
android12DarkImage =
_checkImageExists(config: android12Config, parameter: 'image_dark');
_checkImageExists(config: android12Config, parameter: 'image_dark') ??
android12Image;
android12IconBackgroundColor =
parseColor(android12Config['icon_background_color']);
darkAndroid12IconBackgroundColor =
parseColor(android12Config['icon_background_color_dark']);
parseColor(android12Config['icon_background_color_dark']) ??
android12IconBackgroundColor;
}

if (!config.containsKey('android') || config['android'] as bool) {
Expand Down
2 changes: 1 addition & 1 deletion lib/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ const List<String> _indexHtmlPicture = [
' <picture id="splash">',
' <source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x" media="(prefers-color-scheme: light)">',
' <source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x" media="(prefers-color-scheme: dark)">',
' <img class="[IMAGEMODE]" aria-hidden="true" src="splash/img/light-1x.png" />',
' <img class="[IMAGEMODE]" aria-hidden="true" src="splash/img/light-1x.png" alt=""/>',
' </picture>',
];

Expand Down
2 changes: 1 addition & 1 deletion 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.1.5
version: 2.1.6
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
Expand Down

0 comments on commit 74fb046

Please sign in to comment.