Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Nov 26, 2023
1 parent d55b970 commit 2b92054
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface SelectableColumnOnKeyEvent {
state: SelectableLazyListState,
) {
val initialIndex = state.lastActiveItemIndex ?: return
val newSelection = LinkedHashSet<Any>(max(initialIndex, state.selectedKeys.size)).apply {
val newSelection = HashSet<Any>(max(initialIndex, state.selectedKeys.size)).apply {
addAll(state.selectedKeys)
}
var lastActiveItemIndex = initialIndex
Expand Down Expand Up @@ -75,7 +75,7 @@ public interface SelectableColumnOnKeyEvent {
state: SelectableLazyListState,
) {
val initialIndex = state.lastActiveItemIndex ?: return
val newSelection = LinkedHashSet<Any>(max(keys.size - initialIndex, state.selectedKeys.size)).apply {
val newSelection = HashSet<Any>(max(keys.size - initialIndex, state.selectedKeys.size)).apply {
addAll(state.selectedKeys)
}
var lastActiveItemIndex = initialIndex
Expand All @@ -101,7 +101,7 @@ public interface SelectableColumnOnKeyEvent {
for (index in initialIndex - 1 downTo 0) {
val key = keys[index]
if (key is Selectable) {
state.selectedKeys = linkedSetOf(key.key)
state.selectedKeys = setOf(key.key)
state.lastActiveItemIndex = index
return
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public interface SelectableColumnOnKeyEvent {
for (index in initialIndex + 1..keys.lastIndex) {
val key = keys[index]
if (key is Selectable) {
state.selectedKeys = linkedSetOf(key.key)
state.selectedKeys = setOf(key.key)
state.lastActiveItemIndex = index
return
}
Expand Down Expand Up @@ -173,7 +173,7 @@ public interface SelectableColumnOnKeyEvent {
) {
val visibleSize = state.layoutInfo.visibleItemsInfo.size
val targetIndex = max((state.lastActiveItemIndex ?: 0) - visibleSize, 0)
state.selectedKeys = linkedSetOf(keys[targetIndex].key)
state.selectedKeys = setOf(keys[targetIndex].key)
state.lastActiveItemIndex = targetIndex
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public interface SelectableColumnOnKeyEvent {
* Select All.
*/
public fun onSelectAll(keys: List<SelectableLazyListKey>, state: SelectableLazyListState) {
state.selectedKeys = keys.filterIsInstance<Selectable>().map { it.key }.toCollection(LinkedHashSet())
state.selectedKeys = keys.filterIsInstance<Selectable>().map { it.key }.toCollection(HashSet())
}
}

Expand Down

0 comments on commit 2b92054

Please sign in to comment.