1010package com.mifos.feature.search.components
1111
1212import androidclient.feature.search.generated.resources.Res
13+ import androidclient.feature.search.generated.resources.feature_search_all
14+ import androidclient.feature.search.generated.resources.feature_search_apply
15+ import androidclient.feature.search.generated.resources.feature_search_close
1316import androidclient.feature.search.generated.resources.feature_search_filter
1417import androidx.compose.foundation.clickable
1518import androidx.compose.foundation.layout.Column
@@ -22,6 +25,10 @@ import androidx.compose.material3.MaterialTheme
2225import androidx.compose.material3.RadioButton
2326import androidx.compose.material3.Text
2427import androidx.compose.runtime.Composable
28+ import androidx.compose.runtime.getValue
29+ import androidx.compose.runtime.mutableStateOf
30+ import androidx.compose.runtime.remember
31+ import androidx.compose.runtime.setValue
2532import androidx.compose.ui.Alignment
2633import androidx.compose.ui.Modifier
2734import androidx.compose.ui.unit.sp
@@ -38,12 +45,17 @@ internal fun FilterDialog(
3845 onDismiss : () -> Unit ,
3946 modifier : Modifier = Modifier ,
4047) {
48+ var selectedFilter by remember { mutableStateOf(selected) }
49+
4150 MifosDialogBox (
4251 title = stringResource(Res .string.feature_search_filter),
4352 showDialogState = true ,
44- confirmButtonText = " " ,
45- dismissButtonText = " Close" ,
46- onConfirm = {},
53+ confirmButtonText = stringResource(Res .string.feature_search_apply),
54+ dismissButtonText = stringResource(Res .string.feature_search_close),
55+ onConfirm = {
56+ onEvent(SearchScreenEvent .UpdateSelectedFilter (selectedFilter))
57+ onDismiss()
58+ },
4759 onDismiss = onDismiss,
4860 modifier = modifier,
4961 message = {
@@ -54,21 +66,19 @@ internal fun FilterDialog(
5466 ) {
5567 HorizontalDivider ()
5668 FilterOption (
57- text = " All " ,
58- selected = selected == null ,
69+ text = stringResource( Res .string.feature_search_all) ,
70+ selected = selectedFilter == null ,
5971 onSelected = {
60- onEvent(SearchScreenEvent .UpdateSelectedFilter (null ))
61- onDismiss()
72+ selectedFilter = null
6273 },
6374 )
6475 HorizontalDivider ()
6576 FilterOption .values.forEachIndexed { index, option ->
6677 FilterOption (
6778 text = option.label,
68- selected = option == selected ,
79+ selected = option == selectedFilter ,
6980 onSelected = {
70- onEvent(SearchScreenEvent .UpdateSelectedFilter (option))
71- onDismiss()
81+ selectedFilter = option
7282 },
7383 )
7484 if (index != FilterOption .values.size - 1 ) {
0 commit comments