diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetScreen.kt index 37b60cf58..a2aa0c317 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetScreen.kt @@ -37,12 +37,14 @@ import dev.arkbuilders.rate.R import dev.arkbuilders.rate.data.CurrUtils import dev.arkbuilders.rate.domain.model.CurrencyCode import dev.arkbuilders.rate.di.DIManager +import dev.arkbuilders.rate.domain.model.AmountStr import dev.arkbuilders.rate.presentation.destinations.SearchCurrencyScreenDestination import dev.arkbuilders.rate.presentation.pairalert.DropDownWithIcon import dev.arkbuilders.rate.presentation.shared.AppSharedFlow import dev.arkbuilders.rate.presentation.shared.AppSharedFlowKey import dev.arkbuilders.rate.presentation.theme.ArkColor import dev.arkbuilders.rate.presentation.ui.AppTopBarBack +import dev.arkbuilders.rate.presentation.ui.BasicTextFieldPlaceholder import dev.arkbuilders.rate.presentation.ui.GroupCreateDialog import dev.arkbuilders.rate.presentation.ui.GroupSelectPopup import dev.arkbuilders.rate.presentation.ui.NotifyAddedSnackbarVisuals @@ -215,7 +217,7 @@ private fun Currencies( @Composable fun InputCurrency( pos: Int, - codeToValue: Pair, + amount: AmountStr, onAssetValueChanged: (Int, String) -> Unit, onAssetRemove: (Int) -> Unit, onCodeChange: (Int) -> Unit @@ -242,7 +244,7 @@ fun InputCurrency( ) { Text( modifier = Modifier.padding(start = 14.dp), - text = codeToValue.first, + text = amount.code, fontSize = 16.sp, color = ArkColor.TextSecondary ) @@ -253,29 +255,28 @@ fun InputCurrency( tint = ArkColor.FGQuinary ) } - BasicTextField( + BasicTextFieldPlaceholder( modifier = Modifier.padding(start = 12.dp), - value = codeToValue.second, + value = amount.value, onValueChange = { onAssetValueChanged(pos, it) }, - textStyle = TextStyle.Default.copy( - color = ArkColor.TextPrimary, - fontSize = 16.sp - ), + placeholder = "Input value", keyboardOptions = KeyboardOptions.Default .copy(keyboardType = KeyboardType.Number) ) } - IconButton(modifier = Modifier - .padding(start = 16.dp) - .size(44.dp) - .border( - 1.dp, - ArkColor.Border, - RoundedCornerShape(8.dp) - ) - .clip(RoundedCornerShape(8.dp)), - onClick = { onAssetRemove(pos) } + Box( + modifier = Modifier + .padding(start = 16.dp) + .size(44.dp) + .border( + 1.dp, + ArkColor.Border, + RoundedCornerShape(8.dp) + ) + .clip(RoundedCornerShape(8.dp)) + .clickable { onAssetRemove(pos) }, + contentAlignment = Alignment.Center ) { Icon( painter = painterResource(id = R.drawable.ic_delete), diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetViewModel.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetViewModel.kt index d1f304b1c..45f1639f3 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetViewModel.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/AddAssetViewModel.kt @@ -7,6 +7,7 @@ import dev.arkbuilders.rate.data.CurrUtils import dev.arkbuilders.rate.domain.model.Asset import dev.arkbuilders.rate.domain.model.CurrencyCode import dev.arkbuilders.rate.data.toDoubleSafe +import dev.arkbuilders.rate.domain.model.AmountStr import dev.arkbuilders.rate.domain.repo.CodeUseStatRepo import dev.arkbuilders.rate.domain.repo.CurrencyRepo import dev.arkbuilders.rate.domain.repo.PortfolioRepo @@ -23,10 +24,8 @@ import org.orbitmvi.orbit.viewmodel.container import javax.inject.Inject import javax.inject.Singleton -private val stubCurrency = "USD" to "" - data class AddAssetState( - val currencies: List> = listOf(stubCurrency), + val currencies: List = listOf(AmountStr("USD", "")), val group: String? = null, val availableGroups: List = emptyList() ) @@ -53,7 +52,7 @@ class AddAssetViewModel( reduce { val newCurrencies = state.currencies.toMutableList() newCurrencies[pos] = - newCurrencies[pos].copy(first = selectedCode) + newCurrencies[pos].copy(code = selectedCode) state.copy(currencies = newCurrencies) } } @@ -61,7 +60,7 @@ class AddAssetViewModel( AppSharedFlow.AddAsset.flow.onEach { code -> intent { - reduce { state.copy(currencies = state.currencies + (code to "")) } + reduce { state.copy(currencies = state.currencies + AmountStr(code, "")) } } }.launchIn(viewModelScope) @@ -91,15 +90,15 @@ class AddAssetViewModel( reduce { val newCurrencies = state.currencies.toMutableList() val old = newCurrencies[pos] - val validatedAmount = CurrUtils.validateInput(old.second, input) - newCurrencies[pos] = newCurrencies[pos].copy(second = validatedAmount) + val validatedAmount = CurrUtils.validateInput(old.value, input) + newCurrencies[pos] = newCurrencies[pos].copy(value = validatedAmount) state.copy(currencies = newCurrencies) } } fun onAddAsset() = intent { val currencies = state.currencies.map { - Asset(code = it.first, value = it.second.toDoubleSafe(), group = state.group) + Asset(code = it.code, value = it.value.toDoubleSafe(), group = state.group) } assetsRepo.setAssetsList(currencies) codeUseStatRepo.codesUsed(*currencies.map { it.code }.toTypedArray()) diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioScreen.kt index 543ebf90b..b3e9bf6ee 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioScreen.kt @@ -58,7 +58,8 @@ import dev.arkbuilders.rate.presentation.ui.AppSwipeToDismiss import dev.arkbuilders.rate.presentation.ui.CurrIcon import dev.arkbuilders.rate.presentation.ui.GroupViewPager import dev.arkbuilders.rate.presentation.ui.LoadingScreen -import dev.arkbuilders.rate.presentation.ui.SearchTextFieldWithSort +import dev.arkbuilders.rate.presentation.ui.NoResult +import dev.arkbuilders.rate.presentation.ui.SearchTextField import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.orbitmvi.orbit.compose.collectAsState @@ -119,6 +120,7 @@ fun PortfolioScreen(navigator: DestinationsNavigator) { onClick = { display -> navigator.navigate(EditAssetScreenDestination(display.asset.id)) }, + onFilterChange = viewModel::onFilterChange, onDelete = viewModel::onAssetRemove ) } @@ -134,8 +136,14 @@ private val previewPortfolioAmount = PortfolioDisplayAsset( private val previewState = PortfolioScreenState( pages = listOf( - PortfolioScreenPage("Group1", listOf(previewPortfolioAmount, previewPortfolioAmount)), - PortfolioScreenPage("Group2", listOf(previewPortfolioAmount, previewPortfolioAmount)) + PortfolioScreenPage( + "Group1", + listOf(previewPortfolioAmount, previewPortfolioAmount) + ), + PortfolioScreenPage( + "Group2", + listOf(previewPortfolioAmount, previewPortfolioAmount) + ) ) ) @@ -144,13 +152,24 @@ private val previewState = PortfolioScreenState( private fun Content( state: PortfolioScreenState = previewState, onClick: (PortfolioDisplayAsset) -> Unit = {}, + onFilterChange: (String) -> Unit = {}, onDelete: (Asset) -> Unit = {} ) { val groups = state.pages.map { it.group } Column { - SearchTextFieldWithSort(modifier = Modifier.padding(top = 16.dp)) + SearchTextField( + modifier = Modifier.padding( + top = 16.dp, + start = 16.dp, + end = 16.dp, + bottom = 16.dp + ), + text = state.filter, + onValueChange = onFilterChange + ) if (state.pages.size == 1) { GroupPage( + filter = state.filter, baseCode = state.baseCode, amounts = state.pages.first().assets, onClick = onClick, @@ -162,6 +181,7 @@ private fun Content( groups = groups ) { index -> GroupPage( + filter = state.filter, baseCode = state.baseCode, amounts = state.pages[index].assets, onClick = onClick, @@ -174,6 +194,7 @@ private fun Content( @Composable private fun GroupPage( + filter: String, baseCode: CurrencyCode, amounts: List, onClick: (PortfolioDisplayAsset) -> Unit = {}, @@ -182,33 +203,41 @@ private fun GroupPage( val total = amounts.fold(0.0) { acc, amount -> acc + amount.baseAmount.value } - LazyColumn( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally - ) { - item { - Text( - modifier = Modifier.padding(top = 32.dp), - text = "Total Assets", - color = ArkColor.TextTertiary, - fontWeight = FontWeight.Medium - ) - Text( - modifier = Modifier.padding(top = 8.dp), - text = "${CurrUtils.prepareToDisplay(total)} $baseCode", - color = ArkColor.TextPrimary, - fontWeight = FontWeight.SemiBold, - fontSize = 36.sp - ) - AppHorDiv16(Modifier.padding(top = 32.dp)) - } - items(amounts, key = { it.asset.id }) { - AppSwipeToDismiss( - content = { CurrencyItem(it, onClick = onClick) }, - onDelete = { onDelete(it.asset) } - ) - AppHorDiv16() + val filtered = + amounts.filter { it.asset.code.contains(filter, ignoreCase = true) } + if (filtered.isNotEmpty()) { + LazyColumn( + modifier = Modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + if (filter.isEmpty()) { + item { + Text( + modifier = Modifier.padding(top = 32.dp), + text = "Total Assets", + color = ArkColor.TextTertiary, + fontWeight = FontWeight.Medium + ) + Text( + modifier = Modifier.padding(top = 8.dp), + text = "${CurrUtils.prepareToDisplay(total)} $baseCode", + color = ArkColor.TextPrimary, + fontWeight = FontWeight.SemiBold, + fontSize = 36.sp + ) + AppHorDiv16(Modifier.padding(top = 32.dp)) + } + } + items(filtered, key = { it.asset.id }) { + AppSwipeToDismiss( + content = { CurrencyItem(it, onClick = onClick) }, + onDelete = { onDelete(it.asset) } + ) + AppHorDiv16() + } } + } else { + NoResult() } } diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioViewModel.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioViewModel.kt index f7df0b5e3..9335a4b30 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioViewModel.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/portfolio/PortfolioViewModel.kt @@ -14,9 +14,9 @@ import dev.arkbuilders.rate.domain.usecase.ConvertWithRateUseCase import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.launch import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost +import org.orbitmvi.orbit.syntax.simple.blockingIntent import org.orbitmvi.orbit.syntax.simple.intent import org.orbitmvi.orbit.syntax.simple.reduce import org.orbitmvi.orbit.viewmodel.container @@ -24,6 +24,7 @@ import javax.inject.Inject import javax.inject.Singleton data class PortfolioScreenState( + val filter: String = "", val baseCode: CurrencyCode = "USD", val pages: List = emptyList(), val initialized: Boolean = false @@ -73,10 +74,14 @@ class PortfolioViewModel( assetsRepo.removeAsset(amount.id) } + fun onFilterChange(filter: String) = blockingIntent { + reduce { state.copy(filter = filter) } + } + private fun init() = intent { val baseCode = prefs.get(PreferenceKey.BaseCurrencyCode) - val list = assetsRepo.allAssets() - val groups = list.groupBy(keySelector = { it.group }) + val assets = assetsRepo.allAssets().reversed() + val groups = assets.groupBy(keySelector = { it.group }) val pages = groups.map { (group, assets) -> val displayAssets = assetToPortfolioDisplayAmount( baseCode, @@ -85,7 +90,7 @@ class PortfolioViewModel( PortfolioScreenPage(group, displayAssets) } reduce { - state.copy(baseCode, pages, initialized = true) + state.copy(baseCode = baseCode, pages = pages, initialized = true) } } diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/quick/AddQuickScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/quick/AddQuickScreen.kt index e159a1666..0a12d003d 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/quick/AddQuickScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/quick/AddQuickScreen.kt @@ -64,6 +64,7 @@ import dev.arkbuilders.rate.presentation.shared.AppSharedFlowKey import dev.arkbuilders.rate.presentation.theme.ArkColor import dev.arkbuilders.rate.presentation.ui.AppHorDiv16 import dev.arkbuilders.rate.presentation.ui.AppTopBarBack +import dev.arkbuilders.rate.presentation.ui.BasicTextFieldPlaceholder import dev.arkbuilders.rate.presentation.ui.GroupCreateDialog import dev.arkbuilders.rate.presentation.ui.GroupSelectPopup import dev.arkbuilders.rate.presentation.ui.NotifyAddedSnackbarVisuals @@ -307,43 +308,14 @@ private fun FromInput( tint = ArkColor.FGQuinary ) } - val interactionSource = remember { MutableInteractionSource() } - BasicTextField( + BasicTextFieldPlaceholder( modifier = Modifier.padding(start = 12.dp), value = amount, onValueChange = { onAmountChanged(it) }, - textStyle = TextStyle.Default.copy( - color = ArkColor.TextPrimary, - fontSize = 16.sp - ), + placeholder = "Input value", keyboardOptions = KeyboardOptions.Default - .copy(keyboardType = KeyboardType.Number), - interactionSource = interactionSource, - singleLine = true - ) { innerTextField -> - TextFieldDefaults.DecorationBox( - value = amount, - innerTextField = innerTextField, - placeholder = { - Text( - text = "Input the value", - color = ArkColor.TextPlaceHolder, - fontSize = 16.sp - ) - }, - contentPadding = PaddingValues(0.dp), - colors = TextFieldDefaults.colors( - focusedContainerColor = Color.Transparent, - unfocusedContainerColor = Color.Transparent, - focusedIndicatorColor = Color.Transparent, - unfocusedIndicatorColor = Color.Transparent - ), - enabled = true, - singleLine = true, - visualTransformation = VisualTransformation.None, - interactionSource = interactionSource - ) - } + .copy(keyboardType = KeyboardType.Number) + ) } } } diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/quick/QuickScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/quick/QuickScreen.kt index 753f04d5c..d8c53c686 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/quick/QuickScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/quick/QuickScreen.kt @@ -69,7 +69,7 @@ import dev.arkbuilders.rate.presentation.ui.GroupViewPager import dev.arkbuilders.rate.presentation.ui.LoadingScreen import dev.arkbuilders.rate.presentation.ui.NoResult import dev.arkbuilders.rate.presentation.ui.NotifyAddedSnackbar -import dev.arkbuilders.rate.presentation.ui.SearchTextFieldWithSort +import dev.arkbuilders.rate.presentation.ui.SearchTextField import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.orbitmvi.orbit.compose.collectAsState @@ -150,8 +150,13 @@ private fun Content( ) { val groups = state.pages.map { it.group } Column { - SearchTextFieldWithSort( - modifier = Modifier.padding(top = 16.dp), + SearchTextField( + modifier = Modifier.padding( + top = 16.dp, + start = 16.dp, + end = 16.dp, + bottom = 16.dp + ), text = state.filter ) { onFilterChanged(it) diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/search/SearchCurrencyScreen.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/search/SearchCurrencyScreen.kt index 45c6004e4..f13a70200 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/search/SearchCurrencyScreen.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/search/SearchCurrencyScreen.kt @@ -2,15 +2,9 @@ package dev.arkbuilders.rate.presentation.search -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape @@ -22,12 +16,10 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import androidx.lifecycle.viewmodel.compose.viewModel import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator @@ -35,11 +27,13 @@ import dev.arkbuilders.rate.R import dev.arkbuilders.rate.domain.model.CurrencyName import dev.arkbuilders.rate.di.DIManager import dev.arkbuilders.rate.presentation.theme.ArkColor +import dev.arkbuilders.rate.presentation.ui.AppHorDiv +import dev.arkbuilders.rate.presentation.ui.AppHorDiv16 import dev.arkbuilders.rate.presentation.ui.AppTopBarBack -import dev.arkbuilders.rate.presentation.ui.CurrIcon import dev.arkbuilders.rate.presentation.ui.CurrencyInfoItem import dev.arkbuilders.rate.presentation.ui.LoadingScreen import dev.arkbuilders.rate.presentation.ui.NoResult +import dev.arkbuilders.rate.presentation.ui.SearchTextField import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect @@ -93,28 +87,14 @@ fun SearchCurrencyScreen( @Composable private fun Input(input: String, onInputChange: (String) -> Unit) { - OutlinedTextField( + SearchTextField( modifier = Modifier .padding(16.dp) .fillMaxWidth(), - value = input, + text = input, onValueChange = { onInputChange(it) }, - leadingIcon = { - Icon( - painter = painterResource(id = R.drawable.ic_search), - contentDescription = "", - tint = ArkColor.FGQuarterary - ) - }, - shape = RoundedCornerShape(8.dp), - placeholder = { - Text( - text = "Search", - color = ArkColor.TextPlaceHolder, - ) - } ) - HorizontalDivider(thickness = 1.dp, color = ArkColor.BorderSecondary) + AppHorDiv() } @Composable @@ -163,12 +143,12 @@ private fun Header(header: String) { start = 16.dp, top = 24.dp, end = 16.dp, - bottom = 13.dp ), text = header, fontWeight = FontWeight.Medium, color = ArkColor.TextTertiary ) + AppHorDiv16(modifier = Modifier.padding(top = 12.dp)) } diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/ui/BasicTextFieldPlaceholder.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/ui/BasicTextFieldPlaceholder.kt new file mode 100644 index 000000000..bf99b43f5 --- /dev/null +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/ui/BasicTextFieldPlaceholder.kt @@ -0,0 +1,70 @@ +@file:OptIn(ExperimentalMaterial3Api::class) + +package dev.arkbuilders.rate.presentation.ui + +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text +import androidx.compose.material3.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.VisualTransformation +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import dev.arkbuilders.rate.presentation.theme.ArkColor + +@Composable +fun BasicTextFieldPlaceholder( + modifier: Modifier = Modifier, + value: String, + onValueChange: (String) -> Unit, + placeholder: String, + leadingIcon: (@Composable () -> Unit)? = null, + keyboardOptions: KeyboardOptions = KeyboardOptions.Default +) { + val interactionSource = remember { MutableInteractionSource() } + BasicTextField( + modifier = modifier, + value = value, + onValueChange = { onValueChange(it) }, + textStyle = TextStyle.Default.copy( + color = ArkColor.TextPrimary, + fontSize = 16.sp + ), + keyboardOptions = keyboardOptions, + interactionSource = interactionSource, + singleLine = true + ) { innerTextField -> + TextFieldDefaults.DecorationBox( + value = value, + innerTextField = innerTextField, + leadingIcon = leadingIcon, + placeholder = { + Text( + text = placeholder, + color = ArkColor.TextPlaceHolder, + fontSize = 16.sp + ) + }, + contentPadding = PaddingValues(0.dp), + colors = TextFieldDefaults.colors( + focusedContainerColor = Color.Transparent, + unfocusedContainerColor = Color.Transparent, + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent + ), + enabled = true, + singleLine = true, + visualTransformation = VisualTransformation.None, + interactionSource = interactionSource + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/dev/arkbuilders/rate/presentation/ui/Search.kt b/app/src/main/java/dev/arkbuilders/rate/presentation/ui/Search.kt index 6a0a186eb..d8509ebf1 100644 --- a/app/src/main/java/dev/arkbuilders/rate/presentation/ui/Search.kt +++ b/app/src/main/java/dev/arkbuilders/rate/presentation/ui/Search.kt @@ -1,23 +1,15 @@ package dev.arkbuilders.rate.presentation.ui -import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.height import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.OutlinedTextFieldDefaults -import androidx.compose.material3.Text -import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -32,54 +24,24 @@ fun SearchTextField( placeHolderText: String = "Search", onValueChange: (String) -> Unit = {}, ) { - OutlinedTextField( + Row( modifier = modifier - .padding(start = 16.dp, end = 16.dp) - .fillMaxWidth(), - value = text, - onValueChange = { onValueChange(it) }, - leadingIcon = { - Icon( - painter = painterResource(id = R.drawable.ic_search), - contentDescription = "", - tint = ArkColor.FGQuarterary - ) - }, - shape = RoundedCornerShape(8.dp), - colors = OutlinedTextFieldDefaults - .colors( - unfocusedContainerColor = Color.Transparent, - focusedContainerColor = Color.Transparent, - focusedBorderColor = ArkColor.Border, - unfocusedBorderColor = ArkColor.Border - ), - placeholder = { - Text( - text = placeHolderText, - color = ArkColor.TextPlaceHolder, + .fillMaxWidth() + .height(44.dp) + .border( + 1.dp, + ArkColor.Border, + RoundedCornerShape(8.dp) ) - } - ) -} - -@Preview(showBackground = true) -@Composable -fun SearchTextFieldWithSort( - modifier: Modifier = Modifier, - text: String = "", - placeHolderText: String = "Search", - onValueChange: (String) -> Unit = {}, -) { - Row( - modifier = modifier.fillMaxWidth(), + .clip(RoundedCornerShape(8.dp)), verticalAlignment = Alignment.CenterVertically ) { - OutlinedTextField( + BasicTextFieldPlaceholder( modifier = Modifier - .padding(start = 16.dp, end = 16.dp) .fillMaxWidth(), value = text, - onValueChange = { onValueChange(it) }, + onValueChange = onValueChange, + placeholder = placeHolderText, leadingIcon = { Icon( painter = painterResource(id = R.drawable.ic_search), @@ -87,20 +49,6 @@ fun SearchTextFieldWithSort( tint = ArkColor.FGQuarterary ) }, - shape = RoundedCornerShape(8.dp), - placeholder = { - Text( - text = placeHolderText, - color = ArkColor.TextPlaceHolder, - ) - }, - colors = OutlinedTextFieldDefaults - .colors( - unfocusedContainerColor = Color.Transparent, - focusedContainerColor = Color.Transparent, - focusedBorderColor = ArkColor.Border, - unfocusedBorderColor = ArkColor.Border - ), ) } } \ No newline at end of file