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