Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-16 09:03:49 +01:00
parent 99804d023d
commit 9ee6611585
2 changed files with 11 additions and 6 deletions

View file

@ -29,11 +29,12 @@ internal class DefaultMarketsTokenListComponent(
@Composable
override fun Title(bottomSheetState: State<BottomSheetState>) {
val state by model.state.collectAsStateWithLifecycle()
val bsState by bottomSheetState
TopBarWithSearch(
onBackClick = params.onBackClicked,
onSearchClick = state.onSearchClicked,
marketsSearchBar = state.marketsSearchBar,
buttonsEnabled = bottomSheetState.value == BottomSheetState.EXPANDED,
bottomSheetState = bsState,
)
}

View file

@ -23,6 +23,7 @@ import com.tangem.core.ui.components.SpacerH12
import com.tangem.core.ui.components.SpacerH8
import com.tangem.core.ui.components.appbar.AppBarWithBackButtonAndIcon
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.components.bottomsheets.state.BottomSheetState
import com.tangem.core.ui.components.buttons.SecondarySmallButton
import com.tangem.core.ui.components.buttons.SmallButtonConfig
import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition
@ -51,10 +52,10 @@ private const val DELAY_FOR_FOCUS_REQUEST = 200L
@Composable
internal fun TopBarWithSearch(
buttonsEnabled: Boolean,
onBackClick: () -> Unit,
onSearchClick: () -> Unit,
marketsSearchBar: MarketsSearchBar,
bottomSheetState: BottomSheetState = BottomSheetState.EXPANDED,
) {
val background = LocalMainBottomSheetColor.current.value
val focusRequester = remember { FocusRequester() }
@ -70,8 +71,8 @@ internal fun TopBarWithSearch(
if (showAppBar) {
AppBarWithBackButtonAndIcon(
onBackClick = onBackClick,
backButtonEnabled = buttonsEnabled,
endButtonEnabled = buttonsEnabled,
backButtonEnabled = bottomSheetState == BottomSheetState.EXPANDED,
endButtonEnabled = bottomSheetState == BottomSheetState.EXPANDED,
text = stringResourceSafe(R.string.markets_common_title),
iconRes = R.drawable.ic_search_24,
onIconClick = onSearchClick,
@ -91,8 +92,11 @@ internal fun TopBarWithSearch(
focusRequester = focusRequester,
)
if (marketsSearchBar.shouldAlwaysShowSearchBar || marketsSearchBar.searchBarUM.isActive) {
LaunchedEffect(Unit) {
val shouldRequestFocus =
(marketsSearchBar.shouldAlwaysShowSearchBar || marketsSearchBar.searchBarUM.isActive) &&
bottomSheetState == BottomSheetState.EXPANDED
if (shouldRequestFocus) {
LaunchedEffect(bottomSheetState) {
delay(DELAY_FOR_FOCUS_REQUEST)
focusRequester.requestFocus()
}