Skip to content

Commit

Permalink
Remove v31/styles.xml files if not in use. Fixes #514. Remove web c…
Browse files Browse the repository at this point in the history
…hanges on `remove` command. Fixes #516.
  • Loading branch information
jonbhanson committed Feb 19, 2023
1 parent d67647b commit b957d08
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.2.18] - (2023-Feb-19)
- Remove `v31/styles.xml` files if not in use. Fixes [#514](https://github.com/jonbhanson/flutter_native_splash/issues/514).
- Remove web changes on `remove` command. Fixes [#516](https://github.com/jonbhanson/flutter_native_splash/issues/516).

## [2.2.17] - (2023-Jan-15)
- Updated image dependency to v4.0.10. Fixes [#497](https://github.com/jonbhanson/flutter_native_splash/issues/497).
- Changed image processing from linear to cubic to improve image quality. Fixes [#472](https://github.com/jonbhanson/flutter_native_splash/issues/472).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
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.17
flutter_native_splash: ^2.2.18
```
Don't forget to `flutter pub get`.
Expand Down Expand Up @@ -230,7 +230,7 @@ Be aware of the following considerations regarding these elements:

4. `color` the window background consists of a single opaque color.

~~**_PLEASE NOTE:_** The splash screen may not appear when you launch the app from Android Studio. However, it should appear when you launch by clicking on the launch icon in Android.~~ This seems to be resolved now.
**_PLEASE NOTE:_** The splash screen may not appear when you launch the app from Android Studio on API 31. However, it should appear when you launch by clicking on the launch icon in Android. This seems to be resolved in API 32+.

**_PLEASE NOTE:_** There are a number of reports that non-Google launchers do not display the launch image correctly. If the launch image does not display correctly, please try the Google launcher to confirm that this package is working.

Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
version: "2.4.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -96,7 +96,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.2.17"
version: "2.2.18"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -120,7 +120,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.10"
version: "4.0.15"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -230,7 +230,7 @@ packages:
name: universal_io
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.2.0"
vector_math:
dependency: transitive
description:
Expand Down
6 changes: 6 additions & 0 deletions lib/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ void _createAndroidSplash({
android12IconBackgroundColor: android12IconBackgroundColor,
android12BrandingImagePath: android12BrandingImagePath,
);
} else {
File file = File(_flavorHelper.androidV31StylesFile);
if (file.existsSync()) file.deleteSync();
}

if (android12DarkBackgroundColor != null ||
Expand All @@ -199,6 +202,9 @@ void _createAndroidSplash({
android12IconBackgroundColor: darkAndroid12IconBackgroundColor,
android12BrandingImagePath: android12DarkBrandingImagePath,
);
} else {
File file = File(_flavorHelper.androidV31StylesNightFile);
if (file.existsSync()) file.deleteSync();
}

_applyStylesXml(
Expand Down
30 changes: 30 additions & 0 deletions lib/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@ void _createWebSplash({
return;
}

// Config for removing splash screen:
if (imagePath == null &&
darkImagePath == null &&
color == "ffffff" &&
darkColor == "000000" &&
brandingImagePath == null &&
brandingDarkImagePath == null &&
backgroundImage == null &&
darkBackgroundImage == null) {
Directory splashFolder = Directory(_webSplashFolder);
if (splashFolder.existsSync()) splashFolder.deleteSync(recursive: true);
final webIndex = File(_webIndex);
final document = html_parser.parse(webIndex.readAsStringSync());
// Remove items that may have been added to index.html:
document
.querySelector(
'link[rel="stylesheet"][type="text/css"][href="splash/style.css"]')
?.remove();
document
.querySelector(
'meta[content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"][name="viewport"]',
)
?.remove();
document.querySelector('script[src="splash/splash.js"]')?.remove();
document.querySelector('picture#splash')?.remove();
document.querySelector('picture#splash-branding')?.remove();
webIndex.writeAsStringSync(document.outerHtml);
return;
}

darkImagePath ??= imagePath;
_createWebImages(
imagePath: imagePath,
Expand Down
8 changes: 4 additions & 4 deletions 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.2.17
version: 2.2.18
repository: https://github.com/jonbhanson/flutter_native_splash
issue_tracker: https://github.com/jonbhanson/flutter_native_splash/issues

Expand All @@ -10,17 +10,17 @@ environment:
flutter: ">=2.5.0"

dependencies:
args: ^2.3.1
args: ^2.4.0
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
js: ^0.6.4
html: ^0.15.1
image: ^4.0.10
image: ^4.0.15
meta: ^1.8.0
path: ^1.8.2
universal_io: ^2.0.4
universal_io: ^2.2.0
xml: ^6.1.0
yaml: ^3.1.1

Expand Down

0 comments on commit b957d08

Please sign in to comment.