diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index da24855..7564fd7 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -5,6 +5,8 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
+ alias(libs.plugins.hilt.android)
+ id("kotlin-kapt")
}
val properties = Properties().apply {
@@ -46,6 +48,9 @@ android {
compose = true
buildConfig = true
}
+ hilt {
+ enableAggregatingTask = false
+ }
}
dependencies {
@@ -75,4 +80,9 @@ dependencies {
implementation(libs.retrofit)
implementation(libs.retrofit.kotlin.serialization.converter)
implementation(libs.kotlinx.serialization.json)
+
+ // Hilt
+ implementation(libs.hilt.android)
+ implementation(libs.hilt.navigation.compose)
+ kapt(libs.hilt.compiler)
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e4c2eb1..5595fef 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,6 +5,7 @@
create(): T = retrofit.create(T::class.java)
-}
-
-object ServicePool {
- val authService = ApiFactory.create()
-}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/component/AutoSlidingRow.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/AutoSlidingRow.kt
similarity index 98%
rename from app/src/main/java/org/sopt/and/component/AutoSlidingRow.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/AutoSlidingRow.kt
index af0d530..005e55d 100644
--- a/app/src/main/java/org/sopt/and/component/AutoSlidingRow.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/AutoSlidingRow.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
diff --git a/app/src/main/java/org/sopt/and/component/HomeRowItemTitle.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/HomeRowItemTitle.kt
similarity index 96%
rename from app/src/main/java/org/sopt/and/component/HomeRowItemTitle.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/HomeRowItemTitle.kt
index 327c469..cc22e91 100644
--- a/app/src/main/java/org/sopt/and/component/HomeRowItemTitle.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/HomeRowItemTitle.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
diff --git a/app/src/main/java/org/sopt/and/component/MyPageItem.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/MyPageItem.kt
similarity index 98%
rename from app/src/main/java/org/sopt/and/component/MyPageItem.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/MyPageItem.kt
index 15f9011..8300697 100644
--- a/app/src/main/java/org/sopt/and/component/MyPageItem.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/MyPageItem.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
diff --git a/app/src/main/java/org/sopt/and/component/RecommendationRow.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/RecommendationRow.kt
similarity index 96%
rename from app/src/main/java/org/sopt/and/component/RecommendationRow.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/RecommendationRow.kt
index 18548b4..a12001e 100644
--- a/app/src/main/java/org/sopt/and/component/RecommendationRow.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/RecommendationRow.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
diff --git a/app/src/main/java/org/sopt/and/component/SocialLoginItem.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/SocialLoginItem.kt
similarity index 96%
rename from app/src/main/java/org/sopt/and/component/SocialLoginItem.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/SocialLoginItem.kt
index 713ed4e..118e8c6 100644
--- a/app/src/main/java/org/sopt/and/component/SocialLoginItem.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/SocialLoginItem.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
diff --git a/app/src/main/java/org/sopt/and/component/TabMenu.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/TabMenu.kt
similarity index 94%
rename from app/src/main/java/org/sopt/and/component/TabMenu.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/TabMenu.kt
index ab28626..e1d6722 100644
--- a/app/src/main/java/org/sopt/and/component/TabMenu.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/TabMenu.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.material3.ScrollableTabRow
import androidx.compose.material3.Tab
@@ -15,7 +15,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.sopt.and.R
-import org.sopt.and.model.TabMenuItem
+import org.sopt.and.feature.model.TabMenuItem
@Composable
fun TabMenu(
diff --git a/app/src/main/java/org/sopt/and/component/TextField.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/TextField.kt
similarity index 98%
rename from app/src/main/java/org/sopt/and/component/TextField.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/TextField.kt
index 996b209..a5de32e 100644
--- a/app/src/main/java/org/sopt/and/component/TextField.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/TextField.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
diff --git a/app/src/main/java/org/sopt/and/component/TodayTop20Row.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/TodayTop20Row.kt
similarity index 98%
rename from app/src/main/java/org/sopt/and/component/TodayTop20Row.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/TodayTop20Row.kt
index 85de8bf..bec3e9c 100644
--- a/app/src/main/java/org/sopt/and/component/TodayTop20Row.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/TodayTop20Row.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
diff --git a/app/src/main/java/org/sopt/and/component/TopBar.kt b/app/src/main/java/org/sopt/and/core/designsystem/component/TopBar.kt
similarity index 98%
rename from app/src/main/java/org/sopt/and/component/TopBar.kt
rename to app/src/main/java/org/sopt/and/core/designsystem/component/TopBar.kt
index 8cd2290..fd585c8 100644
--- a/app/src/main/java/org/sopt/and/component/TopBar.kt
+++ b/app/src/main/java/org/sopt/and/core/designsystem/component/TopBar.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.component
+package org.sopt.and.core.designsystem.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
diff --git a/app/src/main/java/org/sopt/and/utils/KeyStorage.kt b/app/src/main/java/org/sopt/and/core/utils/KeyStorage.kt
similarity index 95%
rename from app/src/main/java/org/sopt/and/utils/KeyStorage.kt
rename to app/src/main/java/org/sopt/and/core/utils/KeyStorage.kt
index 935b4af..e0543d0 100644
--- a/app/src/main/java/org/sopt/and/utils/KeyStorage.kt
+++ b/app/src/main/java/org/sopt/and/core/utils/KeyStorage.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.utils
+package org.sopt.and.core.utils
object KeyStorage {
const val TEXTFIELD_MAX_LENGTH = 8
diff --git a/app/src/main/java/org/sopt/and/utils/ContextExt.kt b/app/src/main/java/org/sopt/and/core/utils/context/ContextExt.kt
similarity index 80%
rename from app/src/main/java/org/sopt/and/utils/ContextExt.kt
rename to app/src/main/java/org/sopt/and/core/utils/context/ContextExt.kt
index 03e60c6..cee25ec 100644
--- a/app/src/main/java/org/sopt/and/utils/ContextExt.kt
+++ b/app/src/main/java/org/sopt/and/core/utils/context/ContextExt.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.utils
+package org.sopt.and.core.utils.context
import android.content.Context
import android.widget.Toast
diff --git a/app/src/main/java/org/sopt/and/utils/ModifierExt.kt b/app/src/main/java/org/sopt/and/core/utils/modifier/ModifierExt.kt
similarity index 92%
rename from app/src/main/java/org/sopt/and/utils/ModifierExt.kt
rename to app/src/main/java/org/sopt/and/core/utils/modifier/ModifierExt.kt
index ea65c41..6210c91 100644
--- a/app/src/main/java/org/sopt/and/utils/ModifierExt.kt
+++ b/app/src/main/java/org/sopt/and/core/utils/modifier/ModifierExt.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.utils
+package org.sopt.and.core.utils.modifier
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
diff --git a/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt
new file mode 100644
index 0000000..029dce9
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt
@@ -0,0 +1,16 @@
+package org.sopt.and.data.datasource
+
+import org.sopt.and.data.dto.request.RequestSignInDto
+import org.sopt.and.data.dto.request.RequestSignUpDto
+import org.sopt.and.data.dto.response.BaseResponse
+import org.sopt.and.data.dto.response.ResponseHobbyDto
+import org.sopt.and.data.dto.response.ResponseSignInDto
+import org.sopt.and.data.dto.response.ResponseSignUpDto
+
+interface AuthDataSource {
+ suspend fun signUp(request: RequestSignUpDto): BaseResponse
+
+ suspend fun signIn(request: RequestSignInDto): BaseResponse
+
+ suspend fun getHobby(request: String): BaseResponse
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt
new file mode 100644
index 0000000..b091768
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt
@@ -0,0 +1,24 @@
+package org.sopt.and.data.datasourceimpl
+
+import org.sopt.and.data.datasource.AuthDataSource
+import org.sopt.and.data.dto.request.RequestSignInDto
+import org.sopt.and.data.dto.request.RequestSignUpDto
+import org.sopt.and.data.dto.response.BaseResponse
+import org.sopt.and.data.dto.response.ResponseHobbyDto
+import org.sopt.and.data.dto.response.ResponseSignInDto
+import org.sopt.and.data.dto.response.ResponseSignUpDto
+import org.sopt.and.data.service.AuthService
+import javax.inject.Inject
+
+class AuthDataSourceImpl @Inject constructor(
+ private val authService: AuthService
+) : AuthDataSource {
+ override suspend fun signUp(request: RequestSignUpDto): BaseResponse =
+ authService.signUp(request)
+
+ override suspend fun signIn(request: RequestSignInDto): BaseResponse =
+ authService.signIn(request)
+
+ override suspend fun getHobby(request: String): BaseResponse =
+ authService.getHobby(request)
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/di/ApiModule.kt b/app/src/main/java/org/sopt/and/data/di/ApiModule.kt
new file mode 100644
index 0000000..1001a0e
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/di/ApiModule.kt
@@ -0,0 +1,19 @@
+package org.sopt.and.data.di
+
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import org.sopt.and.data.service.AuthService
+import retrofit2.Retrofit
+import retrofit2.create
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+object ApiModule {
+ @Provides
+ @Singleton
+ fun provideAuthService(retrofit: Retrofit): AuthService =
+ retrofit.create()
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt b/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt
new file mode 100644
index 0000000..d02cf82
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt
@@ -0,0 +1,17 @@
+package org.sopt.and.data.di
+
+import dagger.Binds
+import dagger.Module
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import org.sopt.and.data.datasource.AuthDataSource
+import org.sopt.and.data.datasourceimpl.AuthDataSourceImpl
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+abstract class DataSourceModule {
+ @Binds
+ @Singleton
+ abstract fun bindsAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt b/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt
new file mode 100644
index 0000000..fcdac55
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt
@@ -0,0 +1,63 @@
+package org.sopt.and.data.di
+
+import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import kotlinx.serialization.ExperimentalSerializationApi
+import kotlinx.serialization.json.Json
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.sopt.and.BuildConfig
+import retrofit2.Retrofit
+import java.util.concurrent.TimeUnit
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+object NetworkModule {
+ @Provides
+ @Singleton
+ fun providesOkHttpClient(
+ loggingInterceptor: HttpLoggingInterceptor,
+ // authInterceptor: Interceptor
+ ): OkHttpClient =
+ OkHttpClient.Builder().apply {
+ connectTimeout(10, TimeUnit.SECONDS)
+ writeTimeout(10, TimeUnit.SECONDS)
+ readTimeout(10, TimeUnit.SECONDS)
+ // addInterceptor(authInterceptor)
+ }.build()
+
+ @Provides
+ @Singleton
+ fun providesJson(): Json =
+ Json {
+ isLenient = true
+ prettyPrint = true
+ explicitNulls = false
+ ignoreUnknownKeys = true
+ }
+
+ @Provides
+ @Singleton
+ fun provideLoggingInterceptor(): HttpLoggingInterceptor = HttpLoggingInterceptor().apply {
+ level = HttpLoggingInterceptor.Level.BODY
+ }
+
+ @ExperimentalSerializationApi
+ @Provides
+ @Singleton
+ fun provideRetrofit(
+ okHttpClient: OkHttpClient,
+ json: Json
+ ): Retrofit {
+ return Retrofit.Builder()
+ .baseUrl(BuildConfig.BASE_URL)
+ .client(okHttpClient)
+ .addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
+ .build()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/di/PreferencesModule.kt b/app/src/main/java/org/sopt/and/data/di/PreferencesModule.kt
new file mode 100644
index 0000000..48028c5
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/di/PreferencesModule.kt
@@ -0,0 +1,22 @@
+package org.sopt.and.data.di
+
+import android.content.Context
+import android.content.SharedPreferences
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+object PreferencesModule {
+ @Provides
+ @Singleton
+ fun provideSharedPreferences(
+ @ApplicationContext context: Context
+ ): SharedPreferences {
+ return context.getSharedPreferences("APP_PREFS", Context.MODE_PRIVATE)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt b/app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt
new file mode 100644
index 0000000..1f37e7f
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt
@@ -0,0 +1,17 @@
+package org.sopt.and.data.di
+
+import dagger.Binds
+import dagger.Module
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import org.sopt.and.data.repositoryimpl.AuthRepositoryImpl
+import org.sopt.and.domain.repository.AuthRepository
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+abstract class RepositoryModule {
+ @Binds
+ @Singleton
+ abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/api/dto/request/RequestSignInDto.kt b/app/src/main/java/org/sopt/and/data/dto/request/RequestSignInDto.kt
similarity index 86%
rename from app/src/main/java/org/sopt/and/api/dto/request/RequestSignInDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/request/RequestSignInDto.kt
index 4a11b4a..77374e9 100644
--- a/app/src/main/java/org/sopt/and/api/dto/request/RequestSignInDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/request/RequestSignInDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.request
+package org.sopt.and.data.dto.request
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/request/RequestSignUpDto.kt b/app/src/main/java/org/sopt/and/data/dto/request/RequestSignUpDto.kt
similarity index 88%
rename from app/src/main/java/org/sopt/and/api/dto/request/RequestSignUpDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/request/RequestSignUpDto.kt
index 3478b5f..5b23a75 100644
--- a/app/src/main/java/org/sopt/and/api/dto/request/RequestSignUpDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/request/RequestSignUpDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.request
+package org.sopt.and.data.dto.request
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/response/BaseResponse.kt b/app/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt
similarity index 81%
rename from app/src/main/java/org/sopt/and/api/dto/response/BaseResponse.kt
rename to app/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt
index 8e7a593..a6e90a1 100644
--- a/app/src/main/java/org/sopt/and/api/dto/response/BaseResponse.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.response
+package org.sopt.and.data.dto.response
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/response/ResponseErrorDto.kt b/app/src/main/java/org/sopt/and/data/dto/response/ResponseErrorDto.kt
similarity index 81%
rename from app/src/main/java/org/sopt/and/api/dto/response/ResponseErrorDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/response/ResponseErrorDto.kt
index 5168749..0f8c86d 100644
--- a/app/src/main/java/org/sopt/and/api/dto/response/ResponseErrorDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/response/ResponseErrorDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.response
+package org.sopt.and.data.dto.response
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/response/ResponseHobbyDto.kt b/app/src/main/java/org/sopt/and/data/dto/response/ResponseHobbyDto.kt
similarity index 81%
rename from app/src/main/java/org/sopt/and/api/dto/response/ResponseHobbyDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/response/ResponseHobbyDto.kt
index 0d86545..9bf461a 100644
--- a/app/src/main/java/org/sopt/and/api/dto/response/ResponseHobbyDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/response/ResponseHobbyDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.response
+package org.sopt.and.data.dto.response
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/response/ResponseSignInDto.kt b/app/src/main/java/org/sopt/and/data/dto/response/ResponseSignInDto.kt
similarity index 81%
rename from app/src/main/java/org/sopt/and/api/dto/response/ResponseSignInDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/response/ResponseSignInDto.kt
index d6668ba..7b1802b 100644
--- a/app/src/main/java/org/sopt/and/api/dto/response/ResponseSignInDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/response/ResponseSignInDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.response
+package org.sopt.and.data.dto.response
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/api/dto/response/ResponseSignUpDto.kt b/app/src/main/java/org/sopt/and/data/dto/response/ResponseSignUpDto.kt
similarity index 81%
rename from app/src/main/java/org/sopt/and/api/dto/response/ResponseSignUpDto.kt
rename to app/src/main/java/org/sopt/and/data/dto/response/ResponseSignUpDto.kt
index 76aaedc..7ab4300 100644
--- a/app/src/main/java/org/sopt/and/api/dto/response/ResponseSignUpDto.kt
+++ b/app/src/main/java/org/sopt/and/data/dto/response/ResponseSignUpDto.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.api.dto.response
+package org.sopt.and.data.dto.response
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
diff --git a/app/src/main/java/org/sopt/and/data/mapper/SignInMapper.kt b/app/src/main/java/org/sopt/and/data/mapper/SignInMapper.kt
new file mode 100644
index 0000000..ee25b48
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/mapper/SignInMapper.kt
@@ -0,0 +1,11 @@
+package org.sopt.and.data.mapper
+
+import org.sopt.and.data.dto.request.RequestSignInDto
+import org.sopt.and.domain.entity.SignInModel
+
+fun SignInModel.toSignInRequest(): RequestSignInDto {
+ return RequestSignInDto(
+ username = this.username,
+ password = this.password
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/mapper/SignUpMapper.kt b/app/src/main/java/org/sopt/and/data/mapper/SignUpMapper.kt
new file mode 100644
index 0000000..ca500bc
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/mapper/SignUpMapper.kt
@@ -0,0 +1,12 @@
+package org.sopt.and.data.mapper
+
+import org.sopt.and.data.dto.request.RequestSignUpDto
+import org.sopt.and.domain.entity.SignUpModel
+
+fun SignUpModel.toSignUpRequest(): RequestSignUpDto {
+ return RequestSignUpDto(
+ username = this.username,
+ password = this.password,
+ hobby = this.hobby
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt
new file mode 100644
index 0000000..b30b8bc
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt
@@ -0,0 +1,31 @@
+package org.sopt.and.data.repositoryimpl
+
+import org.sopt.and.data.datasource.AuthDataSource
+import org.sopt.and.data.mapper.toSignInRequest
+import org.sopt.and.data.mapper.toSignUpRequest
+import org.sopt.and.domain.entity.SignInModel
+import org.sopt.and.domain.entity.SignUpModel
+import org.sopt.and.domain.repository.AuthRepository
+import javax.inject.Inject
+
+class AuthRepositoryImpl @Inject constructor(
+ private val authDataSource: AuthDataSource
+) : AuthRepository {
+ override suspend fun signUp(request: SignUpModel): Result =
+ runCatching {
+ val response = authDataSource.signUp(request.toSignUpRequest())
+ response.result.userNumber
+ }
+
+ override suspend fun signIn(request: SignInModel): Result =
+ runCatching {
+ val response = authDataSource.signIn(request.toSignInRequest())
+ response.result.token
+ }
+
+ override suspend fun getHobby(request: String): Result =
+ runCatching {
+ val response = authDataSource.getHobby(request)
+ response.result.hobby
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/api/service/AuthService.kt b/app/src/main/java/org/sopt/and/data/service/AuthService.kt
similarity index 64%
rename from app/src/main/java/org/sopt/and/api/service/AuthService.kt
rename to app/src/main/java/org/sopt/and/data/service/AuthService.kt
index f6ae38b..5f86c05 100644
--- a/app/src/main/java/org/sopt/and/api/service/AuthService.kt
+++ b/app/src/main/java/org/sopt/and/data/service/AuthService.kt
@@ -1,11 +1,11 @@
-package org.sopt.and.api.service
+package org.sopt.and.data.service
-import org.sopt.and.api.dto.request.RequestSignInDto
-import org.sopt.and.api.dto.request.RequestSignUpDto
-import org.sopt.and.api.dto.response.BaseResponse
-import org.sopt.and.api.dto.response.ResponseHobbyDto
-import org.sopt.and.api.dto.response.ResponseSignInDto
-import org.sopt.and.api.dto.response.ResponseSignUpDto
+import org.sopt.and.data.dto.request.RequestSignInDto
+import org.sopt.and.data.dto.request.RequestSignUpDto
+import org.sopt.and.data.dto.response.BaseResponse
+import org.sopt.and.data.dto.response.ResponseHobbyDto
+import org.sopt.and.data.dto.response.ResponseSignInDto
+import org.sopt.and.data.dto.response.ResponseSignUpDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
diff --git a/app/src/main/java/org/sopt/and/domain/entity/SignInModel.kt b/app/src/main/java/org/sopt/and/domain/entity/SignInModel.kt
new file mode 100644
index 0000000..187267c
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/domain/entity/SignInModel.kt
@@ -0,0 +1,6 @@
+package org.sopt.and.domain.entity
+
+data class SignInModel(
+ val username: String,
+ val password: String
+)
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/domain/entity/SignUpModel.kt b/app/src/main/java/org/sopt/and/domain/entity/SignUpModel.kt
new file mode 100644
index 0000000..fbe2f0c
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/domain/entity/SignUpModel.kt
@@ -0,0 +1,7 @@
+package org.sopt.and.domain.entity
+
+data class SignUpModel(
+ val username: String,
+ val password: String,
+ val hobby: String
+)
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt
new file mode 100644
index 0000000..0865f24
--- /dev/null
+++ b/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt
@@ -0,0 +1,12 @@
+package org.sopt.and.domain.repository
+
+import org.sopt.and.domain.entity.SignInModel
+import org.sopt.and.domain.entity.SignUpModel
+
+interface AuthRepository {
+ suspend fun signUp(request: SignUpModel): Result
+
+ suspend fun signIn(request: SignInModel): Result
+
+ suspend fun getHobby(request: String): Result
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/feature/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/feature/home/HomeScreen.kt
index ce88757..1b36c28 100644
--- a/app/src/main/java/org/sopt/and/feature/home/HomeScreen.kt
+++ b/app/src/main/java/org/sopt/and/feature/home/HomeScreen.kt
@@ -15,11 +15,11 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import org.sopt.and.R
-import org.sopt.and.component.AutoSlidingRow
-import org.sopt.and.component.HomeTopBar
-import org.sopt.and.component.RecommendationRow
-import org.sopt.and.component.TabMenu
-import org.sopt.and.component.TodayTop20Row
+import org.sopt.and.core.designsystem.component.AutoSlidingRow
+import org.sopt.and.core.designsystem.component.HomeTopBar
+import org.sopt.and.core.designsystem.component.RecommendationRow
+import org.sopt.and.core.designsystem.component.TabMenu
+import org.sopt.and.core.designsystem.component.TodayTop20Row
@Composable
fun HomeScreen(
diff --git a/app/src/main/java/org/sopt/and/model/BottomNavItem.kt b/app/src/main/java/org/sopt/and/feature/model/BottomNavItem.kt
similarity index 76%
rename from app/src/main/java/org/sopt/and/model/BottomNavItem.kt
rename to app/src/main/java/org/sopt/and/feature/model/BottomNavItem.kt
index 19bc539..b1806f1 100644
--- a/app/src/main/java/org/sopt/and/model/BottomNavItem.kt
+++ b/app/src/main/java/org/sopt/and/feature/model/BottomNavItem.kt
@@ -1,11 +1,11 @@
-package org.sopt.and.model
+package org.sopt.and.feature.model
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import org.sopt.and.R
-import org.sopt.and.utils.KeyStorage.HOME
-import org.sopt.and.utils.KeyStorage.MY_PAGE
-import org.sopt.and.utils.KeyStorage.SEARCH
+import org.sopt.and.core.utils.KeyStorage.HOME
+import org.sopt.and.core.utils.KeyStorage.MY_PAGE
+import org.sopt.and.core.utils.KeyStorage.SEARCH
enum class BottomNavItem(val route: String, val iconResId: Int) {
Home(HOME, R.drawable.ic_home_24),
diff --git a/app/src/main/java/org/sopt/and/model/TabMenuItem.kt b/app/src/main/java/org/sopt/and/feature/model/TabMenuItem.kt
similarity index 92%
rename from app/src/main/java/org/sopt/and/model/TabMenuItem.kt
rename to app/src/main/java/org/sopt/and/feature/model/TabMenuItem.kt
index 5522e06..7a7d06b 100644
--- a/app/src/main/java/org/sopt/and/model/TabMenuItem.kt
+++ b/app/src/main/java/org/sopt/and/feature/model/TabMenuItem.kt
@@ -1,4 +1,4 @@
-package org.sopt.and.model
+package org.sopt.and.feature.model
import androidx.annotation.StringRes
import org.sopt.and.R
diff --git a/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt b/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt
index 365c4c1..ec9418e 100644
--- a/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt
+++ b/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt
@@ -30,17 +30,17 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import androidx.lifecycle.viewmodel.compose.viewModel
+import androidx.hilt.navigation.compose.hiltViewModel
import org.sopt.and.R
-import org.sopt.and.component.MyPageHistoryItem
-import org.sopt.and.component.MyPagePurchaseItem
-import org.sopt.and.utils.KeyStorage.AUTH_PREFS
-import org.sopt.and.utils.KeyStorage.TOKEN
+import org.sopt.and.core.designsystem.component.MyPageHistoryItem
+import org.sopt.and.core.designsystem.component.MyPagePurchaseItem
+import org.sopt.and.core.utils.KeyStorage.AUTH_PREFS
+import org.sopt.and.core.utils.KeyStorage.TOKEN
@Composable
fun MyPageScreen(
modifier: Modifier = Modifier,
- viewModel: MyPageViewModel = viewModel()
+ viewModel: MyPageViewModel = hiltViewModel()
) {
val context = LocalContext.current
val sharedPreferences = context.getSharedPreferences(AUTH_PREFS, Context.MODE_PRIVATE)
@@ -48,7 +48,9 @@ fun MyPageScreen(
val hobby by viewModel.hobby.collectAsState()
- viewModel.initHobby(token)
+ LaunchedEffect(Unit) {
+ viewModel.initHobby(token)
+ }
Column (
modifier = Modifier
diff --git a/app/src/main/java/org/sopt/and/feature/mypage/MyPageViewModel.kt b/app/src/main/java/org/sopt/and/feature/mypage/MyPageViewModel.kt
index a9f0ff9..8c8f8da 100644
--- a/app/src/main/java/org/sopt/and/feature/mypage/MyPageViewModel.kt
+++ b/app/src/main/java/org/sopt/and/feature/mypage/MyPageViewModel.kt
@@ -1,30 +1,36 @@
package org.sopt.and.feature.mypage
-import android.content.Context
import android.content.SharedPreferences
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import org.sopt.and.R
-import org.sopt.and.api.ServicePool.authService
-import org.sopt.and.api.dto.response.ResponseErrorDto
-import org.sopt.and.utils.KeyStorage.AUTH_PREFS
-import org.sopt.and.utils.KeyStorage.ERROR_CODE_00
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_200
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_401
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_403
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_404
+import org.sopt.and.core.utils.KeyStorage.ERROR_CODE_00
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_200
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_401
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_403
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_404
+import org.sopt.and.core.utils.KeyStorage.TOKEN
+import org.sopt.and.data.dto.response.ResponseErrorDto
+import org.sopt.and.domain.repository.AuthRepository
import retrofit2.HttpException
+import javax.inject.Inject
-class MyPageViewModel : ViewModel() {
+@HiltViewModel
+class MyPageViewModel @Inject constructor(
+ private val authRepository: AuthRepository,
+ private val sharedPreferences: SharedPreferences
+) : ViewModel() {
private val _hobby = MutableStateFlow("")
val hobby: StateFlow get() = _hobby
fun initHobby(token: String) {
+ val token = sharedPreferences.getString(TOKEN, "").orEmpty()
if (token.isNotEmpty()) {
getHobby(token)
}
@@ -32,25 +38,23 @@ class MyPageViewModel : ViewModel() {
private fun getHobby(token: String) {
viewModelScope.launch {
- runCatching {
- authService.getHobby(token)
- }.onSuccess { response ->
- val hobby = response.result.hobby
- if (hobby.isNotEmpty()) {
- _hobby.value = hobby
- } else {
- handleError(STATUS_CODE_200, ERROR_CODE_00)
- }
- }.onFailure { throwable ->
- when (throwable) {
- is HttpException -> {
- val errorBody = throwable.response()?.errorBody()?.string()
- val errorDto = errorBody?.let { Json.decodeFromString(it) }
- val statusCode = throwable.code()
- val errorCode = errorDto?.code.orEmpty()
- handleError(statusCode, errorCode)
+ authRepository.getHobby(token)
+ .onSuccess { hobby ->
+ if (hobby.isNotEmpty()) {
+ _hobby.value = hobby
+ } else {
+ handleError(STATUS_CODE_200, ERROR_CODE_00)
}
- else -> {}
+ }.onFailure { throwable ->
+ when (throwable) {
+ is HttpException -> {
+ val errorBody = throwable.response()?.errorBody()?.string()
+ val errorDto = errorBody?.let { Json.decodeFromString(it) }
+ val statusCode = throwable.code()
+ val errorCode = errorDto?.code.orEmpty()
+ handleError(statusCode, errorCode)
+ }
+ else -> {}
}
}
}
diff --git a/app/src/main/java/org/sopt/and/feature/nav/BottomNavigation.kt b/app/src/main/java/org/sopt/and/feature/nav/BottomNavigation.kt
index 857622a..9f89bb3 100644
--- a/app/src/main/java/org/sopt/and/feature/nav/BottomNavigation.kt
+++ b/app/src/main/java/org/sopt/and/feature/nav/BottomNavigation.kt
@@ -13,7 +13,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.navigation.compose.rememberNavController
import org.sopt.and.R
-import org.sopt.and.model.BottomNavItem
+import org.sopt.and.feature.model.BottomNavItem
@Composable
fun BottomNavigation(
diff --git a/app/src/main/java/org/sopt/and/feature/nav/NavGraph.kt b/app/src/main/java/org/sopt/and/feature/nav/NavGraph.kt
index c2839ce..5813224 100644
--- a/app/src/main/java/org/sopt/and/feature/nav/NavGraph.kt
+++ b/app/src/main/java/org/sopt/and/feature/nav/NavGraph.kt
@@ -2,17 +2,15 @@ package org.sopt.and.feature.nav
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
+import org.sopt.and.core.utils.KeyStorage.HOME
+import org.sopt.and.core.utils.KeyStorage.MY_PAGE
+import org.sopt.and.core.utils.KeyStorage.SEARCH
import org.sopt.and.feature.home.HomeScreen
import org.sopt.and.feature.mypage.MyPageScreen
-import org.sopt.and.feature.mypage.MyPageViewModel
import org.sopt.and.feature.search.SearchScreen
-import org.sopt.and.utils.KeyStorage.HOME
-import org.sopt.and.utils.KeyStorage.MY_PAGE
-import org.sopt.and.utils.KeyStorage.SEARCH
@Composable
fun NavGraph(
@@ -31,7 +29,7 @@ fun NavGraph(
SearchScreen()
}
composable(MY_PAGE) {
- MyPageScreen(viewModel = MyPageViewModel())
+ MyPageScreen()
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInScreen.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInScreen.kt
index 15ecd50..081211c 100644
--- a/app/src/main/java/org/sopt/and/feature/signin/SignInScreen.kt
+++ b/app/src/main/java/org/sopt/and/feature/signin/SignInScreen.kt
@@ -28,14 +28,15 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import org.sopt.and.R
-import org.sopt.and.component.SignInTopBar
-import org.sopt.and.component.SocialLoginItem
-import org.sopt.and.component.WavveCustomTextField
-import org.sopt.and.utils.noRippleClickable
-import org.sopt.and.utils.toast
+import org.sopt.and.core.designsystem.component.SignInTopBar
+import org.sopt.and.core.designsystem.component.SocialLoginItem
+import org.sopt.and.core.designsystem.component.WavveCustomTextField
+import org.sopt.and.core.utils.context.toast
+import org.sopt.and.core.utils.modifier.noRippleClickable
@Composable
fun SignInScreen(
@@ -47,7 +48,7 @@ fun SignInScreen(
modifier: Modifier = Modifier
) {
val context = LocalContext.current
- val viewModel = remember { SignInViewModel(sharedPreferences) }
+ val viewModel: SignInViewModel = hiltViewModel()
val username by viewModel.username.collectAsStateWithLifecycle()
val password by viewModel.password.collectAsStateWithLifecycle()
val scope = rememberCoroutineScope()
diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInViewModel.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInViewModel.kt
index fcdb958..b81bac1 100644
--- a/app/src/main/java/org/sopt/and/feature/signin/SignInViewModel.kt
+++ b/app/src/main/java/org/sopt/and/feature/signin/SignInViewModel.kt
@@ -1,29 +1,31 @@
package org.sopt.and.feature.signin
-import android.content.Context
import android.content.SharedPreferences
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import org.sopt.and.R
-import org.sopt.and.api.ServicePool.authService
-import org.sopt.and.api.dto.request.RequestSignInDto
-import org.sopt.and.api.dto.response.ResponseErrorDto
-import org.sopt.and.utils.KeyStorage.AUTH_PREFS
-import org.sopt.and.utils.KeyStorage.ERROR_CODE_01
-import org.sopt.and.utils.KeyStorage.ERROR_CODE_02
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_400
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_403
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_404
-import org.sopt.and.utils.KeyStorage.TOKEN
+import org.sopt.and.data.dto.response.ResponseErrorDto
+import org.sopt.and.core.utils.KeyStorage.ERROR_CODE_01
+import org.sopt.and.core.utils.KeyStorage.ERROR_CODE_02
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_400
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_403
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_404
+import org.sopt.and.core.utils.KeyStorage.TOKEN
+import org.sopt.and.domain.entity.SignInModel
+import org.sopt.and.domain.repository.AuthRepository
import retrofit2.HttpException
import java.io.IOException
+import javax.inject.Inject
-class SignInViewModel(
- private val sharedPreferences: SharedPreferences
+@HiltViewModel
+class SignInViewModel @Inject constructor(
+ private val sharedPreferences: SharedPreferences,
+ private val authRepository: AuthRepository
) : ViewModel() {
private val _username = MutableStateFlow("")
@@ -41,30 +43,25 @@ class SignInViewModel(
}
private fun saveToken(token: String) {
- sharedPreferences?.edit()?.putString(TOKEN, token)?.apply()
+ sharedPreferences.edit()?.putString(TOKEN, token)?.apply()
}
fun signIn(
onSuccess: (String) -> Unit,
onFailure: (Int) -> Unit
) {
- val request = RequestSignInDto(username = _username.value, password = _password.value)
+ val request = SignInModel(username = _username.value, password = _password.value)
viewModelScope.launch {
- runCatching {
- authService.signIn(request)
- }.onSuccess { response ->
- if (response.result.token.isNotEmpty()) {
- val token = response.result.token
+ authRepository.signIn(request)
+ .onSuccess { token ->
saveToken(token)
onSuccess(token)
- } else {
- onFailure(R.string.sign_in_failure)
}
- }.onFailure { throwable ->
- val errorMessageId = handleSignInError(throwable)
- onFailure(errorMessageId)
- }
+ .onFailure { throwable ->
+ val errorMessageId = handleSignInError(throwable)
+ onFailure(errorMessageId)
+ }
}
}
diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpScreen.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpScreen.kt
index 01948e5..faf3629 100644
--- a/app/src/main/java/org/sopt/and/feature/signup/SignUpScreen.kt
+++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpScreen.kt
@@ -20,21 +20,22 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import org.sopt.and.R
-import org.sopt.and.component.SignUpTopBar
-import org.sopt.and.component.SocialLoginItem
-import org.sopt.and.component.WavveCustomTextField
-import org.sopt.and.utils.toast
+import org.sopt.and.core.designsystem.component.SignUpTopBar
+import org.sopt.and.core.designsystem.component.SocialLoginItem
+import org.sopt.and.core.designsystem.component.WavveCustomTextField
+import org.sopt.and.core.utils.context.toast
@Composable
fun SignUpScreen(
navController: NavHostController,
modifier: Modifier = Modifier,
onSignUpSuccess: () -> Unit,
- viewModel: SignUpViewModel = viewModel(),
+ viewModel: SignUpViewModel = hiltViewModel(),
) {
val username by viewModel.username.collectAsStateWithLifecycle()
val password by viewModel.password.collectAsStateWithLifecycle()
diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpViewModel.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpViewModel.kt
index 4c6a892..410a03a 100644
--- a/app/src/main/java/org/sopt/and/feature/signup/SignUpViewModel.kt
+++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpViewModel.kt
@@ -2,24 +2,29 @@ package org.sopt.and.feature.signup
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import org.sopt.and.R
-import org.sopt.and.api.ServicePool.authService
-import org.sopt.and.api.dto.request.RequestSignUpDto
-import org.sopt.and.api.dto.response.ResponseErrorDto
-import org.sopt.and.utils.KeyStorage.ERROR_CODE_00
-import org.sopt.and.utils.KeyStorage.ERROR_CODE_01
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_400
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_404
-import org.sopt.and.utils.KeyStorage.STATUS_CODE_409
-import org.sopt.and.utils.KeyStorage.TEXTFIELD_MAX_LENGTH
+import org.sopt.and.data.dto.response.ResponseErrorDto
+import org.sopt.and.core.utils.KeyStorage.ERROR_CODE_00
+import org.sopt.and.core.utils.KeyStorage.ERROR_CODE_01
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_400
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_404
+import org.sopt.and.core.utils.KeyStorage.STATUS_CODE_409
+import org.sopt.and.core.utils.KeyStorage.TEXTFIELD_MAX_LENGTH
+import org.sopt.and.domain.entity.SignUpModel
+import org.sopt.and.domain.repository.AuthRepository
import retrofit2.HttpException
import java.io.IOException
+import javax.inject.Inject
-class SignUpViewModel : ViewModel() {
+@HiltViewModel
+class SignUpViewModel @Inject constructor(
+ private val authRepository: AuthRepository
+) : ViewModel() {
private val _username = MutableStateFlow("")
val username: StateFlow = _username
@@ -59,7 +64,7 @@ class SignUpViewModel : ViewModel() {
return
}
- val request = RequestSignUpDto(
+ val request = SignUpModel(
username = username.value,
password = password.value,
hobby = hobby.value
@@ -67,7 +72,7 @@ class SignUpViewModel : ViewModel() {
viewModelScope.launch {
runCatching {
- authService.signUp(request)
+ authRepository.signUp(request)
}.onSuccess {
onSuccess()
}.onFailure { throwable ->
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index dd9df16..f8db019 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -14,6 +14,8 @@ okhttp = "4.11.0"
retrofit = "2.9.0"
retrofitKotlinSerializationConverter = "1.0.0"
kotlinxSerializationJson = "1.6.3"
+hilt = "2.51.1"
+hilt-navigation-compose = "1.2.0"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -38,6 +40,9 @@ okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-i
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
retrofit-kotlin-serialization-converter = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinSerializationConverter" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
+hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
+hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
+hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
[plugins]
@@ -45,4 +50,4 @@ android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
-
+hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
\ No newline at end of file