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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import com.android.build.api.dsl.LibraryExtension
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.hilt) apply false
|
||||
alias(libs.plugins.kotlin.kapt) apply false
|
||||
@@ -5,4 +8,22 @@ plugins {
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
plugins.withId("com.android.application") {
|
||||
extensions.configure<ApplicationExtension> {
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtension.get()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("com.android.library") {
|
||||
extensions.configure<LibraryExtension> {
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtension.get()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -22,6 +22,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@@ -30,9 +33,8 @@ dependencies {
|
||||
kapt(libs.hilt.compiler)
|
||||
implementation(libs.hilt.android)
|
||||
|
||||
// Kotlin Serialization
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
|
||||
implementation(project(":core:network"))
|
||||
implementation(project(":core:common"))
|
||||
implementation(projects.core.network)
|
||||
implementation(projects.core.common)
|
||||
}
|
||||
@@ -29,6 +29,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
|
||||
47
core/navigation/build.gradle.kts
Normal file
47
core/navigation/build.gradle.kts
Normal file
@@ -0,0 +1,47 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ru.fincode.tsudesk.core.navigation"
|
||||
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.minSdk.get().toInt()
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val jvm = JavaVersion.toVersion(libs.versions.jvmTarget.get())
|
||||
compileOptions {
|
||||
sourceCompatibility = jvm
|
||||
targetCompatibility = jvm
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
// Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.runtime)
|
||||
// Navigation Compose
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
implementation(libs.androidx.navigation.common)
|
||||
|
||||
implementation(projects.core.ui)
|
||||
}
|
||||
0
core/navigation/consumer-rules.pro
Normal file
0
core/navigation/consumer-rules.pro
Normal file
21
core/navigation/proguard-rules.pro
vendored
Normal file
21
core/navigation/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,37 @@
|
||||
package ru.fincode.tsudesk.core.navigation
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface AppRoute {
|
||||
|
||||
@Serializable
|
||||
data object Splash : AppRoute
|
||||
|
||||
/**
|
||||
* Root-граф приложения после сплеша.
|
||||
* Внутри него лежат табы: Schedule/News/Progress.
|
||||
*/
|
||||
@Serializable
|
||||
data object Main : AppRoute
|
||||
|
||||
// Tabs
|
||||
@Serializable
|
||||
data object Schedule : AppRoute
|
||||
|
||||
@Serializable
|
||||
data object News : AppRoute
|
||||
|
||||
@Serializable
|
||||
data object Progress : AppRoute
|
||||
|
||||
@Serializable
|
||||
data class ScheduleDetails(
|
||||
val lessonId: Long
|
||||
) : AppRoute
|
||||
|
||||
@Serializable
|
||||
data class NewsDetails(
|
||||
val id: String
|
||||
) : AppRoute
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package ru.fincode.tsudesk.core.navigation
|
||||
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
import androidx.navigation.toRoute
|
||||
|
||||
inline fun <reified T : AppRoute> NavBackStackEntry.route(): T = toRoute()
|
||||
@@ -0,0 +1,28 @@
|
||||
package ru.fincode.tsudesk.core.navigation
|
||||
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
import androidx.navigation.NavOptionsBuilder
|
||||
|
||||
|
||||
fun NavController.navigateToTopLevel(destination: TopLevelDestination) {
|
||||
val route = destination.toRoute()
|
||||
navigate(route) {
|
||||
popUpTo(graph.findStartDestination().id) {
|
||||
saveState = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
}
|
||||
|
||||
fun NavController.navigateRoute(
|
||||
route: AppRoute,
|
||||
builder: (NavOptionsBuilder.() -> Unit)? = null
|
||||
) {
|
||||
if (builder == null) {
|
||||
navigate(route)
|
||||
} else {
|
||||
navigate(route, builder)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package ru.fincode.tsudesk.core.navigation
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class TopLevelDestination {
|
||||
SCHEDULE,
|
||||
NEWS,
|
||||
PROGRESS
|
||||
}
|
||||
|
||||
fun TopLevelDestination.toRoute(): AppRoute = when (this) {
|
||||
TopLevelDestination.SCHEDULE -> AppRoute.Schedule
|
||||
TopLevelDestination.NEWS -> AppRoute.News
|
||||
TopLevelDestination.PROGRESS -> AppRoute.Progress
|
||||
}
|
||||
|
||||
val TOP_LEVEL_DESTINATIONS: List<TopLevelDestination> = listOf(
|
||||
TopLevelDestination.SCHEDULE,
|
||||
TopLevelDestination.NEWS,
|
||||
TopLevelDestination.PROGRESS
|
||||
)
|
||||
@@ -13,9 +13,6 @@ android {
|
||||
minSdk = libs.versions.minSdk.get().toInt()
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
@@ -33,6 +30,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@@ -51,5 +51,5 @@ dependencies {
|
||||
api(libs.moshiKotlin)
|
||||
api(libs.retrofitMoshi)
|
||||
|
||||
implementation(project(":core:common"))
|
||||
implementation(projects.core.common)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import okhttp3.Response
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
private const val TAG = "NETWORK_DEBUG"
|
||||
private const val LOG_DEBUG_TAG = "LOG_DEBUG_TAG"
|
||||
|
||||
@Singleton
|
||||
class DebugInterceptor @Inject constructor() : Interceptor {
|
||||
@@ -14,8 +14,8 @@ class DebugInterceptor @Inject constructor() : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
|
||||
Log.d(TAG, "URL: ${request.url}")
|
||||
Log.d(TAG, "Method: ${request.method}")
|
||||
Log.d(LOG_DEBUG_TAG, "URL: ${request.url}")
|
||||
Log.d(LOG_DEBUG_TAG, "Method: ${request.method}")
|
||||
|
||||
return chain.proceed(request)
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ import okhttp3.EventListener
|
||||
import java.io.IOException
|
||||
import java.net.InetAddress
|
||||
|
||||
private const val LOG_TAG = "NETWORK_DEBUG"
|
||||
private const val LOG_DEBUG_TAG = "LOG_DEBUG_TAG"
|
||||
|
||||
class NetEventLogger : EventListener() {
|
||||
override fun dnsStart(call: Call, domainName: String) {
|
||||
Log.d(LOG_TAG, "dnsStart: $domainName")
|
||||
Log.d(LOG_DEBUG_TAG, "dnsStart: $domainName")
|
||||
}
|
||||
|
||||
override fun dnsEnd(call: Call, domainName: String, inetAddressList: List<InetAddress>) {
|
||||
Log.d(LOG_TAG, "dnsEnd: $domainName -> $inetAddressList")
|
||||
Log.d(LOG_DEBUG_TAG, "dnsEnd: $domainName -> $inetAddressList")
|
||||
}
|
||||
|
||||
override fun connectStart(
|
||||
@@ -22,30 +22,30 @@ class NetEventLogger : EventListener() {
|
||||
inetSocketAddress: java.net.InetSocketAddress,
|
||||
proxy: java.net.Proxy
|
||||
) {
|
||||
Log.d(LOG_TAG, "connectStart: $inetSocketAddress proxy=$proxy")
|
||||
Log.d(LOG_DEBUG_TAG, "connectStart: $inetSocketAddress proxy=$proxy")
|
||||
}
|
||||
|
||||
override fun secureConnectStart(call: Call) {
|
||||
Log.d(LOG_TAG, "tlsStart")
|
||||
Log.d(LOG_DEBUG_TAG, "tlsStart")
|
||||
}
|
||||
|
||||
override fun secureConnectEnd(call: Call, handshake: okhttp3.Handshake?) {
|
||||
Log.d(LOG_TAG, "tlsEnd: $handshake")
|
||||
Log.d(LOG_DEBUG_TAG, "tlsEnd: $handshake")
|
||||
}
|
||||
|
||||
override fun requestHeadersStart(call: Call) {
|
||||
Log.d(LOG_TAG, "reqHeadersStart")
|
||||
Log.d(LOG_DEBUG_TAG, "reqHeadersStart")
|
||||
}
|
||||
|
||||
override fun responseHeadersStart(call: Call) {
|
||||
Log.d(LOG_TAG, "respHeadersStart")
|
||||
Log.d(LOG_DEBUG_TAG, "respHeadersStart")
|
||||
}
|
||||
|
||||
override fun callFailed(call: Call, ioe: IOException) {
|
||||
Log.e(LOG_TAG, "callFailed", ioe)
|
||||
Log.e(LOG_DEBUG_TAG, "callFailed", ioe)
|
||||
}
|
||||
|
||||
override fun callEnd(call: Call) {
|
||||
Log.d(LOG_TAG, "callEnd")
|
||||
Log.d(LOG_DEBUG_TAG, "callEnd")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation(libs.core.ktx)
|
||||
|
||||
@@ -31,7 +31,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation(libs.core.ktx)
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -32,6 +32,10 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@@ -40,10 +44,25 @@ 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:database"))
|
||||
implementation(project(":core:common"))
|
||||
implementation(projects.core.network)
|
||||
implementation(projects.core.database)
|
||||
implementation(projects.core.common)
|
||||
implementation(projects.core.config)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.navigation)
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,22 @@
|
||||
package ru.fincode.tsudesk.feature.schedule.presentation.ui
|
||||
|
||||
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
|
||||
|
||||
@Composable
|
||||
fun ScheduleScreen() {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = "Schedule",
|
||||
color = Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package ru.fincode.tsudesk.feature.schedule.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.schedule.presentation.ui.ScheduleScreen
|
||||
|
||||
fun NavGraphBuilder.scheduleGraph(
|
||||
navController: NavHostController
|
||||
) {
|
||||
composable<AppRoute.Schedule> {
|
||||
ScheduleScreen()
|
||||
}
|
||||
|
||||
// регистрация экрана детальной информации о занятии
|
||||
// composable<AppRoute.ScheduleDetails> { backStackEntry ->
|
||||
// // val args = backStackEntry.toRoute<AppRoute.ScheduleDetails>()
|
||||
// // ScheduleDetailsRoute(lessonId = args.lessonId)
|
||||
// }
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ activity = "1.8.0"
|
||||
constraintlayout = "2.1.4"
|
||||
compose-bom = "2024.10.00"
|
||||
hilt-nav-compose = "1.2.0"
|
||||
navigation = "2.8.5"
|
||||
|
||||
hilt = "2.50"
|
||||
retrofit = "2.11.0"
|
||||
@@ -28,9 +29,6 @@ lifecycle = "2.7.0"
|
||||
coroutines = "1.8.1"
|
||||
|
||||
room = "2.6.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
|
||||
[libraries]
|
||||
# Android
|
||||
@@ -42,12 +40,15 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
|
||||
hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-nav-compose" }
|
||||
# Compose UI
|
||||
compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
|
||||
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-nav-compose" }
|
||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" }
|
||||
androidx-navigation-common = { group = "androidx.navigation", name = "navigation-common-ktx", version.ref = "navigation" }
|
||||
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
|
||||
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
|
||||
# Network: okhhtp3+retrofit2
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
|
||||
@@ -65,9 +66,6 @@ core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx"
|
||||
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
|
||||
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
|
||||
[plugins]
|
||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
||||
|
||||
@@ -18,13 +18,14 @@ dependencyResolutionManagement {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
rootProject.name = "TSUDesk"
|
||||
include(":app")
|
||||
|
||||
include(":core:common")
|
||||
include(":core:ui")
|
||||
include(":core:navigation")
|
||||
include(":core:network")
|
||||
include(":core:database")
|
||||
include(":core:config")
|
||||
|
||||
Reference in New Issue
Block a user