Impl base app navigation
This commit is contained in:
@@ -29,11 +29,6 @@ android {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
val jvm = JavaVersion.toVersion(libs.versions.jvmTarget.get())
|
||||
compileOptions {
|
||||
sourceCompatibility = jvm
|
||||
@@ -42,6 +37,10 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@@ -52,20 +51,29 @@ dependencies {
|
||||
implementation(libs.androidx.activity)
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
|
||||
// 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.okhttp)
|
||||
implementation(libs.retrofit)
|
||||
|
||||
implementation(project(":core:common"))
|
||||
implementation(project(":core:network"))
|
||||
implementation(project(":core:database"))
|
||||
implementation(project(":core:config"))
|
||||
|
||||
implementation(project(":feature:splash"))
|
||||
implementation(project(":feature:schedule"))
|
||||
implementation(project(":feature:progress"))
|
||||
implementation(project(":feature:news"))
|
||||
implementation(projects.core.common)
|
||||
implementation(projects.core.config)
|
||||
implementation(projects.core.navigation)
|
||||
implementation(projects.core.ui)
|
||||
|
||||
implementation(projects.feature.splash)
|
||||
implementation(projects.feature.schedule)
|
||||
implementation(projects.feature.progress)
|
||||
implementation(projects.feature.news)
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:name=".TSUDeskApp"
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
13
app/src/main/java/ru/fincode/tsudesk/App.kt
Normal file
13
app/src/main/java/ru/fincode/tsudesk/App.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package ru.fincode.tsudesk
|
||||
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
const val LOG_DEBUG_TAG = "NETWORK_DEBUG"
|
||||
|
||||
@HiltAndroidApp
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,19 @@
|
||||
package ru.fincode.tsudesk
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.activity.compose.setContent
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.fincode.tsudesk.core.common.model.DataResult
|
||||
import ru.fincode.tsudesk.feature.schedule.domain.model.ScheduleType
|
||||
import ru.fincode.tsudesk.feature.schedule.domain.usecase.GetScheduleUseCase
|
||||
import javax.inject.Inject
|
||||
|
||||
import ru.fincode.tsudesk.ui.TSUDeskApp
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
@Inject
|
||||
lateinit var getScheduleUseCase: GetScheduleUseCase
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
lifecycleScope.launch {
|
||||
getScheduleUseCase(ScheduleType.Group("220631"))
|
||||
.collect { result ->
|
||||
when (result) {
|
||||
is DataResult.Data -> {
|
||||
val src = if (result.refreshedFromNetwork) "NETWORK" else "CACHE"
|
||||
Log.d(LOG_TAG, "FROM $src: ${result.data}")
|
||||
}
|
||||
|
||||
is DataResult.Error -> {
|
||||
Log.e(LOG_TAG, "ERROR: $result")
|
||||
}
|
||||
}
|
||||
}
|
||||
setContent {
|
||||
TSUDeskApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package ru.fincode.tsudesk
|
||||
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
||||
const val LOG_TAG = "NETWORK_DEBUG"
|
||||
|
||||
@HiltAndroidApp
|
||||
class TSUDeskApp : Application() {
|
||||
|
||||
// private val appScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
}
|
||||
}
|
||||
26
app/src/main/java/ru/fincode/tsudesk/ui/TSUDeskApp.kt
Normal file
26
app/src/main/java/ru/fincode/tsudesk/ui/TSUDeskApp.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package ru.fincode.tsudesk.ui
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import ru.fincode.tsudesk.ui.navigation.AppNavHost
|
||||
|
||||
@Composable
|
||||
fun TSUDeskApp() {
|
||||
val navController = rememberNavController()
|
||||
|
||||
MaterialTheme {
|
||||
Surface(
|
||||
modifier = Modifier,
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
AppNavHost(
|
||||
navController = navController,
|
||||
contentPadding = PaddingValues()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package ru.fincode.tsudesk.ui.navigation
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.navigation
|
||||
import ru.fincode.tsudesk.core.navigation.AppRoute
|
||||
import ru.fincode.tsudesk.feature.schedule.ui.navigation.scheduleGraph
|
||||
import ru.fincode.tsudesk.feature.splash.ui.navigation.splashGraph
|
||||
|
||||
@Composable
|
||||
fun AppNavHost(
|
||||
navController: NavHostController,
|
||||
contentPadding: PaddingValues
|
||||
) {
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = AppRoute.Splash
|
||||
) {
|
||||
splashGraph(navController)
|
||||
|
||||
navigation<AppRoute.Main>(
|
||||
startDestination = AppRoute.Schedule
|
||||
) {
|
||||
scheduleGraph(navController)
|
||||
// newsGraph(navController)
|
||||
// progressGraph(navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user