From 0ebb8fc2a9b46e0e8b413ec1d0dcefa323fa41a2 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 5 Dec 2024 00:39:49 +0900 Subject: [PATCH 01/40] chore #13: move component to presentation layer --- .../org/sopt/and/{ => feature}/component/AuthTextField.kt | 2 +- .../org/sopt/and/{ => feature}/component/EventContent.kt | 2 +- .../org/sopt/and/{ => feature}/component/ExpandedButton.kt | 2 +- .../org/sopt/and/{ => feature}/component/HistoryContent.kt | 2 +- .../org/sopt/and/{ => feature}/component/HomeContent.kt | 2 +- .../org/sopt/and/{ => feature}/component/RoundedButton.kt | 2 +- .../java/org/sopt/and/{ => feature}/component/TopBar.kt | 2 +- app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt | 4 ++-- app/src/main/java/org/sopt/and/feature/my/MyRoute.kt | 4 ++-- .../main/java/org/sopt/and/feature/signin/SignInRoute.kt | 6 +++--- .../main/java/org/sopt/and/feature/signup/SignUpRoute.kt | 6 +++--- 11 files changed, 17 insertions(+), 17 deletions(-) rename app/src/main/java/org/sopt/and/{ => feature}/component/AuthTextField.kt (98%) rename app/src/main/java/org/sopt/and/{ => feature}/component/EventContent.kt (98%) rename app/src/main/java/org/sopt/and/{ => feature}/component/ExpandedButton.kt (97%) rename app/src/main/java/org/sopt/and/{ => feature}/component/HistoryContent.kt (98%) rename app/src/main/java/org/sopt/and/{ => feature}/component/HomeContent.kt (99%) rename app/src/main/java/org/sopt/and/{ => feature}/component/RoundedButton.kt (97%) rename app/src/main/java/org/sopt/and/{ => feature}/component/TopBar.kt (97%) diff --git a/app/src/main/java/org/sopt/and/component/AuthTextField.kt b/app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt similarity index 98% rename from app/src/main/java/org/sopt/and/component/AuthTextField.kt rename to app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt index 790e103..bb78032 100644 --- a/app/src/main/java/org/sopt/and/component/AuthTextField.kt +++ b/app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/app/src/main/java/org/sopt/and/component/EventContent.kt b/app/src/main/java/org/sopt/and/feature/component/EventContent.kt similarity index 98% rename from app/src/main/java/org/sopt/and/component/EventContent.kt rename to app/src/main/java/org/sopt/and/feature/component/EventContent.kt index 2d806da..7ff9e1e 100644 --- a/app/src/main/java/org/sopt/and/component/EventContent.kt +++ b/app/src/main/java/org/sopt/and/feature/component/EventContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column diff --git a/app/src/main/java/org/sopt/and/component/ExpandedButton.kt b/app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt similarity index 97% rename from app/src/main/java/org/sopt/and/component/ExpandedButton.kt rename to app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt index 56aca03..db06796 100644 --- a/app/src/main/java/org/sopt/and/component/ExpandedButton.kt +++ b/app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.background import androidx.compose.foundation.clickable diff --git a/app/src/main/java/org/sopt/and/component/HistoryContent.kt b/app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt similarity index 98% rename from app/src/main/java/org/sopt/and/component/HistoryContent.kt rename to app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt index 485d3e0..ef26b10 100644 --- a/app/src/main/java/org/sopt/and/component/HistoryContent.kt +++ b/app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth diff --git a/app/src/main/java/org/sopt/and/component/HomeContent.kt b/app/src/main/java/org/sopt/and/feature/component/HomeContent.kt similarity index 99% rename from app/src/main/java/org/sopt/and/component/HomeContent.kt rename to app/src/main/java/org/sopt/and/feature/component/HomeContent.kt index d67c2cf..ed467ca 100644 --- a/app/src/main/java/org/sopt/and/component/HomeContent.kt +++ b/app/src/main/java/org/sopt/and/feature/component/HomeContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement diff --git a/app/src/main/java/org/sopt/and/component/RoundedButton.kt b/app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt similarity index 97% rename from app/src/main/java/org/sopt/and/component/RoundedButton.kt rename to app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt index 93246d4..aa37335 100644 --- a/app/src/main/java/org/sopt/and/component/RoundedButton.kt +++ b/app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.background import androidx.compose.foundation.clickable diff --git a/app/src/main/java/org/sopt/and/component/TopBar.kt b/app/src/main/java/org/sopt/and/feature/component/TopBar.kt similarity index 97% rename from app/src/main/java/org/sopt/and/component/TopBar.kt rename to app/src/main/java/org/sopt/and/feature/component/TopBar.kt index b2a38cc..1d10474 100644 --- a/app/src/main/java/org/sopt/and/component/TopBar.kt +++ b/app/src/main/java/org/sopt/and/feature/component/TopBar.kt @@ -1,4 +1,4 @@ -package org.sopt.and.component +package org.sopt.and.feature.component import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize diff --git a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt index 127af7d..d2a0cab 100644 --- a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt @@ -33,8 +33,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import org.sopt.and.R -import org.sopt.and.component.HomeContent -import org.sopt.and.component.TopBar +import org.sopt.and.feature.component.HomeContent +import org.sopt.and.feature.component.TopBar import org.sopt.and.feature.home.model.ContentModel import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black diff --git a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt index ab0a44c..3c4ecc1 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt @@ -33,8 +33,8 @@ import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import org.sopt.and.R -import org.sopt.and.component.EventContent -import org.sopt.and.component.HistoryContent +import org.sopt.and.feature.component.EventContent +import org.sopt.and.feature.component.HistoryContent import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.Blue diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt index 8d1bce0..45b023a 100644 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt @@ -37,9 +37,9 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R -import org.sopt.and.component.RoundedButton -import org.sopt.and.component.AuthTextField -import org.sopt.and.component.TopBar +import org.sopt.and.feature.component.RoundedButton +import org.sopt.and.feature.component.AuthTextField +import org.sopt.and.feature.component.TopBar import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.LightGray diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt index f2a7271..ae4c4d0 100644 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt @@ -31,9 +31,9 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R -import org.sopt.and.component.ExpandedButton -import org.sopt.and.component.AuthTextField -import org.sopt.and.component.TopBar +import org.sopt.and.feature.component.ExpandedButton +import org.sopt.and.feature.component.AuthTextField +import org.sopt.and.feature.component.TopBar import org.sopt.and.showToast import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black From f512b3513da4f1673474cf48205023c24b8cf056 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 5 Dec 2024 00:50:24 +0900 Subject: [PATCH 02/40] add #13: add core package --- .../sopt/and/{feature => core}/component/AuthTextField.kt | 2 +- .../and/{feature => core}/component/ExpandedButton.kt | 2 +- .../sopt/and/{feature => core}/component/RoundedButton.kt | 2 +- .../org/sopt/and/{feature => core}/component/TopBar.kt | 2 +- .../{Extension.kt => core/extension/ContextExtension.kt} | 2 +- .../and/{feature/main => core/navigation}/MainRoute.kt | 2 +- .../main/java/org/sopt/and/feature/home/HomeNavigation.kt | 2 +- app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt | 2 +- .../main/java/org/sopt/and/feature/main/MainBottomTab.kt | 2 ++ .../main/java/org/sopt/and/feature/main/MainNavigation.kt | 1 + app/src/main/java/org/sopt/and/feature/my/MyNavigation.kt | 2 +- .../java/org/sopt/and/feature/search/SearchNavigation.kt | 2 +- .../java/org/sopt/and/feature/signin/SignInNavigation.kt | 2 +- .../main/java/org/sopt/and/feature/signin/SignInRoute.kt | 7 +++---- .../java/org/sopt/and/feature/signup/SignUpNavigation.kt | 2 +- .../main/java/org/sopt/and/feature/signup/SignUpRoute.kt | 8 ++++---- 16 files changed, 22 insertions(+), 20 deletions(-) rename app/src/main/java/org/sopt/and/{feature => core}/component/AuthTextField.kt (98%) rename app/src/main/java/org/sopt/and/{feature => core}/component/ExpandedButton.kt (97%) rename app/src/main/java/org/sopt/and/{feature => core}/component/RoundedButton.kt (97%) rename app/src/main/java/org/sopt/and/{feature => core}/component/TopBar.kt (97%) rename app/src/main/java/org/sopt/and/{Extension.kt => core/extension/ContextExtension.kt} (85%) rename app/src/main/java/org/sopt/and/{feature/main => core/navigation}/MainRoute.kt (60%) diff --git a/app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt b/app/src/main/java/org/sopt/and/core/component/AuthTextField.kt similarity index 98% rename from app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt rename to app/src/main/java/org/sopt/and/core/component/AuthTextField.kt index bb78032..ab52fc0 100644 --- a/app/src/main/java/org/sopt/and/feature/component/AuthTextField.kt +++ b/app/src/main/java/org/sopt/and/core/component/AuthTextField.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.core.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt b/app/src/main/java/org/sopt/and/core/component/ExpandedButton.kt similarity index 97% rename from app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt rename to app/src/main/java/org/sopt/and/core/component/ExpandedButton.kt index db06796..88f8f8f 100644 --- a/app/src/main/java/org/sopt/and/feature/component/ExpandedButton.kt +++ b/app/src/main/java/org/sopt/and/core/component/ExpandedButton.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.core.component import androidx.compose.foundation.background import androidx.compose.foundation.clickable diff --git a/app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt b/app/src/main/java/org/sopt/and/core/component/RoundedButton.kt similarity index 97% rename from app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt rename to app/src/main/java/org/sopt/and/core/component/RoundedButton.kt index aa37335..516a840 100644 --- a/app/src/main/java/org/sopt/and/feature/component/RoundedButton.kt +++ b/app/src/main/java/org/sopt/and/core/component/RoundedButton.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.core.component import androidx.compose.foundation.background import androidx.compose.foundation.clickable diff --git a/app/src/main/java/org/sopt/and/feature/component/TopBar.kt b/app/src/main/java/org/sopt/and/core/component/TopBar.kt similarity index 97% rename from app/src/main/java/org/sopt/and/feature/component/TopBar.kt rename to app/src/main/java/org/sopt/and/core/component/TopBar.kt index 1d10474..003d626 100644 --- a/app/src/main/java/org/sopt/and/feature/component/TopBar.kt +++ b/app/src/main/java/org/sopt/and/core/component/TopBar.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.core.component import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize diff --git a/app/src/main/java/org/sopt/and/Extension.kt b/app/src/main/java/org/sopt/and/core/extension/ContextExtension.kt similarity index 85% rename from app/src/main/java/org/sopt/and/Extension.kt rename to app/src/main/java/org/sopt/and/core/extension/ContextExtension.kt index 3b765c4..9fe2a89 100644 --- a/app/src/main/java/org/sopt/and/Extension.kt +++ b/app/src/main/java/org/sopt/and/core/extension/ContextExtension.kt @@ -1,4 +1,4 @@ -package org.sopt.and +package org.sopt.and.core.extension import android.content.Context import android.widget.Toast diff --git a/app/src/main/java/org/sopt/and/feature/main/MainRoute.kt b/app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt similarity index 60% rename from app/src/main/java/org/sopt/and/feature/main/MainRoute.kt rename to app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt index 65c9692..b0fcfc1 100644 --- a/app/src/main/java/org/sopt/and/feature/main/MainRoute.kt +++ b/app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.main +package org.sopt.and.core.navigation interface MainRoute diff --git a/app/src/main/java/org/sopt/and/feature/home/HomeNavigation.kt b/app/src/main/java/org/sopt/and/feature/home/HomeNavigation.kt index d7cab1a..f3aa396 100644 --- a/app/src/main/java/org/sopt/and/feature/home/HomeNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/home/HomeNavigation.kt @@ -6,7 +6,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions import androidx.navigation.compose.composable import kotlinx.serialization.Serializable -import org.sopt.and.feature.main.MainTabRoute +import org.sopt.and.core.navigation.MainTabRoute fun NavController.navigateHome( navOptions: NavOptions diff --git a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt index d2a0cab..bea864f 100644 --- a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt @@ -34,7 +34,7 @@ import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import org.sopt.and.R import org.sopt.and.feature.component.HomeContent -import org.sopt.and.feature.component.TopBar +import org.sopt.and.core.component.TopBar import org.sopt.and.feature.home.model.ContentModel import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black diff --git a/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt b/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt index bf219b2..ac3b9ad 100644 --- a/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt +++ b/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt @@ -6,6 +6,8 @@ import androidx.compose.material.icons.outlined.Home import androidx.compose.material.icons.outlined.Search import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.vector.ImageVector +import org.sopt.and.core.navigation.MainRoute +import org.sopt.and.core.navigation.MainTabRoute enum class MainBottomTab( val icon: ImageVector, diff --git a/app/src/main/java/org/sopt/and/feature/main/MainNavigation.kt b/app/src/main/java/org/sopt/and/feature/main/MainNavigation.kt index ccdaf6e..c53206e 100644 --- a/app/src/main/java/org/sopt/and/feature/main/MainNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/main/MainNavigation.kt @@ -8,6 +8,7 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions +import org.sopt.and.core.navigation.MainTabRoute import org.sopt.and.feature.home.Home import org.sopt.and.feature.home.navigateHome import org.sopt.and.feature.my.navigateMy diff --git a/app/src/main/java/org/sopt/and/feature/my/MyNavigation.kt b/app/src/main/java/org/sopt/and/feature/my/MyNavigation.kt index 15739a3..797ecd7 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyNavigation.kt @@ -6,7 +6,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions import androidx.navigation.compose.composable import kotlinx.serialization.Serializable -import org.sopt.and.feature.main.MainTabRoute +import org.sopt.and.core.navigation.MainTabRoute fun NavController.navigateMy( navOptions: NavOptions diff --git a/app/src/main/java/org/sopt/and/feature/search/SearchNavigation.kt b/app/src/main/java/org/sopt/and/feature/search/SearchNavigation.kt index 594b14d..1a4f53a 100644 --- a/app/src/main/java/org/sopt/and/feature/search/SearchNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/search/SearchNavigation.kt @@ -6,7 +6,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions import androidx.navigation.compose.composable import kotlinx.serialization.Serializable -import org.sopt.and.feature.main.MainTabRoute +import org.sopt.and.core.navigation.MainTabRoute fun NavController.navigateSearch( navOptions: NavOptions diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInNavigation.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInNavigation.kt index d827541..c9bb2a5 100644 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInNavigation.kt @@ -4,7 +4,7 @@ import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import kotlinx.serialization.Serializable -import org.sopt.and.feature.main.MainTabRoute +import org.sopt.and.core.navigation.MainTabRoute fun NavController.navigateSignIn() { navigate(SignIn) diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt index 45b023a..949a70d 100644 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt @@ -25,7 +25,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle @@ -37,9 +36,9 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R -import org.sopt.and.feature.component.RoundedButton -import org.sopt.and.feature.component.AuthTextField -import org.sopt.and.feature.component.TopBar +import org.sopt.and.core.component.RoundedButton +import org.sopt.and.core.component.AuthTextField +import org.sopt.and.core.component.TopBar import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.LightGray diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpNavigation.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpNavigation.kt index a97bcca..b473226 100644 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpNavigation.kt +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpNavigation.kt @@ -4,7 +4,7 @@ import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import kotlinx.serialization.Serializable -import org.sopt.and.feature.main.MainTabRoute +import org.sopt.and.core.navigation.MainTabRoute fun NavController.navigateSignUp() { navigate(SignUp) diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt index ae4c4d0..21eefe1 100644 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt @@ -31,10 +31,10 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R -import org.sopt.and.feature.component.ExpandedButton -import org.sopt.and.feature.component.AuthTextField -import org.sopt.and.feature.component.TopBar -import org.sopt.and.showToast +import org.sopt.and.core.component.ExpandedButton +import org.sopt.and.core.component.AuthTextField +import org.sopt.and.core.component.TopBar +import org.sopt.and.core.extension.showToast import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.LightGray From 1248207d26d436047c8e2180485a4750c68a6d8b Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 5 Dec 2024 00:59:57 +0900 Subject: [PATCH 03/40] chore #13: add Route and edit navigation package --- app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt | 5 ----- .../main/java/org/sopt/and/core/navigation/MainTabRoute.kt | 3 +++ app/src/main/java/org/sopt/and/core/navigation/Route.kt | 3 +++ app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt create mode 100644 app/src/main/java/org/sopt/and/core/navigation/MainTabRoute.kt create mode 100644 app/src/main/java/org/sopt/and/core/navigation/Route.kt diff --git a/app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt b/app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt deleted file mode 100644 index b0fcfc1..0000000 --- a/app/src/main/java/org/sopt/and/core/navigation/MainRoute.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.sopt.and.core.navigation - -interface MainRoute - -interface MainTabRoute : MainRoute diff --git a/app/src/main/java/org/sopt/and/core/navigation/MainTabRoute.kt b/app/src/main/java/org/sopt/and/core/navigation/MainTabRoute.kt new file mode 100644 index 0000000..98b4ab3 --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/navigation/MainTabRoute.kt @@ -0,0 +1,3 @@ +package org.sopt.and.core.navigation + +interface MainTabRoute : Route diff --git a/app/src/main/java/org/sopt/and/core/navigation/Route.kt b/app/src/main/java/org/sopt/and/core/navigation/Route.kt new file mode 100644 index 0000000..292dd41 --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/navigation/Route.kt @@ -0,0 +1,3 @@ +package org.sopt.and.core.navigation + +interface Route diff --git a/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt b/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt index ac3b9ad..97c99f3 100644 --- a/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt +++ b/app/src/main/java/org/sopt/and/feature/main/MainBottomTab.kt @@ -6,7 +6,6 @@ import androidx.compose.material.icons.outlined.Home import androidx.compose.material.icons.outlined.Search import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.vector.ImageVector -import org.sopt.and.core.navigation.MainRoute import org.sopt.and.core.navigation.MainTabRoute enum class MainBottomTab( @@ -37,7 +36,7 @@ enum class MainBottomTab( } @Composable - fun contains(predicate: @Composable (MainRoute) -> Boolean): Boolean { + fun contains(predicate: @Composable (MainTabRoute) -> Boolean): Boolean { return entries.map { it.route }.any { predicate(it) } } } From 0f51c4fc62212137d1049ddb8ca9ad3df4a8cd62 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 5 Dec 2024 01:11:03 +0900 Subject: [PATCH 04/40] chore #13: divide component to each package --- app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt | 2 +- .../org/sopt/and/feature/{ => home}/component/HomeContent.kt | 2 +- app/src/main/java/org/sopt/and/feature/my/MyRoute.kt | 4 ++-- .../org/sopt/and/feature/{ => my}/component/EventContent.kt | 2 +- .../org/sopt/and/feature/{ => my}/component/HistoryContent.kt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename app/src/main/java/org/sopt/and/feature/{ => home}/component/HomeContent.kt (99%) rename app/src/main/java/org/sopt/and/feature/{ => my}/component/EventContent.kt (98%) rename app/src/main/java/org/sopt/and/feature/{ => my}/component/HistoryContent.kt (98%) diff --git a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt index bea864f..6ea690a 100644 --- a/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/home/HomeRoute.kt @@ -33,8 +33,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import org.sopt.and.R -import org.sopt.and.feature.component.HomeContent import org.sopt.and.core.component.TopBar +import org.sopt.and.feature.home.component.HomeContent import org.sopt.and.feature.home.model.ContentModel import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black diff --git a/app/src/main/java/org/sopt/and/feature/component/HomeContent.kt b/app/src/main/java/org/sopt/and/feature/home/component/HomeContent.kt similarity index 99% rename from app/src/main/java/org/sopt/and/feature/component/HomeContent.kt rename to app/src/main/java/org/sopt/and/feature/home/component/HomeContent.kt index ed467ca..277fcff 100644 --- a/app/src/main/java/org/sopt/and/feature/component/HomeContent.kt +++ b/app/src/main/java/org/sopt/and/feature/home/component/HomeContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.feature.home.component import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement diff --git a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt index 3c4ecc1..075aca1 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt @@ -33,8 +33,8 @@ import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import org.sopt.and.R -import org.sopt.and.feature.component.EventContent -import org.sopt.and.feature.component.HistoryContent +import org.sopt.and.feature.my.component.EventContent +import org.sopt.and.feature.my.component.HistoryContent import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.Blue diff --git a/app/src/main/java/org/sopt/and/feature/component/EventContent.kt b/app/src/main/java/org/sopt/and/feature/my/component/EventContent.kt similarity index 98% rename from app/src/main/java/org/sopt/and/feature/component/EventContent.kt rename to app/src/main/java/org/sopt/and/feature/my/component/EventContent.kt index 7ff9e1e..6c96fb6 100644 --- a/app/src/main/java/org/sopt/and/feature/component/EventContent.kt +++ b/app/src/main/java/org/sopt/and/feature/my/component/EventContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.feature.my.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column diff --git a/app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt b/app/src/main/java/org/sopt/and/feature/my/component/HistoryContent.kt similarity index 98% rename from app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt rename to app/src/main/java/org/sopt/and/feature/my/component/HistoryContent.kt index ef26b10..e0d3a6c 100644 --- a/app/src/main/java/org/sopt/and/feature/component/HistoryContent.kt +++ b/app/src/main/java/org/sopt/and/feature/my/component/HistoryContent.kt @@ -1,4 +1,4 @@ -package org.sopt.and.feature.component +package org.sopt.and.feature.my.component import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth From 0a6499fbe74c348073112794a8c2bd19b3bf4a63 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:15:04 +0900 Subject: [PATCH 05/40] feature #13: MyUseCase --- .../java/org/sopt/and/domain/usecase/MyUseCase.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt diff --git a/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt new file mode 100644 index 0000000..4f0246a --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt @@ -0,0 +1,12 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.entity.response.ResponseHobbyEntity +import org.sopt.and.domain.repository.WavveRepository +import javax.inject.Inject + +class MyUseCase @Inject constructor( + private val myRepository: WavveRepository +) { + suspend operator fun invoke(): Result = + myRepository.getHobby() +} From 13738ee12672643558b11732917cb3743a4d4c9d Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:15:15 +0900 Subject: [PATCH 06/40] chore #13: apply MyUseCase --- app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt index abe8514..312ba2d 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt @@ -11,12 +11,12 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.R -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.usecase.MyUseCase import javax.inject.Inject @HiltViewModel class MyViewModel @Inject constructor( - private val wavveRepository: WavveRepository + private val getHobbyUseCase : MyUseCase ) : ViewModel() { private val _state = MutableStateFlow(MyState()) val state: StateFlow @@ -28,7 +28,7 @@ class MyViewModel @Inject constructor( fun getUserHobby() { viewModelScope.launch { - wavveRepository.getHobby().onSuccess { hobbyEntity -> + getHobbyUseCase.invoke().onSuccess { hobbyEntity -> _state.value = _state.value.copy( hobby = hobbyEntity.hobby ) From e8cc88b632792557a71fc5a3e06d4d82efb5c777 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:15:25 +0900 Subject: [PATCH 07/40] feature #13: SignInUseCase --- .../org/sopt/and/domain/usecase/SignInUseCase.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt new file mode 100644 index 0000000..0416fcc --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt @@ -0,0 +1,13 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.entity.request.RequestSignInEntity +import org.sopt.and.domain.entity.response.ResponseSignInEntity +import org.sopt.and.domain.repository.WavveRepository +import javax.inject.Inject + +class SignInUseCase @Inject constructor( + private val signInRepository: WavveRepository +) { + suspend operator fun invoke(signInEntity: RequestSignInEntity): Result = + signInRepository.signIn(signInEntity) +} From e4170ab58249459ff4545bf99e8ce569d895fb5d Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:16:20 +0900 Subject: [PATCH 08/40] chore #13: apply SignInUseCase --- .../java/org/sopt/and/feature/signin/SignInViewModel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 d976b19..24d73ae 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 @@ -11,14 +11,14 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.domain.entity.request.RequestSignInEntity -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.usecase.SignInUseCase import org.sopt.and.sharedpreference.User import javax.inject.Inject @HiltViewModel class SignInViewModel @Inject constructor( - private val user:User, - private val wavveRepository: WavveRepository + private val user: User, + private val signInUseCase: SignInUseCase ) : ViewModel() { private val _state = MutableStateFlow(SignInState()) val state: StateFlow @@ -49,7 +49,7 @@ class SignInViewModel @Inject constructor( fun isSignInValid() { viewModelScope.launch { var toastMessage: String = "" - wavveRepository.signIn( + signInUseCase.invoke( RequestSignInEntity( username = _state.value.username, password = _state.value.password From 833364c8f016f1427c1b06979f8e3fa0542c8fa7 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:16:33 +0900 Subject: [PATCH 09/40] feature #13: SignUpUseCase --- .../org/sopt/and/domain/usecase/SignUpUseCase.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt new file mode 100644 index 0000000..0699404 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt @@ -0,0 +1,13 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.entity.request.RequestSignUpEntity +import org.sopt.and.domain.entity.response.ResponseSignUpEntity +import org.sopt.and.domain.repository.WavveRepository +import javax.inject.Inject + +class SignUpUseCase @Inject constructor( + private val signUpRepository: WavveRepository +) { + suspend operator fun invoke(signUpEntity: RequestSignUpEntity): Result = + signUpRepository.signUp(signUpEntity) +} From 8383beede810fe4639ad89538ca86e18defab2f8 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:16:45 +0900 Subject: [PATCH 10/40] chore #13: apply SignUpUseCase --- .../java/org/sopt/and/feature/signup/SignUpViewModel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 09c27d2..777e059 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 @@ -12,13 +12,13 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.R import org.sopt.and.domain.entity.request.RequestSignUpEntity -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.usecase.SignUpUseCase import java.util.regex.Pattern import javax.inject.Inject @HiltViewModel class SignUpViewModel @Inject constructor( - private val wavveRepository: WavveRepository + private val signUpUseCase: SignUpUseCase ) : ViewModel() { private val _state = MutableStateFlow(SignUpState()) @@ -50,7 +50,7 @@ class SignUpViewModel @Inject constructor( fun isSignUpValid() { viewModelScope.launch { if (isUsernameValid() && isPasswordValid() && isHobbyValid()) { - wavveRepository.signUp( + signUpUseCase.invoke( RequestSignUpEntity( username = _state.value.username, password = _state.value.password, From 094db33a95464ca1175ed36cd3c54b08016f03d2 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:44:31 +0900 Subject: [PATCH 11/40] feature #13: SignInRepositoryImpl --- .../repositoryimpl/SignInRepositoryImpl.kt | 17 ++++++++++++ .../repositoryimpl/WavveRepositoryImpl.kt | 27 ------------------- 2 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt delete mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/WavveRepositoryImpl.kt diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt new file mode 100644 index 0000000..4a5ed3f --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt @@ -0,0 +1,17 @@ +package org.sopt.and.data.repositoryimpl + +import org.sopt.and.data.datasource.AuthDataSource +import org.sopt.and.data.dto.request.toDto +import org.sopt.and.domain.entity.request.RequestSignInEntity +import org.sopt.and.domain.entity.response.ResponseSignInEntity +import org.sopt.and.domain.repository.SignInRepository +import javax.inject.Inject + +class SignInRepositoryImpl @Inject constructor( + private val authDataSource: AuthDataSource +) : SignInRepository { + override suspend fun signIn(body: RequestSignInEntity): Result = + runCatching { + authDataSource.postSignIn(body.toDto()).result.toEntity() + } +} diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/WavveRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/WavveRepositoryImpl.kt deleted file mode 100644 index 90169c6..0000000 --- a/app/src/main/java/org/sopt/and/data/repositoryimpl/WavveRepositoryImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package org.sopt.and.data.repositoryimpl - -import org.sopt.and.data.datasource.WavveDataSource -import org.sopt.and.data.dto.request.toDto -import org.sopt.and.domain.entity.request.RequestSignInEntity -import org.sopt.and.domain.entity.request.RequestSignUpEntity -import org.sopt.and.domain.entity.response.ResponseHobbyEntity -import org.sopt.and.domain.entity.response.ResponseSignInEntity -import org.sopt.and.domain.entity.response.ResponseSignUpEntity -import org.sopt.and.domain.repository.WavveRepository -import javax.inject.Inject - -class WavveRepositoryImpl @Inject constructor( - private val wavveDataSource: WavveDataSource -) : WavveRepository { - override suspend fun signUp(body: RequestSignUpEntity): Result = runCatching { - wavveDataSource.postSignUp(body.toDto()).result.toEntity() - } - - override suspend fun signIn(body: RequestSignInEntity): Result = runCatching { - wavveDataSource.postSignIn(body.toDto()).result.toEntity() - } - - override suspend fun getHobby(): Result = runCatching { - wavveDataSource.getUserHobby().result.toEntity() - } -} From fdf48875762a94164d7b9644e8afff3acf98329a Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:44:40 +0900 Subject: [PATCH 12/40] feature #13: SignUpRepositoryImpl --- .../data/repositoryimpl/SignUpRepositoryImpl.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt new file mode 100644 index 0000000..ffb3bd5 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt @@ -0,0 +1,17 @@ +package org.sopt.and.data.repositoryimpl + +import org.sopt.and.data.datasource.AuthDataSource +import org.sopt.and.data.dto.request.toDto +import org.sopt.and.domain.entity.request.RequestSignUpEntity +import org.sopt.and.domain.entity.response.ResponseSignUpEntity +import org.sopt.and.domain.repository.SignUpRepository +import javax.inject.Inject + +class SignUpRepositoryImpl @Inject constructor( + private val authDataSource: AuthDataSource +) : SignUpRepository { + override suspend fun signUp(body: RequestSignUpEntity): Result = + runCatching { + authDataSource.postSignUp(body.toDto()).result.toEntity() + } +} From 7cb7dc712c37be482f1b8c7a26f442b00dcc058a Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:44:48 +0900 Subject: [PATCH 13/40] feature #13: MyRepositoryImpl --- .../and/data/repositoryimpl/MyRepositoryImpl.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/MyRepositoryImpl.kt diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/MyRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/MyRepositoryImpl.kt new file mode 100644 index 0000000..681c3ae --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/MyRepositoryImpl.kt @@ -0,0 +1,14 @@ +package org.sopt.and.data.repositoryimpl + +import org.sopt.and.data.datasource.MyDataSource +import org.sopt.and.domain.entity.response.ResponseHobbyEntity +import org.sopt.and.domain.repository.MyRepository +import javax.inject.Inject + +class MyRepositoryImpl @Inject constructor( + private val myDataSource: MyDataSource +) : MyRepository { + override suspend fun getHobby(): Result = runCatching { + myDataSource.getUserHobby().result.toEntity() + } +} From f228e2f5ac1ab4f6284a845aca6df2201a9f2f95 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:45:48 +0900 Subject: [PATCH 14/40] feature #13: MyRepository --- .../java/org/sopt/and/domain/repository/MyRepository.kt | 7 +++++++ app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/domain/repository/MyRepository.kt diff --git a/app/src/main/java/org/sopt/and/domain/repository/MyRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/MyRepository.kt new file mode 100644 index 0000000..708122c --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/MyRepository.kt @@ -0,0 +1,7 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.domain.entity.response.ResponseHobbyEntity + +interface MyRepository { + suspend fun getHobby(): Result +} diff --git a/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt index 4f0246a..224b23f 100644 --- a/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt +++ b/app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt @@ -1,11 +1,11 @@ package org.sopt.and.domain.usecase import org.sopt.and.domain.entity.response.ResponseHobbyEntity -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.repository.MyRepository import javax.inject.Inject class MyUseCase @Inject constructor( - private val myRepository: WavveRepository + private val myRepository: MyRepository ) { suspend operator fun invoke(): Result = myRepository.getHobby() From a7ba5971a1434108a05b4a0f6ce2b632bb9d2d4c Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:46:02 +0900 Subject: [PATCH 15/40] feature #13: SignInRepository --- .../sopt/and/domain/repository/SignInRepository.kt | 8 ++++++++ .../sopt/and/domain/repository/WavveRepository.kt | 13 ------------- .../org/sopt/and/domain/usecase/SignInUseCase.kt | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt delete mode 100644 app/src/main/java/org/sopt/and/domain/repository/WavveRepository.kt diff --git a/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt new file mode 100644 index 0000000..853a70f --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt @@ -0,0 +1,8 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.domain.entity.request.RequestSignInEntity +import org.sopt.and.domain.entity.response.ResponseSignInEntity + +interface SignInRepository { + suspend fun signIn(body: RequestSignInEntity): Result +} diff --git a/app/src/main/java/org/sopt/and/domain/repository/WavveRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/WavveRepository.kt deleted file mode 100644 index 6900eab..0000000 --- a/app/src/main/java/org/sopt/and/domain/repository/WavveRepository.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.sopt.and.domain.repository - -import org.sopt.and.domain.entity.request.RequestSignInEntity -import org.sopt.and.domain.entity.request.RequestSignUpEntity -import org.sopt.and.domain.entity.response.ResponseHobbyEntity -import org.sopt.and.domain.entity.response.ResponseSignInEntity -import org.sopt.and.domain.entity.response.ResponseSignUpEntity - -interface WavveRepository { - suspend fun signUp(body: RequestSignUpEntity): Result - suspend fun signIn(body:RequestSignInEntity): Result - suspend fun getHobby(): Result -} diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt index 0416fcc..3fb75ff 100644 --- a/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt @@ -2,11 +2,11 @@ package org.sopt.and.domain.usecase import org.sopt.and.domain.entity.request.RequestSignInEntity import org.sopt.and.domain.entity.response.ResponseSignInEntity -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.repository.SignInRepository import javax.inject.Inject class SignInUseCase @Inject constructor( - private val signInRepository: WavveRepository + private val signInRepository: SignInRepository ) { suspend operator fun invoke(signInEntity: RequestSignInEntity): Result = signInRepository.signIn(signInEntity) From 859d8e8af3e3e7639878ef50f99cb8bac8f9cff6 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:46:10 +0900 Subject: [PATCH 16/40] feature #13: SignUpRepository --- .../org/sopt/and/domain/repository/SignUpRepository.kt | 8 ++++++++ .../java/org/sopt/and/domain/usecase/SignUpUseCase.kt | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt diff --git a/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt new file mode 100644 index 0000000..d6dccaf --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt @@ -0,0 +1,8 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.domain.entity.request.RequestSignUpEntity +import org.sopt.and.domain.entity.response.ResponseSignUpEntity + +interface SignUpRepository { + suspend fun signUp(body: RequestSignUpEntity): Result +} diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt index 0699404..ba10919 100644 --- a/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt @@ -2,11 +2,11 @@ package org.sopt.and.domain.usecase import org.sopt.and.domain.entity.request.RequestSignUpEntity import org.sopt.and.domain.entity.response.ResponseSignUpEntity -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.domain.repository.SignUpRepository import javax.inject.Inject class SignUpUseCase @Inject constructor( - private val signUpRepository: WavveRepository + private val signUpRepository: SignUpRepository ) { suspend operator fun invoke(signUpEntity: RequestSignUpEntity): Result = signUpRepository.signUp(signUpEntity) From ad24c45eb73a339a15f8ad2956b659826c11ff85 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:46:24 +0900 Subject: [PATCH 17/40] feature #13: AuthService --- .../and/data/service/{WavveService.kt => AuthService.kt} | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) rename app/src/main/java/org/sopt/and/data/service/{WavveService.kt => AuthService.kt} (74%) diff --git a/app/src/main/java/org/sopt/and/data/service/WavveService.kt b/app/src/main/java/org/sopt/and/data/service/AuthService.kt similarity index 74% rename from app/src/main/java/org/sopt/and/data/service/WavveService.kt rename to app/src/main/java/org/sopt/and/data/service/AuthService.kt index 79a306f..afd81d0 100644 --- a/app/src/main/java/org/sopt/and/data/service/WavveService.kt +++ b/app/src/main/java/org/sopt/and/data/service/AuthService.kt @@ -3,14 +3,12 @@ package org.sopt.and.data.service 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.ResponseUserHobbyDto 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.POST -interface WavveService { +interface AuthService { @POST("/user") suspend fun postSignUp( @Body body: RequestSignUpDto @@ -20,7 +18,4 @@ interface WavveService { suspend fun postSignIn( @Body body: RequestSignInDto ): BaseResponse - - @GET("/user/my-hobby") - suspend fun getUserHobby(): BaseResponse } From 0ca0bed269455e4227c71cbfc57c1d2999f89922 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:46:33 +0900 Subject: [PATCH 18/40] feature #13: MyService --- .../main/java/org/sopt/and/data/service/MyService.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/service/MyService.kt diff --git a/app/src/main/java/org/sopt/and/data/service/MyService.kt b/app/src/main/java/org/sopt/and/data/service/MyService.kt new file mode 100644 index 0000000..806a278 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/MyService.kt @@ -0,0 +1,10 @@ +package org.sopt.and.data.service + +import org.sopt.and.data.dto.response.BaseResponse +import org.sopt.and.data.dto.response.ResponseUserHobbyDto +import retrofit2.http.GET + +interface MyService { + @GET("/user/my-hobby") + suspend fun getUserHobby(): BaseResponse +} From 0b0d469a9c15a6b42448bd9eaea94ae2d1cf10b3 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:46:52 +0900 Subject: [PATCH 19/40] feature #13: MyDataSourceImpl --- .../and/data/datasourceimpl/MyDataSourceImpl.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/datasourceimpl/MyDataSourceImpl.kt diff --git a/app/src/main/java/org/sopt/and/data/datasourceimpl/MyDataSourceImpl.kt b/app/src/main/java/org/sopt/and/data/datasourceimpl/MyDataSourceImpl.kt new file mode 100644 index 0000000..fcaf119 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasourceimpl/MyDataSourceImpl.kt @@ -0,0 +1,14 @@ +package org.sopt.and.data.datasourceimpl + +import org.sopt.and.data.datasource.MyDataSource +import org.sopt.and.data.dto.response.BaseResponse +import org.sopt.and.data.dto.response.ResponseUserHobbyDto +import org.sopt.and.data.service.MyService +import javax.inject.Inject + +class MyDataSourceImpl @Inject constructor( + private val myService: MyService +) : MyDataSource { + override suspend fun getUserHobby(): BaseResponse = + myService.getUserHobby() +} From bcba10b7a070d46c7aa3e343d9216133284f5894 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:11 +0900 Subject: [PATCH 20/40] feature #13: AuthDataSourceImpl --- ...ataSourceImpl.kt => AuthDataSourceImpl.kt} | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) rename app/src/main/java/org/sopt/and/data/datasourceimpl/{WavveDataSourceImpl.kt => AuthDataSourceImpl.kt} (53%) diff --git a/app/src/main/java/org/sopt/and/data/datasourceimpl/WavveDataSourceImpl.kt b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt similarity index 53% rename from app/src/main/java/org/sopt/and/data/datasourceimpl/WavveDataSourceImpl.kt rename to app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt index db581fa..3ec8307 100644 --- a/app/src/main/java/org/sopt/and/data/datasourceimpl/WavveDataSourceImpl.kt +++ b/app/src/main/java/org/sopt/and/data/datasourceimpl/AuthDataSourceImpl.kt @@ -1,25 +1,20 @@ package org.sopt.and.data.datasourceimpl -import org.sopt.and.data.datasource.WavveDataSource +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.ResponseUserHobbyDto import org.sopt.and.data.dto.response.ResponseSignInDto import org.sopt.and.data.dto.response.ResponseSignUpDto -import org.sopt.and.data.service.WavveService +import org.sopt.and.data.service.AuthService import javax.inject.Inject -class WavveDataSourceImpl @Inject constructor( - private val wavveService: WavveService -) : WavveDataSource { +class AuthDataSourceImpl @Inject constructor( + private val authService: AuthService +) : AuthDataSource { override suspend fun postSignUp(requestSignUpDto: RequestSignUpDto): BaseResponse = - wavveService.postSignUp(requestSignUpDto) + authService.postSignUp(requestSignUpDto) override suspend fun postSignIn(requestSignInDto: RequestSignInDto): BaseResponse = - wavveService.postSignIn(requestSignInDto) - - override suspend fun getUserHobby(): BaseResponse = - wavveService.getUserHobby() - + authService.postSignIn(requestSignInDto) } From 9f0cd0e08df015ff80b6467fbbfbfa6f4a3b5817 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:18 +0900 Subject: [PATCH 21/40] feature #13: AuthDataSource --- .../data/datasource/{WavveDataSource.kt => AuthDataSource.kt} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename app/src/main/java/org/sopt/and/data/datasource/{WavveDataSource.kt => AuthDataSource.kt} (76%) diff --git a/app/src/main/java/org/sopt/and/data/datasource/WavveDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt similarity index 76% rename from app/src/main/java/org/sopt/and/data/datasource/WavveDataSource.kt rename to app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt index 6477aad..4abdf08 100644 --- a/app/src/main/java/org/sopt/and/data/datasource/WavveDataSource.kt +++ b/app/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt @@ -3,12 +3,10 @@ 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.ResponseUserHobbyDto import org.sopt.and.data.dto.response.ResponseSignInDto import org.sopt.and.data.dto.response.ResponseSignUpDto -interface WavveDataSource { +interface AuthDataSource { suspend fun postSignUp(requestSignUpDto: RequestSignUpDto): BaseResponse suspend fun postSignIn(requestSignInDto: RequestSignInDto): BaseResponse - suspend fun getUserHobby(): BaseResponse } From 66fa970b2fc4a37db1b4b2ddd276f74f64d18d20 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:25 +0900 Subject: [PATCH 22/40] feature #13: MyDataSource --- .../java/org/sopt/and/data/datasource/MyDataSource.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/data/datasource/MyDataSource.kt diff --git a/app/src/main/java/org/sopt/and/data/datasource/MyDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/MyDataSource.kt new file mode 100644 index 0000000..821fba6 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasource/MyDataSource.kt @@ -0,0 +1,8 @@ +package org.sopt.and.data.datasource + +import org.sopt.and.data.dto.response.BaseResponse +import org.sopt.and.data.dto.response.ResponseUserHobbyDto + +interface MyDataSource { + suspend fun getUserHobby(): BaseResponse +} From 92f4d7866773d00be2189a4dceca1c74df772c7a Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:39 +0900 Subject: [PATCH 23/40] chore #13: DataSourceModule --- .../java/org/sopt/and/data/di/DataSourceModule.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 index 62ef271..9f8309c 100644 --- a/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt @@ -4,8 +4,10 @@ import dagger.Binds import dagger.Module import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import org.sopt.and.data.datasource.WavveDataSource -import org.sopt.and.data.datasourceimpl.WavveDataSourceImpl +import org.sopt.and.data.datasource.AuthDataSource +import org.sopt.and.data.datasource.MyDataSource +import org.sopt.and.data.datasourceimpl.AuthDataSourceImpl +import org.sopt.and.data.datasourceimpl.MyDataSourceImpl import javax.inject.Singleton @Module @@ -13,6 +15,10 @@ import javax.inject.Singleton internal abstract class DataSourceModule { @Binds @Singleton - abstract fun bindsDataSource(myDataSourceImpl: WavveDataSourceImpl): WavveDataSource + abstract fun bindsDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource + + @Binds + @Singleton + abstract fun myDataSource(MyDataSourceImpl: MyDataSourceImpl): MyDataSource } From 2bf2804910b2b8f98ebb3c40284b0c0b6950f7cc Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:48 +0900 Subject: [PATCH 24/40] chore #13: RepositoryModule --- .../org/sopt/and/data/di/RepositoryModule.kt | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) 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 index fe12ba9..16d6588 100644 --- a/app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt @@ -4,8 +4,12 @@ import dagger.Binds import dagger.Module import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import org.sopt.and.data.repositoryimpl.WavveRepositoryImpl -import org.sopt.and.domain.repository.WavveRepository +import org.sopt.and.data.repositoryimpl.MyRepositoryImpl +import org.sopt.and.data.repositoryimpl.SignInRepositoryImpl +import org.sopt.and.data.repositoryimpl.SignUpRepositoryImpl +import org.sopt.and.domain.repository.MyRepository +import org.sopt.and.domain.repository.SignInRepository +import org.sopt.and.domain.repository.SignUpRepository import javax.inject.Singleton @Module @@ -13,7 +17,19 @@ import javax.inject.Singleton internal abstract class RepositoryModule { @Binds @Singleton - abstract fun bindsRepository( - myRepositoryImpl: WavveRepositoryImpl - ): WavveRepository + abstract fun bindsSignInRepository( + signInRepositoryImpl: SignInRepositoryImpl + ): SignInRepository + + @Binds + @Singleton + abstract fun bindsSignUpRepository( + signUpRepositoryImpl: SignUpRepositoryImpl + ): SignUpRepository + + @Binds + @Singleton + abstract fun bindsMyRepository( + myRepositoryImpl: MyRepositoryImpl + ): MyRepository } From ce45e9e681b7c9cb0dce314f4f9bc6e765fd0bc8 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:47:59 +0900 Subject: [PATCH 25/40] chore #13: ServiceModule --- .../main/java/org/sopt/and/data/di/ServiceModule.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/sopt/and/data/di/ServiceModule.kt b/app/src/main/java/org/sopt/and/data/di/ServiceModule.kt index 3933554..2a72638 100644 --- a/app/src/main/java/org/sopt/and/data/di/ServiceModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/ServiceModule.kt @@ -4,7 +4,8 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import org.sopt.and.data.service.WavveService +import org.sopt.and.data.service.AuthService +import org.sopt.and.data.service.MyService import retrofit2.Retrofit import javax.inject.Singleton @@ -13,6 +14,11 @@ import javax.inject.Singleton object ServiceModule { @Provides @Singleton - fun providerService(retrofit: Retrofit): WavveService = - retrofit.create(WavveService::class.java) + fun providerAuthService(retrofit: Retrofit): AuthService = + retrofit.create(AuthService::class.java) + + @Provides + @Singleton + fun providerMyService(retrofit: Retrofit): MyService = + retrofit.create(MyService::class.java) } From 374274f11b83c3cfe1859228e6666922ce9a3185 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 6 Dec 2024 22:48:48 +0900 Subject: [PATCH 26/40] chore #13: edit DataSourceModule function naming --- app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 9f8309c..84ae88c 100644 --- a/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt +++ b/app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt @@ -15,10 +15,10 @@ import javax.inject.Singleton internal abstract class DataSourceModule { @Binds @Singleton - abstract fun bindsDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource + abstract fun bindsAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource @Binds @Singleton - abstract fun myDataSource(MyDataSourceImpl: MyDataSourceImpl): MyDataSource + abstract fun bindsMyDataSource(MyDataSourceImpl: MyDataSourceImpl): MyDataSource } From 59fae349bc2dd3950c0b9a675681266a577f45c7 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:26:18 +0900 Subject: [PATCH 27/40] Add #15: SignUpEvent --- .../main/java/org/sopt/and/feature/signup/SignUpEvent.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt new file mode 100644 index 0000000..cec1a0d --- /dev/null +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt @@ -0,0 +1,7 @@ +package org.sopt.and.feature.signup + +sealed class SignUpEvent { + data class SetUsername(val username: String) : SignUpEvent() + data class SetPassword(val password: String) : SignUpEvent() + data class SetHobby(val hobby: String) : SignUpEvent() +} From a799136c46368a1cd8121c74c23bb05270b87d4a Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:27:00 +0900 Subject: [PATCH 28/40] Chore #15: apply SignUpEvent --- .../java/org/sopt/and/feature/signup/SignUpRoute.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt index 21eefe1..6a6c8ac 100644 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt @@ -70,10 +70,16 @@ fun SignUpRoute( username = state.username, password = state.password, hobby = state.hobby, - onUsernameChange = viewModel::setUsername, - onPasswordChange = viewModel::setPassword, + onUsernameChange = { username -> + viewModel.setEvent(SignUpEvent.SetUsername(username = username)) + }, + onPasswordChange = { password -> + viewModel.setEvent(SignUpEvent.SetPassword(password = password)) + }, isPasswordVisible = state.isPasswordVisible, - onHobbyChange = viewModel::setHobby, + onHobbyChange = { hobby -> + viewModel.setEvent(SignUpEvent.SetHobby(hobby = hobby)) + }, reversePasswordVisibility = viewModel::reversePasswordVisibility, isButtonEnabled = state.isButtonEnabled, checkSignUpValidation = viewModel::isSignUpValid, From 0388bd4cf06c4e2dccfdc12a12d93745378caeef Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:27:22 +0900 Subject: [PATCH 29/40] Chore #15: apply SignUpEvent --- .../and/feature/signup/SignUpViewModel.kt | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) 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 777e059..95901bb 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 @@ -24,27 +24,44 @@ class SignUpViewModel @Inject constructor( private val _state = MutableStateFlow(SignUpState()) val state: StateFlow get() = _state.asStateFlow() + private val currentState: SignUpState + get() = state.value private val _sideEffect: MutableSharedFlow = MutableSharedFlow() val sideEffect: SharedFlow get() = _sideEffect.asSharedFlow() - fun setUsername(username: String) { - _state.value = _state.value.copy( - username = username - ) + private fun setState(reduce: SignUpState.() -> SignUpState) { + _state.value = currentState.reduce() } - fun setPassword(password: String) { - _state.value = _state.value.copy( - password = password - ) + fun setEvent(event: SignUpEvent) { + dispatchEvent(event) } - fun setHobby(hobby: String) { - _state.value = _state.value.copy( - hobby = hobby - ) + private fun dispatchEvent(event: SignUpEvent) = viewModelScope.launch { + handleEvent(event) + } + + private fun handleEvent(event: SignUpEvent) { + when (event) { + is SignUpEvent.SetUsername -> { + setState { + copy(username = event.username) + } + } + + is SignUpEvent.SetPassword -> { + setState { + copy(password = event.password) + } + } + is SignUpEvent.SetHobby -> { + setState { + copy(hobby = event.hobby) + } + } + } } fun isSignUpValid() { From 03a85c7c6517f5f70cc6309eed9cd3f4f0969a98 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:31:29 +0900 Subject: [PATCH 30/40] Add #15: SignInEvent --- .../main/java/org/sopt/and/feature/signin/SignInEvent.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt new file mode 100644 index 0000000..435745a --- /dev/null +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt @@ -0,0 +1,6 @@ +package org.sopt.and.feature.signin + +sealed class SignInEvent { + data class SetUsername(val username: String) : SignInEvent() + data class SetPassword(val password: String) : SignInEvent() +} From 006ffb2817163060056877e05d13d8f1b24eb5e4 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:31:40 +0900 Subject: [PATCH 31/40] Chore #15: apply SignInEvent --- .../sopt/and/feature/signin/SignInRoute.kt | 10 ++++-- .../and/feature/signin/SignInViewModel.kt | 34 ++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt index 949a70d..56e149b 100644 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt @@ -36,8 +36,8 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R -import org.sopt.and.core.component.RoundedButton import org.sopt.and.core.component.AuthTextField +import org.sopt.and.core.component.RoundedButton import org.sopt.and.core.component.TopBar import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black @@ -78,8 +78,12 @@ fun SignInRoute( navigateToSignUp = navigateToSignUp, username = state.username, password = state.password, - onUsernameChange = viewModel::setUsername, - onPasswordChange = viewModel::setPassword, + onUsernameChange = { username -> + viewModel.setEvent(SignInEvent.SetUsername(username = username)) + }, + onPasswordChange = { password -> + viewModel.setEvent(SignInEvent.SetPassword(password = password)) + }, isPasswordVisible = state.isPasswordVisible, reversePasswordVisibility = viewModel::reversePasswordVisibility, isButtonEnabled = state.isButtonEnabled, 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 24d73ae..e7d0ba7 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 @@ -23,21 +23,39 @@ class SignInViewModel @Inject constructor( private val _state = MutableStateFlow(SignInState()) val state: StateFlow get() = _state.asStateFlow() + private val currentState: SignInState + get() = state.value private val _sideEffect: MutableSharedFlow = MutableSharedFlow() val sideEffect: SharedFlow get() = _sideEffect.asSharedFlow() - fun setUsername(username: String) { - _state.value = _state.value.copy( - username = username - ) + private fun setState(reduce: SignInState.() -> SignInState) { + _state.value = currentState.reduce() } - fun setPassword(password: String) { - _state.value = _state.value.copy( - password = password - ) + fun setEvent(event: SignInEvent) { + dispatchEvent(event) + } + + private fun dispatchEvent(event: SignInEvent) = viewModelScope.launch { + handleEvent(event) + } + + private fun handleEvent(event: SignInEvent) { + when (event) { + is SignInEvent.SetUsername -> { + setState { + copy(username = event.username) + } + } + + is SignInEvent.SetPassword -> { + setState { + copy(password = event.password) + } + } + } } fun reversePasswordVisibility() { From c690d8aac33c720fb3d38b25942dbf9320c2a7bd Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:40:06 +0900 Subject: [PATCH 32/40] Chore #15: apply Timber --- app/build.gradle.kts | 3 +++ app/src/main/java/org/sopt/and/data/di/NetworkModule.kt | 4 ++-- gradle/libs.versions.toml | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2a39dff..6d480c5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -85,4 +85,7 @@ dependencies { // Network implementation(platform(libs.okhttp.bom)) implementation(libs.bundles.network) + + //timer + implementation(libs.timber) } 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 2085458..aab8c61 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 @@ -13,6 +13,7 @@ import okhttp3.logging.HttpLoggingInterceptor import org.sopt.and.BuildConfig import org.sopt.and.sharedpreference.User import retrofit2.Retrofit +import timber.log.Timber import javax.inject.Singleton @Module @@ -36,13 +37,12 @@ object NetworkModule { @Provides fun provideLoggingInterceptor(): HttpLoggingInterceptor { return HttpLoggingInterceptor { message -> - Log.d("Retrofit2", "CONNECTION INFO -> $message") + Timber.tag("Retrofit2").d("CONNECTION INFO -> $message") }.apply { level = HttpLoggingInterceptor.Level.BODY } } - @Singleton @Provides fun provideAuthInterceptor(user: User): AuthInterceptor { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4386653..6c71402 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,6 +18,7 @@ ksp = "2.0.0-1.0.22" okhttp = "4.11.0" retrofit = "2.9.0" retrofitKotlinSerializationConverter = "1.0.0" +timber = "5.0.1" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -46,6 +47,7 @@ okhttp = { group = "com.squareup.okhttp3", name = "okhttp" } okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor" } 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" } +timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } From b0e0fb649aca4cbe7a085d237abd6907906b6591 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:49:01 +0900 Subject: [PATCH 33/40] Chore #15: SignUpContract --- .../sopt/and/feature/signup/SignUpContract.kt | 23 +++++++++++++++++++ .../sopt/and/feature/signup/SignUpRoute.kt | 2 ++ .../and/feature/signup/SignUpViewModel.kt | 10 ++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/feature/signup/SignUpContract.kt diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpContract.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpContract.kt new file mode 100644 index 0000000..cd09789 --- /dev/null +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpContract.kt @@ -0,0 +1,23 @@ +package org.sopt.and.feature.signup + +class SignUpContract { + data class SignUpState( + val username: String = "", + val password: String = "", + val hobby: String = "", + var isPasswordVisible: Boolean = false, + ) { + val isButtonEnabled: Boolean = username.isNotEmpty() && password.isNotEmpty() + } + + sealed class SignUpEvent { + data class SetUsername(val username: String) : SignUpEvent() + data class SetPassword(val password: String) : SignUpEvent() + data class SetHobby(val hobby: String) : SignUpEvent() + } + + sealed class SignUpSideEffect { + data object NavigateToSignIn : SignUpSideEffect() + data class ShowToast(val toastMessage: Int) : SignUpSideEffect() + } +} diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt index 6a6c8ac..06c1b98 100644 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signup/SignUpRoute.kt @@ -35,6 +35,8 @@ import org.sopt.and.core.component.ExpandedButton import org.sopt.and.core.component.AuthTextField import org.sopt.and.core.component.TopBar import org.sopt.and.core.extension.showToast +import org.sopt.and.feature.signup.SignUpContract.SignUpEvent +import org.sopt.and.feature.signup.SignUpContract.SignUpSideEffect import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.LightGray 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 95901bb..aec4598 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 @@ -13,6 +13,8 @@ import kotlinx.coroutines.launch import org.sopt.and.R import org.sopt.and.domain.entity.request.RequestSignUpEntity import org.sopt.and.domain.usecase.SignUpUseCase +import org.sopt.and.feature.signup.SignUpContract.SignUpEvent +import org.sopt.and.feature.signup.SignUpContract.SignUpSideEffect import java.util.regex.Pattern import javax.inject.Inject @@ -21,17 +23,17 @@ class SignUpViewModel @Inject constructor( private val signUpUseCase: SignUpUseCase ) : ViewModel() { - private val _state = MutableStateFlow(SignUpState()) - val state: StateFlow + private val _state = MutableStateFlow(SignUpContract.SignUpState()) + val state: StateFlow get() = _state.asStateFlow() - private val currentState: SignUpState + private val currentState: SignUpContract.SignUpState get() = state.value private val _sideEffect: MutableSharedFlow = MutableSharedFlow() val sideEffect: SharedFlow get() = _sideEffect.asSharedFlow() - private fun setState(reduce: SignUpState.() -> SignUpState) { + private fun setState(reduce: SignUpContract.SignUpState.() -> SignUpContract.SignUpState) { _state.value = currentState.reduce() } From 63c27e97377ced4167f440e912fe9f1f871e93b8 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:49:21 +0900 Subject: [PATCH 34/40] Delete #15: delete origin SignUpEvent,SideEffect,State --- .../java/org/sopt/and/feature/signup/SignUpEvent.kt | 7 ------- .../org/sopt/and/feature/signup/SignUpSideEffect.kt | 6 ------ .../java/org/sopt/and/feature/signup/SignUpState.kt | 10 ---------- 3 files changed, 23 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt delete mode 100644 app/src/main/java/org/sopt/and/feature/signup/SignUpSideEffect.kt delete mode 100644 app/src/main/java/org/sopt/and/feature/signup/SignUpState.kt diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt deleted file mode 100644 index cec1a0d..0000000 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpEvent.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.sopt.and.feature.signup - -sealed class SignUpEvent { - data class SetUsername(val username: String) : SignUpEvent() - data class SetPassword(val password: String) : SignUpEvent() - data class SetHobby(val hobby: String) : SignUpEvent() -} diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpSideEffect.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpSideEffect.kt deleted file mode 100644 index 5c1deb0..0000000 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpSideEffect.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.sopt.and.feature.signup - -sealed class SignUpSideEffect { - data object NavigateToSignIn : SignUpSideEffect() - data class ShowToast(val toastMessage: Int) : SignUpSideEffect() -} diff --git a/app/src/main/java/org/sopt/and/feature/signup/SignUpState.kt b/app/src/main/java/org/sopt/and/feature/signup/SignUpState.kt deleted file mode 100644 index 0184f88..0000000 --- a/app/src/main/java/org/sopt/and/feature/signup/SignUpState.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.sopt.and.feature.signup - -data class SignUpState( - val username: String = "", - val password: String = "", - val hobby: String = "", - var isPasswordVisible: Boolean = false, -) { - val isButtonEnabled: Boolean = username.isNotEmpty() && password.isNotEmpty() -} From a1fe2e60a5234b5d270d1a9fd0409b5e77787f60 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Tue, 17 Dec 2024 23:50:41 +0900 Subject: [PATCH 35/40] Delete #15: delete origin SignInEvent,SideEffect,State --- .../main/java/org/sopt/and/feature/signin/SignInEvent.kt | 6 ------ .../java/org/sopt/and/feature/signin/SignInSideEffect.kt | 7 ------- .../main/java/org/sopt/and/feature/signin/SignInState.kt | 9 --------- 3 files changed, 22 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt delete mode 100644 app/src/main/java/org/sopt/and/feature/signin/SignInSideEffect.kt delete mode 100644 app/src/main/java/org/sopt/and/feature/signin/SignInState.kt diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt deleted file mode 100644 index 435745a..0000000 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInEvent.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.sopt.and.feature.signin - -sealed class SignInEvent { - data class SetUsername(val username: String) : SignInEvent() - data class SetPassword(val password: String) : SignInEvent() -} diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInSideEffect.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInSideEffect.kt deleted file mode 100644 index 2163076..0000000 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInSideEffect.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.sopt.and.feature.signin - -sealed class SignInSideEffect { - data object NavigateToSignUp : SignInSideEffect() - data object NavigateToHome : SignInSideEffect() - data class ShowSnackBar(val snackBarMessage: String) : SignInSideEffect() -} diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInState.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInState.kt deleted file mode 100644 index eb3319b..0000000 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInState.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.sopt.and.feature.signin - -data class SignInState( - val username: String = "", - val password: String = "", - var isPasswordVisible: Boolean = false, -) { - val isButtonEnabled: Boolean = username.isNotEmpty() && password.isNotEmpty() -} From 11aa8c380d679ba38cce47de74cfef19c73f25ab Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 18 Dec 2024 00:13:27 +0900 Subject: [PATCH 36/40] Chore #15: SignInContract --- .../sopt/and/feature/signin/SignInContract.kt | 22 +++++++++++++++++++ .../sopt/and/feature/signin/SignInRoute.kt | 2 ++ .../and/feature/signin/SignInViewModel.kt | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/feature/signin/SignInContract.kt diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInContract.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInContract.kt new file mode 100644 index 0000000..d6d0f10 --- /dev/null +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInContract.kt @@ -0,0 +1,22 @@ +package org.sopt.and.feature.signin + +class SignInContract { + data class SignInState( + val username: String = "", + val password: String = "", + var isPasswordVisible: Boolean = false, + ) { + val isButtonEnabled: Boolean = username.isNotEmpty() && password.isNotEmpty() + } + + sealed class SignInEvent { + data class SetUsername(val username: String) : SignInEvent() + data class SetPassword(val password: String) : SignInEvent() + } + + sealed class SignInSideEffect { + data object NavigateToSignUp : SignInSideEffect() + data object NavigateToHome : SignInSideEffect() + data class ShowSnackBar(val snackBarMessage: String) : SignInSideEffect() + } +} diff --git a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt index 56e149b..c57f6d5 100644 --- a/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/signin/SignInRoute.kt @@ -39,6 +39,8 @@ import org.sopt.and.R import org.sopt.and.core.component.AuthTextField import org.sopt.and.core.component.RoundedButton import org.sopt.and.core.component.TopBar +import org.sopt.and.feature.signin.SignInContract.SignInEvent +import org.sopt.and.feature.signin.SignInContract.SignInSideEffect import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Black import org.sopt.and.ui.theme.LightGray 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 e7d0ba7..79980df 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 @@ -12,6 +12,9 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.domain.entity.request.RequestSignInEntity import org.sopt.and.domain.usecase.SignInUseCase +import org.sopt.and.feature.signin.SignInContract.SignInEvent +import org.sopt.and.feature.signin.SignInContract.SignInSideEffect +import org.sopt.and.feature.signin.SignInContract.SignInState import org.sopt.and.sharedpreference.User import javax.inject.Inject From f724a13a1f00283f608a8b55cba9db3fc27a10a5 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 18 Dec 2024 00:26:29 +0900 Subject: [PATCH 37/40] Delete #15: delete origin MySideEffect,State --- app/src/main/java/org/sopt/and/feature/my/MySideEffect.kt | 5 ----- app/src/main/java/org/sopt/and/feature/my/MyState.kt | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/feature/my/MySideEffect.kt delete mode 100644 app/src/main/java/org/sopt/and/feature/my/MyState.kt diff --git a/app/src/main/java/org/sopt/and/feature/my/MySideEffect.kt b/app/src/main/java/org/sopt/and/feature/my/MySideEffect.kt deleted file mode 100644 index 35a6656..0000000 --- a/app/src/main/java/org/sopt/and/feature/my/MySideEffect.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.sopt.and.feature.my - -sealed class MySideEffect { - data class ShowToast(val toastMessage: Int) : MySideEffect() -} diff --git a/app/src/main/java/org/sopt/and/feature/my/MyState.kt b/app/src/main/java/org/sopt/and/feature/my/MyState.kt deleted file mode 100644 index 22d4476..0000000 --- a/app/src/main/java/org/sopt/and/feature/my/MyState.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.sopt.and.feature.my - -data class MyState( - val hobby: String = "" -) From e4b685804b90d4310133173c6d400550b496e5ae Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 18 Dec 2024 00:27:44 +0900 Subject: [PATCH 38/40] Chore #15: MyContract --- .../java/org/sopt/and/feature/my/MyContract.kt | 11 +++++++++++ .../java/org/sopt/and/feature/my/MyViewModel.kt | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/feature/my/MyContract.kt diff --git a/app/src/main/java/org/sopt/and/feature/my/MyContract.kt b/app/src/main/java/org/sopt/and/feature/my/MyContract.kt new file mode 100644 index 0000000..2b69e5d --- /dev/null +++ b/app/src/main/java/org/sopt/and/feature/my/MyContract.kt @@ -0,0 +1,11 @@ +package org.sopt.and.feature.my + +class MyContract { + data class MyState( + val hobby: String = "" + ) + + sealed class MySideEffect { + data class ShowToast(val toastMessage: Int) : MySideEffect() + } +} diff --git a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt index 312ba2d..6383ea9 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt @@ -12,13 +12,19 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.R import org.sopt.and.domain.usecase.MyUseCase +import org.sopt.and.feature.my.MyContract.MySideEffect +import org.sopt.and.feature.my.MyContract.MyState import javax.inject.Inject @HiltViewModel class MyViewModel @Inject constructor( - private val getHobbyUseCase : MyUseCase + private val getHobbyUseCase: MyUseCase ) : ViewModel() { - private val _state = MutableStateFlow(MyState()) + private val _state: MutableStateFlow + get() = MutableStateFlow(MyState()) + private val currentState: MyState + get() = state.value + val state: StateFlow get() = _state.asStateFlow() @@ -26,6 +32,10 @@ class MyViewModel @Inject constructor( val sideEffect: SharedFlow get() = _sideEffect.asSharedFlow() + private fun setState(reduce: MyState.() -> MyState) { + _state.value = currentState.reduce() + } + fun getUserHobby() { viewModelScope.launch { getHobbyUseCase.invoke().onSuccess { hobbyEntity -> From 40aa62c988eba068aed63de172982fddc0e805dc Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Sun, 5 Jan 2025 14:50:47 +0900 Subject: [PATCH 39/40] Feature #15: set BaseViewModel --- .../org/sopt/and/core/util/BaseViewModel.kt | 50 +++++++++++++++++++ .../java/org/sopt/and/core/util/UiEvent.kt | 3 ++ .../org/sopt/and/core/util/UiSideEffect.kt | 3 ++ .../java/org/sopt/and/core/util/UiState.kt | 3 ++ 4 files changed, 59 insertions(+) create mode 100644 app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt create mode 100644 app/src/main/java/org/sopt/and/core/util/UiEvent.kt create mode 100644 app/src/main/java/org/sopt/and/core/util/UiSideEffect.kt create mode 100644 app/src/main/java/org/sopt/and/core/util/UiState.kt diff --git a/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt b/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt new file mode 100644 index 0000000..7c7bc95 --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt @@ -0,0 +1,50 @@ +package org.sopt.and.core.util + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch + +abstract class BaseViewModel() : + ViewModel() { + private val initialState: State by lazy { createInitialState() } + abstract fun createInitialState(): State + + private val _uiState = MutableStateFlow(initialState) + val uiState: StateFlow + get() = _uiState.asStateFlow() + val currentState: State + get() = uiState.value + + private val _event: MutableSharedFlow = MutableSharedFlow() + val event: SharedFlow + get() = _event.asSharedFlow() + + private val _sideEffect: MutableSharedFlow = MutableSharedFlow() + val sideEffect: Flow + get() = _sideEffect.asSharedFlow() + + fun setState(reduce: State.() -> State) { + _uiState.value = currentState.reduce() + } + + open fun setEvent(event: Event) { + dispatchEvent(event) + } + + private fun dispatchEvent(event: Event) = viewModelScope.launch { + handleEvent(event) + } + + protected abstract suspend fun handleEvent(event: Event) + + fun setSideEffect(sideEffect: SideEffect) { + viewModelScope.launch { _sideEffect.emit(sideEffect) } + } +} diff --git a/app/src/main/java/org/sopt/and/core/util/UiEvent.kt b/app/src/main/java/org/sopt/and/core/util/UiEvent.kt new file mode 100644 index 0000000..0540a39 --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/util/UiEvent.kt @@ -0,0 +1,3 @@ +package org.sopt.and.core.util + +interface UiEvent diff --git a/app/src/main/java/org/sopt/and/core/util/UiSideEffect.kt b/app/src/main/java/org/sopt/and/core/util/UiSideEffect.kt new file mode 100644 index 0000000..ded471b --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/util/UiSideEffect.kt @@ -0,0 +1,3 @@ +package org.sopt.and.core.util + +interface UiSideEffect diff --git a/app/src/main/java/org/sopt/and/core/util/UiState.kt b/app/src/main/java/org/sopt/and/core/util/UiState.kt new file mode 100644 index 0000000..56c7b3c --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/util/UiState.kt @@ -0,0 +1,3 @@ +package org.sopt.and.core.util + +interface UiState From cc2f3b373e89314bfe13dd7d8215685777bbcaa2 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Sun, 5 Jan 2025 21:58:57 +0900 Subject: [PATCH 40/40] Refactor #15: APPJAM Refactor --- .../org/sopt/and/core/util/BaseViewModel.kt | 32 ++++---- .../java/org/sopt/and/core/util/LoadState.kt | 8 ++ .../entity/response/ResponseHobbyEntity.kt | 2 +- .../org/sopt/and/feature/my/MyContract.kt | 20 ++++- .../java/org/sopt/and/feature/my/MyRoute.kt | 45 +++++++++-- .../org/sopt/and/feature/my/MyViewModel.kt | 80 ++++++++++++------- 6 files changed, 133 insertions(+), 54 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/core/util/LoadState.kt diff --git a/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt b/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt index 7c7bc95..513ec83 100644 --- a/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt +++ b/app/src/main/java/org/sopt/and/core/util/BaseViewModel.kt @@ -2,6 +2,7 @@ package org.sopt.and.core.util import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -9,42 +10,43 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.launch -abstract class BaseViewModel() : +abstract class BaseViewModel() : ViewModel() { private val initialState: State by lazy { createInitialState() } abstract fun createInitialState(): State - private val _uiState = MutableStateFlow(initialState) + private val _state = MutableStateFlow(initialState) val uiState: StateFlow - get() = _uiState.asStateFlow() + get() = _state.asStateFlow() val currentState: State get() = uiState.value - private val _event: MutableSharedFlow = MutableSharedFlow() - val event: SharedFlow + private val _event: MutableSharedFlow = MutableSharedFlow() + val event: SharedFlow get() = _event.asSharedFlow() - private val _sideEffect: MutableSharedFlow = MutableSharedFlow() + private val _sideEffect: Channel = Channel() val sideEffect: Flow - get() = _sideEffect.asSharedFlow() + get() = _sideEffect.receiveAsFlow() fun setState(reduce: State.() -> State) { - _uiState.value = currentState.reduce() + _state.value = currentState.reduce() } - open fun setEvent(event: Event) { - dispatchEvent(event) + open fun setIntent(intent: Intent) { + dispatchIntent(intent) } - private fun dispatchEvent(event: Event) = viewModelScope.launch { - handleEvent(event) + private fun dispatchIntent(intent: Intent) = viewModelScope.launch { + handleEvent(intent) } - protected abstract suspend fun handleEvent(event: Event) + protected abstract suspend fun handleEvent(intent: Intent) - fun setSideEffect(sideEffect: SideEffect) { - viewModelScope.launch { _sideEffect.emit(sideEffect) } + fun setSideEffect(sideEffect: () -> SideEffect) { + viewModelScope.launch { _sideEffect.send(sideEffect()) } } } diff --git a/app/src/main/java/org/sopt/and/core/util/LoadState.kt b/app/src/main/java/org/sopt/and/core/util/LoadState.kt new file mode 100644 index 0000000..8cfcf6e --- /dev/null +++ b/app/src/main/java/org/sopt/and/core/util/LoadState.kt @@ -0,0 +1,8 @@ +package org.sopt.and.core.util + +enum class LoadState { + Idle, + Loading, + Success, + Failure +} diff --git a/app/src/main/java/org/sopt/and/domain/entity/response/ResponseHobbyEntity.kt b/app/src/main/java/org/sopt/and/domain/entity/response/ResponseHobbyEntity.kt index 61feb7b..6f74d1b 100644 --- a/app/src/main/java/org/sopt/and/domain/entity/response/ResponseHobbyEntity.kt +++ b/app/src/main/java/org/sopt/and/domain/entity/response/ResponseHobbyEntity.kt @@ -1,5 +1,5 @@ package org.sopt.and.domain.entity.response data class ResponseHobbyEntity( - val hobby: String + val hobby: String = "" ) diff --git a/app/src/main/java/org/sopt/and/feature/my/MyContract.kt b/app/src/main/java/org/sopt/and/feature/my/MyContract.kt index 2b69e5d..6cccbac 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyContract.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyContract.kt @@ -1,11 +1,25 @@ package org.sopt.and.feature.my +import org.sopt.and.core.util.LoadState +import org.sopt.and.core.util.UiEvent +import org.sopt.and.core.util.UiSideEffect +import org.sopt.and.core.util.UiState +import org.sopt.and.domain.entity.response.ResponseHobbyEntity + class MyContract { data class MyState( - val hobby: String = "" - ) + val uiState: LoadState = LoadState.Loading, + val profile: ResponseHobbyEntity = ResponseHobbyEntity() + ) : UiState - sealed class MySideEffect { + sealed class MySideEffect : UiSideEffect { data class ShowToast(val toastMessage: Int) : MySideEffect() } + + sealed class MyEvent : UiEvent { + data class FetchMyHobby( + val uiState: LoadState, + val userInformation: ResponseHobbyEntity + ) : MyEvent() + } } diff --git a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt index 075aca1..51c4ef6 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyRoute.kt @@ -21,9 +21,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.traceEventEnd import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextOverflow @@ -31,8 +31,12 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.flowWithLifecycle import org.sopt.and.R +import org.sopt.and.core.extension.showToast +import org.sopt.and.core.util.LoadState import org.sopt.and.feature.my.component.EventContent import org.sopt.and.feature.my.component.HistoryContent import org.sopt.and.ui.theme.ANDANDROIDTheme @@ -48,17 +52,42 @@ fun MyRoute( modifier: Modifier = Modifier, viewModel: MyViewModel = hiltViewModel() ) { - val state by viewModel.state.collectAsStateWithLifecycle() + val context = LocalContext.current + val lifecycleOwner = LocalLifecycleOwner.current + val state by viewModel.uiState.collectAsStateWithLifecycle() LaunchedEffect(true) { - viewModel.getUserHobby() + // usecase 사용했을 때, + viewModel.fetchUserHobby() + + // usecase 사용안했을 때, + viewModel.getUserHobbyRepository() } - MyScreen( - paddingValues = paddingValues, - hobby = state.hobby, - modifier = modifier - ) + LaunchedEffect(viewModel.sideEffect, lifecycleOwner) { + viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) + .collect { mySideEffect -> + when (mySideEffect) { + is MyContract.MySideEffect.ShowToast -> context.showToast(message = mySideEffect.toastMessage) + } + } + } + + when (state.uiState) { + LoadState.Idle -> {} + + LoadState.Loading -> {} + + LoadState.Success -> { + MyScreen( + paddingValues = paddingValues, + hobby = state.profile.hobby, + modifier = modifier + ) + } + + LoadState.Failure -> {} + } } @Composable diff --git a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt index 6383ea9..b054a01 100644 --- a/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt +++ b/app/src/main/java/org/sopt/and/feature/my/MyViewModel.kt @@ -1,49 +1,75 @@ package org.sopt.and.feature.my -import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.SharedFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asSharedFlow -import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.sopt.and.R +import org.sopt.and.core.util.BaseViewModel +import org.sopt.and.core.util.LoadState +import org.sopt.and.domain.repository.MyRepository import org.sopt.and.domain.usecase.MyUseCase -import org.sopt.and.feature.my.MyContract.MySideEffect -import org.sopt.and.feature.my.MyContract.MyState import javax.inject.Inject @HiltViewModel class MyViewModel @Inject constructor( - private val getHobbyUseCase: MyUseCase -) : ViewModel() { - private val _state: MutableStateFlow - get() = MutableStateFlow(MyState()) - private val currentState: MyState - get() = state.value + private val getHobbyUseCase: MyUseCase, + private val MyRepository : MyRepository +) : BaseViewModel() { - val state: StateFlow - get() = _state.asStateFlow() + override fun createInitialState(): MyContract.MyState = MyContract.MyState() - private val _sideEffect: MutableSharedFlow = MutableSharedFlow() - val sideEffect: SharedFlow - get() = _sideEffect.asSharedFlow() + override suspend fun handleEvent(intent: MyContract.MyEvent) { + when (intent) { + is MyContract.MyEvent.FetchMyHobby -> setState { copy(uiState = intent.uiState) } + } + } - private fun setState(reduce: MyState.() -> MyState) { - _state.value = currentState.reduce() + // usecase 사용했을 때, + fun fetchUserHobby() { + viewModelScope.launch { + setIntent( + MyContract.MyEvent.FetchMyHobby(uiState = LoadState.Loading, userInformation = currentState.profile) + ) + getHobbyUseCase().onSuccess { profile-> + setIntent( + MyContract.MyEvent.FetchMyHobby( + uiState = LoadState.Success, + userInformation = profile + ) + ) + }.onFailure { + setIntent( + MyContract.MyEvent.FetchMyHobby( + uiState = LoadState.Failure, + userInformation = currentState.profile + ) + ) + setSideEffect({ MyContract.MySideEffect.ShowToast(R.string.common_failure) }) + } + } } - fun getUserHobby() { + // usecase 사용안했을 때, + fun getUserHobbyRepository() { viewModelScope.launch { - getHobbyUseCase.invoke().onSuccess { hobbyEntity -> - _state.value = _state.value.copy( - hobby = hobbyEntity.hobby + setIntent( + MyContract.MyEvent.FetchMyHobby(uiState = LoadState.Loading, userInformation = currentState.profile) + ) + MyRepository.getHobby().onSuccess { + setIntent( + MyContract.MyEvent.FetchMyHobby( + uiState = LoadState.Success, + userInformation = currentState.profile + ) ) }.onFailure { - _sideEffect.emit(MySideEffect.ShowToast(R.string.common_failure)) + setIntent( + MyContract.MyEvent.FetchMyHobby( + uiState = LoadState.Failure, + userInformation = currentState.profile + ) + ) + setSideEffect({ MyContract.MySideEffect.ShowToast(R.string.common_failure) }) } } }