Mehdi Haghgoo
08/30/2020, 8:38 AMAlexander Sitnikov
08/30/2020, 10:58 AMThe restart behavior is designed to help your application adapt to new configurations by automatically reloading your application with alternative resources that match the new device configuration.But compose screen can easily recompose with new configuration without having to restart an activity. Or if resources are read inside composable function via
dimensionResource()
etc, we still need to recreate activity?dimsuz
08/30/2020, 11:11 AMflorent
08/30/2020, 12:11 PMcarbaj0
08/30/2020, 3:23 PM@Composable
private fun ZoomControls(
zoom: Float,
onZoomChanged: (Float) -> Unit
) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
ZoomButton("-", onClick = { onZoomChanged(zoom * 0.8f) })
ZoomButton("+", onClick = { onZoomChanged(zoom * 1.2f) })
}
}
ZoomControls(zoom) {
zoom = it.coerceIn(MinZoom, MaxZoom)
}
This is a bit confusing since being a Composable, I expect the lambda to be a content: @Composable () -> Unit
instead of a callback.Archie
08/30/2020, 3:25 PMTopAppBar
consume Window Inset
? Doing:
TopAppBar(
modifier = Modifier.fillMaxWidth()
.statusBarsPadding()
.wrapContentHeight(),
...
just result in something like this where the added padding is just white and not the TopAppbar Color.Davide Giuseppe Farella
08/30/2020, 4:15 PMScaffold(topBar = ..., bottomBar = ..., ...) {
when (currentScreen) {
...
}
}
Problem is that some screen have fab, some have search bar in topBar, which has actions, etc.
So I change that as
val content @Composable () -> Unit = {
when (currentScreen) {
...
}
}
if (currentScreen.isHomeDestination) {
Scaffold(...) { content() }
else
content()
and it was still looking nice on the UI prospective, but ugly on the code, because some screens will be wrapped in Scaffold, while some will be wrapped somewhere else ( 👆 ),
So I created a custom Scaffold and moved into my screens
@Composable
fun SearchMovie(...) {
HomeScaffold {
...
}
}
But now it looks ugly on the UI, because I open my drawer, but when I select an item it replaces the whole screen, so my drawer disappear without the animation.
What would be the best way to deal with that?Karthick
08/30/2020, 5:25 PMEric Martori
08/30/2020, 8:34 PMonImeAction
when used in the header: it doesn't work properly. It happens in what I have done and the "finished" versión given in the codeLab. Is this a known issue with the TextField
composable or is there some problem with my setup?
That TextField also won't let me delete the last character.
This things only happen in the header so I don't know if this issues are with the TextField
or something else about have this lab teaches about how to manage stateSergey Y.
08/30/2020, 10:10 PMdoubov
08/30/2020, 10:48 PMKyant
08/31/2020, 1:17 AMIcyrockton
08/31/2020, 1:27 AMfengdai
08/31/2020, 3:02 AM@Stable
’s guarantees? > The result of equals will always return the same result for the same two instances.Pavel Ratushnyi
08/31/2020, 6:48 AMe: androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 0.1.0-dev16) expects a minimum runtime version of 0.1.0-dev16.
But i specify in build.gradle for 2 modules (feature module when i want to use compose and app module) latest version of compose:
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerVersion '1.4.0'
kotlinCompilerExtensionVersion '1.0.0-alpha01'
}
kotlinOptions {
jvmTarget = jvmTargetVer
useIR = true
}
}
I use gradle plugin version 4.2.0-alpha08:
classpath 'com.android.tools.build:gradle:4.2.0-alpha08'
and gradle version 6.6:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
and kotlin version 1.4.0:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0"
Could anyone help me please? What i'm doing wrong?Zan Skamljic
08/31/2020, 8:43 AMTomáš Kuhn
08/31/2020, 11:00 AMNiklas Schnettler
08/31/2020, 2:10 PMMarcin Środa
08/31/2020, 2:13 PMDavide Giuseppe Farella
08/31/2020, 6:46 PMTopAppBar
and BottomAppBar
, in dark theme, have a way lighter background of what I set?
I’ve set Color(0xFF1c1c1c)
but they’re so light, specially the Bottom one. I can see it very clearly compared to the status bar, which I’ve set as #1c1c1c
Colton Idle
08/31/2020, 9:14 PMEric Martori
08/31/2020, 9:18 PM@Composable
fun Body() {
Stack(Modifier.fillMaxSize()) {
var items by remember { mutableStateOf(listOf(0)) }
items.reversed().forEach {
Item(
it,
modifier = Modifier
.clickable(onClick = {
items += items.last() + 1
})
.gravity(Alignment.Center)
.matchParentSize()
.padding((100 - (it * 10)).dp)
)
}
}
}
@Composable
fun Item(num: Int, modifier: Modifier = Modifier) {
val color = remember(num) { Color(Random.nextFloat(), Random.nextFloat(), Random.nextFloat()) }
Box(modifier = modifier, backgroundColor = color, gravity = Alignment.Center) {
Text(text = "$num", style = MaterialTheme.typography.h1)
}
}
Sivan
09/01/2020, 7:01 AMContextAmbient.current
but android studio is unable to generate the error message.
So I ended up using the context like this
val context = ambientOf { ContextAmbient } as Context
But when I fire the intent, the app crashes with the following error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sivan.pinotes, PID: 25739
java.lang.ClassCastException: androidx.compose.runtime.DynamicProvidableAmbient cannot be cast to android.content.Context
at com.sivan.pinotes.MainActivityKt$extendedFAB$2$1.invoke(MainActivity.kt:65)
at com.sivan.pinotes.MainActivityKt$extendedFAB$2$1.invoke(Unknown Source:0)
at androidx.compose.foundation.ClickableKt$clickable$2$tap$1.invoke(Clickable.kt:79)
If DynamicProvidableAmbient cannot be cast to a Context, are there any alternatives to this approach?Rodri Represa
09/01/2020, 7:03 AMdimsuz
09/01/2020, 12:11 PMvar inputState: TextFieldValue by mutableStateOf(TextFieldValue())
fails with an error
Type 'MutableState<TypeVariable(T)>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
Archie
09/01/2020, 1:15 PMefemoney
09/01/2020, 1:39 PMefemoney
09/01/2020, 1:43 PMJD
09/01/2020, 1:45 PMjannis
09/01/2020, 2:08 PMe: java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.common.messages.MessageCollector$DefaultImpls.report$default(org.jetbrains.kotlin.cli.common.messages.MessageCollector, org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity, java.lang.String, org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation, int, java.lang.Object)'
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Internal compiler error. See log for more details