Status Update
Comments
so...@google.com <so...@google.com>
an...@google.com <an...@google.com> #2
Yes, it is currently a known limitation. You have to choose manually how multiple elements will be positioned when put inside Surface. You can solve it with doing something like
Surface {
Column {
YourScreen()
}
}
or
Surface {
Stack {
YourScreen()
}
}
we are considering to make Column the default behaviour in future, but it is not yet ready
yu...@gmail.com <yu...@gmail.com> #3
I don't this it is a duplicate, because I already have only one child for the surface (Box) and the issue occurs ONLY when one of the TextFields contains text. The issue does not occur when this TextField has no text in it. If TextFieldValue contains text, application crashes upon selecting a row in the list.
an...@google.com <an...@google.com> #4
Surface(color = MaterialTheme.colors.background) {
when (val scr = screen.value) {
is Screen.List -> ListScreen(false, currentScreen, search)
is Screen.Details -> DetailsScreen(scr.transaction, currentScreen)
...
}
}
so or inside ListScreen or inside DetailsScreen there is a condition where you have multiple layouts. maybe something like
if (myConditionIsTrue) {
Text()
}
Button()
in this case when myConditionIsTrue we emit two layouts - Text and Button and we didn't define the layout strategy for them
yu...@gmail.com <yu...@gmail.com> #5
The crash occurs when switching to the DetailsScreen, in case if the TextView is filled. DeatilsScreen functionis defined as following:
@Composable
fun DetailsScreen(
transaction: Transaction?,
currentScreen: MutableState<Screen>
) {
/* mutable states omitted */
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
text = "${sum.value.text} to ${merchant.value.text}",
style = MaterialTheme.typography.body1
)
},
actions = {
IconButton(onClick = { /* code omitted */ }) {
Text(
text = "Save",
style = MaterialTheme.typography.body2,
)
}
}
)
},
bodyContent = {
Box(modifier = Modifier.fillMaxSize().wrapContentSize(Alignment.TopCenter)) {
Column {
ScrollableColumn {
Column {
Row {
NamedTextFieldInput(
header = "€",
state = sum,
)
Checkbox(
modifier = Modifier.debugBorder().padding(16.dp),
checked = !cancelled.value,
onCheckedChange = { cancelled.value = !cancelled.value }
)
}
}
Column {
NamedTextFieldInput(header = "to", state = merchant)
NamedTextFieldInput(header = "for", state = comment)
Row {
NamedTextFieldInput(
header = "on",
state = time,
enabled = transaction?.notification == null,
modifier = Modifier.weight(0.5f).padding(start = 16.dp),
)
NamedTextFieldInput(
header = "Trip",
state = trip,
modifier = Modifier.weight(0.5f).padding(end = 16.dp).padding(start = 8.dp),
)
}
InputDivider()
CategorySelector(category)
}
}
}
}
}
)
}
Should I create a GitHub repo with a project which reproduces the issue?
an...@google.com <an...@google.com> #6
yu...@gmail.com <yu...@gmail.com> #7
Hello,
I have adjusted my app in order to be able to reproduce the issue. Here is a link:
Instructions how to crash the app will be displayed on the screen (3 steps).
I hope this helps.
an...@google.com <an...@google.com> #8
By reading the code I didn't understand where is the case where you emit multiple layouts inside the Surface. But this will anyway be allowed in the nearest future.
By the way, you seems to use Crossfade incorrectly. Instead of
Crossfade(currentScreen) { screen ->
when (val scr = screen.value) {...}
}
it should be
Crossfade(currentScreen.value) { screen ->
when (val scr = screen) {...}
}
As the Crossfade starts the animation when you started passing another value into Crossfade as a param. with passing a state object this object is always the same so there is no animation
yu...@gmail.com <yu...@gmail.com> #9
Have you checked out the correct branch? I have prepared a branch named compose-ticket. I have removed everything which is related to google-services.json.
I will change the way Crossfade is used, thanks for the tip!
yu...@gmail.com <yu...@gmail.com> #10
Interesting, I have corrected the use of the Crossfade function and now the app does not crash :)
So I guess the issue is solved for me, but perhaps some checking in the crossfade function would be nice to have in order to prevent this kind of confusion.
If you want to look into the crash and the fix, please see this branch:
Commit which fixed the crash:
Thank you!
yu...@gmail.com <yu...@gmail.com> #11
BTW Crossfade use was copypasted from JetNews app where it is used like this. It was dev14 I think. I have checked the newest version and it was changed there as well.
Description
Android Studio Build: #AI-202.6397.94.42.6795674
Version of Gradle Plugin: com.android.tools.build:gradle:4.2.0-alpha09
Version of Gradle: 6.6.1 Version of Java: OpedJDK 8
OS: Windows 10
Preconditions: The issue is 100% reproducible in my application, unfortunately it requires Firebase credentials. I think I will be able to reproduce this issue without Firebase and publish it on GitHub (if this will help).
Steps to reproduce (see block comments):
Recovery: If "search" is empty, then the exception is not thrown