@@ -20,38 +20,33 @@ import androidx.compose.ui.unit.dp
20
20
import com.chan.android.ui.theme.Spacing
21
21
import com.chan.android.ui.theme.White
22
22
import com.chan.search.R
23
+ import com.chan.search.ui.contract.SearchContract
23
24
import com.chan.search.ui.model.filter.DeliveryOption
24
25
import com.chan.search.ui.model.filter.FilterCategoriesModel
25
26
26
27
@OptIn(ExperimentalMaterial3Api ::class )
27
28
@Composable
28
29
fun SearchFilterScreen (
29
- selectedDeliveryOption : DeliveryOption ? ,
30
- categoryFilters : List <FilterCategoriesModel >,
31
- expandedCategoryName : String? ,
32
- selectedSubCategories : Set <String >,
33
- isCategorySectionExpanded : Boolean ,
34
- filteredProductCount : Int ,
35
- onClose : () -> Unit ,
36
- onDeliveryOptionClick : (DeliveryOption ) -> Unit ,
37
- onCategoryHeaderClick : (String ) -> Unit ,
38
- onSubCategoryClick : (String ) -> Unit ,
39
- onFilterCategoryClick : () -> Unit ,
40
- onFilterClear : () -> Unit ,
30
+ state : SearchContract .State ,
31
+ onEvent : (SearchContract .Event ) -> Unit ,
41
32
modifier : Modifier = Modifier
42
33
) {
43
34
44
35
Scaffold (
45
36
modifier = modifier,
46
37
containerColor = White ,
47
- topBar = { FilterHeader (
48
- onClose = onClose,
49
- onFilterClear = onFilterClear
50
- ) },
51
- bottomBar = { FilterBottomButton (
52
- itemCount = filteredProductCount,
53
- onClick = onClose
54
- ) }
38
+ topBar = {
39
+ FilterHeader (
40
+ onClose = { onEvent(SearchContract .Event .Filter .OnFilterClick ) },
41
+ onFilterClear = { onEvent(SearchContract .Event .Filter .OnClear ) }
42
+ )
43
+ },
44
+ bottomBar = {
45
+ FilterBottomButton (
46
+ itemCount = state.filter.filteredProductCount,
47
+ onApplyFilters = { onEvent(SearchContract .Event .Filter .OnFilterClick ) }
48
+ )
49
+ }
55
50
) { paddingValues ->
56
51
LazyColumn (
57
52
modifier = Modifier
@@ -60,8 +55,8 @@ fun SearchFilterScreen(
60
55
// "오늘드림", "픽업" 체크박스 섹션
61
56
item {
62
57
FilterToggleSection (
63
- selectedOption = selectedDeliveryOption,
64
- onOptionClick = onDeliveryOptionClick
58
+ selectedOption = state.filter. selectedDeliveryOption,
59
+ onOptionClick = { onEvent( SearchContract . Event . Filter . OnDeliveryOptionChanged (it)) }
65
60
)
66
61
HorizontalDivider (
67
62
color = Color .LightGray .copy(alpha = 0.2f ),
@@ -75,21 +70,27 @@ fun SearchFilterScreen(
75
70
// 카테고리
76
71
ExpandableFilterSection (
77
72
title = stringResource(R .string.category_label),
78
- isExpanded = isCategorySectionExpanded,
79
- onClick = onFilterCategoryClick
73
+ isExpanded = state.filter. isCategorySectionExpanded,
74
+ onClick = { onEvent( SearchContract . Event . Filter . OnCategoryClick ) }
80
75
)
81
76
HorizontalDivider (
82
77
color = Color .LightGray .copy(alpha = 0.5f ),
83
78
thickness = 1 .dp
84
79
)
85
80
// 서브 카테고리
86
- if (isCategorySectionExpanded) {
81
+ if (state.filter. isCategorySectionExpanded) {
87
82
SubFilterCategory (
88
- categoryFilters = categoryFilters,
89
- expandedCategoryName = expandedCategoryName,
90
- selectedSubCategories = selectedSubCategories,
91
- onCategoryHeaderClick = onCategoryHeaderClick,
92
- onSubCategoryClick = onSubCategoryClick
83
+ categoryFilters = state.filter.categoryFilters,
84
+ expandedCategoryName = state.filter.expandedCategoryName,
85
+ selectedSubCategories = state.filter.selectedSubCategories,
86
+ onCategoryHeaderClick = {
87
+ onEvent(
88
+ SearchContract .Event .Filter .OnCategoryHeaderClick (
89
+ it
90
+ )
91
+ )
92
+ },
93
+ onSubCategoryClick = { onEvent(SearchContract .Event .Filter .OnSubCategoryClick (it)) }
93
94
)
94
95
}
95
96
}
@@ -103,7 +104,10 @@ fun SearchFilterScreen(
103
104
}
104
105
105
106
item {
106
- ExpandableFilterSection (title = stringResource(R .string.product_view_mode_label), details = " 2단" )
107
+ ExpandableFilterSection (
108
+ title = stringResource(R .string.product_view_mode_label),
109
+ details = " 2단"
110
+ )
107
111
HorizontalDivider (
108
112
color = Color .LightGray .copy(alpha = 0.5f ),
109
113
thickness = 1 .dp
@@ -118,8 +122,8 @@ private fun SubFilterCategory(
118
122
categoryFilters : List <FilterCategoriesModel >,
119
123
expandedCategoryName : String? ,
120
124
selectedSubCategories : Set <String >,
121
- onCategoryHeaderClick : (String ) -> Unit ,
122
- onSubCategoryClick : (String ) -> Unit ,
125
+ onCategoryHeaderClick : (categoryName: String ) -> Unit ,
126
+ onSubCategoryClick : (subCategoryName: String ) -> Unit ,
123
127
) {
124
128
Column {
125
129
categoryFilters.forEach { category ->
@@ -258,10 +262,10 @@ fun ExpandableFilterSection(
258
262
@Composable
259
263
fun FilterBottomButton (
260
264
itemCount : Int ,
261
- onClick : () -> Unit
265
+ onApplyFilters : () -> Unit
262
266
) {
263
267
Button (
264
- onClick = onClick ,
268
+ onClick = onApplyFilters ,
265
269
modifier = Modifier
266
270
.fillMaxWidth()
267
271
.padding(Spacing .spacing4),
@@ -278,4 +282,8 @@ fun FilterBottomButton(
278
282
fontWeight = FontWeight .Bold
279
283
)
280
284
}
281
- }
285
+ }
286
+
287
+
288
+
289
+
0 commit comments