You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
Kotlin
55 lines
1.6 KiB
Kotlin
2 years ago
|
package com.yinuo.safetywatcher.ui
|
||
|
|
||
|
import androidx.compose.animation.animateColorAsState
|
||
|
import androidx.compose.animation.core.tween
|
||
|
import androidx.compose.foundation.background
|
||
|
import androidx.compose.foundation.layout.Box
|
||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||
|
import androidx.compose.material3.MaterialTheme
|
||
|
import androidx.compose.material3.Text
|
||
|
import androidx.compose.runtime.*
|
||
|
import androidx.compose.ui.Alignment
|
||
|
import androidx.compose.ui.Modifier
|
||
|
import androidx.compose.ui.graphics.Color
|
||
|
import kotlinx.coroutines.delay
|
||
|
|
||
|
/**
|
||
|
* @Description: todo
|
||
|
* @Author: yshh
|
||
|
* @CreateDate: 2022/2/22 14:19
|
||
|
*/
|
||
|
|
||
|
@Composable
|
||
|
fun SplashView(startMain: () -> Unit) {
|
||
|
var enabled by remember { mutableStateOf(false) }
|
||
|
val bgColor: Color by animateColorAsState(
|
||
|
if (enabled) MaterialTheme.colorScheme.primary
|
||
|
else MaterialTheme.colorScheme.primary.copy(alpha = 0.3f),
|
||
|
animationSpec = tween(durationMillis = 2000)
|
||
|
)
|
||
|
val textColor: Color by animateColorAsState(
|
||
|
if (enabled) Color.White
|
||
|
else Color.White.copy(alpha = 0.3f),
|
||
|
animationSpec = tween(durationMillis = 2000)
|
||
|
)
|
||
|
Box(
|
||
|
Modifier
|
||
|
.fillMaxSize()
|
||
|
.background(Color.White)
|
||
|
) {
|
||
|
Box(
|
||
|
Modifier
|
||
|
.fillMaxSize()
|
||
|
.background(bgColor),
|
||
|
contentAlignment = Alignment.Center
|
||
|
) {
|
||
|
Text(text = "Safety Watcher", color = textColor)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
LaunchedEffect(Unit) {
|
||
|
enabled = true
|
||
|
delay(2000)
|
||
|
startMain.invoke()
|
||
|
}
|
||
|
}
|