Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #8

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4,6 +4,7 @@ import android.app.Application
import com.stslex.aproselection.controller.AuthController
import com.stslex.aproselection.core.datastore.coreDataStoreModule
import com.stslex.aproselection.core.network.di.ModuleCoreNetwork.moduleCoreNetwork
import com.stslex.aproselection.core.user.di.moduleCoreUser
import com.stslex.aproselection.di.appModule
import com.stslex.aproselection.feature.auth.di.ModuleFeatureAuth.moduleFeatureAuth
import com.stslex.aproselection.feature.home.di.moduleFeatureHome
Expand Down Expand Up @@ -33,6 +34,7 @@ class SelectApplication : Application() {
modules(
appModule,
moduleCoreNetwork,
moduleCoreUser,
coreDataStoreModule,
moduleFeatureAuth,
moduleFeatureHome,
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
* Configure Compose-specific options
*/
internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *>,
commonExtension: CommonExtension<*, *, *, *, *>,
) {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
* Configure base Kotlin with Android options
*/
internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *>,
commonExtension: CommonExtension<*, *, *, *, *>,
) {
commonExtension.apply {

Expand Down Expand Up @@ -64,7 +64,7 @@ internal fun Project.configureKotlinAndroid(
}
}

private fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
private fun CommonExtension<*, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}

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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ interface AppDataStore {
suspend fun setUuid(uuid: String)

suspend fun setToken(token: String)

suspend fun clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ class AppDataStoreImpl(
}
}
}

override suspend fun clear() {
setUuid("")
setToken("")
}
}
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
Loading
Loading