Skip to content

Commit

Permalink
#1223 show reset sort button when changing the order as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Feb 2, 2025
1 parent 5eb072b commit 7833710
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private fun SortBottomSheetContent(
TextButton(
modifier = Modifier.align(Alignment.CenterEnd),
onClick = onReset,
enabled = sortFieldOrderList.any { it.order != SortOrder.NONE },
enabled = sortFieldOrderList != SortKeyMapsUseCaseImpl.defaultOrder,
) {
Text(stringResource(R.string.reset))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,22 @@ class SortKeyMapsUseCaseImpl(
SortField.ACTIONS -> KeyMapActionsComparator(reverseOrder)

SortField.CONSTRAINTS -> KeyMapConstraintsComparator(
constraintUiHelper,
displaySimpleMappingUseCase,
reverseOrder,
)

SortField.OPTIONS -> KeyMapOptionsComparator(reverseOrder)
}
}

companion object {
val defaultOrder = listOf(
SortFieldOrder(SortField.TRIGGER),
SortFieldOrder(SortField.ACTIONS),
SortFieldOrder(SortField.CONSTRAINTS),
SortFieldOrder(SortField.OPTIONS),
)
}
}

interface SortKeyMapsUseCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ class SortViewModel(
}

fun resetSortPriority() {
sortFieldOrder.update {
it.map { sortFieldOrder ->
sortFieldOrder.copy(order = SortOrder.NONE)
}
}
sortFieldOrder.value = SortKeyMapsUseCaseImpl.defaultOrder
}

fun applySortPriority() {
Expand Down

0 comments on commit 7833710

Please sign in to comment.