Skip to content

Commit

Permalink
Update README.me and version to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nanihadesuka committed Apr 21, 2024
1 parent a6f3c4d commit c790ce9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 124 deletions.
182 changes: 64 additions & 118 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@
Compose implementation of the scroll bar. Can drag, scroll smoothly and includes animations.

### Features:
- Supports LazyColumn, LazyVerticalGrid & Column
- Support sticky headers
- Support reverseLayout

- Support for:
- Column, Row, LazyColumn, LazyRow, LazyVerticalGrid, LazyHorizontalGrid
- Takes into account:
- sticky headers
- reverseLayout
- Optional current position indicator
- Multiple selection states (Disabled, Full, Thumb)
- Multiple selection actionable states (Always, WhenVisible)
- Multiple selection modes:
- States (Disabled, Full, Thumb)
- Actionable states (Always, WhenVisible)
- Customizable look
- Easy integration with other composables
- UI tests
- Extensive UI tests
- Sample app

## Installation

Add it in your root build.gradle at the end of repositories:
Add it in your root build.gradle at the end of repositories:

```groovy
allprojects {
Expand All @@ -36,146 +41,87 @@ Add it to your app build.gradle

```groovy
dependencies {
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:1.10.0'
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.0.0'
}
```

# How to use for LazyColumn

Simply wrap the LazyColumn with it
# Available scrolls components
- ColumnScrollbar
- RowScrollbar
- LazyColumnScrollbar
- LazyRowScrollbar
- LazyVerticalGridScrollbar
- LazyHorizontalGridScrollbar

# Example for LazyColumn
```kotlin
val listData = (0..1000).toList()
val listState = rememberLazyListState()

LazyColumnScrollbar(listState) {
LazyColumnScrollbar(
state = listState,
settings = ScrollbarSettings.Default
) {
LazyColumn(state = listState) {
items(listData) {
Text(
text = "Item $it",
modifier = Modifier
.fillMaxWidth()
.padding(6.dp)
)
Text("Item $it")
}
}
}
```

indicatorContent example:
```kotlin
indicatorContent = { index, isThumbSelected ->
Text(
text = "i: $index",
Modifier
.padding(4.dp)
.background(if (isThumbSelected) Color.Red else Color.Black, CircleShape)
.padding(12.dp)
)
}
```

## LazyColumnScrollbar arguments

```kotlin
fun LazyColumnScrollbar(
listState: LazyListState,
rightSide: Boolean = true,
alwaysShowScrollBar: Boolean = false,
thickness: Dp = 6.dp,
padding: Dp = 8.dp,
thumbMinHeight: Float = 0.1f,
thumbColor: Color = Color(0xFF2A59B6),
thumbSelectedColor: Color = Color(0xFF5281CA),
thumbShape: Shape = CircleShape,
selectionMode: ScrollbarSelectionMode = ScrollbarSelectionMode.Thumb,
selectionActionable: ScrollbarSelectionActionable = ScrollbarSelectionActionable.Always,
hideDelayMillis: Int = 400,
enabled: Boolean = true,
indicatorContent: (@Composable (index: Int, isThumbSelected: Boolean) -> Unit)? = null,
content: @Composable () -> Unit
)
```

# How to use for LazyVerticalGrid

Simply wrap the LazyVerticalGrid with it

```kotlin
val listData = (0..1000).toList()
val lazyGridState = rememberLazyGridState()

LazyGridVerticalScrollbar(lazyGridState) {
LazyVerticalGrid(state = lazyGridState) {
items(listData) {
Text(
text = "Item $it",
modifier = Modifier
.fillMaxWidth()
.padding(6.dp)
)
}
}
}
```

indicatorContent example:
```kotlin
indicatorContent = { index, isThumbSelected ->
Text(
text = "i: $index",
Modifier
.padding(4.dp)
.background(if (isThumbSelected) Color.Red else Color.Black, CircleShape)
.padding(12.dp)
Modifier.background(if (isThumbSelected) Color.Red else Color.Black, CircleShape)
)
}
```

# How to use for Column
Simply wrap the LazyColumn with it

# Default settings parameters
```kotlin
val listData = (0..1000).toList()
val listState = rememberLazyListState()

ColumnScrollbar(listState) {
Column(
modifier = Modifier.verticalScroll(listState)
) {
for (it in listData) {
Text(
text = "Item $it",
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
)
}
/**
* @param thumbMinLength Thumb minimum length proportional to total scrollbar's length (eg: 0.1 -> 10% of total)
*/
@Stable
data class ScrollbarSettings(
val enabled: Boolean = Default.enabled,
val side: ScrollbarLayoutSide = Default.side,
val alwaysShowScrollbar: Boolean = Default.alwaysShowScrollbar,
val scrollbarPadding: Dp = Default.scrollbarPadding,
val thumbThickness: Dp = Default.thumbThickness,
val thumbShape: Shape = Default.thumbShape,
val thumbMinLength: Float = Default.thumbMinLength,
val thumbUnselectedColor: Color = Default.thumbUnselectedColor,
val thumbSelectedColor: Color = Default.thumbSelectedColor,
val selectionMode: ScrollbarSelectionMode = Default.selectionMode,
val selectionActionable: ScrollbarSelectionActionable = Default.selectionActionable,
val hideDelayMillis: Int = Default.hideDelayMillis,
val durationAnimationMillis: Int = Default.durationAnimationMillis
) {
companion object {
val Default = ScrollbarSettings(
enabled = true,
side = ScrollbarLayoutSide.End,
alwaysShowScrollbar = false,
thumbThickness = 6.dp,
scrollbarPadding = 8.dp,
thumbMinLength = 0.1f,
thumbUnselectedColor = Color(0xFF2A59B6),
thumbSelectedColor = Color(0xFF5281CA),
thumbShape = CircleShape,
selectionMode = ScrollbarSelectionMode.Thumb,
selectionActionable = ScrollbarSelectionActionable.Always,
hideDelayMillis = 400,
durationAnimationMillis = 500,
)
}
}
```

## ColumnScrollbar arguments

```kotlin
fun ColumnScrollbar(
state: ScrollState,
rightSide: Boolean = true,
alwaysShowScrollBar: Boolean = false,
thickness: Dp = 6.dp,
padding: Dp = 8.dp,
thumbMinHeight: Float = 0.1f,
thumbColor: Color = Color(0xFF2A59B6),
thumbSelectedColor: Color = Color(0xFF5281CA),
thumbShape: Shape = CircleShape,
enabled: Boolean = true,
selectionMode: ScrollbarSelectionMode = ScrollbarSelectionMode.Thumb,
selectionActionable: ScrollbarSelectionActionable = ScrollbarSelectionActionable.Always,
hideDelayMillis: Int = 400,
indicatorContent: (@Composable (normalizedOffset: Float, isThumbSelected: Boolean) -> Unit)? = null,
content: @Composable () -> Unit
)
```

# License

Copyright © 2022, [nani](https://github.com/nanihadesuka), Released under [MIT License](LICENSE)
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "my.nanihadesuka.lazycolumnscrollbar"
minSdk = 21
targetSdk = 34
versionCode = 7
versionName = "1.5.0"
versionCode = 8
versionName = "2.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id("maven-publish")
}

val versionCode: Int = 20
val versionName: String = "1.10.0"
val versionCode: Int = 21
val versionName: String = "2.0.0"

android {
namespace = "my.nanihadesuka.lazycolumnscrollbar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

/**
* @param thumbThickness Thickness of the scrollbar thumb
* @param scrollbarPadding Padding of the scrollbar
* @param thumbMinLength Thumb minimum length proportional to total scrollbar's length (eg: 0.1 -> 10% of total)
*/
@Stable
Expand Down

0 comments on commit c790ce9

Please sign in to comment.