adding fixedRotation to settings
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user