Skip to content

Commit

Permalink
Enable user to use index property of key (#21)
Browse files Browse the repository at this point in the history
* enable user to use index property of key
* update readme for 2.0.1
  • Loading branch information
pushpalroy authored Jan 29, 2024
1 parent 10ea7c0 commit f52df6c
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 41 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ In `build.gradle` of app module, include the following dependency

```gradle
dependencies {
implementation("io.github.pushpalroy:jetlime:2.0.0")
implementation("io.github.pushpalroy:jetlime:2.0.1")
}
```

Expand All @@ -44,7 +44,7 @@ val items = remember { mutableListOf(Item1, Item2, Item3) } // Any type of items
JetLimeColumn(
modifier = Modifier.padding(16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
style = JetLimeEventDefaults.eventStyle(
Expand All @@ -65,7 +65,7 @@ val items = remember { mutableListOf(Item1, Item2, Item3) } // Any type of items
JetLimeRow(
modifier = Modifier.padding(16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
style = JetLimeEventDefaults.eventStyle(
Expand All @@ -77,7 +77,8 @@ JetLimeRow(
}
```

Pass the `keyExtractor` lambda to define how your `key` will be used in the internal Lazy lists.
Pass the `key` to define factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed.
This key will be used by a LazyColumn or LazyRow internally.

### ⚡ Modify `JetLimeColumn` Style

Expand Down Expand Up @@ -193,7 +194,7 @@ This classification is needed to render correct lines for start and end items.
```kotlin
JetLimeColumn(
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
style = JetLimeEventDefaults.eventStyle(
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
buildTypes {
getByName("release") {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun BasicHorizontalTimeLine(modifier: Modifier = Modifier) {
JetLimeRow(
modifier = Modifier.padding(vertical = 32.dp, horizontal = 16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
style = JetLimeEventDefaults.eventStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun BasicVerticalTimeLine(modifier: Modifier = Modifier) {
JetLimeColumn(
modifier = Modifier.padding(16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
style = JetLimeEventDefaults.eventStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun CustomizedHorizontalTimeLine(modifier: Modifier = Modifier) {
JetLimeRow(
modifier = Modifier.padding(vertical = 32.dp, horizontal = 16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
style = JetLimeDefaults.rowStyle(
contentDistance = 16.dp,
itemSpacing = 16.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun CustomizedVerticalTimeLine(modifier: Modifier = Modifier) {
JetLimeColumn(
modifier = Modifier.padding(16.dp),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
style = JetLimeDefaults.columnStyle(
contentDistance = 32.dp,
itemSpacing = 16.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fun VerticalDynamicTimeLine(modifier: Modifier = Modifier) {
lineBrush = JetLimeDefaults.lineGradientBrush(),
),
itemsList = ItemsList(items),
keyExtractor = { item -> item.id },
key = { _, item -> item.id },
) { index, item, position ->
JetLimeEvent(
modifier = Modifier.clickable {
Expand Down
4 changes: 2 additions & 2 deletions docs/jetlime/com.pushpal.jetlime/-jet-lime-column.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jetlime/com.pushpal.jetlime/-jet-lime-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="cover ">
<h1 class="cover"><span>Jet</span><wbr></wbr><span>Lime</span><wbr></wbr><span><span>Event</span></span></h1>
</div>
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":jetlime:dokkaHtml/release"><div class="symbol monospace"><div class="block"><div class="block"><span class="token annotation builtin">@</span><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html"><span class="token annotation builtin">Composable</span></a></div></div><span class="token keyword"></span><span class="token keyword">fun </span><a href="-jet-lime-event.html"><span class="token function">JetLimeEvent</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">modifier<span class="token operator">: </span><a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.html">Modifier</a><span class="token operator"> = </span>Modifier<span class="token punctuation">, </span></span><span class="parameter ">style<span class="token operator">: </span><a href="-jet-lime-event-style/index.html">JetLimeEventStyle</a><span class="token operator"> = </span>JetLimeEventDefaults.eventStyle(EventPosition.END)<span class="token punctuation">, </span></span><span class="parameter ">content<span class="token operator">: </span><span><span class="token annotation builtin">@</span><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html"><span class="token annotation builtin">Composable</span></a> </span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><span class="token keyword"></span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></span></span><span class="token punctuation">)</span></div><p class="paragraph">Composable function for creating a <a href="-jet-lime-column.html">JetLimeColumn</a> or <a href="-jet-lime-row.html">JetLimeRow</a> event.</p><p class="paragraph">Example usage:</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">val items = remember { getItemsList() }<br><br>JetLimeColumn(<br> itemsList = ItemsList(items),<br> keyExtractor = { item -&gt; item.id },<br> style = JetLimeDefaults.columnStyle(),<br>) { index, item, position -&gt;<br> JetLimeEvent(<br> style = JetLimeEventDefaults.eventStyle(position = position)<br> ) {<br> ComposableContent(item = item)<br> }<br> }</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><h4 class="">Parameters</h4><div class="table"><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>modifier</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The modifier to be applied to the event.</p></div></div></div></div><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>style</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The style of the <a href="-jet-lime-column.html">JetLimeColumn</a> or <a href="-jet-lime-row.html">JetLimeRow</a> event, defaulting to <a href="-jet-lime-event-defaults/event-style.html">JetLimeEventDefaults.eventStyle</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>content</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The composable content inside the event.</p></div></div></div></div></div></div></div>
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":jetlime:dokkaHtml/release"><div class="symbol monospace"><div class="block"><div class="block"><span class="token annotation builtin">@</span><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html"><span class="token annotation builtin">Composable</span></a></div></div><span class="token keyword"></span><span class="token keyword">fun </span><a href="-jet-lime-event.html"><span class="token function">JetLimeEvent</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">modifier<span class="token operator">: </span><a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.html">Modifier</a><span class="token operator"> = </span>Modifier<span class="token punctuation">, </span></span><span class="parameter ">style<span class="token operator">: </span><a href="-jet-lime-event-style/index.html">JetLimeEventStyle</a><span class="token operator"> = </span>JetLimeEventDefaults.eventStyle(EventPosition.END)<span class="token punctuation">, </span></span><span class="parameter ">content<span class="token operator">: </span><span><span class="token annotation builtin">@</span><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html"><span class="token annotation builtin">Composable</span></a> </span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><span class="token keyword"></span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></span></span><span class="token punctuation">)</span></div><p class="paragraph">Composable function for creating a <a href="-jet-lime-column.html">JetLimeColumn</a> or <a href="-jet-lime-row.html">JetLimeRow</a> event.</p><p class="paragraph">Example usage:</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">val items = remember { getItemsList() }<br><br>JetLimeColumn(<br> itemsList = ItemsList(items),<br> key = { _, item -&gt; item.id },<br> style = JetLimeDefaults.columnStyle(),<br>) { index, item, position -&gt;<br> JetLimeEvent(<br> style = JetLimeEventDefaults.eventStyle(position = position)<br> ) {<br> ComposableContent(item = item)<br> }<br> }</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><h4 class="">Parameters</h4><div class="table"><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>modifier</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The modifier to be applied to the event.</p></div></div></div></div><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>style</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The style of the <a href="-jet-lime-column.html">JetLimeColumn</a> or <a href="-jet-lime-row.html">JetLimeRow</a> event, defaulting to <a href="-jet-lime-event-defaults/event-style.html">JetLimeEventDefaults.eventStyle</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":jetlime:dokkaHtml/release" data-filterable-set=":jetlime:dokkaHtml/release"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>content</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The composable content inside the event.</p></div></div></div></div></div></div></div>
</div>
<div class="footer">
<span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2024 Copyright</span><span
Expand Down
Loading

0 comments on commit f52df6c

Please sign in to comment.