brandonmcansh
07/21/2021, 3:15 PMBottomAppBarCutoutOffset
of the BottomAppBar?alorma
07/21/2021, 3:22 PMDp
, you can use animateDpAsState? https://developer.android.com/jetpack/compose/animation#animate-as-statebrandonmcansh
07/21/2021, 3:25 PMbrandonmcansh
07/21/2021, 3:25 PMbrandonmcansh
07/21/2021, 3:27 PMalorma
07/21/2021, 3:29 PMbrandonmcansh
07/21/2021, 3:29 PMprivate fun Path.addCutoutShape(layoutDirection: LayoutDirection, density: Density) {
// The gap on all sides between the FAB and the cutout
val cutoutOffset = with(density) { BottomAppBarCutoutOffset.toPx() }
val cutoutSize = Size(
width = fabPlacement.width + (cutoutOffset * 2),
height = fabPlacement.height + (cutoutOffset * 2)
)
val cutoutStartX = fabPlacement.left - cutoutOffset
val cutoutEndX = cutoutStartX + cutoutSize.width
val cutoutRadius = cutoutSize.height / 2f
// Shift the cutout up by half its height, so only the bottom half of the cutout is actually
// cut into the app bar
val cutoutStartY = -cutoutRadius
addOutline(cutoutShape.createOutline(cutoutSize, layoutDirection, density))
translate(Offset(cutoutStartX, cutoutStartY))
// TODO: consider exposing the custom cutout shape instead of just replacing circle shapes?
if (cutoutShape == CircleShape) {
val edgeRadius = with(density) { BottomAppBarRoundedEdgeRadius.toPx() }
// TODO: possibly support providing a custom vertical offset?
addRoundedEdges(cutoutStartX, cutoutEndX, cutoutRadius, edgeRadius, 0f)
}
}
brandonmcansh
07/21/2021, 3:30 PMbrandonmcansh
07/21/2021, 3:34 PMalorma
07/21/2021, 3:34 PMbrandonmcansh
07/21/2021, 3:34 PMbrandonmcansh
07/21/2021, 3:37 PMalorma
07/21/2021, 3:40 PMbrandonmcansh
07/21/2021, 3:42 PMbrandonmcansh
07/21/2021, 3:47 PManimateFloatAsState
for the scale and apply that the FloatingActionButton
modifier in tandem with M.size(width = fabWidth * scale, height = fabHeight * scale)