Mohammad Sianaki
10/09/2021, 1:25 PM@Composable
fun Demo() {
val scroll = rememberScrollState(0)
Column(modifier = Modifier.fillMaxSize()) {
CollapsingToolbar(scroll = scroll.value, title = "Screen Title")
Body(scroll)
}
}
@Composable
fun Body(scroll: ScrollState) {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(scroll)
) {
repeat(5) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.background(Color.Red)
)
}
}
}
@Composable
fun CollapsingToolbar(
scroll: Int,
title: String,
onNavigateUpClicked: () -> Unit = {},
) {
val collapseRange = with(LocalDensity.current) {
(150.dp - 56.dp).toPx()
}
val collapseFraction = (scroll / collapseRange).coerceIn(0f, 1f)
Box(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 56.dp)
.wrapContentHeight()
.background(Color.Green),
) {
IconButton(
onClick = onNavigateUpClicked,
modifier = Modifier
.padding(start = 8.dp, top = 8.dp)
.background(Color.Cyan)
.align(Alignment.TopStart)
) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = null,
modifier = Modifier.background(Color.Red)
)
}
Text(
text = title,
style = MaterialTheme.typography.h6,
modifier = Modifier
.padding(start = 24.dp, top = 150.dp * (1 - collapseFraction))
.align(Alignment.CenterStart)
.offset(x = 32.dp * collapseFraction)
)
}
}
eygraber
10/10/2021, 1:44 AMsetValue
import issue ever get resolved? I thought I saw that it was a while ago, but I'm re-exploring Compose and I'm running into issues with it not getting imported.Nikhil
10/10/2021, 7:09 AMLaunchedEffect(){…}
along with withFrameNanos{..}
to update a state (using loop, say for creating a game or animation). Can the previous frame be preserved without recomposition in jetpack compose? Something like preserveDrawingBuffer
in JS.elye
10/10/2021, 10:20 AMsetContent
, cause to it be slower. The profile looks as the image below. How can it be speed up?
FYI, the detail question in.
https://stackoverflow.com/questions/69514265/how-to-make-recyclerview-with-composable-viewholder-render-fasteralorma
10/10/2021, 3:23 PMCsaba Szugyiczki
10/10/2021, 4:06 PMfillMaxHeight
height, and then applying the verticalScroll
modifier on it. But if we use an inner Column, then the way it is measured is different than what we got used to using XML layouts. Setting an inner Columns height to wrapContentHeight
and applying .weight(1f)
on it only respects the weight modifier, but the wrapContentHeight
modifier is ignored. This makes the Column
cut its children.
Is there a workaround for this?
Sample code in 🧵Matti MK
10/11/2021, 7:57 AMMichael Ndiritu
10/11/2021, 8:10 AMZoltan Demant
10/11/2021, 9:14 AMZoltan Demant
10/11/2021, 10:51 AMOrhan Tozan
10/11/2021, 11:12 AMMike Speed
10/11/2021, 1:46 PMBadgeBox(badgeContent = { Text(value) }) {
//whatever
}
I have a BadgeBox
like this, but if the value is 0
, I want to badge to be hidden. If I pass null to badgeContent
, the circle still shows but with nothing in it. How do I hide it completely while still showing the inner content?bodo
10/11/2021, 1:59 PMSurface(
modifier = Modifier.padding(10.dp)
shape = AppTheme.shapes.medium,
color = AppTheme.colors.surface
) {
content()
}
It is only working when i add a box around the content(). is this the correct way to do it???
Surface(
shape = AppTheme.shapes.medium,
color = AppTheme.colors.surface
) {
Box(modifier = Modifier.padding(10.dp)) {
content()
}
}
Cicero
10/11/2021, 3:49 PMDamian Zawadzki
10/11/2021, 5:35 PMMahmoud Alim
10/11/2021, 8:50 PMaherbel
10/11/2021, 11:34 PMShabinder Singh
10/12/2021, 6:35 AMTgo1014
10/12/2021, 7:40 AMSharedFlow
?Filippo Vigani
10/12/2021, 9:25 AMRow
, Column
, LazyVerticalGrid
and the accompanist FlowRow
) trying to achieve something like CSS `minmax` function for columns.
Basically I'd like to lay out a list of elements such that they take all the available space, as in visually they always occupy the whole width of the screen, but are still constrained by a min size and a max size. Is there any way to achieve that using Jetpack Compose?K Merle
10/12/2021, 10:21 AMUtkarsh Tiwari
10/12/2021, 2:27 PMTolriq
10/12/2021, 3:58 PMAshu
10/12/2021, 5:17 PMChris Fillmore
10/12/2021, 5:37 PMBasicTextField
and TextField
with respect to cursor placement and/or LTR/RTL behaviour? The code below produces a text field where the cursor stays to the left, and thus text comes out “backwards” as you type. A TextField
with the same parameters works as expected. Thanks!
BasicTextField(
value = TextFieldValue(text),
onValueChange = { onValueChange(it.text) },
textStyle = TextStyle.Default.copy(
color = Color.White,
fontSize = fontSize.em,
fontWeight = FontWeight.Bold,
),
enabled = /* calculated from some state */,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
keyboardOptions = KeyboardOptions(
autoCorrect = false,
),
)
Colton Idle
10/12/2021, 5:53 PMeygraber
10/12/2021, 10:16 PMSnapshotStateList
?eygraber
10/12/2021, 10:22 PMSnapshotStateList
and Flow<List<T>>.collectAsState
?pavankumar
10/13/2021, 2:25 AMNipun Rajput
10/13/2021, 7:32 AMNipun Rajput
10/13/2021, 7:32 AMWill Shelor
10/15/2021, 9:42 PMNipun Rajput
10/18/2021, 5:45 AM