Mariano Zorrilla
03/11/2020, 2:36 PMFunctions which invoke @Composable functions must be marked with the @Composable annotation
Any ideas?Mariano Zorrilla
03/11/2020, 2:41 PMSrSouza
03/11/2020, 6:55 PMcaelum19
03/11/2020, 8:42 PMKevin Hester
03/11/2020, 10:26 PMMBegemot
03/12/2020, 12:04 PMKazemihabib1996
03/12/2020, 4:57 PM@Composable
private fun HomeScreenTopSection(post: Post) {
ProvideEmphasis(emphasis = EmphasisLevels().high) {
Text(
modifier = LayoutPadding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 0.dp),
text = "Top stories for you",
style = MaterialTheme.typography().subtitle1
)
}
Ripple(bounded = true) {
Clickable(onClick = {
navigateTo(Screen.Article(post.id))
}) {
PostCardTop(post = post)
}
}
HomeScreenDivider()
}
As you see it's an incomplete composable function because we are calling 3 other functions without a Row or Column, and HomeScreenTopSection
can draw correctly just because the parent has called it inside a column:
https://github.com/android/compose-samples/blob/master/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreen.kt#L88
Column(modifier = modifier) {
HomeScreenTopSection(post = postTop)
HomeScreenSimpleSection(posts = postsSimple)
HomeScreenPopularSection(posts = postsPopular)
HomeScreenHistorySection(posts = postsHistory)
}
So if I call HomeScreenTopSection
outside a column or row, there are multiple possible solutions:
1) the compose framework can decide to put it inside a Row for example
2) Keep the first one and throw away others and seems that compose follows this approach at the moment.
3) Threw error
I think first and second solutions are not appropriate solutions and seems that throwing compile time error is not possible and just remains run time error.
Our functions return Unit, if they return something the HomeScreenTopSection
should return a list and the problem is solved we can throw compile time errors.
but with returning functions we loose lots of its benefits so that's not an option here,
but what about adding annotations like ThisShouldBeCalledInsideRowOrColumn
(I know it's a worst naming you ever seen 😬) ?Matthewdhowell
03/12/2020, 10:47 PMTash
03/13/2020, 1:08 AMKazemihabib1996
03/13/2020, 4:02 PMSurface(color = color, contentColor = contentColor, elevation = elevation, shape = shape) {
Row(
LayoutWidth.Fill + LayoutPadding(
start = AppBarHorizontalPadding,
end = AppBarHorizontalPadding
) + LayoutHeight(AppBarHeight),
arrangement = Arrangement.SpaceBetween,
children = children
)
}
Kazemihabib1996
03/13/2020, 6:49 PMSemantics
from the documentation:
for example here:
Box(LayoutHeight.Fill + LayoutFlexible(1f), gravity = ContentGravity.BottomStart) {
val baselineOffset = with(DensityAmbient.current) { TitleBaselineOffset.toDp() }
AlignmentLineOffset(alignmentLine = LastBaseline, after = baselineOffset) {
Semantics(container = true) {
CurrentTextStyleProvider(value = MaterialTheme.typography().h6) {
Row {
title()
}
}
}
}
}
Can you please explain what is Semantics
?Lin Min Phyo
03/15/2020, 6:36 AM@Preview
@Composable
fun FullFeaturedTable() {
val numbers = mutableListOf(1, 2, 100, 500)
DataTable(
columns = 1,
sorting = DefaultDataTableSorting(
sortableColumns = setOf(0),
onSortRequest = { column , isAscending ->
if (isAscending) {
numbers.sortBy { it }
} else {
numbers.sortByDescending { it }
}
})
) {
headerRow { Text(text = "Number") }
for (number in numbers) {
dataRow { Text("$number") }
}
}
}
Val Salamakha
03/15/2020, 8:15 AM......
SetContent{
......
FullFeaturedTable()
......
}
@Composable
fun FullFeaturedTable() {
val numbers = mutableListOf(1, 2, 100, 500)
DataTable(
columns = 1,
sorting = DefaultDataTableSorting(
sortableColumns = setOf(0),
onSortRequest = { column , isAscending ->
if (isAscending) {
numbers.sortBy { it }
} else {
numbers.sortByDescending { it }
}
})
) {
headerRow { Text(text = "Number") }
for (number in numbers) {
dataRow { Text("$number") }
}
}
}
@Preview
@Composable
fun FeaturedTable() {
FullFeaturedTable()
}
Matthewdhowell
03/16/2020, 11:30 AMKazemihabib1996
03/16/2020, 5:19 PMKazemihabib1996
03/16/2020, 7:34 PM200.ipx
and MaxWidth to 300.ipx but the when I print the constraints minWidth is 0.ipx
, MaxWidth's value is 300.ipx as expected.
WithConstraints { constraints ->
Log.d("Constraints", constraints.toString())
with(DensityAmbient.current) {
Container( modifier = LayoutWidth.Constrain(200.ipx.toDp(), 300.ipx.toDp())) {
WithConstraints { constraints2 ->
Log.d("Constraints2", constraints2.toString())
Column() {
Text("Test1")
Text("Test2")
}
}
}
}
}
The log:
D/Constraints: Constraints(minWidth=0.ipx, maxWidth=800.ipx, minHeight=0.ipx, maxHeight=1173.ipx)
D/Constraints2: Constraints(minWidth=0.ipx, maxWidth=300.ipx, minHeight=0.ipx, maxHeight=1173.ipx)
Kevin Hester
03/17/2020, 1:07 AMoscarg798
03/17/2020, 8:44 PMe: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
amar_1995
03/18/2020, 1:27 AMBrian Gardner
03/18/2020, 1:01 PMAdapterList
. If I have actions in the individual row items that should update the view state, I’ve found that using a MutableState
for the individual row views does not work. I’m guessing this is because even if the row view tries to set its state it still needs the state of the AdapterList to update in order to trigger the recomposition. My question then, is how should the state be updated for the AdapterList
? In the itemCallback
of AdapterList
we only get the item passed to the lambda, not an index. Is it safe to grab the index of the item from within the itemCallback
to update the list state?Klaas Kabini
03/19/2020, 3:54 AMVinay Gaba
03/19/2020, 5:50 AMdagomni
03/19/2020, 12:17 PMjava.lang.NoSuchMethodError: No static method setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function0;)Landroidx/compose/Composition; in class Landroidx/ui/core/WrapperKt; or its super classes
Does anyone have any idea why this happens when calling setContent { }?
I have tried:
• 0.1.0-dev05, dev06 and dev07
• Kotlin 1.3.61 and 1.3.70
• with and without buildFeatures { compose true } and/or composeOptionsZach Klippenstein (he/him) [MOD]
03/19/2020, 3:20 PMOnChildPositionedModifier
seems surprising to me. Given that a node can have any number of children, I'm glad the kdoc calls out that the callback will be invoked once for every child. But it would seem a lot more intuitive (and more consistent with the Layout
composable) to invoke the callback once per layout pass, and instead pass in the list of LayoutCoordinates
corresponding to all the children laid out in that pass. The current API makes it difficult to determine if two given callback invocations correspond to two siblings in the same pass or the same child in subsequent passes. What's the reasoning behind this API design?Miguel A. Ruiz
03/19/2020, 9:26 PMZsolt
03/19/2020, 10:30 PMjava.lang.IllegalStateException: Couldn't find composer parameter
, any ideas? (stack trace in thread)Miguel A. Ruiz
03/19/2020, 10:31 PMZsolt
03/19/2020, 11:03 PMLayoutPadding(bottom = (-10).dp, end = (-5).dp)
Beyond the crash, what's the suggested way to achieve the same positioning?Zsolt
03/19/2020, 11:20 PMtint
parameter, which is gone now.
I see colorFilter
which needs a BlendMode
beyond just passing the color. Looking at the possible values, hue
is the one I guess I should use (commented "The effect is to tint the destination image with the source image.").
To my disappointment this is how it looks:
hue(null), // Not Supported
Is there any other suitable replacement to achieve tinting the image?Klaas Kabini
03/20/2020, 4:51 AMKlaas Kabini
03/20/2020, 4:51 AMLeland Richardson [G]
03/20/2020, 9:45 PMKlaas Kabini
03/24/2020, 6:36 AM