я использую модель представления, чтобы увеличить время отображения заставки.
Код: Выделить всё
class SplashScreenViewModel: ViewModel() {
private val _isLoading = MutableStateFlow(true)
val isLoading = _isLoading.asStateFlow()
init {
viewModelScope.launch {
delay(800)
_isLoading.value = false
}
}
}
Код: Выделить всё
Код: Выделить всё
@color/black
@drawable/baseline_pause_24
@style/Theme.AudioApp
Код: Выделить всё
class MainActivity : ComponentActivity() {
private val splashViewModel: SplashScreenViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen().apply {
setKeepOnScreenCondition{
splashViewModel.isLoading.value
}
}
enableEdgeToEdge()
setContent {
AudioAppTheme {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
HomeScreen(
0f,
{ },
false,
Audio(
id = 1,
audioName = "256",
audioUrl = "",
audioImage = R.drawable.image1,
artistName = "Selena",
duration = 250,
),
AudioRepositoryImpl().getTrackList(),
{ },
{ },
{}
)
}
}
}
}
}
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/787 ... ck-compose
Мобильная версия