Nat Strangerweather
04/29/2021, 8:07 PMNat Strangerweather
04/29/2021, 8:07 PMNat Strangerweather
04/29/2021, 8:08 PMColumn(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(0.75f)
.padding(20.dp)
.background(Color.DarkGray)
.clipToBounds()
) {
Row(
Modifier
.fillMaxSize(), horizontalArrangement = Arrangement.SpaceBetween
) {
Column() {
repeat(7) {
Tile()
}
}
Column() {
repeat(7) {
Tile()
}
}
}
}
Chris Sinco [G]
04/29/2021, 8:12 PMTile
Composable as well?Chris Sinco [G]
04/29/2021, 8:13 PMIcon
Nat Strangerweather
04/29/2021, 8:13 PMNat Strangerweather
04/29/2021, 8:14 PMfun Tile() {
val coroutineScope = rememberCoroutineScope()
val offsetX = remember { Animatable(0f) }
val offsetY = remember { Animatable(0f) }
Box(
Modifier
.offset {
IntOffset(
offsetX.value.roundToInt(),
offsetY.value.roundToInt()
)
}
.padding(3.dp)
.fillMaxWidth(1 / 7f)
.aspectRatio(1f)
.clip(RoundedCornerShape(5.dp))
.background(Color.Magenta)
.draggable(
state = rememberDraggableState { delta ->
coroutineScope.launch {
offsetX.snapTo(offsetX.value + delta)
}
},
orientation = Orientation.Horizontal,
onDragStopped = {
coroutineScope.launch {
offsetX.animateTo(
targetValue = 0f,
animationSpec = tween(
durationMillis = 1000,
delayMillis = 0
)
)
}
}
))
{
}
Olivier Patry
04/29/2021, 8:19 PM.fillMaxWidth(1 / 7f)
Not sure but when computing this, first column have 100% of the width but for second one only remains 100% minus the width took by first column? (then tile being smaller with 1:1 aspect ratio, less height took as well).
I don't know if this is the way layout are done though, just a thought.Sergey Y.
04/29/2021, 8:19 PMfillMaxWidth(1/7f)
, once you added the first column, the available horizontal space is reduced by its size, and the width of the second column is within the remaining available space.Olivier Patry
04/29/2021, 8:20 PMfillMaxWidth()
on your tiles?Nat Strangerweather
04/29/2021, 8:22 PMNat Strangerweather
04/29/2021, 8:22 PMOlivier Patry
04/29/2021, 8:25 PM@Composable
fun Mychild(someData: String, modifier: Modifier = Modifier) {
Box(modifier) {
}
}
And then:
@Composable
fun Myparent() {
Mychild("blah", Modifier.someproperty())
}
Olivier Patry
04/29/2021, 8:26 PMNat Strangerweather
04/29/2021, 8:27 PMNat Strangerweather
04/29/2021, 8:41 PMOlivier Patry
04/29/2021, 8:50 PMNat Strangerweather
04/29/2021, 8:51 PMOlivier Patry
04/29/2021, 8:53 PMOlivier Patry
04/29/2021, 8:53 PMOlivier Patry
04/29/2021, 8:53 PMOlivier Patry
04/29/2021, 8:54 PMNat Strangerweather
04/29/2021, 8:55 PMNat Strangerweather
04/29/2021, 8:55 PM