Compare commits
3 commits
b7933fc5b0
...
8403bcf9c7
| Author | SHA1 | Date | |
|---|---|---|---|
| 8403bcf9c7 | |||
| 59158e10c7 | |||
| df40aa8455 |
1 changed files with 33 additions and 20 deletions
|
|
@ -11,6 +11,7 @@ import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.togetherWith
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
|
@ -64,11 +65,12 @@ fun HomeScreen(paddingValues: PaddingValues) {
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.imePadding()
|
.imePadding()
|
||||||
.padding(all = 56.dp),
|
.padding(start = 56.dp, end = 56.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.Center) {
|
verticalArrangement = Arrangement.Center) {
|
||||||
Greeting(serverURL, currentScreen);
|
Greeting(serverURL, currentScreen);
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
|
modifier = Modifier.padding(bottom = 24.dp),
|
||||||
targetState = currentScreen,
|
targetState = currentScreen,
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
fadeIn(
|
fadeIn(
|
||||||
|
|
@ -84,34 +86,44 @@ fun HomeScreen(paddingValues: PaddingValues) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row (
|
AnimatedVisibility(currentScreen == "passwordDialog" || currentScreen == "apiDialog") {
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
Row(
|
||||||
) {
|
modifier = Modifier.padding(bottom = 12.dp)
|
||||||
AnimatedVisibility(currentScreen == "passwordDialog") {
|
.fillMaxWidth(),
|
||||||
OutlinedButton (
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
onClick = {currentScreen = "serverDialog"},
|
) {
|
||||||
modifier = Modifier.padding(top = 24.dp)
|
OutlinedButton(
|
||||||
|
onClick = { currentScreen = "serverDialog" },
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
) {
|
) {
|
||||||
Row() {
|
Row() {
|
||||||
Text(text = "Change Server")
|
Text(text = "Change Server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Spacer(modifier = Modifier.width(12.dp))
|
||||||
Spacer(modifier = Modifier.width(12.dp))
|
OutlinedButton(
|
||||||
AnimatedVisibility(currentScreen == "passwordDialog") {
|
modifier = Modifier.weight(1f),
|
||||||
OutlinedButton (
|
onClick = {
|
||||||
onClick = {},
|
when (currentScreen) {
|
||||||
modifier = Modifier.padding(top = 24.dp)
|
"passwordDialog" -> {
|
||||||
|
currentScreen = "apiDialog"
|
||||||
|
}
|
||||||
|
|
||||||
|
"apidialog" -> {
|
||||||
|
currentScreen = "passwordDialog"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
Row() {
|
Row() {
|
||||||
when(currentScreen) {
|
when (currentScreen) {
|
||||||
"passwordDialog" -> Text(text = "Use API Key")
|
"passwordDialog" -> Text(text = "Use API Key")
|
||||||
"apiDialog" -> Text(text = "Use Password")
|
"apiDialog" -> Text(text = "Use Password")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
onClick = {when(currentScreen) {
|
onClick = {when(currentScreen) {
|
||||||
"serverDialog" -> currentScreen = "passwordDialog"
|
"serverDialog" -> currentScreen = "passwordDialog"
|
||||||
|
|
@ -119,9 +131,9 @@ fun HomeScreen(paddingValues: PaddingValues) {
|
||||||
"apiDialog" -> currentScreen = "loadingDialog"
|
"apiDialog" -> currentScreen = "loadingDialog"
|
||||||
"loadingDialog" -> currentScreen = "loadingDialog"
|
"loadingDialog" -> currentScreen = "loadingDialog"
|
||||||
}},
|
}},
|
||||||
modifier = Modifier.padding(top = 24.dp)
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(128.dp),
|
.height(96.dp),
|
||||||
enabled = when(currentScreen) {
|
enabled = when(currentScreen) {
|
||||||
"serverDialog" -> isValidUrl(serverURL)
|
"serverDialog" -> isValidUrl(serverURL)
|
||||||
"passwordDialog" -> username.isNotEmpty() && password.isNotEmpty()
|
"passwordDialog" -> username.isNotEmpty() && password.isNotEmpty()
|
||||||
|
|
@ -229,11 +241,11 @@ fun PasswordDialog(username: String, password: String, updateUsername: (newUsern
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ApiDialog(apiKey: String, updateApiKey: (newApiKey: String) -> Unit) {
|
fun ApiDialog(apiKey: String, updateApiKey: (newApiKey: String) -> Unit) {
|
||||||
var dialogApiKey by remember { mutableStateOf("") }
|
var dialogApiKey by remember { mutableStateOf(apiKey) }
|
||||||
Column {
|
Column {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
label = { Text(text = "Password") },
|
label = { Text(text = "API Key") },
|
||||||
textStyle = MaterialTheme.typography.bodySmall,
|
textStyle = MaterialTheme.typography.bodySmall,
|
||||||
value = dialogApiKey,
|
value = dialogApiKey,
|
||||||
onValueChange = { text ->
|
onValueChange = { text ->
|
||||||
|
|
@ -245,6 +257,7 @@ fun ApiDialog(apiKey: String, updateApiKey: (newApiKey: String) -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun LoadingDialog () {
|
fun LoadingDialog () {
|
||||||
CircularWavyProgressIndicator()
|
CircularWavyProgressIndicator()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue