Skip to content

Commit

Permalink
Merge pull request #79 from stslex/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
stslex authored May 21, 2024
2 parents d5e4516 + 8ed4ea9 commit bc67fcf
Show file tree
Hide file tree
Showing 175 changed files with 1,661 additions and 2,999 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
plugins {
id("csplashscreen.android.application")
id("csplashscreen.android.application.compose")
alias(libs.plugins.convention.application)
alias(libs.plugins.convention.application.compose)
}

dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))
implementation(project(":core:database"))

implementation(project(":core:collection"))
implementation(project(":core:navigation"))
Expand Down
33 changes: 17 additions & 16 deletions app/src/main/java/st/slex/csplashscreen/SplashApplication.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package st.slex.csplashscreen

import android.app.Application
import st.slex.csplashscreen.core.core.api.AppApi
import st.slex.csplashscreen.core.core.api.ApplicationApiProvider
import st.slex.csplashscreen.di.app.AppComponent
import st.slex.csplashscreen.di.app.DaggerAppComponent
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.GlobalContext.startKoin
import org.koin.core.logger.Level
import st.slex.csplashscreen.di.AppModules

class SplashApplication : Application(), ApplicationApiProvider {

private val appComponent: AppComponent by lazy {
DaggerAppComponent
.builder()
.context(this)
.build()
}

override val appApi: AppApi
get() = appComponent
class SplashApplication : Application() {

override fun onCreate() {
appComponent.inject(this)
super.onCreate()
initKoin()
}

private fun initKoin() {
startKoin {
androidLogger(
level = if (BuildConfig.DEBUG) Level.ERROR else Level.NONE
)
androidContext(this@SplashApplication)
modules(AppModules)
}
}
}
37 changes: 37 additions & 0 deletions app/src/main/java/st/slex/csplashscreen/di/AppComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package st.slex.csplashscreen.di

import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.dsl.module
import st.slex.csplashscreen.core.collection.di.moduleCoreCollection
import st.slex.csplashscreen.core.core.di.moduleCore
import st.slex.csplashscreen.core.database.di.moduleCoreDatabase
import st.slex.csplashscreen.core.favourite.di.moduleCoreFavourite
import st.slex.csplashscreen.core.network.di.moduleCoreNetwork
import st.slex.csplashscreen.core.photos.di.moduleCorePhotos
import st.slex.csplashscreen.feature.collection.di.moduleFeatureSingleCollection
import st.slex.csplashscreen.feature.favourite.di.moduleFeatureFavourite
import st.slex.csplashscreen.feature.feature_photo_detail.di.moduleFeatureImageDetail
import st.slex.csplashscreen.feature.home.di.moduleFeatureHome
import st.slex.csplashscreen.feature.search.di.moduleFeatureSearchPhotos
import st.slex.csplashscreen.feature.user.di.moduleFeatureUser
import st.slex.csplashscreen.ui.InitialAppViewModel

internal val appModule = module {
viewModelOf(::InitialAppViewModel)
}

val AppModules = listOf(
appModule,
moduleCore,
moduleCoreCollection,
moduleCoreDatabase,
moduleCoreFavourite,
moduleCoreNetwork,
moduleCorePhotos,
moduleFeatureSingleCollection,
moduleFeatureFavourite,
moduleFeatureHome,
moduleFeatureImageDetail,
moduleFeatureSearchPhotos,
moduleFeatureUser
)
24 changes: 0 additions & 24 deletions app/src/main/java/st/slex/csplashscreen/di/app/AppComponent.kt

This file was deleted.

15 changes: 0 additions & 15 deletions app/src/main/java/st/slex/csplashscreen/di/app/AppModule.kt

This file was deleted.

38 changes: 0 additions & 38 deletions app/src/main/java/st/slex/csplashscreen/di/main/MainComponent.kt

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions app/src/main/java/st/slex/csplashscreen/di/main/MainModule.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package st.slex.csplashscreen.ui
import androidx.lifecycle.ViewModel
import st.slex.csplashscreen.core.navigation.navigator.NavigationTarget
import st.slex.csplashscreen.core.navigation.navigator.Navigator
import javax.inject.Inject

class InitialAppViewModel @Inject constructor(
class InitialAppViewModel(
private val navigator: Navigator
) : ViewModel() {

Expand Down
35 changes: 16 additions & 19 deletions app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@ import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.core.view.WindowCompat
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import st.slex.csplashscreen.core.ui.base.daggerViewModel
import st.slex.csplashscreen.core.ui.di.MainUiApi
import st.slex.csplashscreen.core.ui.di.MainUiProvider
import org.koin.androidx.compose.getKoin
import org.koin.androidx.compose.koinViewModel
import st.slex.csplashscreen.core.navigation.di.moduleCoreNavigation
import st.slex.csplashscreen.core.ui.theme.AppTheme
import st.slex.csplashscreen.di.main.buildMainUIApi

class MainActivity : ComponentActivity(), MainUiProvider {

private var _api: MainUiApi? = null
override val api: MainUiApi
get() = requireNotNull(_api)
class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
AppTheme {
val viewModel = buildViewModel()
val navHostController = rememberNavController()
SetupComposeDependencies(navHostController)

val viewModel = koinViewModel<InitialAppViewModel>()
InitialApp(
/*TODO AFTER reconfiguration controller in VM don't change it State,
so it need to have latest instance.
Need Research to find more efficient way */
navController = api.navigator.controller,
navController = navHostController,
onBottomAppBarClick = remember {
{ viewModel.navigate(it) }
}
Expand All @@ -41,14 +39,13 @@ class MainActivity : ComponentActivity(), MainUiProvider {
}

@Composable
private fun buildViewModel(): InitialAppViewModel {
val navHostController = rememberNavController()
val component = buildMainUIApi(
navHostController = navHostController
private fun SetupComposeDependencies(
navController: NavHostController
) {
getKoin().loadModules(
listOf(
moduleCoreNavigation(navController),
)
)
_api = component
return daggerViewModel {
component.viewModelFactory
}
}
}
Loading

0 comments on commit bc67fcf

Please sign in to comment.