From 8ab2f03a1b5cc78958bf7a15fd539e0f6025b46b Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sun, 21 Nov 2021 14:34:49 +0800 Subject: [PATCH] add edit server page, fix drawer not open --- .../ui/screen/editserver/EditServer.kt | 106 ++++++++++++++++++ .../pcmdroid/ui/screen/main/MainPlayer.kt | 1 + 2 files changed, 107 insertions(+) create mode 100644 app/src/main/java/net/blumia/pcmdroid/ui/screen/editserver/EditServer.kt diff --git a/app/src/main/java/net/blumia/pcmdroid/ui/screen/editserver/EditServer.kt b/app/src/main/java/net/blumia/pcmdroid/ui/screen/editserver/EditServer.kt new file mode 100644 index 0000000..a856d92 --- /dev/null +++ b/app/src/main/java/net/blumia/pcmdroid/ui/screen/editserver/EditServer.kt @@ -0,0 +1,106 @@ +package net.blumia.pcmdroid.ui.screen.editserver + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.AddCircle +import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.Edit +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp + +@Preview(showBackground = true) +@Composable +fun EditServerScreen( + onCloseActionTriggered: () -> Unit = {}, +) +{ + Scaffold( + topBar = { + TopAppBar( + backgroundColor = Color.Transparent, + elevation = 0.dp, + title = {}, + navigationIcon = { + IconButton(onClick = onCloseActionTriggered) { + Icon(imageVector = Icons.Filled.Close, contentDescription = "Close") + } + }, + ) + } + ) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(20.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Icon( + modifier = Modifier.size(50.dp), + imageVector = Icons.Filled.Edit, + contentDescription = null, + ) + Text( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + text = "Edit Server", + textAlign = TextAlign.Center, + style = MaterialTheme.typography.h5, + ) + Text( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 10.dp), + text = "Edit existed Private Cloud Music server", + textAlign = TextAlign.Center, + style = MaterialTheme.typography.subtitle2, + ) + + var nameStr by rememberSaveable { mutableStateOf("") } + var urlStr by rememberSaveable { mutableStateOf("") } + var baseFolderNameStr by rememberSaveable { mutableStateOf("") } + + OutlinedTextField( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + value = nameStr, + onValueChange = { value -> nameStr = value}, + label = { Text("Server Name") }, + ) + + OutlinedTextField( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Uri, + ), + value = urlStr, + onValueChange = { value -> urlStr = value}, + label = { Text("Server API Url") }, + ) + + OutlinedTextField( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + value = baseFolderNameStr, + onValueChange = { value -> baseFolderNameStr = value}, + label = { Text("Base folder name") }, + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/net/blumia/pcmdroid/ui/screen/main/MainPlayer.kt b/app/src/main/java/net/blumia/pcmdroid/ui/screen/main/MainPlayer.kt index 8fbc487..25d46c3 100644 --- a/app/src/main/java/net/blumia/pcmdroid/ui/screen/main/MainPlayer.kt +++ b/app/src/main/java/net/blumia/pcmdroid/ui/screen/main/MainPlayer.kt @@ -104,6 +104,7 @@ fun MainPlayer( val scaffoldScope = rememberCoroutineScope() Scaffold( + scaffoldState = scaffoldState, topBar = { TopAppBar( title = { Text(stringResource(id = R.string.app_name)) },