adding fixedRotation to settings

This commit is contained in:
Sir-Photch
2023-02-02 21:33:12 +01:00
parent 17a8eda910
commit e492a4975d
5 changed files with 25 additions and 0 deletions
@@ -64,6 +64,15 @@ fun LayoutSettingsScreen() {
if (it != null) viewModel.setReverseSearchResults(it)
},
)
val fixedRotation by viewModel.fixedRotation.observeAsState()
SwitchPreference(
title = stringResource(R.string.preference_layout_fixed_rotation),
summary = stringResource(R.string.preference_layout_fixed_rotation_summary),
value = fixedRotation == true,
onValueChanged = {
viewModel.setFixedRotation(it)
},
)
}
}
}
@@ -1,5 +1,6 @@
package de.mm20.launcher2.ui.settings.layout
import android.content.pm.ActivityInfo
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
@@ -57,4 +58,15 @@ class LayoutSettingsScreenVM: ViewModel(), KoinComponent {
}
}
}
val fixedRotation = dataStore.data.map { it.layout.fixedRoation }.asLiveData()
fun setFixedRotation(fixedRotation: Boolean) {
viewModelScope.launch {
dataStore.updateData {
it.toBuilder()
.setLayout(it.layout.toBuilder().setFixedRotation(fixedRotation))
.build()
}
}
}
}