Kiprop Victor
10/13/2021, 3:58 PMFloatingActionButton(
onClick = {
coroutineScope.safeLaunch {
navController.navigate("AddTodoPage") {
launchSingleTop = true
}
}
},
shape = RoundedCornerShape(14.dp),
backgroundColor = Color.Transparent,
modifier = Modifier
.constrainAs(addFab) {
bottom.linkTo(parent.bottom)
end.linkTo(parent.end)
}
.offset(x = (-16).dp, y = (-24).dp)
.background(
brush = Brush.verticalGradient(
colors = BluePinkGradient()
),
shape = RoundedCornerShape(14.dp)
)
) {
Icon(
painter = painterResource(id = R.drawable.ic_add),
contentDescription = "Add icon",
tint = Color.White
)
}
But from the image below, the button has a "Whitish" shade on the plus icon. How can I remove that shade or a better way to set the FAB background to a gradient?
https://kotlinlang.slack.com/files/U022ZVC37PE/F02J1559G8H/image.png▾
Kirill Grouchnikov
10/13/2021, 4:08 PMKiprop Victor
10/13/2021, 4:28 PMfun BluePinkGradient(inverse: Boolean = false) = when (inverse) {
true -> listOf(
MutedBlue,
MutedPink
)
false -> listOf(
MutedPink,
MutedBlue
)
}
and the colros:
val MutedBlue = Color(0xFF26A69A)
val MutedPink = Color(0xFFEC407A)
Kiprop Victor
10/13/2021, 4:31 PMKirill Grouchnikov
10/13/2021, 5:56 PMAlbert Chang
10/13/2021, 11:51 PMColton Idle
05/16/2023, 3:45 PMAlbert Chang
05/17/2023, 3:37 AM@Composable
fun FloatingActionButton(
onClick: () -> Unit,
backgroundBrush: Brush,
contentColor: Color,
modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = MaterialTheme.shapes.small.copy(CornerSize(percent = 50)),
elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalContentColor provides contentColor,
LocalContentAlpha provides contentColor.alpha
) {
Box(
contentAlignment = Alignment.Center,
modifier = modifier
.defaultMinSize(minWidth = 56.dp, minHeight = 56.dp)
.shadow(
elevation = elevation.elevation(interactionSource = interactionSource).value,
shape = shape,
clip = false
)
.background(brush = backgroundBrush, shape = shape)
.clip(shape)
.clickable(
interactionSource = interactionSource,
indication = rememberRipple(),
role = Role.Button,
onClick = onClick
)
) {
content()
}
}
}