that fixes the main player preview..

This commit is contained in:
Gary Wang 2021-11-24 23:36:36 +08:00
parent b614106dd9
commit a939e6b88a
5 changed files with 86 additions and 4 deletions

View File

@ -15,6 +15,10 @@ data class Server (
val name: String,
@ColumnInfo(name = "shortName")
val shortName: String,
@ColumnInfo(name = "mediaBaseUrl")
val mediaBaseUrl: String,
@ColumnInfo(name = "preferredFormats", defaultValue = "")
val preferredFormats: String,
@ColumnInfo(name = "baseFolderName")
val baseFolderName: String,
) {

View File

@ -1,8 +1,10 @@
package net.blumia.pcmdroid.ui.screen.addserver
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AddCircle
@ -71,9 +73,15 @@ fun StepOtherDetail(
onShortNameStrChange: (String) -> Unit = {},
baseFolderNameStr: String = "",
onBaseFolderNameStrChange: (String) -> Unit = {},
mediaBaseUrlStr: String = "",
mediaBaseUrlStrChange: (String) -> Unit = {},
preferredFormatsStr: String = "",
preferredFormatsStrChange: (String) -> Unit = {},
) {
Column(
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
) {
OutlinedTextField(
@ -102,6 +110,24 @@ fun StepOtherDetail(
onValueChange = onBaseFolderNameStrChange,
label = { Text("Base folder name") },
)
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp),
value = mediaBaseUrlStr,
onValueChange = mediaBaseUrlStrChange,
label = { Text("Media base url") },
)
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp),
value = preferredFormatsStr,
onValueChange = preferredFormatsStrChange,
label = { Text("Preferred formats") },
)
}
}
@ -150,6 +176,8 @@ fun AddServerScreen(
var nameStr by rememberSaveable { mutableStateOf("") }
var shortNameStr by rememberSaveable { mutableStateOf("") }
var baseFolderNameStr by rememberSaveable { mutableStateOf("") }
var mediaBaseUrlStr by rememberSaveable { mutableStateOf("") }
var preferredFormatsStr by rememberSaveable { mutableStateOf("") }
Column(
modifier = Modifier
@ -180,6 +208,14 @@ fun AddServerScreen(
onBaseFolderNameStrChange = { value ->
baseFolderNameStr = value
},
mediaBaseUrlStr,
mediaBaseUrlStrChange = { value ->
mediaBaseUrlStr = value
},
preferredFormatsStr,
preferredFormatsStrChange = { value ->
preferredFormatsStr = value
},
)
}
}
@ -207,6 +243,8 @@ fun AddServerScreen(
name = nameStr,
shortName = shortNameStr,
baseFolderName = baseFolderNameStr,
mediaBaseUrl = mediaBaseUrlStr,
preferredFormats = preferredFormatsStr,
)
onSubmitServerTriggered(srv)
}

View File

@ -1,7 +1,9 @@
package net.blumia.pcmdroid.ui.screen.editserver
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AddCircle
@ -45,6 +47,7 @@ fun EditServerScreen(
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
@ -74,6 +77,8 @@ fun EditServerScreen(
var nameStr by rememberSaveable { mutableStateOf(server.name) }
var urlStr by rememberSaveable { mutableStateOf(server.url) }
var baseFolderNameStr by rememberSaveable { mutableStateOf(server.baseFolderName) }
var mediaBaseUrlStr by rememberSaveable { mutableStateOf(server.mediaBaseUrl) }
var preferredFormatsStr by rememberSaveable { mutableStateOf(server.preferredFormats) }
OutlinedTextField(
modifier = Modifier
@ -114,6 +119,24 @@ fun EditServerScreen(
label = { Text("Base folder name") },
)
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp),
value = mediaBaseUrlStr,
onValueChange = { value -> mediaBaseUrlStr = value},
label = { Text("Media base url") },
)
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp),
value = preferredFormatsStr,
onValueChange = { value -> preferredFormatsStr = value},
label = { Text("Preferred formats") },
)
Button(
modifier = Modifier.fillMaxWidth(),
onClick = {
@ -124,6 +147,8 @@ fun EditServerScreen(
shortName = shortNameStr,
url = urlStr,
baseFolderName = baseFolderNameStr,
mediaBaseUrl = mediaBaseUrlStr,
preferredFormats = preferredFormatsStr,
)
)
},
@ -144,7 +169,9 @@ fun EditServerScreenPreview()
"http://localhost/api.cgi",
"Demo server",
"Demo",
"demo",
"http://localhost/",
"ogg,mp3",
"demo"
)
)
}

View File

@ -125,7 +125,6 @@ fun NowPlaying() {
}
}
@Preview(showBackground = true)
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun MainPlayer(
@ -228,5 +227,17 @@ fun MainPlayer(
}
}
}
}
@Preview(showBackground = true)
@Composable
fun MainPlayerPreview() {
MainPlayer(
currentServer = null,
servers = listOf(),
drawerFolders = listOf(),
currentFolder = null,
folders = listOf(),
songs = listOf(),
)
}

View File

@ -125,6 +125,8 @@ fun ServerSummaryDrawerPreview()
"http://localhost/",
"Demo server",
"Demo",
"http://localhost/",
"ogg,mp3",
"pcm"
)
)