diff --git a/v4/feature/market/src/main/java/exchange/dydx/trading/feature/market/search/DydxMarketSearchView.kt b/v4/feature/market/src/main/java/exchange/dydx/trading/feature/market/search/DydxMarketSearchView.kt index 3e1d34d2..c1a74160 100644 --- a/v4/feature/market/src/main/java/exchange/dydx/trading/feature/market/search/DydxMarketSearchView.kt +++ b/v4/feature/market/src/main/java/exchange/dydx/trading/feature/market/search/DydxMarketSearchView.kt @@ -13,9 +13,12 @@ import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.text.TextStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -142,7 +145,7 @@ object DydxMarketSearchView : DydxComponent { state: ViewState, ) { val shape = RoundedCornerShape(50) - + val focusRequester = remember { FocusRequester() } Row( modifier = modifier.fillMaxWidth() .padding(start = ThemeShapes.HorizontalPadding) @@ -156,6 +159,7 @@ object DydxMarketSearchView : DydxComponent { .padding(horizontal = 16.dp, vertical = 8.dp), ) { PlatformTextInput( + focusRequester = focusRequester, placeHolder = state.localizer.localize("APP.GENERAL.SEARCH"), textStyle = TextStyle.dydxDefault .themeFont( @@ -166,5 +170,9 @@ object DydxMarketSearchView : DydxComponent { } HeaderViewCloseBotton(closeAction = state.closeAction) } + + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } } } diff --git a/v4/feature/profile/src/main/java/exchange/dydx/trading/feature/profile/tradingnetwork/DydxTradingNetworkViewModel.kt b/v4/feature/profile/src/main/java/exchange/dydx/trading/feature/profile/tradingnetwork/DydxTradingNetworkViewModel.kt index aef9eb96..c4a65996 100644 --- a/v4/feature/profile/src/main/java/exchange/dydx/trading/feature/profile/tradingnetwork/DydxTradingNetworkViewModel.kt +++ b/v4/feature/profile/src/main/java/exchange/dydx/trading/feature/profile/tradingnetwork/DydxTradingNetworkViewModel.kt @@ -57,7 +57,7 @@ class DydxTradingNetworkViewModel @Inject constructor( localizer: LocalizerProtocol, abacusStateManager: AbacusStateManagerProtocol ): String? { - val value = abacusStateManager.currentEnvironmentId.value + val value = abacusStateManager.currentEnvironmentId.value ?: return null return abacusStateManager.availableEnvironments.first { it.type == value }.localizedString(localizer = localizer) } } diff --git a/v4/platformUI/src/main/java/exchange/dydx/platformui/components/inputs/PlatformTextInput.kt b/v4/platformUI/src/main/java/exchange/dydx/platformui/components/inputs/PlatformTextInput.kt index 46329aae..3c9b56bb 100644 --- a/v4/platformUI/src/main/java/exchange/dydx/platformui/components/inputs/PlatformTextInput.kt +++ b/v4/platformUI/src/main/java/exchange/dydx/platformui/components/inputs/PlatformTextInput.kt @@ -18,6 +18,8 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.VisualTransformation @@ -33,6 +35,7 @@ import exchange.dydx.platformui.designSystem.theme.themeFont @Composable fun PlatformTextInput( modifier: Modifier = Modifier, + focusRequester: FocusRequester = remember { FocusRequester() }, label: @Composable (() -> Unit)? = null, value: String? = null, textStyle: TextStyle = @@ -61,7 +64,7 @@ fun PlatformTextInput( val displayValue = if (isFocused) currentValue.value ?: "" else value ?: "" BasicTextField( - modifier = Modifier, + modifier = Modifier.focusRequester(focusRequester = focusRequester), value = displayValue, onValueChange = { currentValue.value = it