mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Match style to regular preferences
This commit is contained in:
parent
b31c0044fc
commit
a8352e7c0d
8 changed files with 47 additions and 84 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
package com.github.damontecres.wholphin.ui.main.settings
|
package com.github.damontecres.wholphin.ui.main.settings
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
|
@ -12,9 +11,6 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.tv.material3.MaterialTheme
|
|
||||||
import androidx.tv.material3.surfaceColorAtElevation
|
|
||||||
import com.github.damontecres.wholphin.R
|
import com.github.damontecres.wholphin.R
|
||||||
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
|
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
|
||||||
import com.github.damontecres.wholphin.preferences.AppChoicePreference
|
import com.github.damontecres.wholphin.preferences.AppChoicePreference
|
||||||
|
|
@ -73,11 +69,10 @@ fun HomeRowSettings(
|
||||||
},
|
},
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.background(
|
.ifElse(
|
||||||
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
groupIndex == 0 && index == 0,
|
||||||
5.dp,
|
Modifier.focusRequester(firstFocus),
|
||||||
),
|
),
|
||||||
).ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,18 +238,24 @@ internal object Options {
|
||||||
ViewOptionsSpacing,
|
ViewOptionsSpacing,
|
||||||
ViewOptionsImageType,
|
ViewOptionsImageType,
|
||||||
ViewOptionsAspectRatio,
|
ViewOptionsAspectRatio,
|
||||||
ViewOptionsUseSeries,
|
|
||||||
ViewOptionsContentScale,
|
ViewOptionsContentScale,
|
||||||
ViewOptionsReset,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.for_episodes,
|
title = R.string.for_episodes,
|
||||||
preferences =
|
preferences =
|
||||||
listOf(
|
listOf(
|
||||||
|
ViewOptionsUseSeries,
|
||||||
ViewOptionsEpisodeImageType,
|
ViewOptionsEpisodeImageType,
|
||||||
ViewOptionsEpisodeContentScale,
|
|
||||||
ViewOptionsEpisodeAspectRatio,
|
ViewOptionsEpisodeAspectRatio,
|
||||||
|
ViewOptionsEpisodeContentScale,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PreferenceGroup(
|
||||||
|
title = R.string.more,
|
||||||
|
preferences =
|
||||||
|
listOf(
|
||||||
|
ViewOptionsReset,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.focus.focusRestorer
|
import androidx.compose.ui.focus.focusRestorer
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.Text
|
|
||||||
import com.github.damontecres.wholphin.R
|
import com.github.damontecres.wholphin.R
|
||||||
import com.github.damontecres.wholphin.ui.ifElse
|
import com.github.damontecres.wholphin.ui.ifElse
|
||||||
|
|
||||||
|
|
@ -49,9 +48,7 @@ fun HomeSettingsAddRow(
|
||||||
) { index, type ->
|
) { index, type ->
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(type.stringId),
|
||||||
Text(stringResource(type.stringId))
|
|
||||||
},
|
|
||||||
onClick = { onClickMeta.invoke(type) },
|
onClick = { onClickMeta.invoke(type) },
|
||||||
modifier = Modifier.ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
modifier = Modifier.ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
||||||
)
|
)
|
||||||
|
|
@ -63,9 +60,7 @@ fun HomeSettingsAddRow(
|
||||||
itemsIndexed(libraries) { index, library ->
|
itemsIndexed(libraries) { index, library ->
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = library.name,
|
||||||
Text(library.name)
|
|
||||||
},
|
|
||||||
onClick = { onClick.invoke(library) },
|
onClick = { onClick.invoke(library) },
|
||||||
modifier = Modifier, // .ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
modifier = Modifier, // .ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
||||||
)
|
)
|
||||||
|
|
@ -77,9 +72,7 @@ fun HomeSettingsAddRow(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(MetaRowType.FAVORITES.stringId),
|
||||||
Text(stringResource(MetaRowType.FAVORITES.stringId))
|
|
||||||
},
|
|
||||||
onClick = { onClickMeta.invoke(MetaRowType.FAVORITES) },
|
onClick = { onClickMeta.invoke(MetaRowType.FAVORITES) },
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
)
|
)
|
||||||
|
|
@ -88,9 +81,7 @@ fun HomeSettingsAddRow(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(MetaRowType.DISCOVER.stringId),
|
||||||
Text(stringResource(MetaRowType.DISCOVER.stringId))
|
|
||||||
},
|
|
||||||
onClick = { onClickMeta.invoke(MetaRowType.DISCOVER) },
|
onClick = { onClickMeta.invoke(MetaRowType.DISCOVER) },
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.focus.focusRestorer
|
import androidx.compose.ui.focus.focusRestorer
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.Text
|
|
||||||
import com.github.damontecres.wholphin.R
|
import com.github.damontecres.wholphin.R
|
||||||
import com.github.damontecres.wholphin.ui.ifElse
|
import com.github.damontecres.wholphin.ui.ifElse
|
||||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||||
|
|
@ -43,11 +42,7 @@ fun HomeSettingsFavoriteList(
|
||||||
itemsIndexed(favoriteOptionsList) { index, type ->
|
itemsIndexed(favoriteOptionsList) { index, type ->
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(favoriteOptions[type]!!),
|
||||||
Text(
|
|
||||||
text = stringResource(favoriteOptions[type]!!),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = { onClick.invoke(type) },
|
onClick = { onClick.invoke(type) },
|
||||||
modifier = Modifier.ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
modifier = Modifier.ifElse(index == 0, Modifier.focusRequester(firstFocus)),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,7 @@ fun HomeSettingsGlobal(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.increase_all_cards_size),
|
||||||
Text(
|
|
||||||
text = "Increase all card size",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.KeyboardArrowUp,
|
imageVector = Icons.Default.KeyboardArrowUp,
|
||||||
|
|
@ -72,11 +68,7 @@ fun HomeSettingsGlobal(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.decrease_all_cards_size),
|
||||||
Text(
|
|
||||||
text = "Decrease all card size",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.KeyboardArrowDown,
|
imageVector = Icons.Default.KeyboardArrowDown,
|
||||||
|
|
@ -91,11 +83,7 @@ fun HomeSettingsGlobal(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.save_to_server),
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.save_to_server),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.fa_cloud_arrow_up),
|
text = stringResource(R.string.fa_cloud_arrow_up),
|
||||||
|
|
@ -109,11 +97,7 @@ fun HomeSettingsGlobal(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.load_from_server),
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.load_from_server),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.fa_cloud_arrow_down),
|
text = stringResource(R.string.fa_cloud_arrow_down),
|
||||||
|
|
@ -127,11 +111,7 @@ fun HomeSettingsGlobal(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.load_from_web_client),
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.load_from_web_client),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.fa_download),
|
text = stringResource(R.string.fa_download),
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,14 @@ import androidx.tv.material3.ListItemDefaults
|
||||||
import androidx.tv.material3.ListItemGlow
|
import androidx.tv.material3.ListItemGlow
|
||||||
import androidx.tv.material3.ListItemScale
|
import androidx.tv.material3.ListItemScale
|
||||||
import androidx.tv.material3.ListItemShape
|
import androidx.tv.material3.ListItemShape
|
||||||
|
import com.github.damontecres.wholphin.ui.preferences.PreferenceTitle
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@NonRestartableComposable
|
@NonRestartableComposable
|
||||||
fun HomeSettingsListItem(
|
fun HomeSettingsListItem(
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
headlineContent: @Composable () -> Unit,
|
headlineText: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
onLongClick: (() -> Unit)? = null,
|
onLongClick: (() -> Unit)? = null,
|
||||||
|
|
@ -38,7 +39,9 @@ fun HomeSettingsListItem(
|
||||||
) = ListItem(
|
) = ListItem(
|
||||||
selected = selected,
|
selected = selected,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
headlineContent = headlineContent,
|
headlineContent = {
|
||||||
|
PreferenceTitle(headlineText)
|
||||||
|
},
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
val settingsWidth = 300.dp
|
val settingsWidth = 360.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeSettingsPage(
|
fun HomeSettingsPage(
|
||||||
|
|
@ -90,7 +90,7 @@ fun HomeSettingsPage(
|
||||||
val destModifier =
|
val destModifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(4.dp)
|
.padding(8.dp)
|
||||||
when (dest) {
|
when (dest) {
|
||||||
HomeSettingsDestination.RowList -> {
|
HomeSettingsDestination.RowList -> {
|
||||||
HomeSettingsRowList(
|
HomeSettingsRowList(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.wrapContentWidth
|
import androidx.compose.foundation.layout.wrapContentWidth
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
|
@ -32,7 +33,6 @@ import androidx.compose.ui.focus.focusRestorer
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.Icon
|
import androidx.tv.material3.Icon
|
||||||
import androidx.tv.material3.MaterialTheme
|
import androidx.tv.material3.MaterialTheme
|
||||||
|
|
@ -59,7 +59,6 @@ fun HomeSettingsRowList(
|
||||||
onClickMove: (MoveDirection, Int) -> Unit,
|
onClickMove: (MoveDirection, Int) -> Unit,
|
||||||
onClickDelete: (Int) -> Unit,
|
onClickDelete: (Int) -> Unit,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
firstFocus: FocusRequester = remember { FocusRequester() },
|
|
||||||
) {
|
) {
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
@ -71,7 +70,9 @@ fun HomeSettingsRowList(
|
||||||
|
|
||||||
var position by rememberInt(0)
|
var position by rememberInt(0)
|
||||||
|
|
||||||
LaunchedEffect(Unit) { focusRequesters.getOrNull(position)?.tryRequestFocus() }
|
LaunchedEffect(Unit) {
|
||||||
|
focusRequesters.getOrNull(position)?.tryRequestFocus()
|
||||||
|
}
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
TitleText(stringResource(R.string.customize_home))
|
TitleText(stringResource(R.string.customize_home))
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
|
@ -80,16 +81,12 @@ fun HomeSettingsRowList(
|
||||||
modifier =
|
modifier =
|
||||||
modifier
|
modifier
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
.focusRestorer(firstFocus),
|
.focusRestorer(focusRequesters[0]),
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.add_row),
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.add_row),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Add,
|
imageVector = Icons.Default.Add,
|
||||||
|
|
@ -106,11 +103,7 @@ fun HomeSettingsRowList(
|
||||||
item {
|
item {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = stringResource(R.string.settings),
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.settings),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Settings,
|
imageVector = Icons.Default.Settings,
|
||||||
|
|
@ -193,13 +186,7 @@ fun HomeRowConfigContent(
|
||||||
) {
|
) {
|
||||||
HomeSettingsListItem(
|
HomeSettingsListItem(
|
||||||
selected = false,
|
selected = false,
|
||||||
headlineContent = {
|
headlineText = config.title,
|
||||||
Text(
|
|
||||||
text = config.title,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
modifier = Modifier,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
)
|
)
|
||||||
|
|
@ -248,8 +235,12 @@ fun TitleText(
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
textAlign = TextAlign.Center,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
modifier = modifier.fillMaxWidth(),
|
textAlign = TextAlign.Start,
|
||||||
|
modifier =
|
||||||
|
modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp, bottom = 4.dp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -501,6 +501,8 @@
|
||||||
<string name="overwrite_local_settings">Overwrite local settings?</string>
|
<string name="overwrite_local_settings">Overwrite local settings?</string>
|
||||||
<string name="for_episodes">For episodes</string>
|
<string name="for_episodes">For episodes</string>
|
||||||
<string name="suggestions_for">Suggestions for %1$s</string>
|
<string name="suggestions_for">Suggestions for %1$s</string>
|
||||||
|
<string name="increase_all_cards_size">Increase all cards size</string>
|
||||||
|
<string name="decrease_all_cards_size">Decrease all cards size</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