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
|
||||
* [UserPreferencesRepository.updateShownUnitGroups]
|
||||
* See [UnitGroupsRepository.moveShownUnitGroups]
|
||||
*/
|
||||
fun onMove(from: ItemPosition, to: ItemPosition) {
|
||||
viewModelScope.launch {
|
||||
unitGroupsRepository.moveShownUnitGroups(from, to)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See [UserPreferencesRepository.updateShownUnitGroups]
|
||||
*/
|
||||
fun onDragEnd() {
|
||||
viewModelScope.launch {
|
||||
userPrefsRepository.updateShownUnitGroups(unitGroupsRepository.shownUnitGroups.value)
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ fun UnitGroupsScreen(
|
||||
|
||||
val state = rememberReorderableLazyListState(
|
||||
onMove = viewModel::onMove,
|
||||
canDragOver = viewModel::canDragOver
|
||||
canDragOver = viewModel::canDragOver,
|
||||
onDragEnd = { _, _ -> viewModel.onDragEnd() }
|
||||
)
|
||||
|
||||
LazyColumn(
|
||||
|
Loading…
x
Reference in New Issue
Block a user