-
Notifications
You must be signed in to change notification settings - Fork 1
[CHORE/#177] 홈 뷰 패키지 구조 수정 #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
50ae0f7
bf1a082
257b4b2
43ddd5b
38c1d51
78f8154
18c1bd8
e8e4853
a4ddeef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.terning.data.mapper.home | ||
|
|
||
| import com.terning.data.dto.response.HomeFilteringInfoResponseDto | ||
| import com.terning.domain.entity.home.HomeFilteringInfo | ||
|
|
||
| fun HomeFilteringInfoResponseDto.toHomeFilteringInfo(): HomeFilteringInfo = | ||
| HomeFilteringInfo( | ||
| grade = this.grade, | ||
| workingPeriod = this.workingPeriod, | ||
| startYear = this.startYear, | ||
| startMonth = this.startMonth, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.terning.data.mapper.home | ||
|
|
||
| import com.terning.data.dto.response.HomeRecommendInternResponseDto | ||
| import com.terning.domain.entity.home.HomeRecommendIntern | ||
|
|
||
| fun HomeRecommendInternResponseDto.toHomeRecommendInternList(): HomeRecommendIntern = | ||
| HomeRecommendIntern( | ||
| scrapId = this.scrapId, | ||
| internshipAnnouncementId = this.internshipAnnouncementId, | ||
| title = this.title, | ||
| dDay = this.dDay, | ||
| deadline = deadline, | ||
| workingPeriod = this.workingPeriod, | ||
| startYearMonth = this.startYearMonth, | ||
| companyImage = this.companyImage, | ||
| isScrapped = this.isScrapped, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.terning.data.mapper.home | ||
|
|
||
| import com.terning.data.dto.response.HomeTodayInternResponseDto | ||
| import com.terning.domain.entity.home.HomeTodayIntern | ||
|
|
||
| fun HomeTodayInternResponseDto.toHomeTodayInternList(): HomeTodayIntern = | ||
| HomeTodayIntern( | ||
| scrapId = this.scrapId, | ||
| internshipAnnouncementId = this.internshipAnnouncementId, | ||
| companyImage = this.companyImage, | ||
| title = this.title, | ||
| dDay = this.dDay, | ||
| deadline = this.deadline, | ||
| workingPeriod = this.workingPeriod, | ||
| startYearMonth = this.startYearMonth, | ||
| color = this.color, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,16 +26,15 @@ import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar | |
| import com.terning.core.designsystem.theme.TerningTheme | ||
| import com.terning.core.extension.toast | ||
| import com.terning.core.state.UiState | ||
| import com.terning.domain.entity.home.HomeFilteringInfo | ||
| import com.terning.domain.entity.request.ChangeFilteringRequestModel | ||
| import com.terning.domain.entity.response.HomeFilteringInfoModel | ||
| import com.terning.feature.R | ||
| import com.terning.feature.home.changefilter.component.ChangeFilteringRadioGroup | ||
| import com.terning.feature.home.changefilter.component.FilteringMainTitleText | ||
| import com.terning.feature.home.changefilter.component.FilteringSubTitleText | ||
| import com.terning.feature.home.changefilter.navigation.navigateChangeFilter | ||
| import com.terning.feature.home.home.HomeSideEffect | ||
| import com.terning.feature.home.home.HomeViewModel | ||
| import com.terning.feature.home.home.navigation.navigateHome | ||
|
|
||
| const val MIN_INDEX = 0 | ||
| const val MAX_WORKING_INDEX = 2 | ||
|
|
@@ -53,7 +52,7 @@ fun ChangeFilterRoute( | |
|
|
||
| when (filteringState) { | ||
| is UiState.Success -> ChangeFilterScreen( | ||
| (filteringState as UiState.Success<HomeFilteringInfoModel>).data, | ||
| (filteringState as UiState.Success<HomeFilteringInfo>).data, | ||
| navController, | ||
| viewModel, | ||
| ) | ||
|
|
@@ -75,7 +74,7 @@ fun ChangeFilterRoute( | |
|
|
||
| @Composable | ||
| fun ChangeFilterScreen( | ||
| filterData: HomeFilteringInfoModel, | ||
| filterData: HomeFilteringInfo, | ||
| navController: NavController, | ||
| viewModel: HomeViewModel, | ||
| ) { | ||
|
Comment on lines
78
to
80
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 바로 밑에 코드에 코멘트가 달리지 않아 여기에 답니다ㅎㅎ 지금 보니까 뷰모델의 상태값을 인자로 받아온 상태에서 밑에 remember를 사용해서 변수를 선언했는데 왜 이렇게 구현한건가요??
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 일단 navController는 함수로 넘기는 방식으로 변경했고, viewModel같은 경우는 현재 년/월과 필터링 재설정 API 함수때문에 viewModel을 그대로 같이 넘겼던 것으로 기억하는데 다른 더 좋은 방법이 있을 것 같아서 계속 고민중입니다!! |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,9 +56,9 @@ import com.terning.core.designsystem.theme.White | |
| import com.terning.core.extension.noRippleClickable | ||
| import com.terning.core.extension.toast | ||
| import com.terning.core.state.UiState | ||
| 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.entity.home.HomeFilteringInfo | ||
| import com.terning.domain.entity.home.HomeRecommendIntern | ||
| import com.terning.domain.entity.home.HomeTodayIntern | ||
| import com.terning.feature.R | ||
| import com.terning.feature.home.changefilter.navigation.navigateChangeFilter | ||
| import com.terning.feature.home.home.component.HomeFilteringEmptyIntern | ||
|
|
@@ -102,7 +102,7 @@ fun HomeRoute( | |
| val homeUserState by viewModel.homeUserState.collectAsStateWithLifecycle() | ||
| val homeDialogState by viewModel.homeDialogState.collectAsStateWithLifecycle() | ||
|
|
||
| val homeTodayInternList: MutableState<List<HomeTodayInternModel>> = remember { | ||
| val homeTodayInternList: MutableState<List<HomeTodayIntern>> = remember { | ||
| mutableStateOf(emptyList()) | ||
| } | ||
|
|
||
|
|
@@ -120,7 +120,7 @@ fun HomeRoute( | |
| LaunchedEffect(homeFilteringState, currentSortBy.value) { | ||
| when (homeFilteringState) { | ||
| is UiState.Success -> | ||
| with((homeFilteringState as UiState.Success<HomeFilteringInfoModel>).data) { | ||
| with((homeFilteringState as UiState.Success<HomeFilteringInfo>).data) { | ||
| viewModel.getRecommendInternsData( | ||
| currentSortBy.value, | ||
| startYear ?: viewModel.currentYear, | ||
|
|
@@ -143,7 +143,7 @@ fun HomeRoute( | |
| when (homeTodayState) { | ||
| is UiState.Success -> { | ||
| homeTodayInternList.value = | ||
| (homeTodayState as UiState.Success<List<HomeTodayInternModel>>).data | ||
| (homeTodayState as UiState.Success<List<HomeTodayIntern>>).data | ||
| } | ||
|
|
||
| is UiState.Loading -> {} | ||
|
|
@@ -154,15 +154,15 @@ fun HomeRoute( | |
|
|
||
| val homeRecommendInternList = when (homeRecommendInternState) { | ||
| is UiState.Success -> { | ||
| (homeRecommendInternState as UiState.Success<List<HomeRecommendInternModel>>).data | ||
| (homeRecommendInternState as UiState.Success<List<HomeRecommendIntern>>).data | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 홈화면에서 목록을 밑으로 스크롤한 상태에서 스크랩을 하면 화면이 다시 로드되면서 위로 되돌아가는 문제가 고쳐졌는지 모르겠지만,
지금 이렇게 최상위 컴포저블에서 모든 상태를 관리하는 방법에서 상태값이 바뀌면 관련된 컴포저블을 업데이트하는 방식으로 바꿔보는 건 어떨까 싶어요!! 즉, When문을 사용해 이게 해결방법이 아닐 수는 있지만, when문에서 뷰를 업데이트하는게 더 옳은 방법이라고 생각합니다!!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우왕 정말 감사합니다!!! 정말 확인해보니 HomeRoute 전체가 리컴포지션되더라구요😭 말씀해주신 방식으로 수정해보겠습니당 진짜 최고최고💚 |
||
| } | ||
|
|
||
| else -> emptyList() | ||
| } | ||
|
|
||
| val homeFilteringInfo = when (homeFilteringState) { | ||
| is UiState.Success -> (homeFilteringState as UiState.Success<HomeFilteringInfoModel>).data | ||
| else -> HomeFilteringInfoModel(null, null, viewModel.currentYear, viewModel.currentMonth) | ||
| is UiState.Success -> (homeFilteringState as UiState.Success<HomeFilteringInfo>).data | ||
| else -> HomeFilteringInfo(null, null, viewModel.currentYear, viewModel.currentMonth) | ||
| } | ||
|
|
||
| val homeUserName = when (homeUserState) { | ||
|
|
@@ -187,9 +187,9 @@ fun HomeRoute( | |
| fun HomeScreen( | ||
| currentSortBy: MutableState<Int>, | ||
| homeUserName: String, | ||
| homeFilteringInfo: HomeFilteringInfoModel, | ||
| homeTodayInternList: List<HomeTodayInternModel>, | ||
| recommendInternList: List<HomeRecommendInternModel>, | ||
| homeFilteringInfo: HomeFilteringInfo, | ||
| homeTodayInternList: List<HomeTodayIntern>, | ||
| recommendInternList: List<HomeRecommendIntern>, | ||
| homeDialogState: HomeDialogState, | ||
| onChangeFilterClick: () -> Unit, | ||
| viewModel: HomeViewModel = hiltViewModel(), | ||
|
|
@@ -372,7 +372,7 @@ fun HomeScreen( | |
| viewModel.updateScrapped(false) | ||
| } | ||
| }, | ||
| homeRecommendInternModel = this, | ||
| homeRecommendIntern = this, | ||
| ) | ||
| } | ||
| } | ||
|
|
@@ -385,7 +385,7 @@ fun HomeScreen( | |
| @Composable | ||
| private fun RecommendInternItem( | ||
| navController: NavHostController, | ||
| intern: HomeRecommendInternModel, | ||
| intern: HomeRecommendIntern, | ||
| onScrapButtonClicked: (Long) -> Unit, | ||
| ) { | ||
| InternItemWithShadow( | ||
|
|
@@ -425,7 +425,7 @@ private fun ShowMainTitleWithName(userName: String) { | |
|
|
||
| @Composable | ||
| private fun ShowTodayIntern( | ||
| homeTodayInternList: List<HomeTodayInternModel>, | ||
| homeTodayInternList: List<HomeTodayIntern>, | ||
| homeDialogState: HomeDialogState, | ||
| navigateToDetail: (Long) -> Unit, | ||
| ) { | ||
|
|
@@ -463,7 +463,7 @@ private fun ShowRecommendTitle() { | |
|
|
||
| @Composable | ||
| private fun ShowInternFilter( | ||
| homeFilteringInfo: HomeFilteringInfoModel, | ||
| homeFilteringInfo: HomeFilteringInfo, | ||
| onChangeFilterClick: () -> Unit, | ||
| ) { | ||
| if (homeFilteringInfo.grade == null) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뷰모델이나 네비게이션 객체를 인자로 넘겨주는 것보단 고차함수로 넘기는 게 좋을 것 같아요!!
유빈이가 깔끔하게 해놨던데 참고해봐요~~!