Skip to content

Commit

Permalink
di 모듈 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
hsgo2430 committed Mar 31, 2024
1 parent d511ffe commit bef2140
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
apply("kotlin-kapt")
}
extensions.configure<ApplicationExtension> {
configureAndroidCompose(this)
Expand Down
5 changes: 5 additions & 0 deletions business/KoinBusinessApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import android.app.Application

@HiltAndroidApp
class KoinBusinessApplication: Application() {
}
5 changes: 4 additions & 1 deletion business/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import `in`.koreatech.convention.kapt

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.koin.compose)
Expand Down Expand Up @@ -34,7 +36,8 @@ dependencies {
implementation(libs.orbit.core)
implementation(libs.orbit.viewmodel)
implementation(libs.hilt.android)
implementation(libs.hilt.compiler)
implementation(libs.hilt.compose)
kapt(libs.hilt.compiler)
implementation(project(mapOf("path" to ":domain")))
implementation(project(mapOf("path" to ":data")))
implementation(project(mapOf("path" to ":core")))
Expand Down
4 changes: 2 additions & 2 deletions business/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.koreatech.business"
>

<application>
<application
android:name=".KoinBusinessApplication">
<activity
android:name=".SplashActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package `in`.koreatech.business

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class KoinBusinessApplication : Application()
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package `in`.koreatech.business.di.network

import `in`.koreatech.koin.core.qualifier.Auth
import `in`.koreatech.koin.core.qualifier.ServerUrl
import `in`.koreatech.koin.data.api.auth.UserAuthApi
import `in`.koreatech.koin.data.source.local.TokenLocalDataSource
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.business.util.RefreshTokenInterceptor
import `in`.koreatech.koin.core.qualifier.Auth
import `in`.koreatech.koin.core.qualifier.OwnerAuth
import `in`.koreatech.koin.core.qualifier.PreSignedUrl
import javax.inject.Singleton
import `in`.koreatech.koin.core.qualifier.REFRESH
import `in`.koreatech.koin.core.qualifier.ServerUrl
import `in`.koreatech.koin.data.api.PreSignedUrlApi
import `in`.koreatech.koin.data.api.UploadUrlApi
import `in`.koreatech.koin.data.api.UserApi
import `in`.koreatech.koin.data.api.auth.UserAuthApi
import `in`.koreatech.koin.data.source.local.TokenLocalDataSource
import kotlinx.coroutines.runBlocking
import okhttp3.Interceptor
import okhttp3.OkHttpClient
Expand All @@ -25,7 +22,6 @@ import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.business.R
Expand All @@ -54,7 +55,7 @@ fun PasswordAuthenticationScreen(
modifier: Modifier = Modifier,
onAuthenticationButtonClicked: () -> Unit,
onBackPressed: () -> Unit,
viewModel: PasswordAuthenticationViewModel = viewModel()
viewModel: PasswordAuthenticationViewModel = hiltViewModel()
) {
val state = viewModel.collectAsState().value
val context = LocalContext.current
Expand Down Expand Up @@ -165,7 +166,7 @@ fun PasswordAuthenticationScreen(
)

Button(
onClick = { /*viewModel.sendAuthCode(state.email)*/ },
onClick = { viewModel.sendAuthCode(state.email) },
shape = RectangleShape,
colors = ButtonDefaults.buttonColors(ColorPrimary),
contentPadding = PaddingValues(1.dp),
Expand Down
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'org.jetbrains.kotlin.android'
}

android {
Expand Down Expand Up @@ -46,6 +47,7 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:+'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.di
package `in`.koreatech.koin.core.di

import dagger.Module
import dagger.Provides
Expand Down
1 change: 1 addition & 0 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ android {

dependencies {
implementation project(':domain')
implementation project(':core')
implementation libs.core.ktx
implementation libs.kotlinx.coroutines.android

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.di.error
package `in`.koreatech.koin.data.di.error

import `in`.koreatech.koin.data.error.BusErrorHandlerImpl
import `in`.koreatech.koin.data.error.DeptErrorHandlerImpl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package `in`.koreatech.koin.di.network
package `in`.koreatech.koin.data.di.network

import `in`.koreatech.koin.core.qualifier.ServerUrl
import `in`.koreatech.koin.data.constant.URLConstant
import `in`.koreatech.koin.util.ext.isDebug
import android.content.Context
import android.util.Log
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.koin.data.BuildConfig
//import `in`.koreatech.koin.domain.util.ext.isDebug
import javax.inject.Singleton
import okhttp3.logging.HttpLoggingInterceptor

Expand All @@ -19,9 +20,9 @@ object NetworkModule {
@Provides
@Singleton
fun provideHttpLoggingInterceptor(
@ApplicationContext applicationContext: Context

) = HttpLoggingInterceptor().apply {
level = if (applicationContext.isDebug) {
level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.HEADERS
Expand All @@ -32,12 +33,12 @@ object NetworkModule {
@Provides
@Singleton
fun provideServerUrl(
@ApplicationContext applicationContext: Context

): String {
return if (applicationContext.isDebug) {
return if (BuildConfig.DEBUG) {
URLConstant.BASE_URL_STAGE
} else {
URLConstant.BASE_URL_PRODUCTION
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.di.network
package `in`.koreatech.koin.data.di.network

import `in`.koreatech.koin.core.qualifier.Auth
import `in`.koreatech.koin.core.qualifier.NoAuth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.di.repository
package `in`.koreatech.koin.data.di.repository

import `in`.koreatech.koin.data.repository.*
import `in`.koreatech.koin.domain.repository.*
Expand Down Expand Up @@ -129,7 +129,7 @@ object RepositoryModule {
): StoreRepository {
return StoreRepositoryImpl(storeRemoteDataSource)
}

@Provides
@Singleton
fun provideLandRepository(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package `in`.koreatech.koin.di.source
package `in`.koreatech.koin.data.di.source

import `in`.koreatech.koin.data.source.local.*
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.koin.core.qualifier.IoDispatcher
import `in`.koreatech.koin.data.source.local.BusLocalDataSource
import `in`.koreatech.koin.data.source.local.DeptLocalDataSource
import `in`.koreatech.koin.data.source.local.SignupTermsLocalDataSource
import `in`.koreatech.koin.data.source.local.TokenLocalDataSource
import `in`.koreatech.koin.data.source.local.VersionLocalDataSource
import kotlinx.coroutines.CoroutineDispatcher
import javax.inject.Singleton

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.di.source
package `in`.koreatech.koin.data.di.source

import `in`.koreatech.koin.data.api.*
import `in`.koreatech.koin.data.api.auth.UserAuthApi
Expand Down Expand Up @@ -76,7 +76,7 @@ object RemoteDataSourceModule {
): StoreRemoteDataSource {
return StoreRemoteDataSource(storeApi)
}

@Provides
@Singleton
fun provideLandRemoteDataSource(
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ butterknifeVersion = "10.1.0"
googleServiceVersion = "4.3.14"
composeNavigationVersion = "2.7.7"
orbitVersion="7.0.1"
hiltComposeVersion="1.0.0"

[libraries]
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activityKtxVersion" }
Expand Down Expand Up @@ -121,6 +122,8 @@ orbit-core = {module= "org.orbit-mvi:orbit-core", version.ref = "orbitVersion"}
orbit-viewmodel = {module= "org.orbit-mvi:orbit-viewmodel", version.ref = "orbitVersion"}
orbit-compose = {module= "org.orbit-mvi:orbit-compose", version.ref = "orbitVersion"}

hilt-compose= {module= "androidx.hilt:hilt-navigation-compose", version.ref = "hiltComposeVersion"}

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradleVersion" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
Expand Down
1 change: 1 addition & 0 deletions koin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'com.google.firebase.crashlytics'
id 'com.google.firebase.appdistribution'
id 'com.google.dagger.hilt.android'
id 'org.jetbrains.kotlin.android'
}

def applicationName = 'koin'
Expand Down

0 comments on commit bef2140

Please sign in to comment.