mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-09-06 18:01:11 +00:00
Login: allow changing account name when suggestions are expanded (bitfireAT/davx5#573)
This commit is contained in:
parent
71b0912494
commit
597c572f24
|
@ -14,6 +14,8 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Email
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
|
@ -38,6 +40,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import at.bitfire.davdroid.R
|
||||
import at.bitfire.davdroid.ui.composable.Assistant
|
||||
|
@ -96,7 +99,8 @@ fun AccountDetailsPageContent(
|
|||
) {
|
||||
Column(Modifier.padding(8.dp)) {
|
||||
if (creatingAccount)
|
||||
LinearProgressIndicator(Modifier
|
||||
LinearProgressIndicator(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 8.dp))
|
||||
|
||||
|
@ -105,6 +109,7 @@ fun AccountDetailsPageContent(
|
|||
expanded = expanded,
|
||||
onExpandedChange = { expanded = it }
|
||||
) {
|
||||
val offerDropdown = suggestedAccountNames.isNotEmpty()
|
||||
OutlinedTextField(
|
||||
value = accountName,
|
||||
onValueChange = onUpdateAccountName,
|
||||
|
@ -119,29 +124,24 @@ fun AccountDetailsPageContent(
|
|||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Email
|
||||
),
|
||||
trailingIcon = {
|
||||
if (suggestedAccountNames.isNotEmpty())
|
||||
ExposedDropdownMenuDefaults.TrailingIcon(
|
||||
expanded = expanded
|
||||
)
|
||||
},
|
||||
trailingIcon = if (offerDropdown) {
|
||||
{ ExposedDropdownMenuDefaults.TrailingIcon(expanded) }
|
||||
} else null,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.menuAnchor()
|
||||
.fillMaxWidth()
|
||||
)
|
||||
|
||||
if (suggestedAccountNames.isNotEmpty())
|
||||
ExposedDropdownMenu(
|
||||
if (offerDropdown)
|
||||
DropdownMenu( // ExposedDropdownMenu takes focus away from the text field when expanded
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
onDismissRequest = { expanded = false },
|
||||
properties = PopupProperties(focusable = false) // prevent focus from being taken away
|
||||
) {
|
||||
for (name in suggestedAccountNames)
|
||||
Text(
|
||||
name,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp)
|
||||
.clickable {
|
||||
DropdownMenuItem(
|
||||
text = { Text(name) },
|
||||
onClick = {
|
||||
onUpdateAccountName(name)
|
||||
expanded = false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue