mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 03:42:13 +00:00
animated splashscreen
This commit is contained in:
parent
4b9180c3c7
commit
78cdb9244c
5 changed files with 89 additions and 10 deletions
|
|
@ -73,4 +73,5 @@ flutter {
|
|||
dependencies {
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
|
||||
implementation 'com.otaliastudios:transcoder:0.11.0'
|
||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,16 @@ import android.view.KeyEvent.KEYCODE_VOLUME_UP
|
|||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import android.content.Context
|
||||
import io.crates.keyring.Keyring
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import android.os.Bundle
|
||||
|
||||
class MainActivity : FlutterFragmentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KEYCODE_VOLUME_DOWN && eventSink != null) {
|
||||
eventSink!!.success(true)
|
||||
|
|
|
|||
69
android/app/src/main/res/drawable/link_animated.xml
Normal file
69
android/app/src/main/res/drawable/link_animated.xml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:width="100dp"
|
||||
android:height="100dp"
|
||||
android:viewportWidth="640"
|
||||
android:viewportHeight="640">
|
||||
|
||||
<!-- Wrap everything in a scaling group to add padding and prevent splash screen circular cropping -->
|
||||
<group
|
||||
android:pivotX="320"
|
||||
android:pivotY="320"
|
||||
android:scaleX="0.6"
|
||||
android:scaleY="0.6">
|
||||
|
||||
<!-- Link One pivots around its visual center (approx X=416, Y=288) -->
|
||||
<group
|
||||
android:name="link_one_group"
|
||||
android:pivotX="416"
|
||||
android:pivotY="288">
|
||||
<path
|
||||
android:name="link_one_path"
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M451.5 160C434.9 160 418.8 164.5 404.7 172.7C388.9 156.7 370.5 143.3 350.2 133.2C378.4 109.2 414.3 96 451.5 96C537.9 96 608 166 608 252.5C608 294 591.5 333.8 562.2 363.1L491.1 434.2C461.8 463.5 422 480 380.5 480C294.1 480 224 410 224 323.5C224 322 224 320.5 224.1 319C224.6 301.3 239.3 287.4 257 287.9C274.7 288.4 288.6 303.1 288.1 320.8C288.1 321.7 288.1 322.6 288.1 323.4C288.1 374.5 329.5 415.9 380.6 415.9C405.1 415.9 428.6 406.2 446 388.8L517.1 317.7C534.4 300.4 544.2 276.8 544.2 252.3C544.2 201.2 502.8 159.8 451.7 159.8z" />
|
||||
</group>
|
||||
|
||||
<!-- Link Two pivots around its visual center (approx X=224, Y=352) -->
|
||||
<group
|
||||
android:name="link_two_group"
|
||||
android:pivotX="224"
|
||||
android:pivotY="352">
|
||||
<path
|
||||
android:name="link_two_path"
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M307.2 237.3C305.3 236.5 303.4 235.4 301.7 234.2C289.1 227.7 274.7 224 259.6 224C235.1 224 211.6 233.7 194.2 251.1L123.1 322.2C105.8 339.5 96 363.1 96 387.6C96 438.7 137.4 480.1 188.5 480.1C205 480.1 221.1 475.7 235.2 467.5C251 483.5 269.4 496.9 289.8 507C261.6 530.9 225.8 544.2 188.5 544.2C102.1 544.2 32 474.2 32 387.7C32 346.2 48.5 306.4 77.8 277.1L148.9 206C178.2 176.7 218 160.2 259.5 160.2C346.1 160.2 416 230.8 416 317.1C416 318.4 416 319.7 416 321C415.6 338.7 400.9 352.6 383.2 352.2C365.5 351.8 351.6 337.1 352 319.4C352 318.6 352 317.9 352 317.1C352 283.4 334 253.8 307.2 237.5z" />
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
|
||||
<!-- Rotate Link One smoothly back and forth -->
|
||||
<target android:name="link_one_group">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="800"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:repeatCount="-1"
|
||||
android:repeatMode="reverse"
|
||||
android:valueFrom="-3"
|
||||
android:valueTo="3" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
|
||||
<!-- Rotate Link Two smoothly in the opposite direction to create the opening/closing effect -->
|
||||
<target android:name="link_two_group">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:duration="800"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||
android:propertyName="rotation"
|
||||
android:repeatCount="-1"
|
||||
android:repeatMode="reverse"
|
||||
android:valueFrom="3"
|
||||
android:valueTo="-3" />
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
<style name="LaunchTheme" parent="Theme.SplashScreen">
|
||||
<!-- Configure the Androidx Splash Screen API parameters -->
|
||||
<item name="windowSplashScreenBackground">#FF57CC99</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/link_animated</item>
|
||||
<item name="windowSplashScreenAnimationDuration">800</item>
|
||||
<item name="postSplashScreenTheme">@style/NormalTheme</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
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
<!-- Set the background color to the primary color so the white logo is visible -->
|
||||
<item name="android:colorBackground">#FF57CC99</item>
|
||||
<style name="LaunchTheme" parent="Theme.SplashScreen">
|
||||
<!-- Configure the Androidx Splash Screen API parameters -->
|
||||
<item name="windowSplashScreenBackground">#FF57CC99</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/link_animated</item>
|
||||
<item name="windowSplashScreenAnimationDuration">800</item>
|
||||
<item name="postSplashScreenTheme">@style/NormalTheme</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
|
||||
|
|
|
|||
Loading…
Reference in a new issue