Skip to content

Commit 60823c5

Browse files
authored
Merge pull request #3 from Kazoroo/main
Allow to set own FAB icon and its rotation rate.
2 parents 1b509c7 + 3e02113 commit 60823c5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

speeddial/src/main/java/de/charlex/compose/SpeedDialFloatingActionButton.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.ui.draw.rotate
1818
import androidx.compose.ui.draw.scale
1919
import androidx.compose.ui.graphics.Color
2020
import androidx.compose.ui.graphics.painter.Painter
21+
import androidx.compose.ui.graphics.vector.ImageVector
2122
import androidx.compose.ui.layout.Layout
2223
import androidx.compose.ui.res.painterResource
2324
import androidx.compose.ui.text.font.FontWeight
@@ -40,6 +41,8 @@ fun <T : SpeedDialData> SpeedDialFloatingActionButton(
4041
fabContentColor: Color = contentColorFor(fabBackgroundColor),
4142
speedDialBackgroundColor: Color = MaterialTheme.colors.secondaryVariant,
4243
speedDialContentColor: Color = contentColorFor(speedDialBackgroundColor),
44+
fabIcon: ImageVector = Icons.Default.Add,
45+
fabIconRotationDegree: Float = 45f,
4346
) {
4447
var expanded by remember { mutableStateOf(initialExpanded) }
4548

@@ -85,7 +88,7 @@ fun <T : SpeedDialData> SpeedDialFloatingActionButton(
8588
tween(durationMillis = animationDuration)
8689
}
8790
) {
88-
if (it) 45f else 0f
91+
if (it) fabIconRotationDegree else 0f
8992
}
9093
val fabBackgroundColorAnimated by transition.animateColor(
9194
label = "fabBackgroundColor",
@@ -121,7 +124,7 @@ fun <T : SpeedDialData> SpeedDialFloatingActionButton(
121124
) {
122125
Icon(
123126
modifier = Modifier.rotate(fabIconRotation),
124-
imageVector = Icons.Default.Add,
127+
imageVector = fabIcon,
125128
contentDescription = null,
126129
)
127130
}

0 commit comments

Comments
 (0)