Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycodeboy committed Jul 23, 2023
0 parents commit b10d79f
Show file tree
Hide file tree
Showing 87 changed files with 2,615 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
.idea/

flutter_export_environment.sh
Generated.xcconfig
path_provider_linux
Flutter-Generated.xcconfig
.flutter-plugins-dependencies
10 changes: 10 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 3054a935791bf0bcc34ba0a111df794ddb7a3589
channel: dev

project_type: plugin
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 2.0.0
- fix not being able to fully screen on higher versions of Android
## 0.3.0
- support null safety.
## 0.1.0
## 0.2.0
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 CrazyCodeBoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
216 changes: 216 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# flutter_splash_screen

[![Download](https://img.shields.io/badge/Download-v2.0.0-ff69b4.svg) ](https://pub.dartlang.org/packages/flutter_splash_screen)
[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/crazycodeboy/flutter_splash_screen/pulls)
[ ![flutter_splash_screen release](https://img.shields.io/github/release/crazycodeboy/flutter_splash_screen.svg?maxAge=2592000?style=flat-square)](https://github.com/crazycodeboy/GitHubPopular/releases)
[![License MIT](http://img.shields.io/badge/license-MIT-orange.svg?style=flat)](https://raw.githubusercontent.com/crazycodeboy/flutter-check-box/master/LICENSE)
[ ![RN](https://img.shields.io/badge/react-native-brightgreen.svg)](https://github.com/crazycodeboy/react-native-splash-screen)

A splash screen API for flutter which can programatically hide and show the splash screen. Works on
Android and iOS.

## Content

- [Changes](#changes)
- [Installation](#installation)
- [Examples](#examples)
- [Getting started](#getting-started)
- [API](#api)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Contribution](#contribution)

## Changes

## Examples

* [Examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)

![flutter_splash_screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-Android.gif)
![flutter_splash_screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-iOS.gif)

## 1. Installation

### Depend on it

Run this command:

```bash
flutter pub add flutter_splash_screen
```

## 2. Plugin Configuration

### Android

#### Update the `MainActivity.kt`

Update the `MainActivity.kt` to use `flutter_splash_screen` via the following changes:

```kotlin
package org.devio.flutter.splashscreen.example

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity

+import org . devio . flutter . splashscreen . SplashScreen

class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
+SplashScreen.show(this)
// or enable full screen
SplashScreen.show(this, true)
super.onCreate(savedInstanceState)
}
}
```

#### Create `launch_screen.xml` file

Create a file called `launch_screen.xml` in `app/src/main/res/layout` (create the `layout`-folder if
it doesn't exist). The contents of the file should be the following:

```xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@android:color/white">

<ImageView android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_gravity="center|top" android:scaleType="centerCrop"
android:src="@mipmap/launch_screen" />
</FrameLayout>
```

Customize your launch screen by creating a `launch_screen.png`-file and placing it in an
appropriate `mipmap`-folder. Android automatically scales drawable, so you do not necessarily need
to provide images for all phone densities.
You can create splash screens in the following folders:

* `mipmap-ldpi`
* `mipmap-mdpi`
* `mipmap-hdpi`
* `mipmap-xhdpi`
* `mipmap-xxhdpi`
* `mipmap-xxxhdpi`

Add a color called `primary_dark` in `app/src/main/res/values/colors.xml`

```
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#000000</color>
</resources>
```

**Optional steps:**

If you want the splash screen to be transparent, follow these steps.

Open `android/app/src/main/res/values/styles.xml` and
add `<item name="android:windowIsTranslucent">true</item>` to the file. It should look like this:

```xml

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!--设置透明背景-->
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>
```

**To learn more
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**

If you want to customize the color of the status bar when the splash screen is displayed:

Create `android/app/src/main/res/values/colors.xml` and add

```xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="status_bar_color"><!-- Colour of your status bar here --></color>
</resources>
```

Create a style definition for this in `android/app/src/main/res/values/styles.xml`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
<item name="colorPrimaryDark">@color/status_bar_color</item>
</style>
</resources>
```

Change your `show` method to include your custom style:

```java
SplashScreen.show(this,R.style.SplashScreenTheme);
```

### iOS

Customize your splash screen via `LaunchScreen.storyboard`,

**Learn more to
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**

## Usage

Use like so:

```dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_splash_screen/flutter_splash_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
hideScreen();
}
///hide your splash screen
Future<void> hideScreen() async {
Future.delayed(Duration(milliseconds: 1800), () {
FlutterSplashScreen.hide();
});
}
...
```

## API

| Method | Type | Optional | Description |
|--------|----------|----------|-------------------------------------|
| show() | function | false | Open splash screen (Native Method ) |
| hide() | function | false | Close splash screen |

## Testing

## Contribution

Issues are welcome. Please add a screenshot of you bug and a code snippet. Quickest way to solve
issue is to reproduce it in one of the examples.

Pull requests are welcome. If you want to change the API or do something big it is best to create an
issue and discuss it first.

---

**[MIT Licensed](https://github.com/crazycodeboy/flutter_splash_screen/blob/master/LICENSE)**
8 changes: 8 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
34 changes: 34 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
group 'org.devio.flutter.splashscreen.flutter_splash_screen'
version '1.0-SNAPSHOT'

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536M
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'flutter_splash_screen'
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.devio.flutter.splashscreen.flutter_splash_screen">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.devio.flutter.splashscreen;

import android.app.Activity;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/**
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Email:[email protected]
*/
public class FlutterSplashScreenPlugin implements MethodCallHandler {
private final Activity activity;

private FlutterSplashScreenPlugin(Activity activity) {
this.activity = activity;
}

public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_splash_screen");
channel.setMethodCallHandler(new FlutterSplashScreenPlugin(registrar.activity()));
}

@Override
public void onMethodCall(MethodCall methodCall, Result result) {
switch (methodCall.method) {
case "show":
show();
break;
case "hide":
hide();
break;
default:
result.notImplemented();
}
}

/**
* 打开启动屏
*/
private void show() {
SplashScreen.show(activity);
}

/**
* 关闭启动屏
*/
private void hide() {
SplashScreen.hide(activity);
}


}
Loading

0 comments on commit b10d79f

Please sign in to comment.