Private
Public Access
1
0

SettingsScreen: username/password

This commit is contained in:
2024-02-26 00:29:53 -08:00
parent ed4e3cd0bb
commit 94bb9baa72

View File

@@ -39,6 +39,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
@@ -81,9 +82,11 @@ fun SettingsFormView(
) {
val serverName = viewModel.serverPreference.collectAsState()
val userName = viewModel.usernamePreference.collectAsState()
val password = viewModel.passwordPreference.collectAsState()
Column(modifier) {
var serverNameInput by remember { mutableStateOf(TextFieldValue(serverName.value)) }
SettingsTextField(
name = "Server",
icon = R.drawable.storage,
@@ -95,20 +98,36 @@ fun SettingsFormView(
})
}
var usernameInput by remember { mutableStateOf(TextFieldValue()) }
var passwordInput by remember { mutableStateOf(TextFieldValue()) }
SettingsTextField(
name = "Authentication",
icon = R.drawable.account_circle,
state = userName,
onSave = { /* TODO */ }
onSave = {
viewModel.saveAuthenticationPreferences(usernameInput.text, passwordInput.text)
}
) {
// TODO
Text("Hoohah!")
Column() {
TextField(
value = usernameInput,
onValueChange = { usernameInput = it },
label = { Text("Username") },
)
TextField(
value = passwordInput,
onValueChange = { passwordInput = it },
label = {Text("Password") },
visualTransformation = PasswordVisualTransformation(),
)
}
}
}
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
@OptIn(ExperimentalMaterialApi::class)
fun <T> SettingsTextField(
name: String,
@DrawableRes icon: Int,