From 78d9996b99d6dd4ec52f38d4713d86c7b58dc602 Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Fri, 6 Dec 2024 11:09:29 +0900 Subject: [PATCH 1/7] #7 [refactor] : edit foldering --- .../designsystem}/component/AutoSlidingRow.kt | 2 +- .../designsystem}/component/HomeRowItemTitle.kt | 2 +- .../designsystem}/component/MyPageItem.kt | 2 +- .../designsystem}/component/RecommendationRow.kt | 2 +- .../designsystem}/component/SocialLoginItem.kt | 2 +- .../{ => core/designsystem}/component/TabMenu.kt | 4 ++-- .../{ => core/designsystem}/component/TextField.kt | 2 +- .../designsystem}/component/TodayTop20Row.kt | 2 +- .../{ => core/designsystem}/component/TopBar.kt | 2 +- .../org/sopt/and/{ => core}/utils/KeyStorage.kt | 2 +- .../{utils => core/utils/context}/ContextExt.kt | 2 +- .../{utils => core/utils/modifier}/ModifierExt.kt | 2 +- .../java/org/sopt/and/{api => data}/ApiFactory.kt | 4 ++-- .../{api => data}/dto/request/RequestSignInDto.kt | 2 +- .../{api => data}/dto/request/RequestSignUpDto.kt | 2 +- .../and/{api => data}/dto/response/BaseResponse.kt | 2 +- .../{api => data}/dto/response/ResponseErrorDto.kt | 2 +- .../{api => data}/dto/response/ResponseHobbyDto.kt | 2 +- .../dto/response/ResponseSignInDto.kt | 2 +- .../dto/response/ResponseSignUpDto.kt | 2 +- .../sopt/and/{api => data}/service/AuthService.kt | 14 +++++++------- .../sopt/and/{ => feature}/model/BottomNavItem.kt | 8 ++++---- .../sopt/and/{ => feature}/model/TabMenuItem.kt | 2 +- 23 files changed, 34 insertions(+), 34 deletions(-) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/AutoSlidingRow.kt (98%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/HomeRowItemTitle.kt (96%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/MyPageItem.kt (98%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/RecommendationRow.kt (96%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/SocialLoginItem.kt (96%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/TabMenu.kt (94%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/TextField.kt (98%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/TodayTop20Row.kt (98%) rename app/src/main/java/org/sopt/and/{ => core/designsystem}/component/TopBar.kt (98%) rename app/src/main/java/org/sopt/and/{ => core}/utils/KeyStorage.kt (95%) rename app/src/main/java/org/sopt/and/{utils => core/utils/context}/ContextExt.kt (80%) rename app/src/main/java/org/sopt/and/{utils => core/utils/modifier}/ModifierExt.kt (92%) rename app/src/main/java/org/sopt/and/{api => data}/ApiFactory.kt (93%) rename app/src/main/java/org/sopt/and/{api => data}/dto/request/RequestSignInDto.kt (86%) rename app/src/main/java/org/sopt/and/{api => data}/dto/request/RequestSignUpDto.kt (88%) rename app/src/main/java/org/sopt/and/{api => data}/dto/response/BaseResponse.kt (81%) rename app/src/main/java/org/sopt/and/{api => data}/dto/response/ResponseErrorDto.kt (81%) rename app/src/main/java/org/sopt/and/{api => data}/dto/response/ResponseHobbyDto.kt (81%) rename app/src/main/java/org/sopt/and/{api => data}/dto/response/ResponseSignInDto.kt (81%) rename app/src/main/java/org/sopt/and/{api => data}/dto/response/ResponseSignUpDto.kt (81%) rename app/src/main/java/org/sopt/and/{api => data}/service/AuthService.kt (64%) rename app/src/main/java/org/sopt/and/{ => feature}/model/BottomNavItem.kt (76%) rename app/src/main/java/org/sopt/and/{ => feature}/model/TabMenuItem.kt (92%) 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/api/ApiFactory.kt b/app/src/main/java/org/sopt/and/data/ApiFactory.kt similarity index 93% rename from app/src/main/java/org/sopt/and/api/ApiFactory.kt rename to app/src/main/java/org/sopt/and/data/ApiFactory.kt index 410e07f..65c5c4d 100644 --- a/app/src/main/java/org/sopt/and/api/ApiFactory.kt +++ b/app/src/main/java/org/sopt/and/data/ApiFactory.kt @@ -1,4 +1,4 @@ -package org.sopt.and.api +package org.sopt.and.data import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import kotlinx.serialization.json.Json @@ -6,7 +6,7 @@ import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import org.sopt.and.BuildConfig -import org.sopt.and.api.service.AuthService +import org.sopt.and.data.service.AuthService import retrofit2.Retrofit object ApiFactory { 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/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/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 From 2408d56f4d4daa12310465aefa537fc5a437c6b6 Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Fri, 6 Dec 2024 11:10:01 +0900 Subject: [PATCH 2/7] #7 [feat] : clean architecture, hilt --- app/build.gradle.kts | 10 +++ app/src/main/AndroidManifest.xml | 1 + .../main/java/org/sopt/and/MainActivity.kt | 10 +-- .../java/org/sopt/and/WavveApplication.kt | 7 +++ .../and/data/datasource/AuthDataSource.kt | 9 +++ .../data/datasourceimpl/AuthDataSourceImpl.kt | 15 +++++ .../java/org/sopt/and/data/di/ApiModule.kt | 18 ++++++ .../org/sopt/and/data/di/DataSourceModule.kt | 17 +++++ .../org/sopt/and/data/di/NetworkModule.kt | 63 +++++++++++++++++++ .../org/sopt/and/data/di/RepositoryModule.kt | 17 +++++ .../org/sopt/and/data/mapper/SignUpMapper.kt | 12 ++++ .../data/repositoryimpl/AuthRepositoryImpl.kt | 17 +++++ .../org/sopt/and/domain/entity/SignUpModel.kt | 7 +++ .../and/domain/repository/AuthRepository.kt | 7 +++ .../org/sopt/and/feature/home/HomeScreen.kt | 10 +-- .../sopt/and/feature/mypage/MyPageScreen.kt | 8 +-- .../and/feature/mypage/MyPageViewModel.kt | 17 +++-- .../sopt/and/feature/nav/BottomNavigation.kt | 2 +- .../java/org/sopt/and/feature/nav/NavGraph.kt | 6 +- .../sopt/and/feature/signin/SignInScreen.kt | 10 +-- .../and/feature/signin/SignInViewModel.kt | 20 +++--- .../sopt/and/feature/signup/SignUpScreen.kt | 11 ++-- .../and/feature/signup/SignUpViewModel.kt | 29 +++++---- gradle/libs.versions.toml | 7 ++- 24 files changed, 269 insertions(+), 61 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/WavveApplication.kt create mode 100644 app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt create mode 100644 app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt create mode 100644 app/src/main/java/org/sopt/and/data/di/ApiModule.kt create mode 100644 app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt create mode 100644 app/src/main/java/org/sopt/and/data/di/NetworkModule.kt create mode 100644 app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt create mode 100644 app/src/main/java/org/sopt/and/data/mapper/SignUpMapper.kt create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt create mode 100644 app/src/main/java/org/sopt/and/domain/entity/SignUpModel.kt create mode 100644 app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt 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 @@ +} \ 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..01d3328 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt @@ -0,0 +1,15 @@ +package org.sopt.and.data.datasourceimpl + +import org.sopt.and.data.datasource.AuthDataSource +import org.sopt.and.data.dto.request.RequestSignUpDto +import org.sopt.and.data.dto.response.BaseResponse +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) +} \ 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..27f03ee --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/di/ApiModule.kt @@ -0,0 +1,18 @@ +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 javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ApiModule { + @Provides + @Singleton + fun provideAuthService(retrofit: Retrofit): AuthService = + retrofit.create(AuthService::class.java) +} \ 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/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/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..58d533c --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt @@ -0,0 +1,17 @@ +package org.sopt.and.data.repositoryimpl + +import org.sopt.and.data.datasource.AuthDataSource +import org.sopt.and.data.mapper.toSignUpRequest +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 + } +} \ 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..cd4c97f --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt @@ -0,0 +1,7 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.domain.entity.SignUpModel + +interface AuthRepository { + suspend fun signUp(request: SignUpModel): 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/feature/mypage/MyPageScreen.kt b/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt index 365c4c1..f45b0cc 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 @@ -32,10 +32,10 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.lifecycle.viewmodel.compose.viewModel 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( 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..bdd26d5 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,7 +1,5 @@ package org.sopt.and.feature.mypage -import android.content.Context -import android.content.SharedPreferences import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import kotlinx.coroutines.flow.MutableStateFlow @@ -9,14 +7,13 @@ 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.data.ServicePool.authService +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.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 retrofit2.HttpException class MyPageViewModel : ViewModel() { 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..8c3f95b 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 @@ -10,9 +10,9 @@ 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 +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 @Composable fun NavGraph( 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..68c15ba 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 @@ -31,11 +31,11 @@ import androidx.compose.ui.unit.sp 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.modifier.noRippleClickable +import org.sopt.and.core.utils.context.toast @Composable fun SignInScreen( 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..cfb1fca 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,6 +1,5 @@ package org.sopt.and.feature.signin -import android.content.Context import android.content.SharedPreferences import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -9,16 +8,15 @@ 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.ServicePool.authService +import org.sopt.and.data.dto.request.RequestSignInDto +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 retrofit2.HttpException import java.io.IOException 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 From f28a36169fa0e2219f8fed878ee6c35e2899608a Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Fri, 6 Dec 2024 11:19:24 +0900 Subject: [PATCH 3/7] #7 [feat] : clean architecture, hilt - sign in, get hobby --- .../org/sopt/and/data/datasource/AuthDataSource.kt | 7 +++++++ .../and/data/datasourceimpl/AuthDataSourceImpl.kt | 9 +++++++++ .../java/org/sopt/and/data/mapper/SignInMapper.kt | 11 +++++++++++ .../and/data/repositoryimpl/AuthRepositoryImpl.kt | 14 ++++++++++++++ .../java/org/sopt/and/domain/entity/SignInModel.kt | 6 ++++++ .../sopt/and/domain/repository/AuthRepository.kt | 5 +++++ 6 files changed, 52 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/mapper/SignInMapper.kt create mode 100644 app/src/main/java/org/sopt/and/domain/entity/SignInModel.kt 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 index e1f5578..029dce9 100644 --- a/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt +++ b/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt @@ -1,9 +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 index 01d3328..b091768 100644 --- a/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt +++ b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt @@ -1,8 +1,11 @@ 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 @@ -12,4 +15,10 @@ class AuthDataSourceImpl @Inject constructor( ) : 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/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/repositoryimpl/AuthRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt index 58d533c..b30b8bc 100644 --- a/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/AuthRepositoryImpl.kt @@ -1,7 +1,9 @@ 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 @@ -14,4 +16,16 @@ class AuthRepositoryImpl @Inject constructor( 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/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/repository/AuthRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt index cd4c97f..0865f24 100644 --- a/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt +++ b/app/src/main/java/org/sopt/and/domain/repository/AuthRepository.kt @@ -1,7 +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 From 2b3d814f6dd924f7ff80f23bd0320bf5421443b9 Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Fri, 6 Dec 2024 13:23:50 +0900 Subject: [PATCH 4/7] #7 [feat] : apply hilt, edit token --- .../org/sopt/and/data/di/NetworkModule.kt | 11 +++++ .../sopt/and/feature/mypage/MyPageScreen.kt | 8 +-- .../and/feature/mypage/MyPageViewModel.kt | 49 +++++++++++-------- .../java/org/sopt/and/feature/nav/NavGraph.kt | 10 ++-- .../sopt/and/feature/signin/SignInScreen.kt | 5 +- .../and/feature/signin/SignInViewModel.kt | 33 ++++++------- 6 files changed, 67 insertions(+), 49 deletions(-) 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 index fcdac55..2d51cd0 100644 --- a/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt @@ -1,9 +1,12 @@ package org.sopt.and.data.di +import android.content.Context +import android.content.SharedPreferences import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json @@ -60,4 +63,12 @@ object NetworkModule { .addConverterFactory(json.asConverterFactory("application/json".toMediaType())) .build() } + + @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/feature/mypage/MyPageScreen.kt b/app/src/main/java/org/sopt/and/feature/mypage/MyPageScreen.kt index f45b0cc..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,7 +30,7 @@ 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.core.designsystem.component.MyPageHistoryItem import org.sopt.and.core.designsystem.component.MyPagePurchaseItem @@ -40,7 +40,7 @@ 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 bdd26d5..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,27 +1,36 @@ package org.sopt.and.feature.mypage +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.data.ServicePool.authService -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.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) } @@ -29,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/NavGraph.kt b/app/src/main/java/org/sopt/and/feature/nav/NavGraph.kt index 8c3f95b..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.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.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.search.SearchScreen @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 68c15ba..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.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.modifier.noRippleClickable 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 cfb1fca..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 @@ -3,13 +3,12 @@ package org.sopt.and.feature.signin 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.data.ServicePool.authService -import org.sopt.and.data.dto.request.RequestSignInDto 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 @@ -17,11 +16,16 @@ 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("") @@ -39,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) + } } } From 0ef1e95067edee867eb6282a5b4a9ee5040d1dfe Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Fri, 6 Dec 2024 14:25:54 +0900 Subject: [PATCH 5/7] #7 [del] : delete ApiFactory code --- .../main/java/org/sopt/and/data/ApiFactory.kt | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/data/ApiFactory.kt diff --git a/app/src/main/java/org/sopt/and/data/ApiFactory.kt b/app/src/main/java/org/sopt/and/data/ApiFactory.kt deleted file mode 100644 index 65c5c4d..0000000 --- a/app/src/main/java/org/sopt/and/data/ApiFactory.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.sopt.and.data - -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -import kotlinx.serialization.json.Json -import okhttp3.MediaType.Companion.toMediaType -import okhttp3.OkHttpClient -import okhttp3.logging.HttpLoggingInterceptor -import org.sopt.and.BuildConfig -import org.sopt.and.data.service.AuthService -import retrofit2.Retrofit - -object ApiFactory { - private const val BASE_URL: String = BuildConfig.BASE_URL - - private val loggingInterceptor = HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY - } - - private val client = OkHttpClient.Builder() - .addInterceptor(loggingInterceptor) - .build() - - val retrofit: Retrofit by lazy { - Retrofit.Builder() - .baseUrl(BASE_URL) - .client(client) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() - } - - inline fun create(): T = retrofit.create(T::class.java) -} - -object ServicePool { - val authService = ApiFactory.create() -} \ No newline at end of file From 72ef76578f77a3d06d65130811b8ec7b44a32d5e Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Tue, 17 Dec 2024 18:37:57 +0900 Subject: [PATCH 6/7] #9 [chore] : edit ApiModule --- app/src/main/java/org/sopt/and/data/di/ApiModule.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 27f03ee..1001a0e 100644 --- a/app/src/main/java/org/sopt/and/data/di/ApiModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/ApiModule.kt @@ -6,6 +6,7 @@ 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 @@ -14,5 +15,5 @@ object ApiModule { @Provides @Singleton fun provideAuthService(retrofit: Retrofit): AuthService = - retrofit.create(AuthService::class.java) + retrofit.create() } \ No newline at end of file From c98baeafb2acb28d2302362bc72c4e4315686038 Mon Sep 17 00:00:00 2001 From: yskim6772 Date: Wed, 18 Dec 2024 21:30:44 +0900 Subject: [PATCH 7/7] #9 [chore] : separate PreferencesModule --- .../org/sopt/and/data/di/NetworkModule.kt | 11 ---------- .../org/sopt/and/data/di/PreferencesModule.kt | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/data/di/PreferencesModule.kt 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 index 2d51cd0..fcdac55 100644 --- a/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/NetworkModule.kt @@ -1,12 +1,9 @@ package org.sopt.and.data.di -import android.content.Context -import android.content.SharedPreferences import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import dagger.Module import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json @@ -63,12 +60,4 @@ object NetworkModule { .addConverterFactory(json.asConverterFactory("application/json".toMediaType())) .build() } - - @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/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