Impl base app navigation
This commit is contained in:
@@ -8,10 +8,6 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace = "ru.fincode.tsudesk.feature.splash"
|
||||
buildFeatures { compose = true }
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtension.get()
|
||||
}
|
||||
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.minSdk.get().toInt()
|
||||
@@ -35,6 +31,10 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@@ -43,17 +43,24 @@ dependencies {
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.material)
|
||||
|
||||
// Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.runtime)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
|
||||
// Navigation Compose
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
implementation(libs.androidx.navigation.common)
|
||||
|
||||
kapt(libs.hilt.compiler)
|
||||
implementation(libs.hilt.android)
|
||||
implementation(libs.hilt.navigation.compose)
|
||||
|
||||
implementation(project(":core:network"))
|
||||
implementation(project(":core:common"))
|
||||
implementation(project(":core:config"))
|
||||
implementation(project(":core:ui"))
|
||||
implementation(projects.core.network)
|
||||
implementation(projects.core.common)
|
||||
implementation(projects.core.config)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.navigation)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package ru.fincode.tsudesk.feature.splash
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("ru.fincode.tsudesk.feature.splash.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -7,15 +7,18 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
|
||||
@Composable
|
||||
fun SplashRoute(
|
||||
onOpenMain: () -> Unit, vm: SplashViewModel = hiltViewModel()
|
||||
onFinish: () -> Unit,
|
||||
viewModel: SplashViewModel = hiltViewModel()
|
||||
) {
|
||||
val state = vm.state.collectAsStateWithLifecycle().value
|
||||
SplashScreen(state)
|
||||
LaunchedEffect(vm) {
|
||||
vm.effects.collect { effect ->
|
||||
val state = viewModel.state.collectAsStateWithLifecycle().value
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.effects.collect { effect ->
|
||||
when (effect) {
|
||||
SplashEffect.OpenMain -> onOpenMain()
|
||||
SplashEffect.OpenMain -> onFinish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SplashScreen(state = state)
|
||||
}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
package ru.fincode.tsudesk.feature.splash.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun SplashScreen(state: SplashUiState) {
|
||||
fun SplashScreen(
|
||||
state: SplashUiState
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
if (state.isLoading) {
|
||||
Spacer(Modifier.height(16.dp))
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = state.title,
|
||||
color = Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.fincode.tsudesk.feature.splash.ui
|
||||
|
||||
data class SplashUiState(
|
||||
val title: String = "TSUDesk",
|
||||
val isLoading: Boolean = true,
|
||||
val errorMessage: String? = null
|
||||
)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package ru.fincode.tsudesk.feature.splash.ui.navigation
|
||||
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.composable
|
||||
import ru.fincode.tsudesk.core.navigation.AppRoute
|
||||
import ru.fincode.tsudesk.feature.splash.ui.SplashRoute
|
||||
|
||||
fun NavGraphBuilder.splashGraph(
|
||||
navController: NavHostController
|
||||
) {
|
||||
composable<AppRoute.Splash> {
|
||||
SplashRoute(
|
||||
onFinish = {
|
||||
navController.navigate(AppRoute.Main) {
|
||||
popUpTo(AppRoute.Splash) { inclusive = true }
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package ru.fincode.tsudesk.feature.splash
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user