Skip to content

Commit f9dc5bf

Browse files
shashank-0-0shashank-0-0
andauthored
Fix: Filter dialog confirmation button (#2537)
Co-authored-by: shashank-0-0 <ss068467@gmail.com>
1 parent a762133 commit f9dc5bf

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

feature/search/src/commonMain/composeResources/values/feature_search_strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
<string name="feature_search_search_options_clients_label">Clients</string>
2020
<string name="feature_search_search_options_clients_value">clients</string>
21+
<string name="feature_search_apply">Apply</string>
22+
<string name="feature_search_close">Close</string>
23+
<string name="feature_search_all">All</string>
2124

2225
<string-array name="feature_search_filter_options">
2326
<item>Clients</item>

feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/FilterDialog.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
package com.mifos.feature.search.components
1111

1212
import 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
1316
import androidclient.feature.search.generated.resources.feature_search_filter
1417
import androidx.compose.foundation.clickable
1518
import androidx.compose.foundation.layout.Column
@@ -22,6 +25,10 @@ import androidx.compose.material3.MaterialTheme
2225
import androidx.compose.material3.RadioButton
2326
import androidx.compose.material3.Text
2427
import 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
2532
import androidx.compose.ui.Alignment
2633
import androidx.compose.ui.Modifier
2734
import 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

Comments
 (0)