diff --git a/CHANGELOG.md b/CHANGELOG.md
index f275d15f..6fcef6ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,14 @@
# Change Log
-## [next] - 2021-05-24
+
+## Compose [1.0.0-alpha01] - 2022-05-14
+- First release of SpeedDial for Compose
+
+## Classic View [3.3.0] - 2022-05-14
- fixed #168: Stack overflow when setting contentDescription to main FAB
- preventing user to be forced out of touch mode (thank you @zhanghai for the PR)
+- updated several dependencies
-## [3.2.0] - 2021-05-22
+## Classic View [3.2.0] - 2021-05-22
- fixed #159: Publish latest version to Maven Central, now that JCenter will be sunset
- fixed #149: Accessibility issues:
- the closest Action Item to the Main FAB is now focused
@@ -11,27 +16,27 @@
- it is possible to set content descriptions for all the FABs
- updated several dependencies
-## [3.1.1] - 2019-09-10
+## Classic View [3.1.1] - 2019-09-10
- fixed #11: Re-enabling FAB size
- Revert `com.google.android.material` to `1.0.0` (version `1.1.0-beta01` can still be used, just specify this version explicitly on your build.gradle file).
-## [3.1.0] - 2019-09-10
+## Classic View [3.1.0] - 2019-09-10
- fixed #113: Main FAB opened image is not centered when using Theme.MaterialComponents
- fixed #101: Add ability to Disable Main Fab
- API changes:
- fixed #111: added option to tint Main FAB icon (`setMainFabClosedIconColor()` and `setMainFabOpenedIconColor()`)
- migrated Sample project to Kotlin
-## [3.0.0] - 2019-07-27
+## Classic View [3.0.0] - 2019-07-27
- fixed #92: Migrate to AndroidX
- fixed #100: Use unique view IDs
- fixed #109: Added resource ID for main FAB
- updated gradle and Android gradle plugin
-## [2.0.1] - 2018-09-28
+## Classic View [2.0.1] - 2018-09-28
- fixed #95: support 28 workaround does not work on minified release apk
-## [2.0.0] - 2018-09-23
+## Classic View [2.0.0] - 2018-09-23
- updated support library to v28.0.0
- workaround for https://issuetracker.google.com/issues/111316656 <- **PLEASE STAR THIS ISSUE**
- fixed #79: Does not change label text language when app language is changed dynamically
@@ -44,19 +49,19 @@
- all the `SpeedDialView` add and replace methods now return an instance of the `FabWithLabelView` they create (useful to modify an existing Action Item without replacing it completely)
- added `FabWithLabelView.getSpeedDialActionItemBuilder()` (useful to modify an existing Action Item without replacing it completely)
-## [1.0.2] - 2018-06-30
+## Classic View [1.0.2] - 2018-06-30
- fixed #65: Main FAB not centered when using RTL
- fixed #71: Animation feels slower than Google Inbox
- fixed #72: FAB vertical padding should be 16dp instead of 18dp
-## [1.0.1] - 2018-06-15
+## Classic View [1.0.1] - 2018-06-15
- fixed #62: Click between Label and FAB handled as a dismiss action
- fixed #60: Label transparent background not being applied
-## [1.0.0] - 2018-06-03
+## Classic View [1.0.0] - 2018-06-03
- first stable release (no changes from 1.0-alpha06)
-## [1.0-alpha06] - 2018-05-12
+## Classic View [1.0-alpha06] - 2018-05-12
- updated gradle plugin to 3.1.2
- several API changes:
- added `sdOverlayLayout` attribute
@@ -75,7 +80,7 @@
- renamed `sdMainFabCloseBackgroundColor` to `sdMainFabOpenedBackgroundColor`
- renamed `sdMainFabCloseRotateAngle` to `sdMainFabAnimationRotateAngle`
-## [1.0-alpha05] - 2018-04-15
+## Classic View [1.0-alpha05] - 2018-04-15
- added Menu Resource support (no color customization possible)
- `Drawable`s are not parcelables so is not possible to restore them when the view is recreated
for example after an orientation change. If possible always use the `DrawableRes`.
@@ -87,7 +92,7 @@
- `SpeedDialView.OnChangeListener.onMainActionSelected()` now returns true to keep the Speed Dial open, false to close it
- optional no animation for open/close/toggle
-## [1.0-alpha04] - 2018-04-14
+## Classic View [1.0-alpha04] - 2018-04-14
- android support library 27.1.1
- lowered minSdk from 15 to 14
- several API changes:
@@ -114,11 +119,11 @@
- added attributes `sdMainFabAnimationRotateAngle`
- minor fixes
-## [1.0-alpha03] - 2018-04-02
+## Classic View [1.0-alpha03] - 2018-04-02
- fixed #4: FAB icons rotate only once
- renamed attribute close_src to sdFabOpenedSrc
- added attributes `sdFabRotateOnToggle` and `sdExpansionMode`
- fixed various minor UI issues
-## [1.0-alpha02] - 2018-04-01
+## Classic View [1.0-alpha02] - 2018-04-01
- first public release
diff --git a/README.md b/README.md
index dc9d8ad0..c7478a10 100644
--- a/README.md
+++ b/README.md
@@ -8,10 +8,13 @@
-Android library providing an implementation of the [Material Design Floating Action Button Speed Dial](https://material.io/guidelines/components/buttons-floating-action-button.html#buttons-floating-action-button-transitions).
+Android library providing an implementation of
+the [Material Design Floating Action Button Speed Dial](https://material.io/guidelines/components/buttons-floating-action-button.html#buttons-floating-action-button-transitions)
+for both classic View and Compose.
## Features
-- [x] MinSdk 14
+
+- [x] MinSdk 14 for Classic View and 21 for Compose
- [x] Highly customizable (label, icon, ripple, fab and label background colors, themes support)
- [x] Same animations as in [Inbox by Gmail](https://play.google.com/store/apps/details?id=com.google.android.apps.inbox)
- [x] Option to have different icons for open/close state
@@ -21,60 +24,140 @@ Android library providing an implementation of the [Material Design Floating Act
- [x] Optional support for `RecyclerView` and `NestedScrollView` behavior
- [x] Support for VectorDrawable
- [x] Easy to use
+- [x] Compose ready!
## How to use
+
### Gradle setup
+
#### Official releases
+
The library is available on Jcenter so no additional repository is required.
Dependencies entry (latest version on Maven Central ![Maven Central](https://img.shields.io/maven-central/v/com.leinardi.android/speed-dial)):
+
```groovy
-implementation "com.leinardi.android:speed-dial:3.2.0"
+// Classic View only
+implementation "com.leinardi.android:speed-dial:3.3.0"
+
+// Compose only
+implementation "com.leinardi.android:speed-dial.compose:1.0.0-alpha01"
```
+
#### Snapshots (development branch)
+
You can use JitPack to test the latest `master` (remember that `master` is the development branch and can be unstable or completely broken).
Add the JitPack repository to your build file:
+
```groovy
maven { url 'https://jitpack.io' }
```
Add the dependency
+
```groovy
implementation 'com.github.leinardi:FloatingActionButtonSpeedDial:master-SNAPSHOT'
```
-### Basic use
+### Basic use for Compose
+
+#### `SpeedDial`
+
+Add the `SpeedDial()` Composable to the `floatingActionButton` of your `Scaffold`:
+
+```kotlin
+var speedDialState by rememberSaveable { mutableStateOf(SpeedDialState.Collapsed) }
+var overlayVisible: Boolean by rememberSaveable { mutableStateOf(speedDialState.isExpanded()) }
+Scaffold(
+ floatingActionButton = {
+ SpeedDial(
+ state = speedDialState,
+ onFabClick = { expanded ->
+ overlayVisible = !expanded
+ speedDialState = SpeedDialState(!expanded)
+ },
+ ) {
+
+ }
+ }
+) {
+ SpeedDialOverlay(
+ visible = overlayVisible,
+ onClick = {
+ overlayVisible = false
+ speedDialState = speedDialState.toggle()
+ },
+ )
+}
+```
+
+#### Action items
+
+Add the `FabWithLabel` items to the `SpeedDial`:
+
+```kotlin
+ SpeedDial(
+ state = speedDialState,
+ onFabClick = { expanded ->
+ overlayVisible = !expanded
+ speedDialState = SpeedDialState(!expanded)
+ },
+) {
+ item {
+ FabWithLabel(
+ onClick = { showToast(context, "Item 1 clicked!") },
+ labelContent = { Text(text = "Item 1") },
+ ) {
+ Icon(Icons.Default.Share, null)
+ }
+ }
+ item {
+ FabWithLabel(
+ onClick = { showToast(context, "Item 2 clicked!") },
+ labelContent = { Text(text = "Item 2") },
+ ) {
+ Icon(Icons.Default.Share, null)
+ }
+ }
+}
+```
+
+### Basic use for Classic View
+
#### `SpeedDialView`
+
Add the `SpeedDialView` to your layout:
```xml
-
+
+
```
#### Action items
+
Add the items to the `SpeedDialView`:
+
```kotlin
val speedDialView = findViewById(R.id.speedDial)
speedDialView.addActionItem(
SpeedDialActionItem.Builder(R.id.fab_no_label, R.drawable.ic_link_white_24dp)
- .create())
+ .create()
+)
```
-If the color customization is not requested, it is also possible to inflate the Action items
-form a Menu Resource:
+If the color customization is not requested, it is also possible to inflate the Action items form a Menu Resource:
+
```kotlin
speedDialView.inflate(R.menu.menu_speed_dial)
```
+
Only the attributes `android:id`, `android:icon` and `android:title` are supported.
#### Click listeners
+
Add the click listeners:
+
```kotlin
speedDialView.setOnActionSelectedListener(SpeedDialView.OnActionSelectedListener { actionItem ->
when (actionItem.id) {
@@ -89,7 +172,9 @@ speedDialView.setOnActionSelectedListener(SpeedDialView.OnActionSelectedListener
```
### Optional steps
+
#### Add the main action click listener
+
```kotlin
speedDialView.setOnChangeListener(object : SpeedDialView.OnChangeListener {
override fun onMainActionSelected(): Boolean {
@@ -104,27 +189,35 @@ speedDialView.setOnChangeListener(object : SpeedDialView.OnChangeListener {
```
#### Customizing the items
+
The `SpeedDialActionItem.Builder` provides several setters to customize the aspect of one item:
```kotlin
-speedDialView.addActionItem(SpeedDialActionItem.Builder(R.id.fab_custom_color, drawable)
+speedDialView.addActionItem(
+ SpeedDialActionItem.Builder(R.id.fab_custom_color, drawable)
.setFabBackgroundColor(ResourcesCompat.getColor(getResources(), R.color.material_white_1000, getTheme()))
.setFabImageTintColor(ResourcesCompat.getColor(getResources(), R.color.inbox_primary, getTheme()))
.setLabel(getString(R.string.label_custom_color))
.setLabelColor(Color.WHITE)
.setLabelBackgroundColor(ResourcesCompat.getColor(getResources(), R.color.inbox_primary, getTheme()))
.setLabelClickable(false)
- .create())
+ .create()
+)
```
+
Is is also possible to specify a theme to easily change the FAB background and ripple effect color:
```kotlin
-speedDialView.addActionItem(SpeedDialActionItem.Builder(R.id.fab_custom_theme, R.drawable.ic_theme_white_24dp)
+speedDialView.addActionItem(
+ SpeedDialActionItem.Builder(R.id.fab_custom_theme, R.drawable.ic_theme_white_24dp)
.setLabel(getString(R.string.label_custom_theme))
.setTheme(R.style.AppTheme_Purple)
- .create())
+ .create()
+)
```
+
```xml
+