11# Compose Action Menu
22
3- This library provides an easy-to-use action menu for Compose, since Compose doesn't offer this by default.
3+ ![ Android] ( https://img.shields.io/badge/-android-6EDB8D.svg?style=flat )
4+ ![ iOS] ( http://img.shields.io/badge/-ios-CDCDCD.svg?style=flat )
5+ ![ JVM] ( https://img.shields.io/badge/-jvm-DB413D.svg?style=flat )
6+
7+ This multi-platform library provides an easy-to-use action menu for Compose, since Compose doesn't offer this by default.
48
59[ ![ Android Arsenal] ( https://img.shields.io/badge/Android%20Arsenal-ComposeActionMenu-green.svg?style=flat )] ( https://android-arsenal.com/details/1/8261 )
610
@@ -11,37 +15,39 @@ This library provides an easy-to-use action menu for Compose, since Compose does
1115- Icons (optional);
1216- Selectable/checkable items;
1317- Nested sub menus;
14- - Automatic overflow for items that don't fit the specified maximum.
18+ - Automatic overflow for items that don't fit the specified maximum;
19+ - Kotlin Multiplatform (KMP) since version 2.0.0, supporting Android, iOS and JVM (desktop).
1520
1621![ Animated preview image] ( preview.gif )
1722
1823# Installation
1924
20- ``` groovy
21- repositories {
22- google()
23- maven { url "https://jitpack.io" }
24- }
25+ ``` kotlin
2526dependencies {
26- implementation "com.github. jacobras:ComposeActionMenu:1. 2.0"
27+ implementation( " nl. jacobras:compose-action-menu: 2.0.0 " )
2728}
2829```
2930
30- ## Compose version
31+ Note: version 2 and newer are available from Maven Central, whereas previous versions were distributed through JitPack.
3132
32- This library uses the Compose BOM (Bill of Materials). Each version depends on specific Compose dependencies .
33+ See also: [ Migrating to V2 ] ( #migrating-from-v1-to-v2 ) .
3334
34- See the Android docs for information about the specific Compose library versions in each BOM: https://developer.android.com/jetpack/compose/bom/bom-mapping .
35+ ## Compose version
36+
37+ Each version depends on specific Compose dependencies.
3538
3639<table >
3740 <tr >
38- <td >Compose 1.1.0-rc01</td ><td ><img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.0.0-blue " ></td >
41+ <td ><img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.0.0-blue " ></td ><td >Compose 1.1.0-rc01</td >
42+ </tr >
43+ <tr >
44+ <td ><img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.1.0-blue " ></td ><td >Compose 1.3.3</td >
3945 </tr >
4046 <tr >
41- <td >Compose 2023.01.00</ td >< td >< img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.1 .0-blue " ></td >
47+ <td >< img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.2 .0-blue " ></ td >< td >Compose 1.4.3 </td >
4248 </tr >
4349 <tr >
44- <td >Compose 2023.05.01</ td >< td >< img alt =" JitPack " src =" https://img.shields.io/badge/jitpack-v1.2 .0-blue " ></td >
50+ <td >< img alt =" JitPack " src =" https://img.shields.io/badge/mavencentral-v2.0 .0-blue " ></ td >< td >Compose Multiplatform 1.5.1 </td >
4551 </tr >
4652</table >
4753
@@ -50,9 +56,10 @@ See the Android docs for information about the specific Compose library versions
5056``` kotlin
5157val toolbarActions = listOf (
5258 RegularActionItem (
53- key = " settings" ,
54- titleResId = R .string.settings,
55- onClick = { /* TODO: Open settings screen */ }
59+ key = " search" ,
60+ title = stringResource(R .string.search),
61+ iconVector = Icons .Filled .Search ,
62+ onClick = { /* TODO: Open search screen */ }
5663 )
5764)
5865
@@ -81,7 +88,7 @@ val subOption3 = RegularActionItem(key = "subOption3", /* ... */)
8188
8289val group = GroupActionItem (
8390 key = " myGroup" ,
84- title = R .string.group_title,
91+ title = stringResource( R .string.group_title) ,
8592 childOptions = listOf (subOption1, subOption2, subOption3)
8693)
8794```
@@ -112,36 +119,39 @@ composeTestRule.onNodeWithTag("ActionMenu#myKey").performClick()
112119
113120There's a reserved key for the overflow icon: ` "ActionMenu#overflow" ` .
114121
115- # Production example
122+ # Migrating from v1 to v2
116123
117- My note taking app uses ComposeActionMenu:
124+ Compose Action Menu version 2 is built using KMP. Android-specific resource support is replaced with broader string + Painter support.
118125
119- < https://play.google.com/store/apps/details?id=nl.jacobras.notes >
126+ 1.x:
120127
121- ![ ] ( preview_notes.png )
128+ ``` kotlin
129+ RegularActionItem (
130+ titleResId = R .string.search,
131+ iconDrawable = R .drawable.search
132+ )
133+ ```
122134
123- # License
135+ 2.x:
124136
137+ ``` kotlin
138+ RegularActionItem (
139+ title = stringResource(R .string.search),
140+ icon = painterResource(R .drawable.search)
141+ )
125142```
126- MIT License
127-
128- Copyright (c) 2021 Jacob Ras
129-
130- Permission is hereby granted, free of charge, to any person obtaining a copy
131- of this software and associated documentation files (the "Software"), to deal
132- in the Software without restriction, including without limitation the rights
133- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
134- copies of the Software, and to permit persons to whom the Software is
135- furnished to do so, subject to the following conditions:
136-
137- The above copyright notice and this permission notice shall be included in all
138- copies or substantial portions of the Software.
139-
140- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
142- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
143- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
144- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
145- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
146- SOFTWARE.
147- ```
143+
144+ # Sample apps
145+
146+ The repository contains two sample apps.
147+
148+ * Run Android: ` gradlew sample-app:installDebug `
149+ * Run Desktop: ` gradlew sample-desktop:run `
150+
151+ # Production example
152+
153+ My note taking app uses ComposeActionMenu:
154+
155+ < https://play.google.com/store/apps/details?id=nl.jacobras.notes >
156+
157+ ![ ] ( preview_notes.png )
0 commit comments