Android Animated Lottie Splash Screen
This commit is contained in:
parent
7347b95c3b
commit
9e8fded8a0
|
@ -64,4 +64,6 @@ dependencies {
|
||||||
implementation project(':cwtch')
|
implementation project(':cwtch')
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
|
||||||
|
implementation "com.airbnb.android:lottie:3.5.0"
|
||||||
|
implementation "com.android.support.constraint:constraint-layout:2.0.4"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/NormalTheme"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
|
@ -24,15 +24,7 @@
|
||||||
android:name="io.flutter.embedding.android.NormalTheme"
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
android:resource="@style/NormalTheme"
|
android:resource="@style/NormalTheme"
|
||||||
/>
|
/>
|
||||||
<!-- Displays an Android View that continues showing the launch screen
|
|
||||||
Drawable until Flutter paints its first frame, then this splash
|
|
||||||
screen fades out. A splash screen is useful to avoid any visual
|
|
||||||
gap between the end of Android's launch screen and the painting of
|
|
||||||
Flutter's first frame. -->
|
|
||||||
<meta-data
|
|
||||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
|
||||||
android:resource="@drawable/launch_background"
|
|
||||||
/>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.example.flutter_app
|
package com.example.flutter_app
|
||||||
|
|
||||||
|
import SplashView
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -10,6 +11,7 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.SplashScreen
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
@ -25,6 +27,8 @@ import org.json.JSONObject
|
||||||
|
|
||||||
class MainActivity: FlutterActivity() {
|
class MainActivity: FlutterActivity() {
|
||||||
|
|
||||||
|
override fun provideSplashScreen(): SplashScreen? = SplashView()
|
||||||
|
|
||||||
// Channel to get app info
|
// Channel to get app info
|
||||||
private val CHANNEL_APP_INFO = "test.flutter.dev/applicationInfo"
|
private val CHANNEL_APP_INFO = "test.flutter.dev/applicationInfo"
|
||||||
private val CALL_APP_INFO = "getNativeLibDir"
|
private val CALL_APP_INFO = "getNativeLibDir"
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import com.example.flutter_app.R
|
||||||
|
import io.flutter.embedding.android.SplashScreen
|
||||||
|
|
||||||
|
class SplashView : SplashScreen {
|
||||||
|
override fun createSplashView(context: Context, savedInstanceState: Bundle?): View? =
|
||||||
|
LayoutInflater.from(context).inflate(R.layout.splash_view, null, false)
|
||||||
|
|
||||||
|
override fun transitionToFlutter(onTransitionComplete: Runnable) {
|
||||||
|
onTransitionComplete.run()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.airbnb.lottie.LottieAnimationView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:lottie_autoPlay="true"
|
||||||
|
app:lottie_rawRes="@raw/cwtch_animated_logo"
|
||||||
|
app:lottie_loop="true"
|
||||||
|
app:lottie_speed="1.00" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
File diff suppressed because one or more lines are too long
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<!-- Theme applied to the Android Window while the process is starting -->
|
|
||||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
|
||||||
<!-- Show a splash screen on the activity. Automatically removed when
|
|
||||||
Flutter draws its first frame -->
|
|
||||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
|
||||||
</style>
|
|
||||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
|
||||||
This theme determines the color of the Android Window while your
|
|
||||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
|
||||||
running.
|
|
||||||
|
|
||||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
|
||||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
|
||||||
<item name="android:windowBackground">@android:color/white</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
|
|
@ -8,6 +8,7 @@ buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -35,7 +35,6 @@ dependencies:
|
||||||
ffi: ^1.0.0
|
ffi: ^1.0.0
|
||||||
path_provider: ^2.0.0
|
path_provider: ^2.0.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
Loading…
Reference in New Issue