Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard : scroll to show relevant items #52

Open
ragaoua opened this issue Oct 2, 2023 · 2 comments
Open

Keyboard : scroll to show relevant items #52

ragaoua opened this issue Oct 2, 2023 · 2 comments

Comments

@ragaoua
Copy link
Owner

ragaoua commented Oct 2, 2023

When the keyboard appears, scroll so that some relevant items appear on tge screen.
On the block screen, that would mean that, when the keyboard appears on tapping a set text field, the screen scrolls so that all sets for that exercise are shown (when possible)
On the "New block" sheet, make sure all elements of the sheet are shown (block name + microcycle settings + button)

@ragaoua
Copy link
Owner Author

ragaoua commented Oct 9, 2023

On the new block sheet, I used bringIntoFocusRequester to bring the validation button into view but it doesn't work. It seems that, since the button is already visible BEFORE the keyboard shows, nothing happens to bring it into view

@ragaoua
Copy link
Owner Author

ragaoua commented Oct 9, 2023

On the block screen, I managed to get the desired behavior by using a "bringIntoFocusRequester". I had this going on :

// Exercise.kt
val bringIntoViewRequester = remember { BringIntoViewRequester() }
...
ExerciseSetRow(
  modifier = Modifier
      .fillMaxWidth()
      .conditional(index == exercise.sets.lastIndex) {
          bringIntoViewRequester(bringIntoViewRequester)
      }
      ...
      bringIntoViewRequester = bringIntoViewRequester,
...
// ExerciseSetRow.kt
// Here, I just add bringIntoViewRequester as an argument an pass it the SetTextField
// SetTextField.kt
val coroutineScope = rememberCoroutineScope()
...
BasicTextField(
  ...
  modifier = Modifier.
    ...
    .onFocusChange(
      if (it.isFocused) {
        ...
        coroutineScope.launch {
            bringIntoViewRequester.bringIntoView()
        }
...

And it works ! What I've done is make it so the screen scrolls to the last set for the same exercise when focusing any set. But if there are a lot of sets (9 or so), it could hide the set we're actually focusing and writing to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant