Move dock settings to home screen settings

This commit is contained in:
MM20 2024-02-20 22:09:35 +01:00
parent 01ea2a2862
commit 8193324b39
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
4 changed files with 24 additions and 26 deletions

View File

@ -285,7 +285,6 @@ fun ConfigureClockWidgetSheet(
val style by viewModel.clockStyle.collectAsState()
val fillHeight by viewModel.fillHeight.collectAsState()
val alignment by viewModel.alignment.collectAsState()
val dock by viewModel.dock.collectAsState()
val parts by viewModel.parts.collectAsState()
BottomSheetDialog(onDismissRequest = onDismiss) {
@ -469,23 +468,6 @@ fun ConfigureClockWidgetSheet(
}
}
}
OutlinedCard(
modifier = Modifier.padding(top = 16.dp),
) {
Column(
modifier = Modifier.fillMaxWidth()
) {
SwitchPreference(
title = stringResource(R.string.preference_clockwidget_favorites_part),
summary = stringResource(R.string.preference_clockwidget_favorites_part_summary),
icon = Icons.Rounded.Star,
value = dock == true,
onValueChanged = {
viewModel.setFavoritesPart(it)
}
)
}
}
Text(
modifier = Modifier.padding(top = 16.dp, bottom = 8.dp),
style = MaterialTheme.typography.titleSmall,

View File

@ -40,9 +40,6 @@ class ClockWidgetSettingsScreenVM : ViewModel(), KoinComponent {
settings.setFillHeight(fillHeight)
}
val dock = settings.dock
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
val parts = settings.parts
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
@ -50,10 +47,6 @@ class ClockWidgetSettingsScreenVM : ViewModel(), KoinComponent {
settings.setDatePart(datePart)
}
fun setFavoritesPart(favoritesPart: Boolean) {
settings.setDock(favoritesPart)
}
fun setBatteryPart(batteryPart: Boolean) {
settings.setBatteryPart(batteryPart)
}

View File

@ -53,6 +53,7 @@ fun HomescreenSettingsScreen() {
val context = LocalContext.current
val dock by viewModel.dock.collectAsStateWithLifecycle(null)
val fixedRotation by viewModel.fixedRotation.collectAsStateWithLifecycle(null)
val editButton by viewModel.widgetEditButton.collectAsStateWithLifecycle(null)
val searchBarStyle by viewModel.searchBarStyle.collectAsStateWithLifecycle(null)
@ -81,6 +82,18 @@ fun HomescreenSettingsScreen() {
)
}
}
item {
PreferenceCategory(stringResource(R.string.preference_clockwidget_favorites_part)) {
SwitchPreference(
title = stringResource(R.string.preference_clockwidget_favorites_part),
summary = stringResource(R.string.preference_clockwidget_favorites_part_summary),
value = dock == true,
onValueChanged = {
viewModel.setDock(it)
},
)
}
}
item {
PreferenceCategory(
title = stringResource(id = R.string.preference_category_widgets)

View File

@ -18,6 +18,7 @@ import de.mm20.launcher2.preferences.ScreenOrientation
import de.mm20.launcher2.preferences.SearchBarColors
import de.mm20.launcher2.preferences.SearchBarStyle
import de.mm20.launcher2.preferences.SystemBarColors
import de.mm20.launcher2.preferences.ui.ClockWidgetSettings
import de.mm20.launcher2.preferences.ui.UiSettings
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
@ -28,6 +29,7 @@ import org.koin.core.component.get
class HomescreenSettingsScreenVM(
private val uiSettings: UiSettings,
private val clockWidgetSettings: ClockWidgetSettings,
) : ViewModel() {
var showClockWidgetSheet by mutableStateOf(false)
@ -119,6 +121,13 @@ class HomescreenSettingsScreenVM(
uiSettings.setBottomSearchBar(bottomSearchBar)
}
val dock = clockWidgetSettings.dock
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
fun setDock(dock: Boolean) {
clockWidgetSettings.setDock(dock)
}
val fixedRotation = uiSettings.orientation.map { it != ScreenOrientation.Auto }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
@ -144,7 +153,8 @@ class HomescreenSettingsScreenVM(
val Factory = viewModelFactory {
initializer {
HomescreenSettingsScreenVM(
uiSettings = get()
uiSettings = get(),
clockWidgetSettings = get(),
)
}
}