Skip to content

Commit

Permalink
additional modules, init user
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Aug 4, 2023
1 parent ce504d0 commit c9d7fd8
Show file tree
Hide file tree
Showing 57 changed files with 469 additions and 44 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ plugins {
}

dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))
implementation(project(":core:navigation"))
implementation(project(":core:datastore"))
implementation(project(":core:network"))
implementation(project(":core:user"))
implementation(project(":feature:auth"))
implementation(project(":feature:home"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.stslex.aproselection.controller

import com.stslex.aproselection.core.datastore.AppDataStore
import com.stslex.aproselection.core.network.client.NetworkClient
import com.stslex.aproselection.core.ui.core.Logger
import com.stslex.aproselection.core.core.Logger
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down
8 changes: 1 addition & 7 deletions app/src/main/java/com/stslex/aproselection/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.stslex.aproselection.di

import androidx.navigation.NavHostController
import com.stslex.aproselection.controller.AuthController
import com.stslex.aproselection.controller.AuthControllerImpl
import com.stslex.aproselection.core.ui.navigation.navigator.Navigator
import com.stslex.aproselection.core.ui.navigation.navigator.NavigatorImpl
import com.stslex.aproselection.ui.InitialAppViewModel
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.core.module.dsl.bind
Expand All @@ -15,9 +12,6 @@ val appModule = module {
singleOf(::AuthControllerImpl) { bind<AuthController>() }
}

fun navigationModule(
navHostController: NavHostController
) = module {
single<Navigator> { NavigatorImpl(navHostController) }
val initialAppModule = module {
viewModelOf(::InitialAppViewModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.stslex.aproselection.core.ui.navigation.destination.AppDestination
import com.stslex.aproselection.core.navigation.destination.AppDestination
import com.stslex.aproselection.feature.auth.ui.navigation.authRouter
import com.stslex.aproselection.feature.home.ui.navigation.homeRouter

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/stslex/aproselection/ui/InitialApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import com.stslex.aproselection.core.ui.navigation.destination.AppDestination
import com.stslex.aproselection.core.navigation.destination.AppDestination
import com.stslex.aproselection.navigation.NavigationHost
import org.koin.androidx.compose.koinViewModel

Expand All @@ -23,7 +23,7 @@ fun InitialApp(
viewModel.init()
}

AppDestination
com.stslex.aproselection.core.navigation.destination.AppDestination
.getStartDestination(isInitialAuth)
?.let { destination ->
NavigationHost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.stslex.aproselection.ui

import androidx.lifecycle.viewModelScope
import com.stslex.aproselection.controller.AuthController
import com.stslex.aproselection.core.navigation.destination.NavigationScreen
import com.stslex.aproselection.core.navigation.navigator.Navigator
import com.stslex.aproselection.core.ui.base.BaseViewModel
import com.stslex.aproselection.core.ui.navigation.destination.NavigationScreen
import com.stslex.aproselection.core.ui.navigation.navigator.Navigator
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/stslex/aproselection/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.stslex.aproselection.core.navigation.di.moduleCoreNavigation
import com.stslex.aproselection.core.ui.theme.AppTheme
import com.stslex.aproselection.di.navigationModule
import com.stslex.aproselection.di.initialAppModule
import org.koin.androidx.compose.getKoin

class MainActivity : ComponentActivity() {
Expand All @@ -30,9 +31,11 @@ class MainActivity : ComponentActivity() {
private fun SetupComposeDependencies(
navController: NavHostController
) {
val navModule = navigationModule(navController)
getKoin().loadModules(
listOf(navModule)
listOf(
moduleCoreNavigation(navController),
initialAppModule
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.stslex.aproselection
import android.content.Context
import com.stslex.aproselection.core.datastore.coreDataStoreModule
import com.stslex.aproselection.core.network.di.ModuleCoreNetwork.moduleCoreNetwork
import com.stslex.aproselection.core.ui.navigation.destination.NavigationScreen
import com.stslex.aproselection.core.navigation.destination.NavigationScreen
import com.stslex.aproselection.di.appModule
import com.stslex.aproselection.feature.auth.di.ModuleFeatureAuth.moduleFeatureAuth
import com.stslex.aproselection.feature.home.di.moduleFeatureHome
Expand All @@ -19,7 +19,7 @@ class DiKoinModuleTest : KoinTest {

@Test
fun checkKoinModules() {
val navigator: (screen: NavigationScreen) -> Unit = {}
val navigator: (screen: com.stslex.aproselection.core.navigation.destination.NavigationScreen) -> Unit = {}

koinApplication {

Expand Down
1 change: 1 addition & 0 deletions core/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
5 changes: 5 additions & 0 deletions core/core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins {
id("aproselection.android.library")
}

android.namespace = "com.stslex.aproselection.core.core"
Empty file added core/core/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stslex.aproselection.core.core

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("com.stslex.aproselection.core.core.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stslex.aproselection.core.ui.core
package com.stslex.aproselection.core.core

import android.util.Log

Expand All @@ -18,4 +18,12 @@ object Logger {
throwable,
)
}

fun debug(
message: String,
tag: String? = null,
) {
val currentTag = "$DEFAULT_TAG:${tag.orEmpty()}"
Log.d(currentTag, message)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stslex.aproselection.core.core

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)
}
}
1 change: 1 addition & 0 deletions core/datastore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
android.namespace = "com.stslex.aproselection.core.datastore"

dependencies {
implementation(project(":core:core"))
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.datastore)
}
1 change: 1 addition & 0 deletions core/navigation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
9 changes: 9 additions & 0 deletions core/navigation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("aproselection.android.library")
}

android.namespace = "com.stslex.aproselection.core.navigation"

dependencies {
implementation(project(":core:core"))
}
Empty file.
21 changes: 21 additions & 0 deletions core/navigation/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stslex.aproselection.core.navigation

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("com.stslex.aproselection.core.navigation.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/navigation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stslex.aproselection.core.ui.navigation.destination
package com.stslex.aproselection.core.navigation.destination

sealed class AppArguments {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stslex.aproselection.core.ui.navigation.destination
package com.stslex.aproselection.core.navigation.destination

enum class AppDestination(
vararg val argsNames: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stslex.aproselection.core.ui.navigation.destination
package com.stslex.aproselection.core.navigation.destination

sealed interface NavigationScreen {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stslex.aproselection.core.navigation.di

import androidx.navigation.NavHostController
import com.stslex.aproselection.core.navigation.navigator.Navigator
import com.stslex.aproselection.core.navigation.navigator.NavigatorImpl
import org.koin.core.module.Module
import org.koin.dsl.module

val moduleCoreNavigation: (navHostController: NavHostController) -> Module = { navHostController ->
module {
single<Navigator> {
NavigatorImpl(
navHostController
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.stslex.aproselection.core.ui.navigation.ext
package com.stslex.aproselection.core.navigation.ext

import androidx.navigation.NamedNavArgument
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.stslex.aproselection.core.ui.navigation.destination.AppDestination
import com.stslex.aproselection.core.navigation.destination.AppDestination

object NavExt {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.stslex.aproselection.core.navigation.navigator

import com.stslex.aproselection.core.navigation.destination.NavigationScreen

interface Navigator {

fun navigate(screen: NavigationScreen)
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stslex.aproselection.core.ui.navigation.navigator
package com.stslex.aproselection.core.navigation.navigator

import androidx.navigation.NavHostController
import com.stslex.aproselection.core.ui.navigation.destination.NavigationScreen
import com.stslex.aproselection.core.navigation.destination.NavigationScreen

class NavigatorImpl(
private val navController: NavHostController
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stslex.aproselection.core.navigation

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)
}
}
Loading

0 comments on commit c9d7fd8

Please sign in to comment.