Hello, I made a custom switch with a number of size parameters. I would like to reuse that composable, but smaller. Is there a way of assigning a scale to the composable, or do I have to pass each size parameter along with the other function params? Here is what the switch looks like:
@Composable
fun CustomToggle(
color: Color, gradientColor: Color, selected: Boolean,
onSelected: () -> Unit
) {
val toggleAlign = animate(if (selected) 65.dp else 5.dp)
Box() {
Box(
modifier = Modifier
.height(40.dp)
.width(100.dp)
.clip(RoundedCornerShape(50))
.background(HorizontalGradient(
0.0f to color,
0.5f to gradientColor,
1.0f to color,
startX = 0.0f,
endX = with(DensityAmbient.current) { 100.dp.toPx() }
)
),
) {}
Surface(
modifier = Modifier.size(30.dp)
.align(Alignment.CenterStart)
.offset(toggleAlign)
.clip(RoundedCornerShape(50))
.toggleable(value = selected, onValueChange = { onSelected() }),
color = Color.White,
elevation = 7.dp
) {}
}
}