Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dokar3/draggable-menu
A fluid draggable menu in Jetpack Compose
https://github.com/dokar3/draggable-menu
android jetpack-compose kotlin
Last synced: 3 months ago
JSON representation
A fluid draggable menu in Jetpack Compose
- Host: GitHub
- URL: https://github.com/dokar3/draggable-menu
- Owner: dokar3
- License: apache-2.0
- Created: 2023-01-07T06:38:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T08:10:41.000Z (9 months ago)
- Last Synced: 2024-05-16T09:29:33.135Z (9 months ago)
- Topics: android, jetpack-compose, kotlin
- Language: Kotlin
- Homepage:
- Size: 5.09 MB
- Stars: 48
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A fluid draggable menu
Inspired by the [original work](https://twitter.com/jmtrivedi/status/1610017363218563072?s=20&t=PP2YsTMOL5FYV4TWfka7cw) from Janum Trivedi ([jmtrivedi@twitter](https://twitter.com/jmtrivedi)), the draggable bouncy menu in Jetpack Compose is here.
Sample GIFs
| ![](images/sample_press_anchor_to_drag.gif) | ![](images/sample_press_item_to_drag.gif) | ![](images/sample_dark.gif) |
|:-------------------------------------------:|:-----------------------------------------:|:---------------------------:|
| Press anchor to drag | Press menu item to drag | Dark |The simplified sample code would be like this:
```kotlin
@Composable
fun MenuSample(modifier: Modifier = Modifier) {
val state = rememberDraggableMenuState()
Box(
modifier = modifier
.fillMaxSize()
.draggableMenuContainer(state),
) {
Box(modifier = Modifier.align(Alignment.Center)) {
Icon(
imageVector = Icons.Default.Share,
contentDescription = null,
modifier = Modifier.draggableMenuAnchor(state),
)DraggableMenu(state = state, onItemSelected = {}) {
items(5) {
Text("Menu item: $it")
}
}
}
}
}
```# License
```
Copyright 2023 dokar3Licensed 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 athttp://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.
```