mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Move some settings to new page
This commit is contained in:
parent
f315531db7
commit
b73900b698
5 changed files with 186 additions and 79 deletions
|
|
@ -29,4 +29,7 @@ sealed interface HomeSettingsDestination : NavKey {
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data object ChooseDiscover : HomeSettingsDestination
|
data object ChooseDiscover : HomeSettingsDestination
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data object GlobalSettings : HomeSettingsDestination
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,146 @@
|
||||||
|
package com.github.damontecres.wholphin.ui.main.settings
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||||
|
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||||
|
import androidx.compose.material3.HorizontalDivider
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.focus.focusRestorer
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.tv.material3.Icon
|
||||||
|
import androidx.tv.material3.MaterialTheme
|
||||||
|
import androidx.tv.material3.Text
|
||||||
|
import com.github.damontecres.wholphin.R
|
||||||
|
import com.github.damontecres.wholphin.ui.FontAwesome
|
||||||
|
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeSettingsGlobal(
|
||||||
|
onClickResize: (Int) -> Unit,
|
||||||
|
onClickSave: () -> Unit,
|
||||||
|
onClickLoad: () -> Unit,
|
||||||
|
onClickLoadWeb: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
val firstFocus: FocusRequester = remember { FocusRequester() }
|
||||||
|
LaunchedEffect(Unit) { firstFocus.tryRequestFocus() }
|
||||||
|
Column(modifier = modifier) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.settings),
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
|
HorizontalDivider()
|
||||||
|
LazyColumn(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
modifier =
|
||||||
|
modifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.focusRestorer(firstFocus),
|
||||||
|
) {
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = "Increase card sizes",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.KeyboardArrowUp,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = { onClickResize.invoke(1) },
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = "Decrease card sizes",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.KeyboardArrowDown,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = { onClickResize.invoke(-1) },
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item { HorizontalDivider() }
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.save_to_server),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.fa_cloud_arrow_up),
|
||||||
|
fontFamily = FontAwesome,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = onClickSave,
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.load_from_server),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.fa_cloud_arrow_down),
|
||||||
|
fontFamily = FontAwesome,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = onClickLoad,
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
HomeSettingsListItem(
|
||||||
|
selected = false,
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.load_from_web_client),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.fa_download),
|
||||||
|
fontFamily = FontAwesome,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = onClickLoadWeb,
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -82,27 +82,18 @@ fun HomeSettingsPage(
|
||||||
),
|
),
|
||||||
modifier = Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)),
|
modifier = Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)),
|
||||||
entryProvider = { key ->
|
entryProvider = { key ->
|
||||||
key as HomeSettingsDestination
|
val dest = key as HomeSettingsDestination
|
||||||
NavEntry(key, contentKey = key.toString()) {
|
NavEntry(dest, contentKey = key.toString()) {
|
||||||
val destModifier =
|
val destModifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
when (val dest = key) {
|
when (dest) {
|
||||||
HomeSettingsDestination.RowList -> {
|
HomeSettingsDestination.RowList -> {
|
||||||
HomeSettingsRowList(
|
HomeSettingsRowList(
|
||||||
state = state,
|
state = state,
|
||||||
onClickAdd = { backStack.add(HomeSettingsDestination.AddRow) },
|
onClickAdd = { backStack.add(HomeSettingsDestination.AddRow) },
|
||||||
onClickSave = {
|
onClickSettings = { backStack.add(HomeSettingsDestination.GlobalSettings) },
|
||||||
showConfirmDialog = {
|
|
||||||
viewModel.saveToRemote()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClickLoad = {
|
|
||||||
showConfirmDialog = {
|
|
||||||
viewModel.loadFromRemote()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClickMove = viewModel::moveRow,
|
onClickMove = viewModel::moveRow,
|
||||||
onClickDelete = viewModel::deleteRow,
|
onClickDelete = viewModel::deleteRow,
|
||||||
onClick = { index, row ->
|
onClick = { index, row ->
|
||||||
|
|
@ -112,9 +103,6 @@ fun HomeSettingsPage(
|
||||||
listState.scrollToItem(index)
|
listState.scrollToItem(index)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClickResize = {
|
|
||||||
viewModel.resizeCards(it)
|
|
||||||
},
|
|
||||||
modifier = destModifier,
|
modifier = destModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -184,6 +172,25 @@ fun HomeSettingsPage(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HomeSettingsDestination.GlobalSettings -> {
|
||||||
|
HomeSettingsGlobal(
|
||||||
|
onClickResize = { viewModel.resizeCards(it) },
|
||||||
|
onClickSave = {
|
||||||
|
showConfirmDialog = {
|
||||||
|
viewModel.saveToRemote()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClickLoad = {
|
||||||
|
showConfirmDialog = {
|
||||||
|
viewModel.loadFromRemote()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClickLoadWeb = {
|
||||||
|
},
|
||||||
|
modifier = destModifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
import androidx.compose.material.icons.filled.Edit
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
|
@ -47,10 +47,8 @@ enum class MoveDirection {
|
||||||
fun HomeSettingsRowList(
|
fun HomeSettingsRowList(
|
||||||
state: HomePageSettingsState,
|
state: HomePageSettingsState,
|
||||||
onClick: (Int, HomeRowConfigDisplay) -> Unit,
|
onClick: (Int, HomeRowConfigDisplay) -> Unit,
|
||||||
onClickResize: (Int) -> Unit,
|
|
||||||
onClickSave: () -> Unit,
|
|
||||||
onClickLoad: () -> Unit,
|
|
||||||
onClickAdd: () -> Unit,
|
onClickAdd: () -> Unit,
|
||||||
|
onClickSettings: () -> Unit,
|
||||||
onClickMove: (MoveDirection, Int) -> Unit,
|
onClickMove: (MoveDirection, Int) -> Unit,
|
||||||
onClickDelete: (Int) -> Unit,
|
onClickDelete: (Int) -> Unit,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
|
|
@ -59,6 +57,12 @@ fun HomeSettingsRowList(
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
LaunchedEffect(Unit) { firstFocus.tryRequestFocus() }
|
LaunchedEffect(Unit) { firstFocus.tryRequestFocus() }
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.customize_home),
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
modifier =
|
modifier =
|
||||||
|
|
@ -84,75 +88,21 @@ fun HomeSettingsRowList(
|
||||||
modifier = Modifier.focusRequester(firstFocus),
|
modifier = Modifier.focusRequester(firstFocus),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item {
|
|
||||||
Row {
|
|
||||||
HomeSettingsListItem(
|
|
||||||
selected = false,
|
|
||||||
headlineContent = {
|
|
||||||
Text(
|
|
||||||
text = "Increase card sizes",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Edit,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = { onClickResize.invoke(1) },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
)
|
|
||||||
HomeSettingsListItem(
|
|
||||||
selected = false,
|
|
||||||
headlineContent = {
|
|
||||||
Text(
|
|
||||||
text = "Decrease card sizes",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Edit,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = { onClickResize.invoke(-1) },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.save_to_server),
|
text = stringResource(R.string.settings),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Text(
|
Icon(
|
||||||
text = stringResource(R.string.fa_cloud_arrow_up),
|
imageVector = Icons.Default.Settings,
|
||||||
fontFamily = FontAwesome,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = onClickSave,
|
onClick = onClickSettings,
|
||||||
modifier = Modifier,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
HomeSettingsListItem(
|
|
||||||
selected = false,
|
|
||||||
headlineContent = {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.load_from_server),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.fa_cloud_arrow_down),
|
|
||||||
fontFamily = FontAwesome,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = onClickLoad,
|
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,6 +471,7 @@
|
||||||
<string name="home_rows">Home rows</string>
|
<string name="home_rows">Home rows</string>
|
||||||
<string name="load_from_server">Load from server</string>
|
<string name="load_from_server">Load from server</string>
|
||||||
<string name="save_to_server">Save to server</string>
|
<string name="save_to_server">Save to server</string>
|
||||||
|
<string name="load_from_web_client">Load from web client</string>
|
||||||
|
|
||||||
<string-array name="theme_song_volume">
|
<string-array name="theme_song_volume">
|
||||||
<item>Disabled</item>
|
<item>Disabled</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue