Skip to content

Commit

Permalink
Update documents for 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cheonjaeung committed Dec 9, 2023
1 parent 4726125 commit 96611ef
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
25 changes: 23 additions & 2 deletions docs/cell-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ And each cell will have 1/n of the grid size.
The API of `Fixed` looks like this:

```kotlin
class Fixed(private val count: Int) : SimpleGridCells
class Fixed(
private val count: Int,
private val fill: Boolean = true
) : SimpleGridCells
```

There is a parameter called `count`. This is the maximum number of cells the grid should have on
each line. The `count` must be a positive number. If 0 or negative number is provided, it occurs
an exception.

!!! note
For information about `fill` parameter, read [Fill Optoin](#fill-option) section.

For example, a grid has 400dp width or height, and `Fixed(4)` is applied.

```kotlin
Expand Down Expand Up @@ -50,14 +56,20 @@ And each cell will have at least minimum size.
The API of `Adaptive` looks like this:

```kotlin
class Adaptive(private val minSize: Dp) : SimpleGridCells
class Adaptive(
private val minSize: Dp,
private val fill: Boolean = true
) : SimpleGridCells
```

There is a parameter called `minSize`. This is the minimum size of each cell should have.
The `minSize` must be a positive size. If the size is 0 or below, it occurs an exception.
The grid layout with `Adaptive` calculates the maximum number of cells possible while keeping
the `minSize` restriction.

!!! note
For information about `fill` parameter, read [Fill Option](#fill-option) section.

For example, a grid has 400dp width or height and `Adaptive(120.dp)` is applied.

```kotlin
Expand All @@ -81,3 +93,12 @@ And each cells will have 1/3 of 400dp (about 133.333dp) width or height.

If the grid size is expanded to 600dp, the number of cells on each line will be changed to 5
and each cell's size will be 120dp.

## Fill Option

Both `Fixed` and `Adaptive` have a optional parameter named `fill`.
The `fill` parameter determines that grid's item composable should fill grid cell's size.

When `fill` is true, grid layout forces item composable to have width or height to fit cell's maximum width or height.
(width when vertical grid, height when horizontal grid)
But when false, item composable can have width or height from 0 to cell's maximum width or height.
Binary file added docs/images/span-graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The following table shows Compose versions which each library version depends on

| GridLayout Version | Compose Version (Android) | Compose Version (Multiplatform) |
|--------------------|---------------------------|---------------------------------|
| 1.1.0 | Jetpack Compose 1.5.0 | Compose Multiplatform 1.5.2 |
| 1.0.0 | Jetpack Compose 1.5.0 | Compose Multiplatform 1.5.2 |
| 0.2.0 | Jetpack Compose 1.4.3 | Compose Multiplatform 1.4.1 |
| 0.1.0 | Jetpack Compose 1.4.3 | Compose Multiplatform 1.4.1 |
Expand All @@ -39,6 +40,7 @@ It is recommended to use following target SDK version when using this library fo

| GridLayout Version | Android Target SDK | Android Minimum SDK |
|--------------------|--------------------|---------------------|
| 1.1.0 | Android 14 (34) | Lollipop (21) |
| 1.0.0 | Android 14 (34) | Lollipop (21) |
| 0.2.0 | Android 13 (33) | Lollipop (21) |
| 0.1.0 | Android 13 (33) | Lollipop (21) |
29 changes: 29 additions & 0 deletions docs/span.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Spanning Cells

The `content` composable lambda of grid layout extends `GridScope`.
To apply span size, you can set `span` modifier in the `GridScope`.

The following code and graphic show a example of span.

```kotlin
HorizontalGrid(rows = SimpleGridCells.Fixed(3)) {
Item()
Item(Modifier.span(2))
Item(Modifier.span(2))
Item()
Item()
}

VerticalGrid(columns = SimpleGridCells.Fixed(3)) {
Item()
Item(Modifier.span(2))
Item(Modifier.span(2))
Item()
Item()
}
```

![span-graphic](images/span-graphic.png)

!!! warning
If given span size is bigger than maximum cell count of the axis, the cell will be undisplayed.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nav:
- 'Layout Composables': layout-composables.md
- 'Cell Strategy': cell-strategy.md
- 'Arrangement': arrangement.md
- 'Spanning Cells': span.md
- 'Changelog': 'https://github.com/cheonjaewoong/gridlayout-compose/blob/main/CHANGELOG.md'

# Repository Information
Expand Down

0 comments on commit 96611ef

Please sign in to comment.