Skip to content

Commit b10d79f

Browse files
committed
v2.0.0
0 parents  commit b10d79f

File tree

87 files changed

+2615
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2615
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
build/
8+
.idea/
9+
10+
flutter_export_environment.sh
11+
Generated.xcconfig
12+
path_provider_linux
13+
Flutter-Generated.xcconfig
14+
.flutter-plugins-dependencies

.metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 3054a935791bf0bcc34ba0a111df794ddb7a3589
8+
channel: dev
9+
10+
project_type: plugin

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## 2.0.0
2+
- fix not being able to fully screen on higher versions of Android
3+
## 0.3.0
4+
- support null safety.
5+
## 0.1.0
6+
## 0.2.0

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 CrazyCodeBoy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# flutter_splash_screen
2+
3+
[![Download](https://img.shields.io/badge/Download-v2.0.0-ff69b4.svg) ](https://pub.dartlang.org/packages/flutter_splash_screen)
4+
[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/crazycodeboy/flutter_splash_screen/pulls)
5+
[ ![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)
6+
[![License MIT](http://img.shields.io/badge/license-MIT-orange.svg?style=flat)](https://raw.githubusercontent.com/crazycodeboy/flutter-check-box/master/LICENSE)
7+
[ ![RN](https://img.shields.io/badge/react-native-brightgreen.svg)](https://github.com/crazycodeboy/react-native-splash-screen)
8+
9+
A splash screen API for flutter which can programatically hide and show the splash screen. Works on
10+
Android and iOS.
11+
12+
## Content
13+
14+
- [Changes](#changes)
15+
- [Installation](#installation)
16+
- [Examples](#examples)
17+
- [Getting started](#getting-started)
18+
- [API](#api)
19+
- [Testing](#testing)
20+
- [Troubleshooting](#troubleshooting)
21+
- [Contribution](#contribution)
22+
23+
## Changes
24+
25+
## Examples
26+
27+
* [Examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)
28+
29+
![flutter_splash_screen-Android](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-Android.gif)
30+
![flutter_splash_screen-iOS](https://raw.githubusercontent.com/crazycodeboy/react-native-splash-screen/v3.0.0/examples/Screenshots/react-native-splash-screen-iOS.gif)
31+
32+
## 1. Installation
33+
34+
### Depend on it
35+
36+
Run this command:
37+
38+
```bash
39+
flutter pub add flutter_splash_screen
40+
```
41+
42+
## 2. Plugin Configuration
43+
44+
### Android
45+
46+
#### Update the `MainActivity.kt`
47+
48+
Update the `MainActivity.kt` to use `flutter_splash_screen` via the following changes:
49+
50+
```kotlin
51+
package org.devio.flutter.splashscreen.example
52+
53+
import android.os.Bundle
54+
import io.flutter.embedding.android.FlutterActivity
55+
56+
+import org . devio . flutter . splashscreen . SplashScreen
57+
58+
class MainActivity : FlutterActivity() {
59+
override fun onCreate(savedInstanceState: Bundle?) {
60+
+SplashScreen.show(this)
61+
// or enable full screen
62+
SplashScreen.show(this, true)
63+
super.onCreate(savedInstanceState)
64+
}
65+
}
66+
```
67+
68+
#### Create `launch_screen.xml` file
69+
70+
Create a file called `launch_screen.xml` in `app/src/main/res/layout` (create the `layout`-folder if
71+
it doesn't exist). The contents of the file should be the following:
72+
73+
```xml
74+
<?xml version="1.0" encoding="utf-8"?>
75+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
76+
android:layout_width="match_parent" android:layout_height="match_parent"
77+
android:background="@android:color/white">
78+
79+
<ImageView android:layout_width="match_parent" android:layout_height="match_parent"
80+
android:layout_gravity="center|top" android:scaleType="centerCrop"
81+
android:src="@mipmap/launch_screen" />
82+
</FrameLayout>
83+
```
84+
85+
Customize your launch screen by creating a `launch_screen.png`-file and placing it in an
86+
appropriate `mipmap`-folder. Android automatically scales drawable, so you do not necessarily need
87+
to provide images for all phone densities.
88+
You can create splash screens in the following folders:
89+
90+
* `mipmap-ldpi`
91+
* `mipmap-mdpi`
92+
* `mipmap-hdpi`
93+
* `mipmap-xhdpi`
94+
* `mipmap-xxhdpi`
95+
* `mipmap-xxxhdpi`
96+
97+
Add a color called `primary_dark` in `app/src/main/res/values/colors.xml`
98+
99+
```
100+
<?xml version="1.0" encoding="utf-8"?>
101+
<resources>
102+
<color name="primary_dark">#000000</color>
103+
</resources>
104+
```
105+
106+
**Optional steps:**
107+
108+
If you want the splash screen to be transparent, follow these steps.
109+
110+
Open `android/app/src/main/res/values/styles.xml` and
111+
add `<item name="android:windowIsTranslucent">true</item>` to the file. It should look like this:
112+
113+
```xml
114+
115+
<resources>
116+
<!-- Base application theme. -->
117+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
118+
<!-- Customize your theme here. -->
119+
<!--设置透明背景-->
120+
<item name="android:windowIsTranslucent">true</item>
121+
</style>
122+
</resources>
123+
```
124+
125+
**To learn more
126+
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**
127+
128+
If you want to customize the color of the status bar when the splash screen is displayed:
129+
130+
Create `android/app/src/main/res/values/colors.xml` and add
131+
132+
```xml
133+
<?xml version="1.0" encoding="utf-8"?>
134+
<resources>
135+
<color name="status_bar_color"><!-- Colour of your status bar here --></color>
136+
</resources>
137+
```
138+
139+
Create a style definition for this in `android/app/src/main/res/values/styles.xml`:
140+
141+
```xml
142+
<?xml version="1.0" encoding="utf-8"?>
143+
<resources>
144+
<style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
145+
<item name="colorPrimaryDark">@color/status_bar_color</item>
146+
</style>
147+
</resources>
148+
```
149+
150+
Change your `show` method to include your custom style:
151+
152+
```java
153+
SplashScreen.show(this,R.style.SplashScreenTheme);
154+
```
155+
156+
### iOS
157+
158+
Customize your splash screen via `LaunchScreen.storyboard`,
159+
160+
**Learn more to
161+
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**
162+
163+
## Usage
164+
165+
Use like so:
166+
167+
```dart
168+
import 'dart:async';
169+
170+
import 'package:flutter/material.dart';
171+
import 'package:flutter_splash_screen/flutter_splash_screen.dart';
172+
173+
void main() => runApp(MyApp());
174+
175+
class MyApp extends StatefulWidget {
176+
@override
177+
_MyAppState createState() => _MyAppState();
178+
}
179+
180+
class _MyAppState extends State<MyApp> {
181+
@override
182+
void initState() {
183+
super.initState();
184+
hideScreen();
185+
}
186+
187+
///hide your splash screen
188+
Future<void> hideScreen() async {
189+
Future.delayed(Duration(milliseconds: 1800), () {
190+
FlutterSplashScreen.hide();
191+
});
192+
}
193+
194+
...
195+
```
196+
197+
## API
198+
199+
| Method | Type | Optional | Description |
200+
|--------|----------|----------|-------------------------------------|
201+
| show() | function | false | Open splash screen (Native Method ) |
202+
| hide() | function | false | Close splash screen |
203+
204+
## Testing
205+
206+
## Contribution
207+
208+
Issues are welcome. Please add a screenshot of you bug and a code snippet. Quickest way to solve
209+
issue is to reproduce it in one of the examples.
210+
211+
Pull requests are welcome. If you want to change the API or do something big it is best to create an
212+
issue and discuss it first.
213+
214+
---
215+
216+
**[MIT Licensed](https://github.com/crazycodeboy/flutter_splash_screen/blob/master/LICENSE)**

android/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

android/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
group 'org.devio.flutter.splashscreen.flutter_splash_screen'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
google()
7+
jcenter()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:3.2.1'
12+
}
13+
}
14+
15+
rootProject.allprojects {
16+
repositories {
17+
google()
18+
jcenter()
19+
}
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
24+
android {
25+
compileSdkVersion 28
26+
27+
defaultConfig {
28+
minSdkVersion 16
29+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
30+
}
31+
lintOptions {
32+
disable 'InvalidPackage'
33+
}
34+
}

android/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx1536M

android/settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'flutter_splash_screen'

android/src/main/AndroidManifest.xml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="org.devio.flutter.splashscreen.flutter_splash_screen">
3+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.devio.flutter.splashscreen;
2+
3+
import android.app.Activity;
4+
5+
import io.flutter.plugin.common.MethodCall;
6+
import io.flutter.plugin.common.MethodChannel;
7+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
8+
import io.flutter.plugin.common.MethodChannel.Result;
9+
import io.flutter.plugin.common.PluginRegistry.Registrar;
10+
11+
/**
12+
* SplashScreen
13+
* 启动屏
14+
* from:http://www.devio.org
15+
* Author:CrazyCodeBoy
16+
* GitHub:https://github.com/crazycodeboy
17+
18+
*/
19+
public class FlutterSplashScreenPlugin implements MethodCallHandler {
20+
private final Activity activity;
21+
22+
private FlutterSplashScreenPlugin(Activity activity) {
23+
this.activity = activity;
24+
}
25+
26+
public static void registerWith(Registrar registrar) {
27+
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_splash_screen");
28+
channel.setMethodCallHandler(new FlutterSplashScreenPlugin(registrar.activity()));
29+
}
30+
31+
@Override
32+
public void onMethodCall(MethodCall methodCall, Result result) {
33+
switch (methodCall.method) {
34+
case "show":
35+
show();
36+
break;
37+
case "hide":
38+
hide();
39+
break;
40+
default:
41+
result.notImplemented();
42+
}
43+
}
44+
45+
/**
46+
* 打开启动屏
47+
*/
48+
private void show() {
49+
SplashScreen.show(activity);
50+
}
51+
52+
/**
53+
* 关闭启动屏
54+
*/
55+
private void hide() {
56+
SplashScreen.hide(activity);
57+
}
58+
59+
60+
}

0 commit comments

Comments
 (0)