Skip to content

Commit

Permalink
* Updated readme. Thanks @j-j-gajjar for PR #216.
Browse files Browse the repository at this point in the history
* Remove references to background images in web when images are missing.  Fixes #196.
* Updated dependencies.
  • Loading branch information
jonbhanson committed Sep 23, 2021
1 parent 015a02e commit 286b800
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
## [1.2.4] - (2021-Sep-23)
* Updated readme. Thanks [@j-j-gajjar](https://github.com/j-j-gajjar) for PR [#216](https://github.com/jonbhanson/flutter_native_splash/pull/216).
* Remove references to background images in web when images are missing. Fixes [#196](https://github.com/jonbhanson/flutter_native_splash/issues/196).
* Updated dependencies.

## [1.2.3] - (2021-Sep-08)
* Reverted XML dependency to be compatible with stable Flutter branch. Closes [#206](https://github.com/jonbhanson/flutter_native_splash/issues/206).

Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -2,7 +2,7 @@
[![pub package](https://img.shields.io/pub/v/flutter_native_splash)](https://pub.dev/packages/flutter_native_splash)
[![Build Status](https://img.shields.io/travis/jonbhanson/flutter_native_splash)](https://travis-ci.org/jonbhanson/flutter_native_splash)

When your app is opened, there is a brief time while the native app loads Flutter. By default, during this time, the native app displays a white splash screen. This package automatically generates iOS, Android, and Web-native code for customizing this native splash screen background colour and splash image. Supports dark mode, full screen, and platform-specific options.
When your app is opened, there is a brief time while the native app loads Flutter. By default, during this time, the native app displays a white splash screen. This package automatically generates iOS, Android, and Web-native code for customizing this native splash screen background color and splash image. Supports dark mode, full screen, and platform-specific options.

<p align='center'>
<img src="https://raw.githubusercontent.com/jonbhanson/flutter_native_splash/master/splash_demo.gif" />
Expand All @@ -17,7 +17,7 @@ First, add `flutter_native_splash` as a dev dependency in your pubspec.yaml file

```yaml
dev_dependencies:
flutter_native_splash: ^1.2.3
flutter_native_splash: ^1.2.4
```

Don't forget to `flutter pub get`.
Expand Down Expand Up @@ -177,7 +177,7 @@ This attribute is only found in Android 12, so if you are getting this error, it
## iOS
* Your splash image will be resized to `@3x` and `@2x` images.
* Color and image properties will be inserted in `LaunchScreen.storyboard`.
* The background colour is implemented by using a single-pixel png file and stretching it to fit the screen.
* The background color is implemented by using a single-pixel png file and stretching it to fit the screen.
* Code for hidden status bar toggle will be added in `Info.plist`.

## Web
Expand Down
4 changes: 2 additions & 2 deletions lib/templates.dart
Expand Up @@ -325,7 +325,7 @@ body, html {
margin:0;
height:100%;
background: [LIGHTBACKGROUNDCOLOR];
background-image: url("img/light-background.png");
[LIGHTBACKGROUNDIMAGE]
background-size: 100% 100%;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ body, html {
margin:0;
height:100%;
background: [DARKBACKGROUNDCOLOR];
background-image: url("img/dark-background.png");
[DARKBACKGROUNDIMAGE]
background-size: 100% 100%;
}
}
Expand Down
27 changes: 25 additions & 2 deletions lib/web.dart
Expand Up @@ -38,7 +38,11 @@ void _createWebSplash({
createBackgroundImages(
backgroundImage: backgroundImage,
darkBackgroundImage: darkBackgroundImage);
createSplashCss(color: color, darkColor: darkColor);
createSplashCss(
color: color,
darkColor: darkColor,
darkBackgroundImage: darkBackgroundImage,
backgroundImage: backgroundImage);
updateIndex(imageMode: imageMode, imagePath: imagePath);
}

Expand Down Expand Up @@ -105,12 +109,31 @@ void _saveImageWeb(
file.writeAsBytesSync(encodePng(newFile));
}

void createSplashCss({required String color, required String darkColor}) {
void createSplashCss(
{required String color,
required String darkColor,
required String? backgroundImage,
required String? darkBackgroundImage}) {
print('[Web] Creating CSS');
if (darkColor.isEmpty) darkColor = color;
var cssContent = _webCss
.replaceFirst('[LIGHTBACKGROUNDCOLOR]', '#' + color)
.replaceFirst('[DARKBACKGROUNDCOLOR]', '#' + darkColor);

if (backgroundImage == null) {
cssContent = cssContent.replaceFirst('[LIGHTBACKGROUNDIMAGE]', '');
} else {
cssContent = cssContent.replaceFirst('[LIGHTBACKGROUNDIMAGE]',
'background-image: url("img/light-background.png");');
}

if (backgroundImage == null) {
cssContent = cssContent.replaceFirst('[DARKBACKGROUNDIMAGE]', '');
} else {
cssContent = cssContent.replaceFirst('[DARKBACKGROUNDIMAGE]',
'background-image: url("img/dark-background.png");');
}

var file = File(_webFolder + _webRelativeStyleFile);
file.createSync(recursive: true);
file.writeAsStringSync(cssContent);
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
@@ -1,17 +1,17 @@
name: flutter_native_splash
description: Generates native code to customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more.
version: 1.2.3
version: 1.2.4
homepage: https://github.com/jonbhanson/flutter_native_splash

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
args: ^2.2.0
image: ^3.0.2
image: ^3.0.5
meta: ^1.3.0
path: ^1.8.0
xml: ^5.1.2
xml: ^5.3.0
yaml: ^3.1.0
universal_io: ^2.0.4

Expand Down

0 comments on commit 286b800

Please sign in to comment.