ajout squelette application
This commit is contained in:
parent
4539301619
commit
9df89f1548
@ -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()
|
||||
}
|
||||
|
||||
}
|
@ -15,8 +15,11 @@ plugins {
|
||||
// Agp
|
||||
alias(libs.plugins.android.library) apply false
|
||||
|
||||
//Hilt
|
||||
alias(libs.plugins.hilt) apply false
|
||||
|
||||
|
||||
//Kotlin serialization
|
||||
alias(libs.plugins.kotlin.serialization) apply false
|
||||
|
||||
|
||||
|
@ -43,8 +43,6 @@ matomo = "4.3"
|
||||
# Serialization
|
||||
serialization = "1.7.1"
|
||||
|
||||
navigationCommonKtx = "2.8.2"
|
||||
navigationRuntimeKtx = "2.8.2"
|
||||
navigationCompose = "2.8.2"
|
||||
|
||||
|
||||
@ -82,9 +80,12 @@ material = { group = "com.google.android.material", name = "material", version.r
|
||||
# Matomo
|
||||
matomo = { module = "com.github.matomo-org:matomo-sdk-android", version.ref = "matomo" }
|
||||
|
||||
# Kotlin serizalization
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
|
||||
androidx-navigation-common-ktx = { group = "androidx.navigation", name = "navigation-common-ktx", version.ref = "navigationCommonKtx" }
|
||||
androidx-navigation-runtime-ktx = { group = "androidx.navigation", name = "navigation-runtime-ktx", version.ref = "navigationRuntimeKtx" }
|
||||
|
||||
# Compose navigation
|
||||
androidx-navigation-common-ktx = { group = "androidx.navigation", name = "navigation-common-ktx", version.ref = "navigationCompose" }
|
||||
androidx-navigation-runtime-ktx = { group = "androidx.navigation", name = "navigation-runtime-ktx", version.ref = "navigationCompose" }
|
||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
||||
|
||||
# Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user