Skip to content

Commit

Permalink
Allow users to set Android gravity and iOS ContentMode directly. Pars…
Browse files Browse the repository at this point in the history
…e LaunchScreen.storyboard with XML package for more reliability. Updated install instructions. Fixes #18. Closes #63.
  • Loading branch information
Jon Hanson committed Jan 25, 2021
1 parent 7d17d65 commit 9a8b7ce
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 251 deletions.
34 changes: 19 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
## [0.2.8] - (2021-Jan-25)

* Allow users to set Android gravity and iOS ContentMode directly. Parse LaunchScreen.storyboard with XML package for more reliability. Updated install instructions. Fixes [#18](https://github.com/jonbhanson/flutter_native_splash/issues/18). Closes [#63](https://github.com/jonbhanson/flutter_native_splash/pull/63).

## [0.2.7] - (2021-Jan-18)

* Added configuration parameter to specify the info.plist location(s). Updated documentation. Fixes [#120](https://github.com/jonbhanson/flutter_native_splash/issues/120), [#42](https://github.com/jonbhanson/flutter_native_splash/issues/42).

## [0.2.6] - (2021-Jan-14)

* Added support for Android -v21 resource folders, which appear in the Flutter beta channel. Parse launch_background.xml with XML package for more reliability. Fixes [#104](https://github.com/henriquearthur/flutter_native_splash/issues/104), [#118](https://github.com/henriquearthur/flutter_native_splash/issues/118).
* Added support for Android -v21 resource folders, which appear in the Flutter beta channel. Parse launch_background.xml with XML package for more reliability. Fixes [#104](https://github.com/jonbhanson/flutter_native_splash/issues/104), [#118](https://github.com/jonbhanson/flutter_native_splash/issues/118).


## [0.2.5] - (2021-Jan-13)

* Handle color parameter that are passed as integers. Fixes [#103](https://github.com/henriquearthur/flutter_native_splash/issues/103)
* Handle color parameter that are passed as integers. Fixes [#103](https://github.com/jonbhanson/flutter_native_splash/issues/103)

## [0.2.4] - (2021-Jan-12)

* Update code that adds fullscreen mode to Android so that it selects the right style (LaunchTheme) in styles.xml. This should resolve [#39](https://github.com/henriquearthur/flutter_native_splash/issues/39), [#54](https://github.com/henriquearthur/flutter_native_splash/issues/54), [#67](https://github.com/henriquearthur/flutter_native_splash/issues/67), [#92](https://github.com/henriquearthur/flutter_native_splash/issues/92), [#112](https://github.com/henriquearthur/flutter_native_splash/issues/112), and [#117](https://github.com/henriquearthur/flutter_native_splash/issues/117). Removed code that modifies MainActivity as it is not longer needed since Flutter embedding V2 uses two styles in styles.xml so full screen is set independently in the style.
* Update code that adds fullscreen mode to Android so that it selects the right style (LaunchTheme) in styles.xml. This should resolve [#39](https://github.com/jonbhanson/flutter_native_splash/issues/39), [#54](https://github.com/jonbhanson/flutter_native_splash/issues/54), [#67](https://github.com/jonbhanson/flutter_native_splash/issues/67), [#92](https://github.com/jonbhanson/flutter_native_splash/issues/92), [#112](https://github.com/jonbhanson/flutter_native_splash/issues/112), and [#117](https://github.com/jonbhanson/flutter_native_splash/issues/117). Removed code that modifies MainActivity as it is not longer needed since Flutter embedding V2 uses two styles in styles.xml so full screen is set independently in the style.

## [0.2.3] - (2021-Jan-11)

Expand All @@ -23,7 +27,7 @@ need to be public were changed to private. Added doc comments for public APIs.

## [0.2.2] - (2021-Jan-09)

* Corrected color of background PNG for iOS. ([The channel order of a uint32 encoded color is BGRA.](https://pub.dev/documentation/image/latest/image/Color/fromRgb.html)) ([#115](https://github.com/henriquearthur/flutter_native_splash/issues/115))
* Corrected color of background PNG for iOS. ([The channel order of a uint32 encoded color is BGRA.](https://pub.dev/documentation/image/latest/image/Color/fromRgb.html)) ([#115](https://github.com/jonbhanson/flutter_native_splash/issues/115))

## [0.2.1] - (2021-Jan-08)

Expand All @@ -42,42 +46,42 @@ need to be public were changed to private. Added doc comments for public APIs.
* (2020-Jan-27) Added createSplashByConfig for external usage
* (2020-Jan-05) Fix run the package command (thanks [@tenhobi](https://github.com/tenhobi))
* (2019-Oct-31) Removing comments from the example (thanks [@lucalves](https://github.com/lucalves))
* (2019-Oct-16) `image` parameter is now optional ([#26](https://github.com/henriquearthur/flutter_native_splash/issues/26))
* (2019-Oct-16) `image` parameter is now optional ([#26](https://github.com/jonbhanson/flutter_native_splash/issues/26))

## [0.1.8+4] - (12th October 2019)

* Fix bug on RegEx preventing `package` tag from being found in `AndroidManifest.xml` ([#25](https://github.com/henriquearthur/flutter_native_splash/issues/25))
* Fix bug on RegEx preventing `package` tag from being found in `AndroidManifest.xml` ([#25](https://github.com/jonbhanson/flutter_native_splash/issues/25))

## [0.1.8+3] - (4th October 2019)

* Prevent unhandled int exception in `color` argument (thanks [@wemersonrv](https://github.com/wemersonrv) - PR [#23](https://github.com/henriquearthur/flutter_native_splash/pull/23))
* Prevent unhandled int exception in `color` argument (thanks [@wemersonrv](https://github.com/wemersonrv) - PR [#23](https://github.com/jonbhanson/flutter_native_splash/pull/23))

## [0.1.8+2] - (16th September 2019)

* Fix code being added multiple times to `MainActivity` ([#19](https://github.com/henriquearthur/flutter_native_splash/issues/19))
* Fix code being added multiple times to `MainActivity` ([#19](https://github.com/jonbhanson/flutter_native_splash/issues/19))

## [0.1.8+1] - (16th September 2019)

* Documentation improvements

## [0.1.8] - (16th September 2019)

* Added `fill` property to use full screen images on Android (thanks [@Bwofls2](https://github.com/Bwolfs2) - PR [#8](https://github.com/henriquearthur/flutter_native_splash/pull/8))
* Added `android_disable_fullscreen` property to disable opening app in full screen on Android ([#14](https://github.com/henriquearthur/flutter_native_splash/issues/14))
* Status bar color on Android is now generated dynamically by using same principles as Material Design (thanks [@yiss](https://github.com/yiss) - PR [#16](https://github.com/henriquearthur/flutter_native_splash/pull/16))
* Added `fill` property to use full screen images on Android (thanks [@Bwofls2](https://github.com/Bwolfs2) - PR [#8](https://github.com/jonbhanson/flutter_native_splash/pull/8))
* Added `android_disable_fullscreen` property to disable opening app in full screen on Android ([#14](https://github.com/jonbhanson/flutter_native_splash/issues/14))
* Status bar color on Android is now generated dynamically by using same principles as Material Design (thanks [@yiss](https://github.com/yiss) - PR [#16](https://github.com/jonbhanson/flutter_native_splash/pull/16))

## [0.1.7+2] - (1th September 2019)

* Fix a bug on `minSdkVersion` reading ([#13](https://github.com/henriquearthur/flutter_native_splash/issues/13))
* Fix a bug on `minSdkVersion` reading ([#13](https://github.com/jonbhanson/flutter_native_splash/issues/13))

## [0.1.7+1] - (1th September 2019)

* Check for `minSdkVersion` >= 21 to add code for changing status bar color to transparent ([#12](https://github.com/henriquearthur/flutter_native_splash/issues/12))
* Check for `minSdkVersion` >= 21 to add code for changing status bar color to transparent ([#12](https://github.com/jonbhanson/flutter_native_splash/issues/12))

## [0.1.7] - (27th August 2019)

* Fix a bug that duplicates entries on `Info.plist` when using multiple `</dict>` on iOS ([#5](https://github.com/henriquearthur/flutter_native_splash/issues/5))
* Fix missing imports on `MainActivity` when not using default class signature ([#7](https://github.com/henriquearthur/flutter_native_splash/issues/7))
* Fix a bug that duplicates entries on `Info.plist` when using multiple `</dict>` on iOS ([#5](https://github.com/jonbhanson/flutter_native_splash/issues/5))
* Fix missing imports on `MainActivity` when not using default class signature ([#7](https://github.com/jonbhanson/flutter_native_splash/issues/7))

## [0.1.6+2] - (27th August 2019)

Expand Down
95 changes: 52 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,74 @@
# flutter_native_splash
[![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/henriquearthur/flutter_native_splash)](https://travis-ci.org/henriquearthur/flutter_native_splash)
[![Build Status](https://img.shields.io/travis/jonbhanson/flutter_native_splash)](https://travis-ci.org/jonbhanson/flutter_native_splash)
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://makeapullrequest.com)

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.

<p>
<img src="https://raw.githubusercontent.com/henriquearthur/flutter_native_splash/master/splash_demo.gif" width="250" height="443" />
<img src="https://raw.githubusercontent.com/jonbhanson/flutter_native_splash/master/splash_demo.gif" width="250" height="443" />
</p>

## Usage
First, add `flutter_native_splash` as a dev dependency in your pubspec.yaml file. You should add the package to `dev_dependencies` because you don't need this plugin in your APK.

```yaml
dev_dependencies:
flutter_native_splash: ^0.2.7
flutter_native_splash: ^0.2.8
```
Don't forget to `flutter pub get`.

### 1. Setting the splash screen
Add your settings to your project's `pubspec.yaml` file or create a file in your root project folder named `flutter_native_splash.yaml` with your settings.

```yaml
flutter_native_splash:
color: "#42a5f5" # required parameter
image: assets/images/splash.png # optional parameter
color_dark: "#042a49" # required if image_dark parameter is used
image_dark: assets/images/splash-invert.png # optional parameter
```

* Images must be `png` files.

To avoid creating a splash screen for a specific platform, `android` or `ios` may be set to `false`.
```yaml
flutter_native_splash:
color: "#42a5f5"
android: false
```

To stretch the image(s) to fill the screen, use `fill` parameter. ([`Gravity=fill`](https://developer.android.com/reference/android/view/Gravity#FILL) on Android, not yet implemented for iOS).
Customized the following settings and add to your project's `pubspec.yaml` file or place in a new file in your root project folder named `flutter_native_splash.yaml`.

```yaml
flutter_native_splash:
# color is the only required parameter. It sets the background color of your splash screen.
color: "#42a5f5"
image: assets/images/splash.png
fill: true
```

To display the notification bar on Android, use the `android_disable_fullscreen` parameter.
```yaml
flutter_native_splash:
color: "#42a5f5"
android_disable_fullscreen: true
```

If you have changed the name(s) of your info.plist file(s), you can specify the filename(s) with the `info_plist_files` parameter:
```yaml
flutter_native_splash:
color: "#42a5f5"
info_plist_files:
- 'ios/Runner/Info-Debug.plist'
- 'ios/Runner/Info-Release.plist'
# Optional parameters are listed below. To enable a parameter, uncomment the line by removing
# the leading # character.
# The image parameter allows you to specifiy an image used in the splash screen. It must be a
# png file.
#image: assets/splash.png
# The color_dark and image_dark are parameters that set the color and image when the device is
# in dark mode. If they are not specified, the app will use the color and image above.
# If the image_dark parameter is specified, color_dark must be specified.
#color_dark: "#042a49"
#image_dark: assets/splash-invert.png
# The android and ios parameters can be used to disable generating a splash screen on a given
# platform.
#android: false
#ios: false
# The position of the splash image can be set with android_gravity and ios_content_mode
# parameters. Both default to center.
#
# android_gravity can be one of the following Android Gravity (see
# https://developer.android.com/reference/android/view/Gravity): bottom, center,
# center_horizontal, center_vertical, clip_horizontal, clip_vertical, end, fill, fill_horizontal,
# fill_vertical, left, right, start, or top.
#android_gravity: center
#
# ios_content_mode can be one of the following iOS UIView.ContentMode (see
# https://developer.apple.com/documentation/uikit/uiview/contentmode): scaleToFill,
# scaleAspectFit, scaleAspectFill, center, top, bottom, left, right, topLeft, topRight,
# bottomLeft, or bottomRight.
#ios_content_mode: center
# To display the notification bar on Android, use the android_disable_fullscreen parameter.
#android_disable_fullscreen: true
# If you have changed the name(s) of your info.plist file(s), you can specify the filename(s)
# with the info_plist_files parameter. Remove only the # characters in the three lines below,
# do not remove any spaces:
#info_plist_files:
# - 'ios/Runner/Info-Debug.plist'
# - 'ios/Runner/Info-Release.plist'
```

### 2. Run the package
Expand All @@ -74,11 +81,13 @@ flutter pub run flutter_native_splash:create
When the package finishes running your splash screen is ready.
## Notes
* If splash screen was not updated properly on iOS or if you experience a white screen before splash screen, run `flutter clean` and recompile your app. (issue [#9](https://github.com/henriquearthur/flutter_native_splash/issues/9))
* This package modifies `launch_background.xml`, and `styles.xml` files on Android and `LaunchScreen.storyboard`, `Info.plist` and `AppDelegate` on iOS. If you modified this files manually this plugin may not work properly, please [open an issue](https://github.com/henriquearthur/flutter_native_splash/issues/new) if you find any bugs.
* If splash screen was not updated properly on iOS or if you experience a white screen before splash screen, run `flutter clean` and recompile your app. If that does not solve the problem, delete your app from the device, power down the device, power up device, install and launch app as per [this stackoverflow thread](https://stackoverflow.com/questions/33002829/ios-keeping-old-launch-screen-and-app-icon-after-update).
* This package modifies `launch_background.xml`, and `styles.xml` files on Android and `LaunchScreen.storyboard`, `Info.plist` and `AppDelegate` on iOS. If you modified this files manually this plugin may not work properly, please [open an issue](https://github.com/jonbhanson/flutter_native_splash/issues/new) if you find any bugs.
## Recommendations
* If you want to use a Material Icon as your splash image, download an icon in [(material.io/resources/icons)](https://material.io/resources/icons/) as **PNG** for **Android**. I recommend using the biggest icon in `drawable-xxxhdpi` folder which was just downloaded for better results.
* Material Colors are available in [material.io/resources/color](https://material.io/resources/color/#!/)
## How it works
Expand Down
Loading

0 comments on commit 9a8b7ce

Please sign in to comment.