mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45:27 +02:00
Saving unit groups order in onDragEnd
This commit is contained in:
parent
3f4b21af4d
commit
c965a68198
@ -134,12 +134,19 @@ class SettingsViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See [UnitGroupsRepository.moveShownUnitGroups] and
|
* See [UnitGroupsRepository.moveShownUnitGroups]
|
||||||
* [UserPreferencesRepository.updateShownUnitGroups]
|
|
||||||
*/
|
*/
|
||||||
fun onMove(from: ItemPosition, to: ItemPosition) {
|
fun onMove(from: ItemPosition, to: ItemPosition) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
unitGroupsRepository.moveShownUnitGroups(from, to)
|
unitGroupsRepository.moveShownUnitGroups(from, to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See [UserPreferencesRepository.updateShownUnitGroups]
|
||||||
|
*/
|
||||||
|
fun onDragEnd() {
|
||||||
|
viewModelScope.launch {
|
||||||
userPrefsRepository.updateShownUnitGroups(unitGroupsRepository.shownUnitGroups.value)
|
userPrefsRepository.updateShownUnitGroups(unitGroupsRepository.shownUnitGroups.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,8 @@ fun UnitGroupsScreen(
|
|||||||
|
|
||||||
val state = rememberReorderableLazyListState(
|
val state = rememberReorderableLazyListState(
|
||||||
onMove = viewModel::onMove,
|
onMove = viewModel::onMove,
|
||||||
canDragOver = viewModel::canDragOver
|
canDragOver = viewModel::canDragOver,
|
||||||
|
onDragEnd = { _, _ -> viewModel.onDragEnd() }
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user