Skip to content

Commit

Permalink
[ANDROAPP-5800] move focus to next item
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr committed Feb 15, 2024
1 parent 397c30c commit 10f2c2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fun SearchParametersScreen(
.weight(1F)
.verticalScroll(rememberScrollState()),
) {
uiState.items.forEach { fieldUiModel ->
uiState.items.forEachIndexed { index, fieldUiModel ->
fieldUiModel.setCallback(callback)
ParameterSelectorItem(
modifier = Modifier
Expand All @@ -174,6 +174,10 @@ fun SearchParametersScreen(
focusManager = focusManager,
fieldUiModel = fieldUiModel,
callback = callback,
onNextClicked = {
val nextItemIndex = (index + 1) % uiState.items.size
uiState.items[nextItemIndex].onItemClick()
},
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -29,6 +28,7 @@ fun provideParameterSelectorItem(
focusManager: FocusManager,
fieldUiModel: FieldUiModel,
callback: FieldUiModel.Callback,
onNextClicked: () -> Unit,
): ParameterSelectorItemModel {
val focusRequester = remember { FocusRequester() }

Expand Down Expand Up @@ -60,7 +60,7 @@ fun provideParameterSelectorItem(
intentHandler = callback::intent,
resources = resources,
focusManager = focusManager,
onNextClicked = { focusManager.moveFocus(FocusDirection.Down) },
onNextClicked = onNextClicked,
)
},
status = status,
Expand Down

0 comments on commit 10f2c2d

Please sign in to comment.