Kevin Hester
02/17/2020, 8:43 PMfun MessagesContent() {
Column(modifier = LayoutSize.Fill) { // want to fill entire screen
Column(modifier = LayoutSize.Fill) {
messages.value.forEach { // I want this list of messages to fill most of the view
MessageCard(
it, modifier = LayoutPadding(
left = sidePad,
right = sidePad,
top = topPad,
bottom = topPad
)
)
}
}
Surface(
modifier = LayoutPadding(8.dp) + LayoutSize.Min(40.dp, 40.dp),
color = backgroundColor,
shape = RoundedCornerShape(4.dp)
) {
TextField(
...
)
}
}
}
Louis Pullen-Freilich [G]
02/17/2020, 9:01 PMLayoutFlexible
- it allows you to assign weight to something inside a row or columnKevin Hester
02/17/2020, 9:11 PMLouis Pullen-Freilich [G]
02/17/2020, 10:05 PMKevin Hester
02/17/2020, 10:06 PMLouis Pullen-Freilich [G]
02/17/2020, 10:17 PMKevin Hester
02/17/2020, 10:19 PM@Composable
fun MessagesContent() {
Column(modifier = LayoutSize.Fill) {
val sidePad = 8.dp
val topPad = 4.dp
Column(modifier = LayoutFlexible(1.0f)) {
messages.value.forEach {
MessageCard(
it, modifier = LayoutPadding(
left = sidePad,
right = sidePad,
top = topPad,
bottom = topPad
)
)
}
}
val message = state { "text message" }
val backgroundColor = palette.secondary.copy(alpha = 0.12f)
Surface(
modifier = LayoutPadding(8.dp),
color = backgroundColor,
shape = RoundedCornerShape(4.dp)
) {
TextField(
value = message.value,
onValueChange = { message.value = it },
textStyle = TextStyle(
color = palette.onSecondary.copy(alpha = 0.8f)
),
imeAction = ImeAction.Send,
onImeActionPerformed = {
<http://MessagesState.info|MessagesState.info>("did IME action")
MessagesState.addMessage(
TextMessage(
"fixme",
message.value
)
)
},
modifier = LayoutPadding(4.dp)
)
}
}
}
Louis Pullen-Freilich [G]
02/17/2020, 10:21 PMKevin Hester
02/17/2020, 10:21 PMLouis Pullen-Freilich [G]
02/17/2020, 10:22 PMKevin Hester
02/17/2020, 10:22 PMLouis Pullen-Freilich [G]
02/17/2020, 10:26 PMSpacer(LayoutFlexible(1f))
between the column and the surface?Kevin Hester
02/17/2020, 10:26 PMLouis Pullen-Freilich [G]
02/17/2020, 10:35 PMVerticalScroller
, right? If you remove the scroller and other stuff, and just call this one function as the root, does it work on device?Kevin Hester
02/17/2020, 10:35 PMLouis Pullen-Freilich [G]
02/17/2020, 10:40 PMKevin Hester
02/17/2020, 10:40 PMLouis Pullen-Freilich [G]
02/17/2020, 10:40 PMKevin Hester
02/17/2020, 10:41 PMLouis Pullen-Freilich [G]
02/17/2020, 10:44 PMKevin Hester
02/17/2020, 10:45 PM