From c7a2821e430c14a59a44035e573239ae0cb501e0 Mon Sep 17 00:00:00 2001 From: Lamberto Basti Date: Tue, 31 Oct 2023 14:12:03 +0100 Subject: [PATCH] Rename 'uiKey' to 'itemKey' --- .../lazy/SelectableLazyListScope.kt | 38 +++++++++---------- .../foundation/lazy/tree/BasicLazyTree.kt | 2 +- .../standalone/components/ChipsAndTree.kt | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt index d6b941801..5282fbb51 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt @@ -11,11 +11,11 @@ interface SelectableLazyListScope { /** * Represents an item in a selectable lazy list. - * By default `[selectionKey] = [uiKey]`, but you can assign [uiKey] if you need to + * By default [selectionKey] = [itemKey], but you can assign [itemKey] if you need to * recompose the item while keeping the selection unchanged. * * @param selectionKey The unique identifier for the item used for selection. - * @param uiKey The unique identifier for the item used for triggering recompositions. + * @param itemKey The unique identifier for the item used for triggering recompositions. * @param contentType The type of content displayed in the item. * @param selectable Determines if the item is selectable. Default is * `true`. @@ -23,7 +23,7 @@ interface SelectableLazyListScope { */ fun item( selectionKey: Any, - uiKey: Any = selectionKey, + itemKey: Any = selectionKey, contentType: Any? = null, selectable: Boolean = true, content: @Composable SelectableLazyItemScope.() -> Unit, @@ -31,13 +31,13 @@ interface SelectableLazyListScope { /** * Represents a list of items based on the provided parameters. - * By default `[selectionKey] = [uiKey]`, but you can assign [uiKey] if you need to + * By default [selectionKey] = [itemKey], but you can assign [itemKey] if you need to * recompose the item while keeping the selection unchanged. * * @param count The number of items in the list. * @param selectionKey A function that generates a unique key for each item based on * its index. It is used for selection. - * @param uiKey A function that generates a unique key for each item based on + * @param itemKey A function that generates a unique key for each item based on * its index. It is used for triggering recompositions. * @param contentType A function that returns the content type of an item * based on its index. Defaults to `null`. @@ -49,7 +49,7 @@ interface SelectableLazyListScope { fun items( count: Int, selectionKey: (index: Int) -> Any, - uiKey: (index: Int) -> Any = selectionKey, + itemKey: (index: Int) -> Any = selectionKey, contentType: (index: Int) -> Any? = { null }, selectable: (index: Int) -> Boolean = { true }, itemContent: @Composable SelectableLazyItemScope.(index: Int) -> Unit, @@ -57,11 +57,11 @@ interface SelectableLazyListScope { /** * A method that enables sticky header behavior in a list or grid view. - * By default `[selectionKey] = [uiKey]`, but you can assign [uiKey] if you need to + * By default [selectionKey] = [itemKey], but you can assign [itemKey] if you need to * recompose the item while keeping the selection unchanged. * * @param selectionKey The unique identifier for the sticky header used for selection. - * @param uiKey The unique identifier for the sticky header used for triggering recompositions. + * @param itemKey The unique identifier for the sticky header used for triggering recompositions. * @param contentType The type of content in the sticky header. * @param selectable Specifies whether the sticky header is selectable. * @param content The content to be displayed in the sticky header, @@ -69,7 +69,7 @@ interface SelectableLazyListScope { */ fun stickyHeader( selectionKey: Any, - uiKey: Any = selectionKey, + itemKey: Any = selectionKey, contentType: Any? = null, selectable: Boolean = false, content: @Composable SelectableLazyItemScope.() -> Unit, @@ -115,20 +115,20 @@ internal class SelectableLazyListScopeContainer : SelectableLazyListScope { override fun item( selectionKey: Any, - uiKey: Any, + itemKey: Any, contentType: Any?, selectable: Boolean, content: @Composable (SelectableLazyItemScope.() -> Unit), ) { selectionKeys.add(if (selectable) Selectable(selectionKey) else NotSelectable(selectionKey)) - entries.add(Entry.Item(selectionKey, uiKey, contentType, content, entriesCount)) + entries.add(Entry.Item(selectionKey, itemKey, contentType, content, entriesCount)) entriesCount++ } override fun items( count: Int, selectionKey: (index: Int) -> Any, - uiKey: (index: Int) -> Any, + itemKey: (index: Int) -> Any, contentType: (index: Int) -> Any?, selectable: (index: Int) -> Boolean, itemContent: @Composable (SelectableLazyItemScope.(index: Int) -> Unit), @@ -141,20 +141,20 @@ internal class SelectableLazyListScopeContainer : SelectableLazyListScope { } } selectionKeys.addAll(selectableKeys) - entries.add(Entry.Items(count, selectionKey, uiKey, contentType, itemContent, entriesCount)) + entries.add(Entry.Items(count, selectionKey, itemKey, contentType, itemContent, entriesCount)) entriesCount += count } @ExperimentalFoundationApi override fun stickyHeader( selectionKey: Any, - uiKey: Any, + itemKey: Any, contentType: Any?, selectable: Boolean, content: @Composable (SelectableLazyItemScope.() -> Unit), ) { selectionKeys.add(if (selectable) Selectable(selectionKey) else NotSelectable(selectionKey)) - entries.add(Entry.StickyHeader(selectionKey, uiKey, contentType, content, entriesCount)) + entries.add(Entry.StickyHeader(selectionKey, itemKey, contentType, content, entriesCount)) entriesCount++ } } @@ -162,7 +162,7 @@ internal class SelectableLazyListScopeContainer : SelectableLazyListScope { fun SelectableLazyListScope.items( items: List, selectionKey: (item: T) -> Any = { it }, - uiKey: (item: T) -> Any = { it }, + itemKey: (item: T) -> Any = selectionKey, contentType: (item: T) -> Any? = { it }, selectable: (item: T) -> Boolean = { true }, itemContent: @Composable SelectableLazyItemScope.(item: T) -> Unit, @@ -170,7 +170,7 @@ fun SelectableLazyListScope.items( items( count = items.size, selectionKey = { selectionKey(items[it]) }, - uiKey = { uiKey(items[it]) }, + itemKey = { itemKey(items[it]) }, contentType = { contentType(items[it]) }, selectable = { selectable(items[it]) }, itemContent = { itemContent(items[it]) }, @@ -180,7 +180,7 @@ fun SelectableLazyListScope.items( fun SelectableLazyListScope.itemsIndexed( items: List, selectionKey: (index: Int, item: T) -> Any = { _, item -> item }, - uiKey: (index: Int, item: T) -> Any = { _, item -> item }, + itemKey: (index: Int, item: T) -> Any = selectionKey, contentType: (index: Int, item: T) -> Any? = { _, item -> item }, selectable: (index: Int, item: T) -> Boolean = { _, _ -> true }, itemContent: @Composable SelectableLazyItemScope.(index: Int, item: T) -> Unit, @@ -188,7 +188,7 @@ fun SelectableLazyListScope.itemsIndexed( items( count = items.size, selectionKey = { selectionKey(it, items[it]) }, - uiKey = { uiKey(it, items[it]) }, + itemKey = { itemKey(it, items[it]) }, contentType = { contentType(it, items[it]) }, selectable = { selectable(it, items[it]) }, itemContent = { itemContent(it, items[it]) }, diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/BasicLazyTree.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/BasicLazyTree.kt index 87f5755b5..8949a27d7 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/BasicLazyTree.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/tree/BasicLazyTree.kt @@ -124,7 +124,7 @@ fun BasicLazyTree( itemsIndexed( items = flattenedTree, selectionKey = { _, item -> item.selectionId }, - uiKey = { _, item -> item.uiId }, + itemKey = { _, item -> item.uiId }, contentType = { _, item -> item.data }, ) { index, element -> val elementState = TreeElementState.of( diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/ChipsAndTree.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/ChipsAndTree.kt index c691ce14f..0e035d77a 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/ChipsAndTree.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/ChipsAndTree.kt @@ -76,7 +76,7 @@ fun SelectableLazyColumnSample() { items( count = listOfItems.size, selectionKey = { index -> index }, - uiKey = { index -> listOfItems[index] }, + itemKey = { index -> listOfItems[index] }, ) { index -> Text( text = listOfItems[index],