1010package com.mifos.feature.search.components
1111
1212import androidclient.feature.search.generated.resources.Res
13+ import androidclient.feature.search.generated.resources.feature_search_apply
14+ import androidclient.feature.search.generated.resources.feature_search_close
1315import androidclient.feature.search.generated.resources.feature_search_filter
1416import androidx.compose.foundation.clickable
1517import androidx.compose.foundation.layout.Column
@@ -22,6 +24,10 @@ import androidx.compose.material3.MaterialTheme
2224import androidx.compose.material3.RadioButton
2325import androidx.compose.material3.Text
2426import androidx.compose.runtime.Composable
27+ import androidx.compose.runtime.getValue
28+ import androidx.compose.runtime.mutableStateOf
29+ import androidx.compose.runtime.remember
30+ import androidx.compose.runtime.setValue
2531import androidx.compose.ui.Alignment
2632import androidx.compose.ui.Modifier
2733import androidx.compose.ui.unit.sp
@@ -38,12 +44,17 @@ internal fun FilterDialog(
3844 onDismiss : () -> Unit ,
3945 modifier : Modifier = Modifier ,
4046) {
47+ var selectedFilter by remember { mutableStateOf(selected) }
48+
4149 MifosDialogBox (
4250 title = stringResource(Res .string.feature_search_filter),
4351 showDialogState = true ,
44- confirmButtonText = " " ,
45- dismissButtonText = " Close" ,
46- onConfirm = {},
52+ confirmButtonText = stringResource(Res .string.feature_search_apply),
53+ dismissButtonText = stringResource(Res .string.feature_search_close),
54+ onConfirm = {
55+ onEvent(SearchScreenEvent .UpdateSelectedFilter (selectedFilter))
56+ onDismiss()
57+ },
4758 onDismiss = onDismiss,
4859 modifier = modifier,
4960 message = {
@@ -55,20 +66,18 @@ internal fun FilterDialog(
5566 HorizontalDivider ()
5667 FilterOption (
5768 text = " All" ,
58- selected = selected == null ,
69+ selected = selectedFilter == null ,
5970 onSelected = {
60- onEvent(SearchScreenEvent .UpdateSelectedFilter (null ))
61- onDismiss()
71+ selectedFilter = null
6272 },
6373 )
6474 HorizontalDivider ()
6575 FilterOption .values.forEachIndexed { index, option ->
6676 FilterOption (
6777 text = option.label,
68- selected = option == selected ,
78+ selected = option == selectedFilter ,
6979 onSelected = {
70- onEvent(SearchScreenEvent .UpdateSelectedFilter (option))
71- onDismiss()
80+ selectedFilter = option
7281 },
7382 )
7483 if (index != FilterOption .values.size - 1 ) {
0 commit comments