Fix wording issue + add authentication autofil.
This commit is contained in:
parent
d3d7f89e22
commit
e176b6827a
6 changed files with 57 additions and 6 deletions
|
|
@ -16,7 +16,16 @@ import androidx.compose.material.icons.sharp.Visibility
|
|||
import androidx.compose.material.icons.sharp.VisibilityOff
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.autofill.AutofillNode
|
||||
import androidx.compose.ui.autofill.AutofillType
|
||||
import androidx.compose.ui.composed
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.layout.boundsInWindow
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.platform.LocalAutofill
|
||||
import androidx.compose.ui.platform.LocalAutofillTree
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
|
|
@ -228,6 +237,7 @@ fun AuthenticationHandler(
|
|||
//////////////////////////////////////
|
||||
// region: Content Helper Composable
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
private fun LoginField(
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -237,7 +247,10 @@ private fun LoginField(
|
|||
keyboardActions: KeyboardActions = KeyboardActions(),
|
||||
) {
|
||||
TextField(
|
||||
modifier = modifier,
|
||||
modifier = modifier.autofill(
|
||||
autofillTypes = listOf(AutofillType.Username, AutofillType.EmailAddress),
|
||||
onFill = onValueChange,
|
||||
),
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
label = { Text(text = stringResource(id = R.string.authentication_login)) },
|
||||
|
|
@ -249,6 +262,7 @@ private fun LoginField(
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
private fun PasswordField(
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -259,7 +273,10 @@ private fun PasswordField(
|
|||
) {
|
||||
var passwordVisibility by remember { mutableStateOf(false) }
|
||||
TextField(
|
||||
modifier = modifier,
|
||||
modifier = modifier.autofill(
|
||||
autofillTypes = listOf(AutofillType.Password),
|
||||
onFill = onValueChange,
|
||||
),
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
label = { Text(text = stringResource(id = R.string.authentication_password)) },
|
||||
|
|
@ -366,6 +383,30 @@ fun googleStringResource(): AnnotatedString = buildAnnotatedString {
|
|||
|
||||
// endregion
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
fun Modifier.autofill(
|
||||
autofillTypes: List<AutofillType>,
|
||||
onFill: ((String) -> Unit),
|
||||
) = composed {
|
||||
val autofill = LocalAutofill.current
|
||||
val autofillNode = AutofillNode(onFill = onFill, autofillTypes = autofillTypes)
|
||||
LocalAutofillTree.current += autofillNode
|
||||
|
||||
this
|
||||
.onGloballyPositioned {
|
||||
autofillNode.boundingBox = it.boundsInWindow()
|
||||
}
|
||||
.onFocusChanged { focusState ->
|
||||
autofill?.run {
|
||||
if (focusState.isFocused) {
|
||||
requestAutofillForNode(autofillNode)
|
||||
} else {
|
||||
cancelAutofillForNode(autofillNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ fun CategorySearchPageContent(
|
|||
label = {
|
||||
Text(
|
||||
color = MaterialTheme.colors.onSurface,
|
||||
text = "Rechercher"
|
||||
text = stringResource(id = R.string.search_filter_title)
|
||||
)
|
||||
},
|
||||
value = search() ?: "",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import androidx.compose.ui.focus.FocusRequester
|
|||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.scaffold.SearchScaffoldState
|
||||
|
|
@ -79,9 +80,9 @@ fun Search(
|
|||
Text(
|
||||
color = MaterialTheme.colors.onSurface,
|
||||
text = if (state.content != ContentState.PROFILE) {
|
||||
"Rechercher sur BibLib"
|
||||
stringResource(id = R.string.search_title)
|
||||
} else {
|
||||
"Profile"
|
||||
stringResource(id = R.string.profile_title)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -42,9 +42,13 @@
|
|||
<string name="detail_series">Séries</string>
|
||||
<string name="detail_emails_title">Envoyer cet eBook à :</string>
|
||||
|
||||
<string name="search_title">Rechercher sur Biblib</string>
|
||||
<string name="search_filter_title">Rechercher</string>
|
||||
<string name="search_filter_author">Auteur</string>
|
||||
<string name="search_filter_serie">Série</string>
|
||||
<string name="search_filter_genre">Genre</string>
|
||||
<string name="search_filter_language">Langue</string>
|
||||
|
||||
<string name="profile_title">Profile</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -48,9 +48,13 @@
|
|||
<string name="detail_series">Series</string>
|
||||
<string name="detail_emails_title">Send this eBook to:</string>
|
||||
|
||||
<string name="search_title">Search on Biblib</string>
|
||||
<string name="search_filter_title">Search</string>
|
||||
<string name="search_filter_author">Author</string>
|
||||
<string name="search_filter_serie">Serie</string>
|
||||
<string name="search_filter_genre">Genre</string>
|
||||
<string name="search_filter_language">Language</string>
|
||||
|
||||
<string name="profile_title">Profil</string>
|
||||
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue