Skip to content

Commit 6fb2d8a

Browse files
committed
[MOD/#323] 저장하기 버튼 활성화 기준 변경
1 parent 38c0cce commit 6fb2d8a

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

feature/home/src/main/java/com/terning/feature/home/component/bottomsheet/HomeFilteringBottomSheet.kt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ internal fun HomeFilteringBottomSheet(
6868
val density = LocalDensity.current
6969
var pageHeight by remember { mutableIntStateOf(0) }
7070

71+
var isCheckBoxChecked by remember {
72+
mutableStateOf(
73+
with(currentFilteringInfo) {
74+
listOf(grade, workingPeriod, startYear, startMonth).all { it == null || it == 0 }
75+
}
76+
)
77+
}
78+
7179
GetPagerHeight(
7280
onHeightMeasured = {
7381
pageHeight = it
@@ -137,6 +145,7 @@ internal fun HomeFilteringBottomSheet(
137145
1 -> {
138146
PlanFilteringScreen(
139147
currentFilteringInfo = currentFilteringInfo,
148+
isCheckBoxChecked = isCheckBoxChecked,
140149
updateGrade = {
141150
currentFilteringInfo = currentFilteringInfo.copy(
142151
grade = if (it != null) {
@@ -161,6 +170,9 @@ internal fun HomeFilteringBottomSheet(
161170
startMonth = it
162171
)
163172
},
173+
updateIsCheckBoxChecked = {
174+
isCheckBoxChecked = it
175+
}
164176
)
165177
}
166178
}
@@ -184,7 +196,10 @@ internal fun HomeFilteringBottomSheet(
184196
)
185197
}
186198
},
187-
isEnabled = checkButtonEnable(currentFilteringInfo = currentFilteringInfo)
199+
isEnabled = checkButtonEnable(
200+
currentFilteringInfo = currentFilteringInfo,
201+
isCheckBoxChecked = isCheckBoxChecked
202+
)
188203
)
189204
}
190205

@@ -238,10 +253,12 @@ fun TerningTab(
238253
}
239254
}
240255

241-
private fun checkButtonEnable(currentFilteringInfo: HomeFilteringInfo): Boolean =
256+
private fun checkButtonEnable(
257+
currentFilteringInfo: HomeFilteringInfo,
258+
isCheckBoxChecked: Boolean
259+
): Boolean =
242260
with(currentFilteringInfo) {
243-
listOf(grade, workingPeriod, startYear, startMonth).all { it == null || it == 0 } ||
244-
listOf(grade, workingPeriod, startYear, startMonth).none { it == null || it == 0 }
261+
isCheckBoxChecked || listOf(grade, workingPeriod, startYear, startMonth).none { it == null }
245262
}
246263

247264
@Composable
@@ -250,6 +267,7 @@ private fun GetPagerHeight(
250267
) {
251268
PlanFilteringScreen(
252269
currentFilteringInfo = HomeFilteringInfo(null, null, null, null, "total"),
270+
isCheckBoxChecked = false,
253271
modifier = Modifier
254272
.onGloballyPositioned {
255273
onHeightMeasured(it.size.height)

feature/home/src/main/java/com/terning/feature/home/component/bottomsheet/PlanFilteringScreen.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,17 @@ import kotlinx.collections.immutable.toImmutableList
4343
@Composable
4444
internal fun PlanFilteringScreen(
4545
currentFilteringInfo: HomeFilteringInfo,
46+
isCheckBoxChecked: Boolean,
4647
modifier: Modifier = Modifier,
4748
updateGrade: (Int?) -> Unit = {},
4849
updateWorkingPeriod: (Int?) -> Unit = {},
4950
updateStartYear: (Int?) -> Unit = {},
5051
updateStartMonth: (Int?) -> Unit = {},
52+
updateIsCheckBoxChecked: (Boolean) -> Unit = {},
5153
) {
5254
var isYearNull by remember { mutableStateOf(currentFilteringInfo.startYear == 0 || currentFilteringInfo.startYear == null) }
5355
var isMonthNull by remember { mutableStateOf(currentFilteringInfo.startMonth == 0 || currentFilteringInfo.startMonth == null) }
5456

55-
var isCheckBoxChecked by remember {
56-
mutableStateOf(
57-
with(currentFilteringInfo) {
58-
listOf(grade, workingPeriod, startYear, startMonth).all { it == null || it == 0 }
59-
}
60-
)
61-
}
62-
6357
var isInitialNullState by remember { mutableStateOf(false) }
6458

6559
val yearsList by remember(isYearNull) {
@@ -99,7 +93,7 @@ internal fun PlanFilteringScreen(
9993
).toImmutableList(),
10094
onButtonClick = {
10195
updateGrade(it)
102-
isCheckBoxChecked = false
96+
updateIsCheckBoxChecked(false)
10397
},
10498
columns = 4,
10599
modifier = Modifier
@@ -124,7 +118,7 @@ internal fun PlanFilteringScreen(
124118
).toImmutableList(),
125119
onButtonClick = {
126120
updateWorkingPeriod(it)
127-
isCheckBoxChecked = false
121+
updateIsCheckBoxChecked(false)
128122
},
129123
modifier = Modifier
130124
.padding(horizontal = 23.dp),
@@ -142,15 +136,15 @@ internal fun PlanFilteringScreen(
142136
onYearChosen = { year, isInitialSelection ->
143137
updateStartYear(year)
144138
if (year != null) {
145-
isCheckBoxChecked = false
139+
updateIsCheckBoxChecked(false)
146140
isYearNull = false
147141
isInitialNullState = isInitialSelection
148142
}
149143
},
150144
onMonthChosen = { month, isInitialSelection ->
151145
updateStartMonth(month)
152146
if (month != null) {
153-
isCheckBoxChecked = false
147+
updateIsCheckBoxChecked(false)
154148
isMonthNull = false
155149
isInitialNullState = isInitialSelection
156150
}
@@ -185,7 +179,7 @@ internal fun PlanFilteringScreen(
185179
updateStartYear(null)
186180
updateStartMonth(null)
187181
}
188-
isCheckBoxChecked = isChecked
182+
updateIsCheckBoxChecked(isChecked)
189183
},
190184
colors = CheckboxDefaults.colors(
191185
checkedColor = TerningMain,

0 commit comments

Comments
 (0)