Fix wording issue + add authentication autofil.
This commit is contained in:
parent
d3d7f89e22
commit
e176b6827a
6 changed files with 57 additions and 6 deletions
|
|
@ -91,12 +91,13 @@ dependencies {
|
||||||
implementation 'com.google.android.material:material:1.6.1'
|
implementation 'com.google.android.material:material:1.6.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
||||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
|
||||||
implementation 'androidx.core:core-ktx:+'
|
|
||||||
debugImplementation "androidx.activity:activity-ktx:1.6.0-rc01"
|
debugImplementation "androidx.activity:activity-ktx:1.6.0-rc01"
|
||||||
implementation 'androidx.activity:activity-compose:1.5.1'
|
implementation 'androidx.activity:activity-compose:1.5.1'
|
||||||
|
|
||||||
// Android Compose
|
// Android Compose
|
||||||
implementation "androidx.compose.ui:ui:1.2.1"
|
implementation "androidx.compose.ui:ui:1.2.1"
|
||||||
|
implementation "androidx.compose.ui:ui-util:1.2.1"
|
||||||
|
implementation "androidx.compose.foundation:foundation:1.2.1"
|
||||||
implementation "androidx.compose.material:material:1.2.1"
|
implementation "androidx.compose.material:material:1.2.1"
|
||||||
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
|
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:1.2.1"
|
implementation "androidx.compose.runtime:runtime-livedata:1.2.1"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,16 @@ import androidx.compose.material.icons.sharp.Visibility
|
||||||
import androidx.compose.material.icons.sharp.VisibilityOff
|
import androidx.compose.material.icons.sharp.VisibilityOff
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||||
import androidx.compose.ui.Modifier
|
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.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
|
|
@ -228,6 +237,7 @@ fun AuthenticationHandler(
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// region: Content Helper Composable
|
// region: Content Helper Composable
|
||||||
|
|
||||||
|
@OptIn(ExperimentalComposeUiApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun LoginField(
|
private fun LoginField(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -237,7 +247,10 @@ private fun LoginField(
|
||||||
keyboardActions: KeyboardActions = KeyboardActions(),
|
keyboardActions: KeyboardActions = KeyboardActions(),
|
||||||
) {
|
) {
|
||||||
TextField(
|
TextField(
|
||||||
modifier = modifier,
|
modifier = modifier.autofill(
|
||||||
|
autofillTypes = listOf(AutofillType.Username, AutofillType.EmailAddress),
|
||||||
|
onFill = onValueChange,
|
||||||
|
),
|
||||||
value = value,
|
value = value,
|
||||||
onValueChange = onValueChange,
|
onValueChange = onValueChange,
|
||||||
label = { Text(text = stringResource(id = R.string.authentication_login)) },
|
label = { Text(text = stringResource(id = R.string.authentication_login)) },
|
||||||
|
|
@ -249,6 +262,7 @@ private fun LoginField(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalComposeUiApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun PasswordField(
|
private fun PasswordField(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -259,7 +273,10 @@ private fun PasswordField(
|
||||||
) {
|
) {
|
||||||
var passwordVisibility by remember { mutableStateOf(false) }
|
var passwordVisibility by remember { mutableStateOf(false) }
|
||||||
TextField(
|
TextField(
|
||||||
modifier = modifier,
|
modifier = modifier.autofill(
|
||||||
|
autofillTypes = listOf(AutofillType.Password),
|
||||||
|
onFill = onValueChange,
|
||||||
|
),
|
||||||
value = value,
|
value = value,
|
||||||
onValueChange = onValueChange,
|
onValueChange = onValueChange,
|
||||||
label = { Text(text = stringResource(id = R.string.authentication_password)) },
|
label = { Text(text = stringResource(id = R.string.authentication_password)) },
|
||||||
|
|
@ -366,6 +383,30 @@ fun googleStringResource(): AnnotatedString = buildAnnotatedString {
|
||||||
|
|
||||||
// endregion
|
// 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
|
@Composable
|
||||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
|
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ fun CategorySearchPageContent(
|
||||||
label = {
|
label = {
|
||||||
Text(
|
Text(
|
||||||
color = MaterialTheme.colors.onSurface,
|
color = MaterialTheme.colors.onSurface,
|
||||||
text = "Rechercher"
|
text = stringResource(id = R.string.search_filter_title)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
value = search() ?: "",
|
value = search() ?: "",
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import com.pixelized.biblib.R
|
import com.pixelized.biblib.R
|
||||||
import com.pixelized.biblib.ui.scaffold.SearchScaffoldState
|
import com.pixelized.biblib.ui.scaffold.SearchScaffoldState
|
||||||
|
|
@ -79,9 +80,9 @@ fun Search(
|
||||||
Text(
|
Text(
|
||||||
color = MaterialTheme.colors.onSurface,
|
color = MaterialTheme.colors.onSurface,
|
||||||
text = if (state.content != ContentState.PROFILE) {
|
text = if (state.content != ContentState.PROFILE) {
|
||||||
"Rechercher sur BibLib"
|
stringResource(id = R.string.search_title)
|
||||||
} else {
|
} else {
|
||||||
"Profile"
|
stringResource(id = R.string.profile_title)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,13 @@
|
||||||
<string name="detail_series">Séries</string>
|
<string name="detail_series">Séries</string>
|
||||||
<string name="detail_emails_title">Envoyer cet eBook à :</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_author">Auteur</string>
|
||||||
<string name="search_filter_serie">Série</string>
|
<string name="search_filter_serie">Série</string>
|
||||||
<string name="search_filter_genre">Genre</string>
|
<string name="search_filter_genre">Genre</string>
|
||||||
<string name="search_filter_language">Langue</string>
|
<string name="search_filter_language">Langue</string>
|
||||||
|
|
||||||
|
<string name="profile_title">Profile</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -48,9 +48,13 @@
|
||||||
<string name="detail_series">Series</string>
|
<string name="detail_series">Series</string>
|
||||||
<string name="detail_emails_title">Send this eBook to:</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_author">Author</string>
|
||||||
<string name="search_filter_serie">Serie</string>
|
<string name="search_filter_serie">Serie</string>
|
||||||
<string name="search_filter_genre">Genre</string>
|
<string name="search_filter_genre">Genre</string>
|
||||||
<string name="search_filter_language">Language</string>
|
<string name="search_filter_language">Language</string>
|
||||||
|
|
||||||
|
<string name="profile_title">Profil</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue