Skip to content

Commit

Permalink
"Invalid password" when tabbing from Username to Password field. Closes
Browse files Browse the repository at this point in the history
#96

Upping versionCode to 38.
  • Loading branch information
Dima-Android committed Dec 28, 2023
1 parent 20d857b commit 712f2a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ internal fun LoginScreen(
keyboardActions = KeyboardActions(
onDone = { viewModel.onSignInClicked() }
),
onEnterOrTab = { viewModel.onSignInClicked() }
onEnterOrTab = {
viewModel.onSignInClicked()
}
)
CustomDivider(modifier = Modifier.padding(vertical = 16.dp))
Spacer(modifier = Modifier.height(12.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Measurable
Expand Down Expand Up @@ -185,6 +188,7 @@ fun CustomTextField(
horizontalAlignment = textStyle.textAlign.asHorizontalAlignment,
) {
val showHint = value.isEmpty()
var hasFocus by remember { mutableStateOf(false) }
BasicTextField(
value = textFieldValue,
visualTransformation = visualTransformation,
Expand All @@ -199,16 +203,21 @@ fun CustomTextField(
},
modifier = Modifier
.focusRequester(focusRequester)
.then(innerModifier.onKeyEvent {
if (onEnterOrTab != null
&& (it.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_ENTER
|| it.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_TAB)
.then(innerModifier)
.onFocusChanged {
hasFocus = it.hasFocus
}
.onKeyEvent {
if (
hasFocus && it.type == KeyEventType.KeyDown
&& onEnterOrTab != null
&& (it.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_ENTER || it.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_TAB)
) {
onEnterOrTab()
return@onKeyEvent true
}
false
})
}
.placeCenterOfFirstAndLastLine(
maxLines = if (singleLine) 1 else maxLines,
),
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 37 // Must be updated on every build
val versionCode = 38 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 712f2a9

Please sign in to comment.