Skip to content

Commit 321530f

Browse files
committed
refactor(ui): relocate SearchBar to shared SearchInput component
Move the currency-selection-local SearchBar into a shared, reusable SearchInput in ui/components. The placeholder is now a parameter, the shape is CircleShape, and the icon tint follows the theme.
1 parent 1983db4 commit 321530f

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

apps/flipcash/shared/currency-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/RegionSelectionModalContent.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import androidx.compose.runtime.LaunchedEffect
1010
import androidx.compose.runtime.getValue
1111
import androidx.compose.runtime.snapshotFlow
1212
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.res.stringResource
1314
import androidx.lifecycle.compose.collectAsStateWithLifecycle
1415
import com.flipcash.app.currency.internal.components.RegionList
15-
import com.flipcash.app.currency.internal.components.SearchBar
16+
import com.flipcash.features.currency.R
1617
import com.getcode.navigation.core.LocalCodeNavigator
1718
import com.getcode.theme.CodeTheme
19+
import com.getcode.ui.components.SearchInput
1820
import com.getcode.ui.core.rememberAnimationScale
1921
import com.getcode.ui.core.scaled
2022
import com.getcode.ui.utils.rememberKeyboardController
@@ -51,10 +53,11 @@ internal fun RegionSelectionModalContent(viewModel: CurrencyViewModel) {
5153
snapshotFlow { state.searchState.text }
5254
.launchIn(this)
5355
}
54-
SearchBar(
56+
SearchInput(
5557
modifier = Modifier.padding(top = CodeTheme.dimens.grid.x3),
5658
state = state.searchState,
5759
contentPadding = PaddingValues(start = CodeTheme.dimens.grid.x1),
60+
placeholder = stringResource(R.string.subtitle_searchRegions)
5861
)
5962

6063
RegionList(

apps/flipcash/shared/currency-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/components/SearchBar.kt renamed to ui/components/src/main/kotlin/com/getcode/ui/components/SearchInput.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package com.flipcash.app.currency.internal.components
1+
package com.getcode.ui.components
22

33
import androidx.compose.foundation.layout.PaddingValues
44
import androidx.compose.foundation.layout.padding
5+
import androidx.compose.foundation.shape.CircleShape
56
import androidx.compose.foundation.text.input.TextFieldState
67
import androidx.compose.foundation.text.input.clearText
78
import androidx.compose.material.Icon
@@ -12,16 +13,15 @@ import androidx.compose.material.icons.outlined.Close
1213
import androidx.compose.runtime.Composable
1314
import androidx.compose.ui.Modifier
1415
import androidx.compose.ui.res.stringResource
15-
import com.flipcash.features.currency.R
1616
import com.getcode.theme.CodeTheme
1717
import com.getcode.theme.White50
18-
import com.getcode.ui.components.TextInput
1918

2019
@Composable
21-
internal fun SearchBar(
20+
fun SearchInput(
2221
state: TextFieldState,
2322
modifier: Modifier = Modifier,
2423
contentPadding: PaddingValues = PaddingValues(),
24+
placeholder: String = stringResource(R.string.action_search),
2525
) {
2626
TextInput(
2727
modifier = modifier
@@ -30,13 +30,13 @@ internal fun SearchBar(
3030
contentPadding = contentPadding,
3131
leadingIcon = {
3232
Icon(
33-
modifier = Modifier.padding(start = CodeTheme.dimens.grid.x1),
33+
modifier = Modifier.padding(start = CodeTheme.dimens.grid.x3),
3434
imageVector = Icons.Filled.Search,
3535
contentDescription = null,
36-
tint = White50,
36+
tint = CodeTheme.colors.textMain,
3737
)
3838
},
39-
placeholder = stringResource(id = R.string.subtitle_searchRegions),
39+
placeholder = placeholder,
4040
placeholderStyle = CodeTheme.typography.textMedium,
4141
trailingIcon = {
4242
if (state.text.isNotEmpty()) {
@@ -55,6 +55,6 @@ internal fun SearchBar(
5555
},
5656
maxLines = 1,
5757
style = CodeTheme.typography.textMedium,
58-
shape = CodeTheme.shapes.small
58+
shape = CircleShape,
5959
)
6060
}

0 commit comments

Comments
 (0)