-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
264 additions
and
37 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Collapsing Header | ||
|
||
Collapsing headers in the library are achieved with a wrapping Composable enclosing a scrollable | ||
layout. | ||
|
||
```kotlin | ||
@Composable | ||
fun CollapsingHeader( | ||
state: CollapsingHeaderState, | ||
headerContent: @Composable () -> Unit, | ||
body: @Composable () -> Unit, | ||
) { | ||
... | ||
} | ||
``` | ||
|
||
It works with any layout in the body composable that supports nested scrolling. | ||
|
||
| Composable | | | | | ||
|---------------------|----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| | ||
| Collapsing Headers |  |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Drag To Dismiss | ||
|
||
Used for easily implementing the drag to dismiss pattern for media. | ||
|
||
```kotlin | ||
@Composable | ||
fun ParentLayout() { | ||
Child( | ||
modifier = Modifier | ||
.dragToDismiss( | ||
state = dragToDismissState, | ||
dragThresholdCheck = { offset, _ -> | ||
offset.getDistanceSquared() > with(density) { | ||
240.dp.toPx().let { it * it } | ||
} | ||
}, | ||
onDismissed = { | ||
... | ||
}, | ||
) | ||
) | ||
... | ||
} | ||
``` | ||
|
||
|
||
| Composable | | | | | ||
|-----------------------------------|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ||
| Drag To Dismiss |  |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Interpolation | ||
|
||
`Alignment` and `ContentScale` are used to help in the layout of composables, however it can be | ||
necessary to interpolate between them when they change. `interpolate()` Composable extension | ||
methods are added to help create a seamless transition. | ||
|
||
```kotlin | ||
@Composable | ||
fun ParentLayout( | ||
contentScale: ContentScale, | ||
alignment: Alignment, | ||
) { | ||
Image( | ||
painter = painter, | ||
contentScale = contentScale.interpolate(), | ||
alignment = alignment.interpolate(), | ||
) | ||
... | ||
} | ||
``` | ||
|
||
| Composable | | | | ||
|----------------------------------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------| | ||
| Alignment / ContentScale Interpolation |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Pointer Offset Scroll Header | ||
|
||
Pointer offsets are useful for manually scrolling containers with [ScrollableState], when the | ||
pointer is already involved in another interaction. For example drag and drop or a long press. | ||
|
||
```kotlin | ||
@Composable | ||
fun Modifier.pointerOffsetScroll( | ||
state: PointerOffsetScrollState, | ||
) { | ||
... | ||
} | ||
``` | ||
|
||
| Composable | | | | | ||
|-----------------------------------|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| | ||
| Pointer Offset Scroll |  |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Scrollbars | ||
|
||
Scrollbars enable tracking a user's position in the list and fast scrolling through it. | ||
|
||
For lazy containers, the easiest way to use them is via the `scrollbarState` extension method: | ||
|
||
```kotlin | ||
@Composable | ||
fun Lazy_State.scrollbarState( | ||
itemsAvailable: Int, | ||
itemIndex: (Lazy_ItemInfo) -> Int = Lazy_ItemInfo::index, | ||
): ScrollbarState { | ||
... | ||
} | ||
``` | ||
|
||
Use of the scroll bar follows the following pattern: | ||
|
||
```kotlin | ||
@Composable | ||
fun FastScrollbar( | ||
modifier: Modifier = Modifier, | ||
state: ScrollbarState, | ||
scrollInProgress: Boolean, | ||
orientation: Orientation, | ||
onThumbMoved: (Float) -> Unit, | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
Scrollbar( | ||
modifier = modifier, | ||
orientation = orientation, | ||
interactionSource = interactionSource, | ||
state = state, | ||
thumb = { | ||
FastScrollbarThumb( | ||
scrollInProgress = scrollInProgress, | ||
interactionSource = interactionSource, | ||
orientation = orientation, | ||
) | ||
}, | ||
onThumbMoved = onThumbMoved, | ||
) | ||
} | ||
``` | ||
|
||
They are implemented for scrollable containers with [ScrollState], lists, grids and staggered grids. | ||
|
||
|
||
| Composable | | | | | ||
|-----------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| | ||
| Collapsing Headers and Scrollbars |  |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Sticky Headers | ||
|
||
Sticky headers in the library are achieved with a wrapping Composable enclosing the lazy layout. | ||
|
||
```kotlin | ||
@Composable | ||
fun StickyHeader_( | ||
state: Lazy_State, | ||
modifier: Modifier = Modifier, | ||
isStickyHeaderItem: @DisallowComposableCalls (Lazy_ItemInfo) -> Boolean, | ||
stickyHeader: @Composable (key: Any?, contentType: Any?) -> Unit, | ||
content: @Composable () -> Unit | ||
) { | ||
... | ||
} | ||
``` | ||
|
||
They are implemented for lists, grids and staggered grids. | ||
|
||
| Composable | | | | | ||
|-----------------------------------|---------------------------------------------------|---------------------------------------------------|-----------------------------------------------------------------------| | ||
| Sticky Headers |  |  |  | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Composables | ||
|
||
[](https://github.com/tunjid/Tiler/actions/workflows/tests.yml) | ||
 | ||
|
||
![badge][badge-ios] | ||
![badge][badge-js] | ||
![badge][badge-jvm] | ||
![badge][badge-linux] | ||
![badge][badge-windows] | ||
![badge][badge-mac] | ||
![badge][badge-tvos] | ||
![badge][badge-watchos] | ||
|
||
Please note, this is an experimental repository. It is a Kotlin multiplatform experiment that makes no guarantees | ||
about API stability or long term support. None of the works presented here are production tested, and should not be | ||
taken as anything more than its face value. | ||
|
||
## Introduction | ||
|
||
Composables are a collection of utility methods that build on the Jetpack Compose UI and Foundation packages. | ||
|
||
They offer APIs for common UI interactions that make UI more delightful. They are summarize below | ||
|
||
| Composable | | | | | ||
|----------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------| | ||
| Sticky Headers |  |  |  | | ||
| Collapsing Headers and Scrollbars |  |  |  | | ||
| Pointer Offset Scroll |  |  |  | | ||
| Drag To Dismiss |  |  |  | | ||
| Alignment / ContentScale Interpolation |  |  | | | ||
|
||
Please see the [documentation](https://tunjid.github.io/Composables/) for more details. | ||
|
||
## License | ||
|
||
Copyright 2023 Adetunji Dahunsi | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
https://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
[badge-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat | ||
|
||
[badge-jvm]: http://img.shields.io/badge/-jvm-DB413D.svg?style=flat | ||
|
||
[badge-js]: http://img.shields.io/badge/-js-F8DB5D.svg?style=flat | ||
|
||
[badge-js-ir]: https://img.shields.io/badge/support-[IR]-AAC4E0.svg?style=flat | ||
|
||
[badge-nodejs]: https://img.shields.io/badge/-nodejs-68a063.svg?style=flat | ||
|
||
[badge-linux]: http://img.shields.io/badge/-linux-2D3F6C.svg?style=flat | ||
|
||
[badge-windows]: http://img.shields.io/badge/-windows-4D76CD.svg?style=flat | ||
|
||
[badge-wasm]: https://img.shields.io/badge/-wasm-624FE8.svg?style=flat | ||
|
||
[badge-apple-silicon]: http://img.shields.io/badge/support-[AppleSilicon]-43BBFF.svg?style=flat | ||
|
||
[badge-ios]: http://img.shields.io/badge/-ios-CDCDCD.svg?style=flat | ||
|
||
[badge-mac]: http://img.shields.io/badge/-macos-111111.svg?style=flat | ||
|
||
[badge-watchos]: http://img.shields.io/badge/-watchos-C0C0C0.svg?style=flat | ||
|
||
[badge-tvos]: http://img.shields.io/badge/-tvos-808080.svg?style=flat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.