diff --git a/app/src/main/java/com/github/damontecres/wholphin/data/model/HomeRowConfig.kt b/app/src/main/java/com/github/damontecres/wholphin/data/model/HomeRowConfig.kt index e15df65e..6b0fee4f 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/data/model/HomeRowConfig.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/data/model/HomeRowConfig.kt @@ -81,7 +81,7 @@ data class HomeRowViewOptions( AppSliderPreference( 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( + title = R.string.apply_all_rows, + ) + val ViewOptionsReset = AppClickablePreference( title = R.string.reset, @@ -169,6 +174,7 @@ data class HomeRowViewOptions( ViewOptionsColumns, ViewOptionsSpacing, ViewOptionsContentScale, + ViewOptionsApplyAll, ViewOptionsReset, ) } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageRowSettings.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageRowSettings.kt index 7b605ebd..f8b2a1e6 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageRowSettings.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageRowSettings.kt @@ -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)), diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageSettings.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageSettings.kt index fba9c5db..9372d547 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageSettings.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/settings/HomePageSettings.kt @@ -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, ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e3663513..f0f23aaa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -466,6 +466,7 @@ Genres in %1$s Recently released in %1$s Height + Apply to all rows Disabled