mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Add settings to go to home settings
This commit is contained in:
parent
025c253a42
commit
2d0e5b84d4
3 changed files with 22 additions and 7 deletions
|
|
@ -617,6 +617,12 @@ sealed interface AppPreference<Pref, T> {
|
|||
setter = { prefs, _ -> prefs },
|
||||
)
|
||||
|
||||
val CustomizeHome =
|
||||
AppDestinationPreference<AppPreferences>(
|
||||
title = R.string.customize_home,
|
||||
destination = Destination.HomeSettings,
|
||||
)
|
||||
|
||||
val SendCrashReports =
|
||||
AppSwitchPreference<AppPreferences>(
|
||||
title = R.string.send_crash_reports,
|
||||
|
|
@ -946,6 +952,7 @@ val basicPreferences =
|
|||
preferences =
|
||||
listOf(
|
||||
AppPreference.RequireProfilePin,
|
||||
AppPreference.CustomizeHome,
|
||||
AppPreference.UserPinnedNavDrawerItems,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class HomeSettingsViewModel
|
|||
}
|
||||
}
|
||||
rows?.let { rows ->
|
||||
_state.update {
|
||||
updateState {
|
||||
it.copy(loading = LoadingState.Success, rowData = rows)
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ class HomeSettingsViewModel
|
|||
direction: MoveDirection,
|
||||
index: Int,
|
||||
) {
|
||||
_state.update {
|
||||
updateState {
|
||||
val rows = it.rows.move(direction, index)
|
||||
// TODO would be more efficient to move rowData, but uncombined continue watching is two rows
|
||||
// val rowData = it.rowData.move(direction, index)
|
||||
|
|
@ -141,7 +141,7 @@ class HomeSettingsViewModel
|
|||
}
|
||||
|
||||
fun deleteRow(index: Int) {
|
||||
_state.update {
|
||||
updateState {
|
||||
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
||||
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
||||
it.copy(
|
||||
|
|
@ -186,7 +186,7 @@ class HomeSettingsViewModel
|
|||
)
|
||||
}
|
||||
}
|
||||
_state.update {
|
||||
updateState {
|
||||
it.copy(
|
||||
loading = LoadingState.Loading,
|
||||
rows = it.rows.toMutableList().apply { add(newRow) },
|
||||
|
|
@ -246,7 +246,7 @@ class HomeSettingsViewModel
|
|||
)
|
||||
}
|
||||
}
|
||||
_state.update {
|
||||
updateState {
|
||||
it.copy(
|
||||
loading = LoadingState.Loading,
|
||||
rows = it.rows.toMutableList().apply { add(newRow) },
|
||||
|
|
@ -261,7 +261,7 @@ class HomeSettingsViewModel
|
|||
viewOptions: HomeRowViewOptions,
|
||||
) {
|
||||
viewModelScope.launchIO {
|
||||
_state.update {
|
||||
updateState {
|
||||
val index = it.rows.indexOfFirst { it.config.id == rowId }
|
||||
val newRowConfig =
|
||||
it.rows[index]
|
||||
|
|
@ -290,7 +290,7 @@ class HomeSettingsViewModel
|
|||
}
|
||||
|
||||
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
||||
_state.update {
|
||||
updateState {
|
||||
it.copy(
|
||||
rowData =
|
||||
it.rowData.toMutableList().map { row ->
|
||||
|
|
@ -319,6 +319,13 @@ class HomeSettingsViewModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateState(update: (HomePageSettingsState) -> HomePageSettingsState) {
|
||||
_state.update {
|
||||
update.invoke(it)
|
||||
}
|
||||
homeSettingsService.currentSettings.update { HomePageResolvedSettings(state.value.rows) }
|
||||
}
|
||||
}
|
||||
|
||||
data class HomePageSettingsState(
|
||||
|
|
|
|||
|
|
@ -467,6 +467,7 @@
|
|||
<string name="recently_released_in">Recently released in %1$s</string>
|
||||
<string name="height">Height</string>
|
||||
<string name="apply_all_rows">Apply to all rows</string>
|
||||
<string name="customize_home">Customize home page</string>
|
||||
|
||||
<string-array name="theme_song_volume">
|
||||
<item>Disabled</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue