Marko Novakovic
05/17/2021, 10:41 AMMarko Novakovic
05/17/2021, 10:42 AM@Composable
fun CircleMenu(
modifier: Modifier = Modifier,
categories: List<Category>,
selectCategory: (Category) -> Unit,
) {
Box(modifier = modifier.fillMaxSize()) {
Cloud(categories = categories, onCategorySelected = selectCategory)
}
}
@Composable
private fun Cloud(
modifier: Modifier = Modifier,
categories: List<Category>,
onCategorySelected: (Category) -> Unit,
) {
var offset by remember { mutableStateOf(Offset.Zero) }
Box(
modifier = modifier
.offset { IntOffset(offset.x.roundToInt(), offset.y.roundToInt()) }
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
change.consumeAllChanges()
offset += dragAmount
}
},
contentAlignment = Alignment.Center
) {
Circle(...)
Icon(...)
}
}
Marko Novakovic
05/17/2021, 10:43 AM@Composable
private fun Circle(
modifier: Modifier = Modifier,
state: CircleMenuState,
) {
val size by animateDpAsState(targetValue = if (state == CircleMenuState.Collapsed) 200.dp else 0.dp)
Surface(
modifier = modifier.size(size),
color = Color.Magenta,
elevation = 8.dp
) {}
}
Albert Chang
05/17/2021, 1:12 PMBox
with the circle's max size and contentAlignment
set to center.Marko Novakovic
05/17/2021, 3:43 PM