From 0a428fb8385aa704f355522d326d64cf88b93068 Mon Sep 17 00:00:00 2001 From: Hyobeen-Park Date: Thu, 18 Jul 2024 21:56:29 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[FEAT/#122]=20=ED=99=88=20=EB=B7=B0=20/=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20=EC=A0=95=EB=A0=AC=20=EA=B8=B0=EC=A4=80=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/home/home/HomeRoute.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt index 2f6988208..144d2afc9 100644 --- a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt +++ b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt @@ -42,7 +42,6 @@ import com.terning.core.designsystem.component.topappbar.LogoTopAppBar import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.Grey200 -import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.customShadow @@ -101,6 +100,21 @@ fun HomeRoute( } } + LaunchedEffect(currentSortBy.value) { + when (homeFilteringState) { + is UiState.Success -> + with((homeFilteringState as UiState.Success).data) { + viewModel.getRecommendInternsData( + currentSortBy.value, + startYear ?: viewModel.currentYear, + startMonth ?: viewModel.currentMonth + ) + } + + else -> {} + } + } + val homeTodayInternList = when (homeTodayState) { is UiState.Success -> { (homeTodayState as UiState.Success>).data From b76cbdae8d18dfcad913ba953da08f70acf4baaa Mon Sep 17 00:00:00 2001 From: Hyobeen-Park Date: Thu, 18 Jul 2024 22:10:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[FEAT/#122]=20=ED=99=88=20=EB=B7=B0=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=20=EC=9D=B4=EB=A6=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/home/home/HomeRoute.kt | 10 +++++++++- .../terning/feature/home/home/HomeViewModel.kt | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt index 144d2afc9..c698a4254 100644 --- a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt +++ b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt @@ -88,6 +88,7 @@ fun HomeRoute( val homeTodayState by viewModel.homeTodayState.collectAsStateWithLifecycle() val homeRecommendInternState by viewModel.homeRecommendInternState.collectAsStateWithLifecycle() val homeFilteringState by viewModel.homeFilteringState.collectAsStateWithLifecycle() + val homeUserState by viewModel.homeUserState.collectAsStateWithLifecycle() LaunchedEffect(viewModel.homeSideEffect, lifecycleOwner) { viewModel.homeSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) @@ -136,8 +137,14 @@ fun HomeRoute( else -> HomeFilteringInfoModel(null, null, viewModel.currentYear, viewModel.currentMonth) } + val homeUserName = when (homeUserState) { + is UiState.Success -> (homeUserState as UiState.Success).data + else -> "" + } + HomeScreen( currentSortBy, + homeUserName = homeUserName, homeFilteringInfo = homeFilteringInfo, homeTodayInternList = homeTodayInternList, recommendInternList = homeRecommendInternList, @@ -149,6 +156,7 @@ fun HomeRoute( @Composable fun HomeScreen( currentSortBy: MutableState, + homeUserName: String, homeFilteringInfo: HomeFilteringInfoModel, homeTodayInternList: List, recommendInternList: List, @@ -189,7 +197,7 @@ fun HomeScreen( modifier = Modifier .padding(bottom = 16.dp) ) { - ShowMainTitleWithName("남지우자랑스러운티엘이되") + ShowMainTitleWithName(homeUserName) ShowTodayIntern(homeTodayInternList = homeTodayInternList) } } diff --git a/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt b/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt index 443ab177d..36dc99c51 100644 --- a/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt +++ b/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt @@ -8,6 +8,7 @@ import com.terning.domain.entity.response.HomeFilteringInfoModel import com.terning.domain.entity.response.HomeRecommendInternModel import com.terning.domain.entity.response.HomeTodayInternModel import com.terning.domain.repository.HomeRepository +import com.terning.domain.repository.MyPageRepository import com.terning.feature.R import com.terning.feature.home.home.model.SortBy import dagger.hilt.android.lifecycle.HiltViewModel @@ -22,6 +23,7 @@ import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( private val homeRepository: HomeRepository, + private val myPageRepository: MyPageRepository, ) : ViewModel() { val currentYear = Calendar.getInstance().get(Calendar.YEAR) val currentMonth = Calendar.getInstance().get(Calendar.MONTH) @@ -44,7 +46,11 @@ class HomeViewModel @Inject constructor( private val _homeSortByState = MutableStateFlow(0) val homeSortByState get() = _homeSortByState.asStateFlow() + private val _homeUserState = MutableStateFlow>(UiState.Loading) + val homeUserState get() = _homeUserState.asStateFlow() + init { + getProfile() getFilteringInfo() getHomeTodayInternList() getRecommendInternsData( @@ -100,4 +106,15 @@ class HomeViewModel @Inject constructor( } } } + + private fun getProfile() { + viewModelScope.launch { + myPageRepository.getProfile().onSuccess { response -> + _homeUserState.value = UiState.Success(response.name) + }.onFailure { exception: Throwable -> + _homeUserState.value = UiState.Failure(exception.message ?: "") + _homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure)) + } + } + } } \ No newline at end of file From b43b56219d554d8db4524c41e850475784bb4540 Mon Sep 17 00:00:00 2001 From: Hyobeen-Park Date: Thu, 18 Jul 2024 22:19:17 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[CHORE/#122]=20=EB=8D=B0=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=ED=94=BC=EC=BB=A4=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/home/changefilter/ChangeFilterRoute.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/home/changefilter/ChangeFilterRoute.kt b/feature/src/main/java/com/terning/feature/home/changefilter/ChangeFilterRoute.kt index 68d943f10..f40269b95 100644 --- a/feature/src/main/java/com/terning/feature/home/changefilter/ChangeFilterRoute.kt +++ b/feature/src/main/java/com/terning/feature/home/changefilter/ChangeFilterRoute.kt @@ -165,7 +165,7 @@ fun ChangeFilterScreen( Spacer(modifier = Modifier.weight(1f)) DatePickerUI( chosenYear = filterData.startYear ?: currentStartYear, - chosenMonth = filterData.startMonth ?: currentStartMonth, + chosenMonth = filterData.startMonth?.minus(1) ?: currentStartMonth, onYearChosen = { currentStartYear = it }, onMonthChosen = { currentStartMonth = it } )