Add apply all button

This commit is contained in:
Damontecres 2026-01-23 17:05:39 -05:00
parent 1ce380f3b5
commit 71ddb59ac3
No known key found for this signature in database
4 changed files with 29 additions and 1 deletions

View file

@ -81,7 +81,7 @@ data class HomeRowViewOptions(
AppSliderPreference<HomeRowViewOptions>(
title = R.string.height,
defaultValue = Cards.HEIGHT_2X3_DP.toLong(),
min = Cards.HEIGHT_2X3_DP / 2L,
min = 64L,
max = Cards.HEIGHT_2X3_DP + 64L,
interval = 4,
getter = { it.heightDp.toLong() },
@ -154,6 +154,11 @@ data class HomeRowViewOptions(
valueToIndex = { it.ordinal },
)
val ViewOptionsApplyAll =
AppClickablePreference<ViewOptions>(
title = R.string.apply_all_rows,
)
val ViewOptionsReset =
AppClickablePreference<ViewOptions>(
title = R.string.reset,
@ -169,6 +174,7 @@ data class HomeRowViewOptions(
ViewOptionsColumns,
ViewOptionsSpacing,
ViewOptionsContentScale,
ViewOptionsApplyAll,
ViewOptionsReset,
)
}

View file

@ -21,6 +21,7 @@ fun HomePageRowSettings(
title: String,
viewOptions: HomeRowViewOptions,
onViewOptionsChange: (HomeRowViewOptions) -> Unit,
onApplyApplyAll: () -> Unit,
modifier: Modifier = Modifier,
defaultViewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) {
@ -46,6 +47,8 @@ fun HomePageRowSettings(
onClickPreference = { pref ->
if (pref == HomeRowViewOptions.ViewOptionsReset) {
onViewOptionsChange.invoke(defaultViewOptions)
} else if (pref == HomeRowViewOptions.ViewOptionsApplyAll) {
onApplyApplyAll.invoke()
}
},
modifier = Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)),

View file

@ -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(
@ -498,6 +513,9 @@ fun HomePageSettings(
onViewOptionsChange = {
viewModel.updateViewOptions(dest.rowId, it)
},
onApplyApplyAll = {
viewModel.updateViewOptionsForAll(row.config.viewOptions)
},
modifier = destModifier,
)
}

View file

@ -466,6 +466,7 @@
<string name="genres_in">Genres in %1$s</string>
<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-array name="theme_song_volume">
<item>Disabled</item>