Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dokar3 committed Jul 28, 2023
1 parent 39acfbb commit 081179f
Showing 1 changed file with 32 additions and 75 deletions.
107 changes: 32 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,54 @@
# Sheets

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.dokar3/sheets/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.dokar3/sheets)

Another BottomSheet in Jetpack Compose.

<a href="images/screenshot_simple.png"><img src="images/screenshot_simple.png" width="32%"/></a>
<a href="images/screenshot_list.png"><img src="images/screenshot_list.png" width="32%"/></a>
<a href="images/screenshot_intent-picker.png"><img src="images/screenshot_intent-picker.png" width="32%"/></a>

**Features**:
# Features

- Independent.
### Easy to use
Unlike [`ModalBottomSheetLayout`](https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#ModalBottomSheetLayout(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.ModalBottomSheetState,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function0))
, this bottom sheet will be displayed in a dialog window, which means we can easily create and
display multiple sheets in the same composable:

```kotlin
@Composable
fun MyComposable() {
val scope = rememberCoroutineScope()

fun MyComposable(modifier: Modifier = Modifier) {
val sheet1 = rememberBottomSheetState()
val sheet2 = rememberBottomSheetState()

Column {
Button(onClick = { scope.launch { sheet1.expand() } }) {
Text("Sheet 1")
}

Button(onClick = { scope.launch { sheet2.expand() } }) {
Text("Sheet 2")
}
}

BottomSheet(state = sheet1) { ... }
BottomSheet(state = sheet2) { ... }
}
```


- Peek support:
### Peek support:

```kotlin
val state = rememberBottomSheetState()

BottomSheet(
state = state,
/*
* PeekHeight.px(Int) and PeekHeight.fraction(Float) are supported as well.
*/
// PeekHeight.px(Int) and PeekHeight.fraction(Float) are supported as well.
peekHeight = PeekHeight.dp(300),
) {
...
}

// In some callback
state.peek()
// Set to true you don't want the peeked state.
skipPeeked = false,
) { ...}
```


- Customizable animations:
### Customizable animations

```kotlin
val state = rememberBottomSheetState()

// In some callback
state.expand(animationSpec = spring())
```

# Usages

Add the
dependency [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.dokar3/sheets/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.dokar3/sheets):

```groovy
implementation "io.github.dokar3:sheets:latest_version"
```

**Basic**

```kotlin
val scope = rememberCoroutineScope()
val state = rememberBottomSheetState()

Button(onClick = { scope.launch { state.expand() } }) {
Text("Show bottom sheet")
}

BottomSheet(state = state) {
Text("Sheet content")
}
```

**Material 3**
```diff
- implementation "io.github.dokar3:sheets:latest_version"
+ implementation "io.github.dokar3:sheets-m3:latest_version"

- import com.dokar.sheets.BottomSheet
+ import com.dokar.sheets.m3.BottomSheet
```

**Skip the peeked state**

```kotlin
BottomSheet(
state = state,
skipPeeked = true,
) {
...
}
```

**Intercept state (value)**
### Interceptable state

```kotlin
val state = rememberBottomSheetState(
Expand All @@ -124,7 +62,26 @@ val state = rememberBottomSheetState(
)
```

**Embedded sheet**
### Material 2 and Material 3

Mateiral 2:

```kotlin
implementation("io.github.dokar3:sheets:latest_version")

import com.dokar.sheets.BottomSheet
```

Material 3:

```kotlin
implementation("io.github.dokar3:sheets-m3:latest_version")

import com.dokar.sheets.m3.BottomSheet
```


### Embedded sheet

To embed the sheet in the current layout hierarchy, use the `BottomSheetLayout()`:

Expand Down

0 comments on commit 081179f

Please sign in to comment.