ajout squelette application
This commit is contained in:
@ -100,15 +100,16 @@ dependencies {
|
||||
// Timber
|
||||
implementation(libs.timber)
|
||||
|
||||
// Compose Navigation
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
|
||||
|
||||
// Tests
|
||||
testImplementation(libs.test.junit)
|
||||
androidTestImplementation(libs.test.junit)
|
||||
androidTestImplementation(libs.test.espresso)
|
||||
androidTestImplementation(libs.test.androidx.junit)
|
||||
|
||||
// Kotlin serialization
|
||||
implementation(libs.kotlin.serialization)
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package fr.openium.consentium
|
||||
|
||||
import DemoNavGraph
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
@ -14,7 +15,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import fr.openium.afu.ui.navigation.DemoNavGraph
|
||||
import fr.openium.consentium.ui.theme.ConsentiumTheme
|
||||
|
||||
@AndroidEntryPoint
|
||||
|
@ -1,4 +1,3 @@
|
||||
package fr.openium.afu.ui.navigation
|
||||
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.openium.afu.ui.navigation
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
sealed interface Destination {
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data object Splash : Destination
|
||||
|
||||
@Serializable
|
||||
|
@ -2,12 +2,11 @@ package fr.openium.consentium.ui.screens.splash
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -19,32 +18,33 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
||||
fun SplashScreen(
|
||||
viewModel: SplashScreenViewModel = hiltViewModel(),
|
||||
navigateToMain: () -> Unit,
|
||||
) {
|
||||
) {
|
||||
|
||||
val state by viewModel.state.collectAsState()
|
||||
|
||||
Text("Splash")
|
||||
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.initMain()
|
||||
}
|
||||
|
||||
when (val _state = state) {
|
||||
|
||||
is SplashScreenViewModel.State.Loading -> Box(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.size(200.dp)
|
||||
.align(Alignment.Center)
|
||||
)
|
||||
//tracking matomo
|
||||
}
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.size(200.dp)
|
||||
.align(Alignment.Center)
|
||||
)
|
||||
//tracking matomo
|
||||
}
|
||||
|
||||
is SplashScreenViewModel.State.Loaded -> {
|
||||
navigateToMain()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ class SplashScreenViewModel @Inject constructor(
|
||||
private val _state = MutableStateFlow<State>(State.Loading)
|
||||
val state: StateFlow<State> = _state
|
||||
|
||||
private fun loadMain() {
|
||||
fun initMain() {
|
||||
val delay = viewModelScope.launch {
|
||||
delay(1500L)
|
||||
}
|
||||
@ -36,8 +36,4 @@ class SplashScreenViewModel @Inject constructor(
|
||||
data object Loaded : State
|
||||
}
|
||||
|
||||
init {
|
||||
loadMain()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user