Skip to content

Commit

Permalink
Fix keyboard navigation crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Sep 22, 2023
1 parent 7de9eea commit c9acd7b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,23 @@ fun AccountScreen(
)

Spacer(modifier = Modifier.weight(1f))
if (IS_PLAY_BUILD.not()) {
ActionButton(
text = stringResource(id = R.string.manage_account),
onClick = onManageAccountClick,
modifier =
Modifier.padding(
start = Dimens.sideMargin,
end = Dimens.sideMargin,
bottom = Dimens.screenVerticalMargin
),
colors =
ButtonDefaults.buttonColors(
contentColor = MaterialTheme.colorScheme.onPrimary,
containerColor = MaterialTheme.colorScheme.surface
)
)
}
if (IS_PLAY_BUILD.not()) {
ActionButton(
text = stringResource(id = R.string.manage_account),
onClick = onManageAccountClick,
modifier =
Modifier.padding(
start = Dimens.sideMargin,
end = Dimens.sideMargin,
bottom = Dimens.screenVerticalMargin
),
colors =
ButtonDefaults.buttonColors(
contentColor = MaterialTheme.colorScheme.onPrimary,
containerColor = MaterialTheme.colorScheme.surface
)
)
}

ActionButton(
text = stringResource(id = R.string.redeem_voucher),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ private fun LoginContent(
)
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }) {
TextField(
modifier = Modifier.menuAnchor().fillMaxWidth(),
modifier =
Modifier.then(
// Using menuAnchor while not showing a dropdown will cause keyboard to
// open and app to crash on navigation
if (state.lastUsedAccount != null) Modifier.menuAnchor() else Modifier
)
.fillMaxWidth(),
value = state.accountNumberInput,
label = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fun accountTokenVisualTransformation() = VisualTransformation {

override fun transformedToOriginal(offset: Int): Int =
offset - (offset - 1) / (ACCOUNT_TOKEN_CHUNK_SIZE + 1)

}
)
}

0 comments on commit c9acd7b

Please sign in to comment.