-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FEAT/#113] 필터링 재설정 서버통신 구현 #132
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b55a1e4
[FEAT/#113] data, domain 설계
Hyobeen-Park 08bf114
Merge remote-tracking branch 'origin/develop' into feat/#113-home-filter
Hyobeen-Park 4af1699
[FEAT/#113] 서버 통신 홈 UI에 적용
Hyobeen-Park 937a73f
Merge remote-tracking branch 'origin/develop' into feat/#113-home-filter
Hyobeen-Park 5a87d3f
[FEAT/#113] 필터링 재설정 뷰 서버 통신으로 수정
Hyobeen-Park 03fd3e2
Merge remote-tracking branch 'origin/develop' into feat/#113-home-filter
Hyobeen-Park 73137cd
[FEAT/#113] data, domain 설계
Hyobeen-Park 07ed341
[FEAT/#113] 저장하기 버튼 오류 수정
Hyobeen-Park c18cf38
[CHORE/#113] 사용하지 않는 파일 정리
Hyobeen-Park 1418d11
Merge remote-tracking branch 'origin/develop' into feat/#113-home-filter
Hyobeen-Park 6ffa8cf
[FEAT/#113] 필터링 재설정 라디오버튼 오류 수정
Hyobeen-Park 76128d7
[CHORE/#113] 코드 정리
Hyobeen-Park ee2a360
Merge remote-tracking branch 'origin/develop' into feat/#113-home-filter
Hyobeen-Park File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
data/src/main/java/com/terning/data/dto/request/ChangeFilterRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.terning.data.dto.request | ||
|
||
import com.terning.domain.entity.request.ChangeFilteringRequestModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ChangeFilterRequestDto( | ||
@SerialName("grade") | ||
val grade: Int, | ||
@SerialName("workingPeriod") | ||
val workingPeriod: Int, | ||
@SerialName("startYear") | ||
val startYear: Int, | ||
@SerialName("startMonth") | ||
val startMonth: Int, | ||
) | ||
|
||
fun ChangeFilteringRequestModel.toChangeFilterRequestDto(): ChangeFilterRequestDto = | ||
ChangeFilterRequestDto( | ||
grade = grade, | ||
workingPeriod = workingPeriod, | ||
startYear = startYear, | ||
startMonth = startMonth, | ||
) |
25 changes: 25 additions & 0 deletions
25
data/src/main/java/com/terning/data/dto/response/HomeFilteringInfoResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.terning.data.dto.response | ||
|
||
import com.terning.domain.entity.response.HomeFilteringInfoModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class HomeFilteringInfoResponseDto( | ||
@SerialName("grade") | ||
val grade: Int?, | ||
@SerialName("workingPeriod") | ||
val workingPeriod: Int?, | ||
@SerialName("startYear") | ||
val startYear: Int?, | ||
@SerialName("startMonth") | ||
val startMonth: Int?, | ||
) { | ||
fun toHomeFilteringInfoModel(): HomeFilteringInfoModel = | ||
HomeFilteringInfoModel( | ||
grade = this.grade, | ||
workingPeriod = this.workingPeriod, | ||
startYear = startYear, | ||
startMonth = startMonth, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/terning/domain/entity/request/ChangeFilteringRequestModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.terning.domain.entity.request | ||
|
||
data class ChangeFilteringRequestModel( | ||
val grade: Int, | ||
val workingPeriod: Int, | ||
val startYear: Int, | ||
val startMonth: Int, | ||
) |
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/terning/domain/entity/response/HomeFilteringInfoModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.terning.domain.entity.response | ||
|
||
data class HomeFilteringInfoModel( | ||
val grade: Int?, | ||
val workingPeriod: Int?, | ||
val startYear: Int?, | ||
val startMonth: Int?, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,51 +5,90 @@ import androidx.compose.foundation.layout.Spacer | |
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.lifecycle.compose.LocalLifecycleOwner | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.navigation.NavController | ||
import com.terning.core.designsystem.component.button.RectangleButton | ||
import com.terning.core.designsystem.component.datepicker.DatePickerUI | ||
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.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.model.InternFilterData | ||
import com.terning.feature.home.home.model.UserNameState | ||
import com.terning.feature.home.home.navigation.navigateHome | ||
import java.util.Calendar | ||
|
||
val currentYear = Calendar.getInstance().get(Calendar.YEAR) | ||
val currentMonth = Calendar.getInstance().get(Calendar.MONTH) | ||
|
||
@Composable | ||
fun ChangeFilterRoute( | ||
navController: NavController, | ||
viewModel: HomeViewModel = hiltViewModel(), | ||
) { | ||
ChangeFilterScreen(navController) | ||
val lifecycleOwner = LocalLifecycleOwner.current | ||
val context = LocalContext.current | ||
|
||
val filteringState by viewModel.homeFilteringState.collectAsStateWithLifecycle() | ||
|
||
when (filteringState) { | ||
is UiState.Success -> ChangeFilterScreen( | ||
(filteringState as UiState.Success<HomeFilteringInfoModel>).data, | ||
navController, | ||
viewModel, | ||
) | ||
|
||
else -> {} | ||
} | ||
|
||
LaunchedEffect(viewModel.homeSideEffect, lifecycleOwner) { | ||
viewModel.homeSideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) | ||
.collect { sideEffect -> | ||
when (sideEffect) { | ||
is HomeSideEffect.ShowToast -> context.toast(sideEffect.message) | ||
is HomeSideEffect.NavigateToChangeFilter -> navController.navigateChangeFilter() | ||
is HomeSideEffect.NavigateToHome -> navController.navigateHome() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun ChangeFilterScreen( | ||
filterData: HomeFilteringInfoModel, | ||
navController: NavController, | ||
viewModel: HomeViewModel = hiltViewModel(), | ||
viewModel: HomeViewModel, | ||
) { | ||
val isGradeButtonValid = remember { | ||
mutableStateOf(viewModel.userName.value.internFilter?.grade != null) | ||
var currentGrade by remember { mutableIntStateOf(filterData.grade ?: -1) } | ||
var currentWorkingPeriod by remember { mutableIntStateOf(filterData.workingPeriod ?: -1) } | ||
var currentStartYear by remember { | ||
mutableIntStateOf( | ||
filterData.startYear ?: viewModel.currentYear | ||
) | ||
} | ||
|
||
val isWorkingPeriodButtonValid = remember { | ||
mutableStateOf(viewModel.userName.value.internFilter?.workingPeriod != null) | ||
var currentStartMonth by remember { | ||
mutableIntStateOf( | ||
filterData.startMonth ?: viewModel.currentMonth | ||
) | ||
} | ||
|
||
|
||
Scaffold( | ||
topBar = { | ||
BackButtonTopAppBar( | ||
|
@@ -76,23 +115,18 @@ fun ChangeFilterScreen( | |
) | ||
) | ||
ChangeFilteringRadioGroup( | ||
filterType = 0, | ||
internFilterData = viewModel.userName.value.internFilter, | ||
onButtonClick = { | ||
isGradeButtonValid.value = true | ||
initOption = filterData.grade ?: -1, | ||
optionList = listOf( | ||
R.string.filtering_status1_button1, | ||
R.string.filtering_status1_button2, | ||
R.string.filtering_status1_button3, | ||
R.string.filtering_status1_button4, | ||
), | ||
onButtonClick = { index -> | ||
currentGrade = index | ||
} | ||
) | ||
|
||
UserNameState( | ||
userName = "남지우자랑스러운티엘이되", | ||
internFilter = InternFilterData( | ||
grade = 4, | ||
workingPeriod = 1, | ||
startYear = 2024, | ||
startMonth = 7, | ||
) | ||
) | ||
|
||
ShowTitle( | ||
mainTitle = stringResource(id = R.string.filtering_status2_title), | ||
subTitle = stringResource(id = R.string.filtering_status2_sub), | ||
|
@@ -103,10 +137,14 @@ fun ChangeFilterScreen( | |
) | ||
) | ||
ChangeFilteringRadioGroup( | ||
filterType = 1, | ||
internFilterData = viewModel.userName.value.internFilter, | ||
onButtonClick = { | ||
isWorkingPeriodButtonValid.value = true | ||
initOption = filterData.workingPeriod ?: -1, | ||
optionList = listOf( | ||
R.string.filtering_status2_button1, | ||
R.string.filtering_status2_button2, | ||
R.string.filtering_status2_button3, | ||
), | ||
onButtonClick = { index -> | ||
currentWorkingPeriod = index | ||
} | ||
) | ||
|
||
|
@@ -122,8 +160,10 @@ fun ChangeFilterScreen( | |
|
||
Spacer(modifier = Modifier.weight(1f)) | ||
DatePickerUI( | ||
chosenYear = currentYear, | ||
chosenMonth = currentMonth, | ||
chosenYear = filterData.startYear ?: currentStartYear, | ||
chosenMonth = filterData.startMonth ?: currentStartMonth, | ||
onYearChosen = { currentStartYear = it }, | ||
onMonthChosen = { currentStartMonth = it } | ||
) | ||
Spacer(modifier = Modifier.weight(1f)) | ||
|
||
|
@@ -132,9 +172,16 @@ fun ChangeFilterScreen( | |
paddingVertical = 19.dp, | ||
text = R.string.change_filter_save, | ||
onButtonClick = { | ||
navController.navigateHome() | ||
viewModel.putFilteringInfo( | ||
ChangeFilteringRequestModel( | ||
grade = currentGrade, | ||
workingPeriod = currentWorkingPeriod, | ||
startYear = currentStartYear, | ||
startMonth = currentStartMonth, | ||
) | ||
) | ||
}, | ||
isEnabled = isGradeButtonValid.value && isWorkingPeriodButtonValid.value | ||
isEnabled = currentGrade in 0..3 && currentWorkingPeriod in 0..2 | ||
) | ||
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. 요거 상수화로 빼주면 더 좋을 것 같아요! 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. 오 좋아요!! |
||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
startYear랑 startMonth는 this를 빼준 의도가 있나용?
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.
헉스 통일시키겠습니다!!