mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +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 },
|
setter = { prefs, _ -> prefs },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val CustomizeHome =
|
||||||
|
AppDestinationPreference<AppPreferences>(
|
||||||
|
title = R.string.customize_home,
|
||||||
|
destination = Destination.HomeSettings,
|
||||||
|
)
|
||||||
|
|
||||||
val SendCrashReports =
|
val SendCrashReports =
|
||||||
AppSwitchPreference<AppPreferences>(
|
AppSwitchPreference<AppPreferences>(
|
||||||
title = R.string.send_crash_reports,
|
title = R.string.send_crash_reports,
|
||||||
|
|
@ -946,6 +952,7 @@ val basicPreferences =
|
||||||
preferences =
|
preferences =
|
||||||
listOf(
|
listOf(
|
||||||
AppPreference.RequireProfilePin,
|
AppPreference.RequireProfilePin,
|
||||||
|
AppPreference.CustomizeHome,
|
||||||
AppPreference.UserPinnedNavDrawerItems,
|
AppPreference.UserPinnedNavDrawerItems,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rows?.let { rows ->
|
rows?.let { rows ->
|
||||||
_state.update {
|
updateState {
|
||||||
it.copy(loading = LoadingState.Success, rowData = rows)
|
it.copy(loading = LoadingState.Success, rowData = rows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ class HomeSettingsViewModel
|
||||||
direction: MoveDirection,
|
direction: MoveDirection,
|
||||||
index: Int,
|
index: Int,
|
||||||
) {
|
) {
|
||||||
_state.update {
|
updateState {
|
||||||
val rows = it.rows.move(direction, index)
|
val rows = it.rows.move(direction, index)
|
||||||
// TODO would be more efficient to move rowData, but uncombined continue watching is two rows
|
// TODO would be more efficient to move rowData, but uncombined continue watching is two rows
|
||||||
// val rowData = it.rowData.move(direction, index)
|
// val rowData = it.rowData.move(direction, index)
|
||||||
|
|
@ -141,7 +141,7 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteRow(index: Int) {
|
fun deleteRow(index: Int) {
|
||||||
_state.update {
|
updateState {
|
||||||
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
||||||
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
||||||
it.copy(
|
it.copy(
|
||||||
|
|
@ -186,7 +186,7 @@ class HomeSettingsViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_state.update {
|
updateState {
|
||||||
it.copy(
|
it.copy(
|
||||||
loading = LoadingState.Loading,
|
loading = LoadingState.Loading,
|
||||||
rows = it.rows.toMutableList().apply { add(newRow) },
|
rows = it.rows.toMutableList().apply { add(newRow) },
|
||||||
|
|
@ -246,7 +246,7 @@ class HomeSettingsViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_state.update {
|
updateState {
|
||||||
it.copy(
|
it.copy(
|
||||||
loading = LoadingState.Loading,
|
loading = LoadingState.Loading,
|
||||||
rows = it.rows.toMutableList().apply { add(newRow) },
|
rows = it.rows.toMutableList().apply { add(newRow) },
|
||||||
|
|
@ -261,7 +261,7 @@ class HomeSettingsViewModel
|
||||||
viewOptions: HomeRowViewOptions,
|
viewOptions: HomeRowViewOptions,
|
||||||
) {
|
) {
|
||||||
viewModelScope.launchIO {
|
viewModelScope.launchIO {
|
||||||
_state.update {
|
updateState {
|
||||||
val index = it.rows.indexOfFirst { it.config.id == rowId }
|
val index = it.rows.indexOfFirst { it.config.id == rowId }
|
||||||
val newRowConfig =
|
val newRowConfig =
|
||||||
it.rows[index]
|
it.rows[index]
|
||||||
|
|
@ -290,7 +290,7 @@ class HomeSettingsViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
||||||
_state.update {
|
updateState {
|
||||||
it.copy(
|
it.copy(
|
||||||
rowData =
|
rowData =
|
||||||
it.rowData.toMutableList().map { row ->
|
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(
|
data class HomePageSettingsState(
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,7 @@
|
||||||
<string name="recently_released_in">Recently released in %1$s</string>
|
<string name="recently_released_in">Recently released in %1$s</string>
|
||||||
<string name="height">Height</string>
|
<string name="height">Height</string>
|
||||||
<string name="apply_all_rows">Apply to all rows</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">
|
<string-array name="theme_song_volume">
|
||||||
<item>Disabled</item>
|
<item>Disabled</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue