Skip to content

Commit

Permalink
Table
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro committed Aug 29, 2024
1 parent c4fcde1 commit bc325a2
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import org.jetbrains.jewel.foundation.lazy.selectable.SelectionType
/**
* A [SelectionManager] that support single cell selection.
*/
public open class SingleCellSelectionManager : TableSelectionManager {
private var selectedRowKey: Any? by mutableStateOf(null)
private var selectedColumnKey: Any? by mutableStateOf(null)
public open class SingleCellSelectionManager(
initialColumnKey: Any?,
initialRowKey: Any?,
) : TableSelectionManager {
private var selectedRowKey: Any? by mutableStateOf(initialRowKey)
private var selectedColumnKey: Any? by mutableStateOf(initialColumnKey)

override val interactionSource: MutableInteractionSource = MutableInteractionSource()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import androidx.compose.runtime.setValue
import org.jetbrains.jewel.foundation.lazy.selectable.SelectionEvent
import org.jetbrains.jewel.foundation.lazy.selectable.SelectionType

public class SingleRowSelectionManager : TableSelectionManager {
private var selectedRowKey: Any? by mutableStateOf(null)
public class SingleRowSelectionManager(
initialRowKey: Any?,
) : TableSelectionManager {
private var selectedRowKey: Any? by mutableStateOf(initialRowKey)

override val interactionSource: MutableInteractionSource = MutableInteractionSource()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jetbrains.jewel.foundation.lazy.table.selectable

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import org.jetbrains.jewel.foundation.lazy.selectable.SelectionManager

public interface TableSelectionManager : SelectionManager {
Expand Down Expand Up @@ -29,3 +31,18 @@ public interface TableSelectionManager : SelectionManager {
return false
}
}

@Composable
public fun rememberSingleCellSelectionManager(
initialColumnKey: Any? = null,
initialRowKey: Any? = null,
): TableSelectionManager =
remember {
SingleCellSelectionManager(initialColumnKey, initialRowKey)
}

@Composable
public fun rememberSingleRowSelectionManager(initialRowKey: Any? = null): TableSelectionManager =
remember {
SingleRowSelectionManager(initialRowKey)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.ui.unit.Constraints
import org.jetbrains.jewel.foundation.lazy.table.LazyTableItemScope
import org.jetbrains.jewel.foundation.lazy.table.LazyTableLayoutScope

public interface ColumnAccessor<T> {
public interface ColumnView<T> {
public fun columns(): Int

public fun pinnedColumns(): Int
Expand All @@ -29,14 +29,6 @@ public interface ColumnAccessor<T> {
) {
}

@Composable
public fun container(
rowKey: Any?,
columnKey: Any?,
content: @Composable () -> Unit,
) {
}

@Composable
public fun supportColumnSorting(): Boolean = false

Expand Down
Loading

0 comments on commit bc325a2

Please sign in to comment.