mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Add apply all button
This commit is contained in:
parent
1ce380f3b5
commit
71ddb59ac3
4 changed files with 29 additions and 1 deletions
|
|
@ -81,7 +81,7 @@ data class HomeRowViewOptions(
|
||||||
AppSliderPreference<HomeRowViewOptions>(
|
AppSliderPreference<HomeRowViewOptions>(
|
||||||
title = R.string.height,
|
title = R.string.height,
|
||||||
defaultValue = Cards.HEIGHT_2X3_DP.toLong(),
|
defaultValue = Cards.HEIGHT_2X3_DP.toLong(),
|
||||||
min = Cards.HEIGHT_2X3_DP / 2L,
|
min = 64L,
|
||||||
max = Cards.HEIGHT_2X3_DP + 64L,
|
max = Cards.HEIGHT_2X3_DP + 64L,
|
||||||
interval = 4,
|
interval = 4,
|
||||||
getter = { it.heightDp.toLong() },
|
getter = { it.heightDp.toLong() },
|
||||||
|
|
@ -154,6 +154,11 @@ data class HomeRowViewOptions(
|
||||||
valueToIndex = { it.ordinal },
|
valueToIndex = { it.ordinal },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val ViewOptionsApplyAll =
|
||||||
|
AppClickablePreference<ViewOptions>(
|
||||||
|
title = R.string.apply_all_rows,
|
||||||
|
)
|
||||||
|
|
||||||
val ViewOptionsReset =
|
val ViewOptionsReset =
|
||||||
AppClickablePreference<ViewOptions>(
|
AppClickablePreference<ViewOptions>(
|
||||||
title = R.string.reset,
|
title = R.string.reset,
|
||||||
|
|
@ -169,6 +174,7 @@ data class HomeRowViewOptions(
|
||||||
ViewOptionsColumns,
|
ViewOptionsColumns,
|
||||||
ViewOptionsSpacing,
|
ViewOptionsSpacing,
|
||||||
ViewOptionsContentScale,
|
ViewOptionsContentScale,
|
||||||
|
ViewOptionsApplyAll,
|
||||||
ViewOptionsReset,
|
ViewOptionsReset,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ fun HomePageRowSettings(
|
||||||
title: String,
|
title: String,
|
||||||
viewOptions: HomeRowViewOptions,
|
viewOptions: HomeRowViewOptions,
|
||||||
onViewOptionsChange: (HomeRowViewOptions) -> Unit,
|
onViewOptionsChange: (HomeRowViewOptions) -> Unit,
|
||||||
|
onApplyApplyAll: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
defaultViewOptions: HomeRowViewOptions = HomeRowViewOptions(),
|
defaultViewOptions: HomeRowViewOptions = HomeRowViewOptions(),
|
||||||
) {
|
) {
|
||||||
|
|
@ -46,6 +47,8 @@ fun HomePageRowSettings(
|
||||||
onClickPreference = { pref ->
|
onClickPreference = { pref ->
|
||||||
if (pref == HomeRowViewOptions.ViewOptionsReset) {
|
if (pref == HomeRowViewOptions.ViewOptionsReset) {
|
||||||
onViewOptionsChange.invoke(defaultViewOptions)
|
onViewOptionsChange.invoke(defaultViewOptions)
|
||||||
|
} else if (pref == HomeRowViewOptions.ViewOptionsApplyAll) {
|
||||||
|
onApplyApplyAll.invoke()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)),
|
modifier = Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)),
|
||||||
|
|
|
||||||
|
|
@ -394,6 +394,21 @@ class HomePageSettingsViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
rowData =
|
||||||
|
it.rowData.toMutableList().map { row ->
|
||||||
|
if (row is HomeRowLoadingState.Success) {
|
||||||
|
row.copy(viewOptions = viewOptions)
|
||||||
|
} else {
|
||||||
|
row
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class HomePageSettingsState(
|
data class HomePageSettingsState(
|
||||||
|
|
@ -498,6 +513,9 @@ fun HomePageSettings(
|
||||||
onViewOptionsChange = {
|
onViewOptionsChange = {
|
||||||
viewModel.updateViewOptions(dest.rowId, it)
|
viewModel.updateViewOptions(dest.rowId, it)
|
||||||
},
|
},
|
||||||
|
onApplyApplyAll = {
|
||||||
|
viewModel.updateViewOptionsForAll(row.config.viewOptions)
|
||||||
|
},
|
||||||
modifier = destModifier,
|
modifier = destModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -466,6 +466,7 @@
|
||||||
<string name="genres_in">Genres in %1$s</string>
|
<string name="genres_in">Genres in %1$s</string>
|
||||||
<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-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