Skip to content

Commit

Permalink
[MERGE] #233 -> develop
Browse files Browse the repository at this point in the history
[FIX/#233] μ˜¨λ³΄λ”© 필터링 μ„€μ • / μ„œλ²„ν†΅μ‹  μˆ˜μ •
  • Loading branch information
leeeyubin authored Sep 12, 2024
2 parents 36d16b8 + 8b1bd6e commit 096461d
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import kotlinx.serialization.Serializable
@Serializable
data class FilteringRequestDto(
@SerialName("grade")
val grade: Int,
val grade: String,
@SerialName("workingPeriod")
val workingPeriod: Int,
val workingPeriod: String,
@SerialName("startYear")
val startYear: Int,
@SerialName("startMonth")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.terning.domain.entity.filtering

data class Filtering(
val grade: Int,
val workingPeriod: Int,
val grade: String,
val workingPeriod: String,
val startYear: Int,
val startMonth: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.terning.feature.filtering.filteringone.component.StatusOneRadioGroup
@Composable
fun FilteringOneRoute(
name: String,
onNextClick: (Int) -> Unit,
onNextClick: (String) -> Unit,
navigateUp: () -> Unit,
paddingValues: PaddingValues,
viewModel: FilteringOneViewModel = hiltViewModel(),
Expand All @@ -46,16 +46,17 @@ fun FilteringOneRoute(
.collect { sideEffect ->
when (sideEffect) {
is FilteringOneSideEffect.NavigateUp -> navigateUp()
is FilteringOneSideEffect.NavigateToFilteringTwo -> onNextClick(sideEffect.grade)
}
}
}

FilteringOneScreen(
name = name,
onButtonClick = { index ->
viewModel.updateGradeAndButton(index)
onButtonClick = { grade ->
viewModel.updateGradeAndButton(grade)
},
onNextClick = onNextClick,
onNextClick = viewModel::navigateToFilteringTwo,
navigateUp = viewModel::navigateUp,
buttonState = state.isButtonValid,
gradeState = state.grade,
Expand All @@ -66,11 +67,11 @@ fun FilteringOneRoute(
@Composable
fun FilteringOneScreen(
name: String,
onNextClick: (Int) -> Unit,
onNextClick: (String) -> Unit,
navigateUp: () -> Unit,
onButtonClick: (Int) -> Unit,
onButtonClick: (String) -> Unit,
buttonState: Boolean,
gradeState: Int,
gradeState: String,
paddingValues: PaddingValues = PaddingValues(),
) {
Column(
Expand Down Expand Up @@ -117,8 +118,8 @@ fun FilteringOneScreen(
)
)
StatusOneRadioGroup(
onButtonClick = { index ->
onButtonClick(index)
onButtonClick = { grade ->
onButtonClick(grade)
}
)
Text(
Expand Down Expand Up @@ -152,7 +153,7 @@ fun FilteringOneScreenPreview() {
onNextClick = {},
navigateUp = {},
buttonState = true,
gradeState = 1
gradeState = "freshman"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.terning.feature.filtering.filteringone

sealed class FilteringOneSideEffect {
data object NavigateUp : FilteringOneSideEffect()
data class NavigateToFilteringTwo(val grade: String) : FilteringOneSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.terning.feature.filtering.filteringone

data class FilteringOneState(
val isButtonValid: Boolean = false,
val grade: Int = -1
val grade: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FilteringOneViewModel : ViewModel() {
private val _sideEffects = MutableSharedFlow<FilteringOneSideEffect>()
val sideEffects: SharedFlow<FilteringOneSideEffect> get() = _sideEffects.asSharedFlow()

fun updateGradeAndButton(grade: Int) {
fun updateGradeAndButton(grade: String) {
_state.value = _state.value.copy(
grade = grade,
isButtonValid = true
Expand All @@ -27,4 +27,13 @@ class FilteringOneViewModel : ViewModel() {

fun navigateUp() =
viewModelScope.launch { _sideEffects.emit(FilteringOneSideEffect.NavigateUp) }

fun navigateToFilteringTwo(grade: String) =
viewModelScope.launch {
_sideEffects.emit(
FilteringOneSideEffect.NavigateToFilteringTwo(
grade
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.component.button.FilteringButton
import com.terning.core.type.Grade
import com.terning.feature.R

@Composable
fun StatusOneRadioGroup(
onButtonClick: (Int) -> Unit,
onButtonClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
val options = listOf(
R.string.filtering_status1_button1,
R.string.filtering_status1_button2,
R.string.filtering_status1_button3,
R.string.filtering_status1_button4
Grade.FRESHMAN.stringResId,
Grade.SOPHOMORE.stringResId,
Grade.JUNIOR.stringResId,
Grade.SENIOR.stringResId
)

val selectedOptions = listOf(
Expand Down Expand Up @@ -52,7 +53,7 @@ fun StatusOneRadioGroup(
selectedIndex.intValue = option
selectedButton.indices.forEach { i -> selectedButton[i] = false }
selectedButton[index] = true
onButtonClick(index)
onButtonClick(Grade.entries[index].stringValue)
},
cornerRadius = 15.dp,
paddingVertical = 14.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import java.util.Calendar

@Composable
fun FilteringThreeRoute(
grade: Int,
workingPeriod: Int,
grade: String,
workingPeriod: String,
navigateUp: () -> Unit,
navigateToStartHome: () -> Unit,
paddingValues: PaddingValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.terning.feature.filtering.filteringthree

data class FilteringThreeState(
val grade: Int = -1,
val workingPeriod: Int = -1,
val grade: String = "",
val workingPeriod: String = "",
val startYear: Int = -1,
val startMonth: Int = -1
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class FilteringThreeViewModel @Inject constructor(
private val _sideEffects = MutableSharedFlow<FilteringThreeSideEffect>()
val sideEffects: SharedFlow<FilteringThreeSideEffect> get() = _sideEffects.asSharedFlow()

fun updateGrade(grade: Int) {
fun updateGrade(grade: String) {
_state.value = _state.value.copy(grade = grade)
}

fun updateWorkingPeriod(workingPeriod: Int) {
fun updateWorkingPeriod(workingPeriod: String) {
_state.value = _state.value.copy(workingPeriod = workingPeriod)
}

Expand Down Expand Up @@ -64,6 +64,7 @@ class FilteringThreeViewModel @Inject constructor(
}
}

fun navigateUp() = viewModelScope.launch { _sideEffects.emit(FilteringThreeSideEffect.NavigateUp) }
fun navigateUp() =
viewModelScope.launch { _sideEffects.emit(FilteringThreeSideEffect.NavigateUp) }

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import com.terning.feature.filtering.starthome.navigation.navigateStartHome
import kotlinx.serialization.Serializable

fun NavController.navigateFilteringThree(
grade: Int,
workingPeriod: Int,
grade: String,
workingPeriod: String,
navOptions: NavOptions? = null
) {
navigate(
Expand All @@ -41,6 +41,6 @@ fun NavGraphBuilder.filteringThreeNavGraph(

@Serializable
data class FilteringThree(
val grade: Int,
val workingPeriod: Int
val grade: String,
val workingPeriod: String
) : Route
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import com.terning.feature.filtering.filteringtwo.component.StatusTwoRadioGroup

@Composable
fun FilteringTwoRoute(
grade: Int,
onNextClick: (Int, Int) -> Unit,
grade: String,
onNextClick: (String, String) -> Unit,
navigateUp: () -> Unit,
paddingValues: PaddingValues,
viewModel: FilteringTwoViewModel = hiltViewModel(),
Expand All @@ -46,16 +46,20 @@ fun FilteringTwoRoute(
.collect { sideEffect ->
when (sideEffect) {
is FilteringTwoSideEffect.NavigateUp -> navigateUp()
is FilteringTwoSideEffect.NavigateToFilteringThree -> onNextClick(
sideEffect.grade,
sideEffect.workingPeriod
)
}
}
}

FilteringTwoScreen(
grade = grade,
onNextClick = onNextClick,
onNextClick = viewModel::navigateToFilteringThree,
navigateUp = viewModel::navigateUp,
onButtonClick = { index ->
viewModel.updateWorkingPeriodAndButton(index)
onButtonClick = { workingPeriod ->
viewModel.updateWorkingPeriodAndButton(workingPeriod)
},
buttonState = state.isButtonValid,
workingPeriod = state.workingPeriod,
Expand All @@ -65,12 +69,12 @@ fun FilteringTwoRoute(

@Composable
fun FilteringTwoScreen(
grade: Int,
onNextClick: (Int, Int) -> Unit,
grade: String,
onNextClick: (String, String) -> Unit,
navigateUp: () -> Unit,
onButtonClick: (Int) -> Unit,
onButtonClick: (String) -> Unit,
buttonState: Boolean,
workingPeriod: Int,
workingPeriod: String,
paddingValues: PaddingValues = PaddingValues(),
) {
Column(
Expand Down Expand Up @@ -111,8 +115,8 @@ fun FilteringTwoScreen(
)
)
StatusTwoRadioGroup(
onButtonClick = { index ->
onButtonClick(index)
onButtonClick = { workingPeriod ->
onButtonClick(workingPeriod)
}
)
Spacer(modifier = Modifier.weight(1f))
Expand All @@ -133,12 +137,12 @@ fun FilteringTwoScreen(
fun FilteringTwoScreenPreview() {
TerningPointTheme {
FilteringTwoScreen(
grade = 1,
grade = "freshman",
onNextClick = { _, _ -> },
navigateUp = { },
onButtonClick = { },
buttonState = true,
workingPeriod = 1
workingPeriod = "short"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package com.terning.feature.filtering.filteringtwo

sealed class FilteringTwoSideEffect {
data object NavigateUp : FilteringTwoSideEffect()
data class NavigateToFilteringThree(val grade: String, val workingPeriod: String) :
FilteringTwoSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.terning.feature.filtering.filteringtwo

data class FilteringTwoState(
val isButtonValid: Boolean = false,
val workingPeriod: Int = -1
val workingPeriod: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FilteringTwoViewModel : ViewModel() {
private val _sideEffects = MutableSharedFlow<FilteringTwoSideEffect>()
val sideEffects: SharedFlow<FilteringTwoSideEffect> get() = _sideEffects.asSharedFlow()

fun updateWorkingPeriodAndButton(workingPeriod: Int) {
fun updateWorkingPeriodAndButton(workingPeriod: String) {
_state.value = _state.value.copy(
workingPeriod = workingPeriod,
isButtonValid = true
Expand All @@ -27,4 +27,14 @@ class FilteringTwoViewModel : ViewModel() {

fun navigateUp() =
viewModelScope.launch { _sideEffects.emit(FilteringTwoSideEffect.NavigateUp) }

fun navigateToFilteringThree(grade: String, workingPeriod: String) =
viewModelScope.launch {
_sideEffects.emit(
FilteringTwoSideEffect.NavigateToFilteringThree(
grade, workingPeriod
)
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.component.button.FilteringButton
import com.terning.core.type.WorkingPeriod
import com.terning.feature.R

@Composable
fun StatusTwoRadioGroup(
onButtonClick: (Int) -> Unit,
onButtonClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
val options = listOf(
R.string.filtering_status2_button1,
R.string.filtering_status2_button2,
R.string.filtering_status2_button3,
WorkingPeriod.SHORT.stringResId,
WorkingPeriod.MIDDLE.stringResId,
WorkingPeriod.LONG.stringResId
)

val selectedOptions = listOf(
Expand All @@ -50,7 +51,7 @@ fun StatusTwoRadioGroup(
selectedIndex.intValue = option
selectedButton.indices.forEach { i -> selectedButton[i] = false }
selectedButton[index] = true
onButtonClick(index)
onButtonClick(WorkingPeriod.entries[index].stringValue)
},
cornerRadius = 15.dp,
paddingVertical = 24.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.terning.feature.filtering.filteringtwo.FilteringTwoRoute
import kotlinx.serialization.Serializable

fun NavController.navigateFilteringTwo(
grade: Int,
grade: String,
navOptions: NavOptions? = null
) {
navigate(
Expand Down Expand Up @@ -44,5 +44,5 @@ fun NavGraphBuilder.filteringTwoNavGraph(

@Serializable
data class FilteringTwo(
val grade: Int
val grade: String
) : Route

0 comments on commit 096461d

Please sign in to comment.