Skip to content

Commit

Permalink
Showing 8 changed files with 414 additions and 88 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
## [0.1.9] - (16th October 2019)
## [0.2.0] - (2021-Jan-07)

* `image` parameter is now optional ([#26](https://github.com/henriquearthur/flutter_native_splash/issues/26))
* Added dark mode.

## [0.1.9] -

* (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))

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

24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ Automatically generates native code for adding splash screens in Android and iOS
This package is heavily inspired by [flutter_launcher_icons](https://pub.dev/packages/flutter_launcher_icons) created by [Mark O'Sullivan](https://github.com/MarkOSullivan94) and [Franz Silva](https://github.com/franzsilva).

<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/henriquearthur/flutter_native_splash/master/splash_demo.gif" width="250" height="443" />
</p>

## Usage
@@ -28,15 +28,25 @@ Add your settings to your project's `pubspec.yaml` file or create a file in your
flutter_native_splash:
image: assets/images/splash.png
color: "42a5f5"
image_dark: assets/images/splash-invert.png
color_dark: "042a49"
```

* `image` must be a `png` file.
* You can use `#` in `color` as well. `color: "#42a5f5"`
* Images must be `png` files.
* You can use `#` in color parameters as well. `color: "#42a5f5"`

You can omit `image` parameter if you just want a colored splash screen:
You can omit `image_dark` and `color_dark` if you want a single splash screen regardless of dark mode:
```yaml
flutter_native_splash:
image: assets/images/splash.png
color: "42a5f5"
```

You can omit `image` and/or the `image_dark` parameter if you just want a colored splash screens:
```yaml
flutter_native_splash:
color: "42a5f5"
color_dark: "042a49"
```

You can also set `android` or `ios` to `false` if you don't want to create a splash screen for a specific platform.
@@ -75,7 +85,7 @@ 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`, `styles.xml` and `MainActivity` 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 a issue](https://github.com/henriquearthur/flutter_native_splash/issues/new) if you find any bugs.
* This package modifies `launch_background.xml`, `styles.xml` and `MainActivity` 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.
## 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.
@@ -87,8 +97,10 @@ When the package finishes running your splash screen is ready.
* An `<item>` tag containing a `<bitmap>` for your splash image drawable will be added in `launch_background.xml`
* Background color will be added in `colors.xml` and referenced in `launch_background.xml`.
* Code for full screen mode toggle will be added in `styles.xml` and `MainActivity`.
* Dark mode variants are placed in `drawable-night`, `values-night`, etc. resource folders.
### iOS
* Your splash image will be resized to `@3x` and `@2x` images.
* Color and image properties will be inserted in `LaunchScreen.storyboard`.
* Code for hidden status bar toggle will be adde in `Info.plist` and `AppDelegate`.
* 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` and `AppDelegate`.
136 changes: 90 additions & 46 deletions lib/android.dart
Original file line number Diff line number Diff line change
@@ -22,21 +22,43 @@ final List<AndroidDrawableTemplate> splashImages = <AndroidDrawableTemplate>[
AndroidDrawableTemplate(directoryName: 'drawable-xxxhdpi', divider: 1.0),
];

final List<AndroidDrawableTemplate> splashImagesDark =
<AndroidDrawableTemplate>[
AndroidDrawableTemplate(directoryName: 'drawable-night-mdpi', divider: 2.0),
AndroidDrawableTemplate(directoryName: 'drawable-night-hdpi', divider: 1.8),
AndroidDrawableTemplate(directoryName: 'drawable-night-xhdpi', divider: 1.4),
AndroidDrawableTemplate(directoryName: 'drawable-night-xxhdpi', divider: 1.2),
AndroidDrawableTemplate(
directoryName: 'drawable-night-xxxhdpi', divider: 1.0),
];

/// Create Android splash screen
createSplash(String imagePath, String color, bool fill,
bool androidDisableFullscreen) async {
createSplash(String imagePath, String darkImagePath, String color,
String darkColor, bool fill, bool androidDisableFullscreen) async {
if (imagePath.isNotEmpty) {
await _applyImage(imagePath);
}
if (darkImagePath.isNotEmpty) {
await _applyImage(darkImagePath, dark: true);
}

await _applyLaunchBackgroundXml(imagePath, fill);
if (darkColor.isNotEmpty) {
await _applyLaunchBackgroundXml(darkImagePath, fill, dark: true);
}

// _applyColor will update launch_background.xml which may be created in _applyLaunchBackgroundXml
// that's why we need to await _applyLaunchBackgroundXml()
await _applyColor(color);
if (darkColor.isNotEmpty) {
await _applyColor(darkColor, dark: true);
}

if (!androidDisableFullscreen) {
await _applyStylesXml();
if (darkColor.isNotEmpty) {
await _applyStylesXml(dark: true);
}
}

await _applyMainActivityUpdate(_generatePrimaryColorDarkFromColor(color));
@@ -50,8 +72,8 @@ String _generatePrimaryColorDarkFromColor(String color) {
}

/// Create splash screen as drawables for multiple screens (dpi)
void _applyImage(String imagePath) {
print("[Android] Creating splash images");
void _applyImage(String imagePath, {bool dark = false}) {
print('[Android] Creating ' + (dark ? 'dark mode ' : '') + 'splash images');

final File file = File(imagePath);

@@ -61,7 +83,8 @@ void _applyImage(String imagePath) {

final Image image = decodeImage(File(imagePath).readAsBytesSync());

for (AndroidDrawableTemplate template in splashImages) {
for (AndroidDrawableTemplate template
in dark ? splashImagesDark : splashImages) {
_saveImage(template, image);
}
}
@@ -85,28 +108,36 @@ void _saveImage(AndroidDrawableTemplate template, Image image) {
}

/// Create or update launch_background.xml adding splash image path
Future _applyLaunchBackgroundXml(String imagePath, bool fill) {
final File launchBackgroundFile = File(androidLaunchBackgroundFile);

Future _applyLaunchBackgroundXml(String imagePath, bool fill,
{bool dark = false}) {
final File launchBackgroundFile = File(
dark ? androidLaunchDarkBackgroundFile : androidLaunchBackgroundFile);

if (launchBackgroundFile.existsSync()) {
if (imagePath.isNotEmpty) {
print("[Android] Updating launch_background.xml with splash image path");
return _updateLaunchBackgroundFileWithImagePath(fill);
print('[Android] Updating ' +
(dark ? 'dark mode ' : '') +
'launch_background.xml with splash image path');
return _updateLaunchBackgroundFileWithImagePath(fill, dark);
}

return Future.value(false);
} else {
print(
"[Android] No launch_background.xml file found in your Android project");
print(
"[Android] Creating launch_background.xml file and adding it to your Android project");
return _createLaunchBackgroundFileWithImagePath(imagePath, fill);
print('[Android] No ' +
(dark ? 'dark mode ' : '') +
'launch_background.xml file found in your Android project');
print('[Android] Creating ' +
(dark ? 'dark mode ' : '') +
'launch_background.xml file and adding it to your Android project');
return _createLaunchBackgroundFileWithImagePath(imagePath, fill, dark);
}
}

/// Updates launch_background.xml adding splash image path
Future _updateLaunchBackgroundFileWithImagePath(bool fill) async {
final File launchBackgroundFile = File(androidLaunchBackgroundFile);
Future _updateLaunchBackgroundFileWithImagePath(bool fill, bool dark) async {
final File launchBackgroundFile = dark
? File(androidLaunchDarkBackgroundFile)
: File(androidLaunchBackgroundFile);
final List<String> lines = await launchBackgroundFile.readAsLines();
bool foundExisting = false;

@@ -140,46 +171,52 @@ Future _updateLaunchBackgroundFileWithImagePath(bool fill) async {

/// Creates launch_background.xml with splash image path
Future _createLaunchBackgroundFileWithImagePath(
String imagePath, bool fill) async {
File file = await File(androidLaunchBackgroundFile).create(recursive: true);
String imagePath, bool fill, bool dark) async {
File file = await File(
dark ? androidLaunchDarkBackgroundFile : androidLaunchBackgroundFile)
.create(recursive: true);
String fileContent;

if (fill == null || !fill) {
fileContent = templates.androidLaunchBackgroundXml;

if (imagePath.isEmpty) {
fileContent.replaceAll(templates.androidLaunchBackgroundItemXml, '');
fileContent = fileContent.replaceAll(templates.androidLaunchBackgroundItemXml, '');
}
} else {
fileContent = templates.androidLaunchBackgroundXmlFill;

if (imagePath.isEmpty) {
fileContent.replaceAll(templates.androidLaunchBackgroundXmlFill, '');
fileContent = fileContent.replaceAll(templates.androidLaunchBackgroundXmlFill, '');
}
}
return await file.writeAsString(fileContent);
}

/// Create or update colors.xml adding splash screen background color
void _applyColor(color) {
final File colorsXml = File(androidColorsFile);
void _applyColor(color, {bool dark = false}) {
final File colorsXml = File(dark ? androidColorsDarkFile : androidColorsFile);

if (!color.contains("#")) {
color = "#" + color;
}

if (colorsXml.existsSync()) {
print(
"[Android] Updating colors.xml with color for splash screen background");
print('[Android] Updating ' +
(dark ? 'dark mode ' : '') +
'colors.xml with color for splash screen background');
_updateColorsFileWithColor(colorsXml, color);
} else {
print("[Android] No colors.xml file found in your Android project");
print(
"[Android] Creating colors.xml file and adding it to your Android project");
_createColorsFile(color);
print('[Android] No ' +
(dark ? 'dark mode ' : '') +
'colors.xml file found in your Android project');
print('[Android] Creating ' +
(dark ? 'dark mode ' : '') +
'colors.xml file and adding it to your Android project');
_createColorsFile(color, colorsXml);
}

_overwriteLaunchBackgroundWithNewSplashColor(color);
_overwriteLaunchBackgroundWithNewSplashColor(color, dark);
}

/// Updates the colors.xml with the splash screen background color
@@ -214,8 +251,8 @@ void _updateColorsFileWithColor(File colorsFile, String color) {
}

/// Creates a colors.xml file if it was missing from android/app/src/main/res/values/colors.xml
void _createColorsFile(String color) {
File(androidColorsFile).create(recursive: true).then((File colorsFile) {
void _createColorsFile(String color, File colorsXml) {
colorsXml.create(recursive: true).then((File colorsFile) {
colorsFile.writeAsString(templates.androidColorsXml).then((File file) {
_updateColorsFileWithColor(colorsFile, color);
});
@@ -226,8 +263,10 @@ void _createColorsFile(String color) {
/// with the new icon name (only if it has changed)
///
/// Note: default color = "splash_color"
Future _overwriteLaunchBackgroundWithNewSplashColor(String color) async {
final File launchBackgroundFile = File(androidLaunchBackgroundFile);
Future _overwriteLaunchBackgroundWithNewSplashColor(
String color, bool dark) async {
final File launchBackgroundFile = File(
dark ? androidLaunchDarkBackgroundFile : androidLaunchBackgroundFile);
final List<String> lines = await launchBackgroundFile.readAsLines();

for (int x = 0; x < lines.length; x++) {
@@ -251,23 +290,28 @@ Future _overwriteLaunchBackgroundWithNewSplashColor(String color) async {
}

/// Create or update styles.xml full screen mode setting
void _applyStylesXml() {
final File stylesFile = File(androidStylesFile);
void _applyStylesXml({bool dark = false}) {
final File stylesFile =
File(dark ? androidStylesDarkFile : androidStylesFile);

if (stylesFile.existsSync()) {
print("[Android] Updating styles.xml with full screen mode setting");
_updateStylesFileWithImagePath();
print('[Android] Updating ' +
(dark ? 'dark mode ' : '') +
'styles.xml with full screen mode setting');
_updateStylesFileWithImagePath(stylesFile);
} else {
print("[Android] No styles.xml file found in your Android project");
print(
"[Android] Creating styles.xml file and adding it to your Android project");
_createStylesFileWithImagePath();
print('[Android] No ' +
(dark ? 'dark mode ' : '') +
'styles.xml file found in your Android project');
print('[Android] Creating ' +
(dark ? 'dark mode ' : '') +
'styles.xml file and adding it to your Android project');
_createStylesFileWithImagePath(stylesFile);
}
}

/// Updates styles.xml adding full screen property
Future _updateStylesFileWithImagePath() async {
final File stylesFile = File(androidStylesFile);
Future _updateStylesFileWithImagePath(File stylesFile) async {
final List<String> lines = await stylesFile.readAsLines();
bool foundExisting = false;
int endStyleLine;
@@ -297,8 +341,8 @@ Future _updateStylesFileWithImagePath() async {
}

/// Creates styles.xml with full screen property
void _createStylesFileWithImagePath() {
File(androidStylesFile).create(recursive: true).then((File colorsFile) {
void _createStylesFileWithImagePath(File stylesFile) {
stylesFile.create(recursive: true).then((File colorsFile) {
colorsFile.writeAsString(templates.androidStylesXml);
});
}
5 changes: 5 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Android-related constants
const String androidColorsFile = 'android/app/src/main/res/values/colors.xml';
const String androidColorsDarkFile = 'android/app/src/main/res/values-night/colors.xml';
const String androidManifestFile = 'android/app/src/main/AndroidManifest.xml';
const String androidLaunchBackgroundFile =
'android/app/src/main/res/drawable/launch_background.xml';
const String androidLaunchDarkBackgroundFile =
'android/app/src/main/res/drawable-night/launch_background.xml';
const String androidStylesFile = 'android/app/src/main/res/values/styles.xml';
const String androidStylesDarkFile = 'android/app/src/main/res/values-night/styles.xml';
const String androidResFolder = 'android/app/src/main/res/';

// iOS-related constants
@@ -14,3 +18,4 @@ const String iOSLaunchScreenStoryboardFile =
const String iOSInfoPlistFile = 'ios/Runner/Info.plist';
const String iOSAppDelegateObjCFile = 'ios/Runner/AppDelegate.m';
const String iOSAppDelegateSwiftFile = 'ios/Runner/AppDelegate.swift';
const String iOSAssetsLaunchImageBackgroundFolder = 'ios/Runner/Assets.xcassets/LaunchBackground.imageset/';
12 changes: 10 additions & 2 deletions lib/flutter_native_splash.dart
Original file line number Diff line number Diff line change
@@ -15,16 +15,18 @@ void createSplash() async {

Future<void> createSplashByConfig(Map<String, dynamic> config) async {
String image = config['image'] ?? '';
String darkImage = config['image_dark'] ?? '';
String color = config['color'].toString();
String darkColor = config['color_dark']?.toString() ?? '';
bool fill = config['fill'] ?? false;
bool androidDisableFullscreen = config['android_disable_fullscreen'] ?? false;

if (!config.containsKey("android") || config['android']) {
await android.createSplash(image, color, fill, androidDisableFullscreen);
await android.createSplash(image, darkImage, color, darkColor, fill, androidDisableFullscreen);
}

if (!config.containsKey("ios") || config['ios']) {
await ios.createSplash(image, color);
await ios.createSplash(image, darkImage, color, darkColor);
}
}

@@ -59,5 +61,11 @@ Map<String, dynamic> _getConfig() {
exit(1);
}

if (config.containsKey('image_dark') && !config.containsKey('color_dark')) {
stderr.writeln(InvalidConfigException(
"Your `flutter_native_splash` section contains `image_dark` but does not contain a `color_dark`."));
exit(1);
}

return config;
}
134 changes: 104 additions & 30 deletions lib/ios.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:color/color.dart';
import 'package:flutter_native_splash/constants.dart';
import 'package:flutter_native_splash/exceptions.dart';
import 'package:flutter_native_splash/templates.dart' as templates;
@@ -20,20 +19,32 @@ final List<IosLaunchImageTemplate> splashImages = <IosLaunchImageTemplate>[
fileName: 'LaunchImage@3x.png', divider: 1), // original image must be @3x
];

final List<IosLaunchImageTemplate> splashImagesDark = <IosLaunchImageTemplate>[
IosLaunchImageTemplate(fileName: 'LaunchImageDark.png', divider: 3),
IosLaunchImageTemplate(fileName: 'LaunchImageDark@2x.png', divider: 2),
IosLaunchImageTemplate(fileName: 'LaunchImageDark@3x.png', divider: 1),
// original image must be @3x
];

/// Create iOS splash screen
createSplash(String imagePath, String color) async {
createSplash(String imagePath, String darkImagePath, String color,
String darkColor) async {
if (imagePath.isNotEmpty) {
await _applyImage(imagePath);
}
if (darkImagePath.isNotEmpty) {
await _applyImage(darkImagePath, dark: true);
}

await _applyLaunchScreenStoryboard(imagePath, color);
await _createBackgroundColor(color, darkColor, darkColor.isNotEmpty);
await _applyInfoPList();
await _applyAppDelegate();
}

/// Create splash screen images for original size, @2x and @3x
void _applyImage(String imagePath) {
print("[iOS] Creating splash images");
void _applyImage(String imagePath, {bool dark = false}) {
print('[iOS] Creating ' + (dark ? 'dark mode ' : '') + 'splash images');

final File file = File(imagePath);

@@ -43,9 +54,16 @@ void _applyImage(String imagePath) {

final img.Image image = img.decodeImage(File(imagePath).readAsBytesSync());

for (IosLaunchImageTemplate template in splashImages) {
for (IosLaunchImageTemplate template
in dark ? splashImagesDark : splashImages) {
_saveImage(template, image);
}
File(iOSAssetsLaunchImageFolder + 'Contents.json')
.create(recursive: true)
.then((File file) {
file.writeAsStringSync(
dark ? templates.iOSContentsJsonDark : templates.iOSContentsJson);
});
}

/// Saves splash screen image to the project
@@ -89,42 +107,65 @@ Future _updateLaunchScreenStoryboard(String imagePath, String color) async {
final File file = File(iOSLaunchScreenStoryboardFile);
final List<String> lines = await file.readAsLines();

bool foundExistingColor = false;
int colorLine;
bool foundExistingBackgroundImage = false;

bool foundExistingImage = false;
int imageLine;

bool foundExistingLaunchBackgroundSubview = false;

int subviewCount = 0;
int subviewTagLine;

int constraintCount = 0;
int constraintClosingTagLine;

for (int x = 0; x < lines.length; x++) {
String line = lines[x];

if (line.contains('<color key="backgroundColor"')) {
foundExistingColor = true;
colorLine = x;
}

if (line.contains('<image name="LaunchImage"')) {
foundExistingImage = true;
imageLine = x;
}
}

// Found the color line, replace with new color information
if (foundExistingColor) {
HexColor hex = HexColor(color);
double appleRed = hex.r / 255;
double appleGreen = hex.g / 255;
double appleBlue = hex.b / 255;
if (line.contains('<image name="LaunchBackground"')) {
foundExistingBackgroundImage = true;
}

lines[colorLine] =
' <color key="backgroundColor" red="$appleRed" green="$appleGreen" blue="$appleBlue" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>';
} else {
throw LaunchScreenStoryboardModified(
"Not able to find 'backgroundColor' color tag in LaunchScreen.storyboard. Background color for splash screen not updated. Did you modify your default LaunchScreen.storyboard file?");
if (line.contains('image="LaunchBackground"')) {
foundExistingLaunchBackgroundSubview = true;
}

if (line.contains('<subviews>')) {
subviewCount++;
subviewTagLine = x;
}

if (line.contains('</constraints>')) {
constraintCount++;
constraintClosingTagLine = x;
}
}
if (imagePath.isNotEmpty) {
// Found the image line, replace with new image information
if (foundExistingImage) {

// Found the image line, replace with new image information
if (foundExistingImage) {
if (!foundExistingLaunchBackgroundSubview) {
if (subviewCount != 1) {
throw LaunchScreenStoryboardModified(
'Multiple subviews found. Did you modify your default LaunchScreen.storyboard file?');
}
if (constraintCount != 1) {
throw LaunchScreenStoryboardModified(
'Multiple constraint blocks found. Did you modify your default LaunchScreen.storyboard file?');
}
lines[subviewTagLine] =
lines[subviewTagLine] + '\n' + templates.iOSLaunchBackgroundSubview;
lines[constraintClosingTagLine] =
templates.iOSLaunchBackgroundConstraints +
lines[constraintClosingTagLine];
}

if (imagePath.isNotEmpty) {
final File file = File(imagePath);

if (!file.existsSync()) {
@@ -138,10 +179,16 @@ Future _updateLaunchScreenStoryboard(String imagePath, String color) async {

lines[imageLine] =
' <image name="LaunchImage" width="$width" height="$height"/>';
} else {
throw LaunchScreenStoryboardModified(
"Not able to find 'LaunchImage' image tag in LaunchScreen.storyboard. Image for splash screen not updated. Did you modify your default LaunchScreen.storyboard file?");
}
// Existing background image was not found, add it before the image line:
if (!foundExistingBackgroundImage) {
lines[imageLine] =
' <image name="LaunchBackground" width="1" height="1"/>\n' +
lines[imageLine];
}
} else {
throw LaunchScreenStoryboardModified(
"Not able to find 'LaunchImage' image tag in LaunchScreen.storyboard. Image for splash screen not updated. Did you modify your default LaunchScreen.storyboard file?");
}

await file.writeAsString(lines.join('\n'));
@@ -155,6 +202,33 @@ Future _createLaunchScreenStoryboard(String imagePath, String color) async {
return _updateLaunchScreenStoryboard(imagePath, color);
}

Future<void> _createBackgroundColor(
String colorString, String darkColorString, bool dark) async {
img.Image background = img.Image(1, 1);
background.fill(
int.parse(colorString.replaceFirst('#', ''), radix: 16) + 0xFF000000);
await File(iOSAssetsLaunchImageBackgroundFolder + 'background.png')
.create(recursive: true)
.then((File file) => file.writeAsBytesSync(img.encodePng(background)));

if (darkColorString.isNotEmpty) {
background.fill(
int.parse(darkColorString.replaceFirst('#', ''), radix: 16) +
0xFF000000);
await File(iOSAssetsLaunchImageBackgroundFolder + 'darkbackground.png')
.create(recursive: true)
.then((File file) => file.writeAsBytesSync(img.encodePng(background)));
}

return File(iOSAssetsLaunchImageBackgroundFolder + 'Contents.json')
.create(recursive: true)
.then((File file) {
file.writeAsStringSync(dark
? templates.iOSLaunchBackgroundDarkJson
: templates.iOSLaunchBackgroundJson);
});
}

/// Update Info.plist for status bar behaviour (hidden/visible)
Future _applyInfoPList() async {
final File infoPlistFile = File(iOSInfoPlistFile);
177 changes: 177 additions & 0 deletions lib/templates.dart
Original file line number Diff line number Diff line change
@@ -164,3 +164,180 @@ String iOSAppDelegateSwiftLines = '''
var flutter_native_splash = 1
UIApplication.shared.isStatusBarHidden = false
''';

const String iOSContentsJson = '''
{
"images" : [
{
"filename" : "LaunchImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "LaunchImage@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "LaunchImage@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
''';

const String iOSContentsJsonDark = '''
{
"images" : [
{
"filename" : "LaunchImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "LaunchImage@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "LaunchImage@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
''';

const String iOSLaunchBackgroundJson = '''
{
"images" : [
{
"filename" : "background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
''';


const String iOSLaunchBackgroundDarkJson = '''
{
"images" : [
{
"filename" : "background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "darkbackground.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
''';

const String iOSLaunchBackgroundSubview = '''
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI">
<rect key="frame" x="0.0" y="0.0" width="1" height="1"/>
</imageView>''';

const String iOSLaunchBackgroundConstraints = '''
<constraint firstItem="tWc-Dq-wcI" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="SvB-DF-27J"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="VdF-Am-v6m"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="width" secondItem="Ze5-6b-2t3" secondAttribute="width" id="fVJ-Ko-pCh"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="height" secondItem="Ze5-6b-2t3" secondAttribute="height" id="sow-8b-b2l"/>
''';
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: flutter_native_splash
description: Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
version: 0.1.9
version: 0.2.0
homepage: https://github.com/henriquearthur/flutter_native_splash
author: Henrique Arthur <eu@henriquearthur.com.br>

environment:
sdk: ">=2.2.0 <3.0.0"

0 comments on commit e3148e9

Please sign in to comment.