mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Move home page specific settings
This commit is contained in:
parent
682b81d936
commit
c844395acd
7 changed files with 70 additions and 19 deletions
|
|
@ -85,11 +85,7 @@ sealed interface HomeRowConfig {
|
|||
@SerialName("Genres")
|
||||
data class Genres(
|
||||
val parentId: UUID,
|
||||
override val viewOptions: HomeRowViewOptions =
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
aspectRatio = AspectRatio.WIDE,
|
||||
),
|
||||
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions.genreDefault,
|
||||
) : HomeRowConfig {
|
||||
override fun updateViewOptions(viewOptions: HomeRowViewOptions): Genres = this.copy(viewOptions = viewOptions)
|
||||
}
|
||||
|
|
@ -214,4 +210,12 @@ data class HomeRowViewOptions(
|
|||
val episodeContentScale: PrefContentScale = PrefContentScale.FIT,
|
||||
val episodeAspectRatio: AspectRatio = AspectRatio.TALL,
|
||||
val episodeImageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
val genreDefault =
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
aspectRatio = AspectRatio.WIDE,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -959,9 +959,6 @@ val basicPreferences =
|
|||
preferences =
|
||||
listOf(
|
||||
AppPreference.SignInAuto,
|
||||
AppPreference.HomePageItems,
|
||||
AppPreference.CombineContinueNext,
|
||||
AppPreference.RewatchNextUp,
|
||||
AppPreference.PlayThemeMusic,
|
||||
AppPreference.RememberSelectedTab,
|
||||
AppPreference.SubtitleStyle,
|
||||
|
|
@ -1058,6 +1055,7 @@ val advancedPreferences =
|
|||
preferences =
|
||||
listOf(
|
||||
AppPreference.ShowClock,
|
||||
AppPreference.CombineContinueNext,
|
||||
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418
|
||||
// AppPreference.NavDrawerSwitchOnFocus,
|
||||
AppPreference.ControllerTimeout,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ class TvProviderWorker
|
|||
getPotentialItems(
|
||||
userId,
|
||||
prefs.homePagePreferences.enableRewatchingNextUp,
|
||||
prefs.homePagePreferences.combineContinueNext,
|
||||
)
|
||||
val potentialItemsToAddIds = potentialItemsToAdd.map { it.id.toString() }
|
||||
|
||||
|
|
@ -144,7 +143,6 @@ class TvProviderWorker
|
|||
private suspend fun getPotentialItems(
|
||||
userId: UUID,
|
||||
enableRewatching: Boolean,
|
||||
combineContinueNext: Boolean,
|
||||
): List<BaseItem> {
|
||||
val resumeItems = latestNextUpService.getResume(userId, 10, true)
|
||||
val seriesIds = resumeItems.mapNotNull { it.data.seriesId }
|
||||
|
|
@ -152,11 +150,7 @@ class TvProviderWorker
|
|||
latestNextUpService
|
||||
.getNextUp(userId, 10, enableRewatching, false)
|
||||
.filter { it.data.seriesId != null && it.data.seriesId !in seriesIds }
|
||||
return if (combineContinueNext) {
|
||||
latestNextUpService.buildCombined(resumeItems, nextUpItems)
|
||||
} else {
|
||||
resumeItems + nextUpItems
|
||||
}
|
||||
return latestNextUpService.buildCombined(resumeItems, nextUpItems)
|
||||
}
|
||||
|
||||
private suspend fun getCurrentTvChannelNextUp(): List<WatchNextProgram> =
|
||||
|
|
|
|||
|
|
@ -23,11 +23,16 @@ 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.preferences.AppPreference
|
||||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.ui.FontAwesome
|
||||
import com.github.damontecres.wholphin.ui.preferences.ComposablePreference
|
||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||
|
||||
@Composable
|
||||
fun HomeSettingsGlobal(
|
||||
preferences: AppPreferences,
|
||||
onPreferenceChange: (AppPreferences) -> Unit,
|
||||
onClickResize: (Int) -> Unit,
|
||||
onClickSave: () -> Unit,
|
||||
onClickLoad: () -> Unit,
|
||||
|
|
@ -52,6 +57,31 @@ fun HomeSettingsGlobal(
|
|||
.fillMaxHeight()
|
||||
.focusRestorer(firstFocus),
|
||||
) {
|
||||
item {
|
||||
ComposablePreference(
|
||||
preference = AppPreference.HomePageItems,
|
||||
value = AppPreference.HomePageItems.getter.invoke(preferences),
|
||||
onValueChange = {
|
||||
val newPrefs = AppPreference.HomePageItems.setter.invoke(preferences, it)
|
||||
onPreferenceChange.invoke(newPrefs)
|
||||
},
|
||||
onNavigate = {},
|
||||
modifier = Modifier.focusRequester(firstFocus),
|
||||
)
|
||||
}
|
||||
item {
|
||||
ComposablePreference(
|
||||
preference = AppPreference.RewatchNextUp,
|
||||
value = AppPreference.RewatchNextUp.getter.invoke(preferences),
|
||||
onValueChange = {
|
||||
val newPrefs = AppPreference.RewatchNextUp.setter.invoke(preferences, it)
|
||||
onPreferenceChange.invoke(newPrefs)
|
||||
},
|
||||
onNavigate = {},
|
||||
modifier = Modifier,
|
||||
)
|
||||
}
|
||||
item { HorizontalDivider() }
|
||||
item {
|
||||
HomeSettingsListItem(
|
||||
selected = false,
|
||||
|
|
@ -63,7 +93,7 @@ fun HomeSettingsGlobal(
|
|||
)
|
||||
},
|
||||
onClick = { onClickResize.invoke(1) },
|
||||
modifier = Modifier.focusRequester(firstFocus),
|
||||
modifier = Modifier,
|
||||
)
|
||||
}
|
||||
item {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ import androidx.tv.material3.MaterialTheme
|
|||
import androidx.tv.material3.surfaceColorAtElevation
|
||||
import com.github.damontecres.wholphin.R
|
||||
import com.github.damontecres.wholphin.data.model.HomeRowConfig
|
||||
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
|
||||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.ui.components.ConfirmDialog
|
||||
import com.github.damontecres.wholphin.ui.launchIO
|
||||
import com.github.damontecres.wholphin.ui.main.HomePageContent
|
||||
import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.ChooseRowType
|
||||
import com.github.damontecres.wholphin.ui.main.settings.HomeSettingsDestination.RowSettings
|
||||
|
|
@ -163,10 +166,18 @@ fun HomeSettingsPage(
|
|||
else -> Options.OPTIONS
|
||||
}
|
||||
}
|
||||
val defaultViewOptions =
|
||||
remember(row.config) {
|
||||
when (row.config) {
|
||||
is HomeRowConfig.Genres -> HomeRowViewOptions.genreDefault
|
||||
else -> HomeRowViewOptions()
|
||||
}
|
||||
}
|
||||
HomeRowSettings(
|
||||
title = row.title,
|
||||
preferenceOptions = preferenceOptions,
|
||||
viewOptions = row.config.viewOptions,
|
||||
defaultViewOptions = defaultViewOptions,
|
||||
onViewOptionsChange = {
|
||||
viewModel.updateViewOptions(dest.rowId, it)
|
||||
},
|
||||
|
|
@ -190,7 +201,18 @@ fun HomeSettingsPage(
|
|||
}
|
||||
|
||||
HomeSettingsDestination.GlobalSettings -> {
|
||||
val preferences by
|
||||
viewModel.preferencesDataStore.data.collectAsState(
|
||||
AppPreferences.getDefaultInstance(),
|
||||
)
|
||||
|
||||
HomeSettingsGlobal(
|
||||
preferences = preferences,
|
||||
onPreferenceChange = { newPrefs ->
|
||||
scope.launchIO {
|
||||
viewModel.preferencesDataStore.updateData { newPrefs }
|
||||
}
|
||||
},
|
||||
onClickResize = { viewModel.resizeCards(it) },
|
||||
onClickSave = {
|
||||
showConfirmDialog =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.github.damontecres.wholphin.ui.main.settings
|
|||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.github.damontecres.wholphin.R
|
||||
|
|
@ -19,6 +20,7 @@ import com.github.damontecres.wholphin.data.model.HomeRowConfig.RecentlyAdded
|
|||
import com.github.damontecres.wholphin.data.model.HomeRowConfig.RecentlyReleased
|
||||
import com.github.damontecres.wholphin.data.model.HomeRowConfig.Suggestions
|
||||
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
|
||||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.services.BackdropService
|
||||
import com.github.damontecres.wholphin.services.HomePageResolvedSettings
|
||||
import com.github.damontecres.wholphin.services.HomeRowConfigDisplay
|
||||
|
|
@ -64,6 +66,7 @@ class HomeSettingsViewModel
|
|||
private val navDrawerItemRepository: NavDrawerItemRepository,
|
||||
private val backdropService: BackdropService,
|
||||
private val seerrServerRepository: SeerrServerRepository,
|
||||
val preferencesDataStore: DataStore<AppPreferences>,
|
||||
@param:IoCoroutineScope private val ioScope: CoroutineScope,
|
||||
) : ViewModel() {
|
||||
private val _state = MutableStateFlow(HomePageSettingsState.EMPTY)
|
||||
|
|
|
|||
|
|
@ -501,8 +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 name="increase_all_cards_size">Increase size for all cards</string>
|
||||
<string name="decrease_all_cards_size">Decrease size for all cards</string>
|
||||
<string name="use_thumb_images">Use thumb images</string>
|
||||
|
||||
<string-array name="theme_song_volume">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue