Julius Marozas
07/23/2020, 9:52 PM'surface: Color' is only available since Kotlin 1.4 and cannot be used in Kotlin 1.3
I have also set the "Update channel" in Languages & Frameworks > Kotlin (Android Studio settings) to "Early Access Preview 1.4.x".shikasd
07/23/2020, 10:30 PMamar_1995
07/24/2020, 7:48 AMgalex
07/24/2020, 10:12 AMBenjO
07/24/2020, 11:41 AMFoobar
composable displaying Foo
and Bar
children composables. Foobar
has two state variables.
@Composable
fun Foobar(fooFlow: StateFlow<Long>, barFlow: StateFlow<Long>) {
val foo by fooFlow.collectAsState()
val bar by barFlow.collectAsState()
Column {
Foo(foo)
Bar(bar)
}
}
@Composable
fun Foo(value: Long) {
Text("Foo $value")
}
@Composable
fun Bar(value: Long) {
Text("Bar $value")
}
Every time either fooFlow
or barFlow
receives a new value, both Foo
and Bar
are recomposed (onCommit is triggered) . I was hoping that only the composable using the flow value would be refreshed.
The only solution I see is to pass each StateFlow down to the children. I’m I correct ?Archie
07/24/2020, 12:58 PMstate { ... }
across configuration changes?Jorge Castillo
07/24/2020, 1:43 PMLayout
?Marcin Środa
07/24/2020, 2:09 PM2020-07-24 16:05:59.308 582-659/system_process W/InputDispatcher: channel '5963efc .ui.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
2020-07-24 16:05:59.308 582-659/system_process E/InputDispatcher: channel '5963efc ui.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
Mohamed Elfiky
07/24/2020, 3:18 PMHalil Ozercan
07/24/2020, 3:52 PMComparison of incompatible enums 'Direction' and '[ERROR : Direction.LEFT]' is always unsuccessful
Android Studio doesn't show any errors though. The offending line is #4
.dragGestureFilter(
dragObserver = dragObserver,
canDrag = {
it == Direction.LEFT || it == Direction.RIGHT
}
)
David Mcrae Jr
07/24/2020, 5:58 PMbohregard
07/24/2020, 10:14 PMhenrikhorbovyi
07/25/2020, 5:24 AMandroid.useAndroidX=true
android.enableJetifier=true
To the gradle.properties, but it would impact imports in the entire project 😞
I've tried to add a gradle.properties for the specific module, but it didn't workMehdi Haghgoo
07/25/2020, 9:22 AMPhilip Blandford
07/25/2020, 2:30 PMtjohnn
07/25/2020, 5:43 PMtjohnn
07/25/2020, 5:54 PMCard
's are somehow showing as margins? Am I getting it wrong?henrikhorbovyi
07/25/2020, 7:11 PMdev14
-> dev15
and I got the following error:
Any ideas?Vinay Gaba
07/25/2020, 7:52 PMandylamax
07/26/2020, 5:22 AM@Composable
fun Widget() = Column(modifier = Modifier.fillMaxSize()) {
Text(
text = "First item",
modifier = Modifier.padding(16.dp)
)
Text(
text = "Second item",
modifier = Modifier.padding(16.dp)
)
Text(
text = "Third item",
modifier = Modifier.padding(16.dp)
)
}
Is there a caveat?Archie
07/26/2020, 12:31 PMViewModel
in Compose
using viewModel()
composable function. I was wondering how to scope these ViewModel
similar to how ViewModel
could be scoped to Activity
/ Fragment
or NavGraph
? Is this possible to do in Compose
?Archie
07/26/2020, 2:58 PM@Composable
fun Greetings() {
val state = state { "Hello" }
Column {
Text(text = state.value)
Button(onClick = {
state.value = "Hello"
}) {
Text(text = "Greet!")
}
}
}
Notice that the initial value of state is "Hello" and whenever the Button is clicked, it sets the value of the state to the same value (state.value = "Hello"
). Does this trigger recomposition? or recomposition is only triggered when state
is set with a different value? Also is there a hook or callback I could attach to see how recomposition works in compose
?Fudge
07/26/2020, 3:13 PMgalex
07/26/2020, 3:31 PMbodyContent
of Scaffold in my case) ?brandonmcansh
07/26/2020, 4:25 PMFudge
07/26/2020, 4:33 PM@Composable suspend fun askQuestion() : Answer {
return suspendCoroutine { continuation ->
QuestionComponent(onAnswer = {answer -> continuation.resume(answer)})
}
}
The problem is that if I do something like this
setContent {
runBlocking { askQuestion() }
}
It won't compile because "@Composable invocations can only happen from the context of a @Composable function"galex
07/26/2020, 5:07 PMIcon(vectorResource(id = R.drawable.ic_google))
shows it as a black rectangle, I guess its the icon trying to tint it? Here’s the SVG:
<vector xmlns:android="<http://schemas.android.com/apk/res/android>"
android:width="23dp"
android:height="23dp"
android:viewportWidth="46"
android:viewportHeight="46">
<path
android:fillColor="#4285F4"
android:fillType="evenOdd"
android:pathData="M5,3L41,3A2,2 0,0 1,43 5L43,41A2,2 0,0 1,41 43L5,43A2,2 0,0 1,3 41L3,5A2,2 0,0 1,5 3z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:pathData="M5,4L41,4A1,1 0,0 1,42 5L42,41A1,1 0,0 1,41 42L5,42A1,1 0,0 1,4 41L4,5A1,1 0,0 1,5 4z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillColor="#4285F4"
android:fillType="evenOdd"
android:pathData="M31.64,23.2045C31.64,22.5664 31.5827,21.9527 31.4764,21.3636L23,21.3636L23,24.845L27.8436,24.845C27.635,25.97 27.0009,26.9232 26.0477,27.5614L26.0477,29.8195L28.9564,29.8195C30.6582,28.2527 31.64,25.9455 31.64,23.2045L31.64,23.2045Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillColor="#34A853"
android:fillType="evenOdd"
android:pathData="M23,32C25.43,32 27.4673,31.1941 28.9564,29.8195L26.0477,27.5614C25.2418,28.1014 24.2109,28.4205 23,28.4205C20.6559,28.4205 18.6718,26.8373 17.9641,24.71L14.9573,24.71L14.9573,27.0418C16.4382,29.9832 19.4818,32 23,32L23,32Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillColor="#FBBC05"
android:fillType="evenOdd"
android:pathData="M17.9641,24.71C17.7841,24.17 17.6818,23.5932 17.6818,23C17.6818,22.4068 17.7841,21.83 17.9641,21.29L17.9641,18.9582L14.9573,18.9582C14.3477,20.1732 14,21.5477 14,23C14,24.4523 14.3477,25.8268 14.9573,27.0418L17.9641,24.71L17.9641,24.71Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
<path
android:fillColor="#EA4335"
android:fillType="evenOdd"
android:pathData="M23,17.5795C24.3214,17.5795 25.5077,18.0336 26.4405,18.9255L29.0218,16.3441C27.4632,14.8918 25.4259,14 23,14C19.4818,14 16.4382,16.0168 14.9573,18.9582L17.9641,21.29C18.6718,19.1627 20.6559,17.5795 23,17.5795L23,17.5795Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
William Barbosa
07/27/2020, 12:59 PMitem == lastItem
inside the loop and updating the bottom padding accordingly. Is there a way of doing what we did in xml files by adding android:clipToPadding="false"
so that the padding was always added at the end of the scroll or is checking item by item the Compose Way™️? 🤔Horv
07/27/2020, 1:05 PMjetified-kotlin-stdlib-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
Using latest stable Kotlin plugin for Android Studio. Do I need to switch to 1.4 preview?Fudge
07/27/2020, 1:46 PMFudge
07/27/2020, 1:46 PMbrandonmcansh
07/27/2020, 2:04 PMandroid {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "${compose_version}"
kotlinCompilerVersion "1.4.0-dev-withExperimentalGoogleExtensions-20200720"
}
}
Did you update the compiler version?Horv
07/27/2020, 2:11 PMbrandonmcansh
07/27/2020, 2:11 PMHorv
07/27/2020, 2:18 PMapp
included). You can view my current experimentation here: https://github.com/fredagsdeploy/cheer-with-me/tree/feature/jetpack-compose/android if that's any help. I've more or less copied the sample here https://github.com/romainguy/sample-materials-shop for the gradle configurationAndroid Studio 4.2 Canary 5
Build #AI-201.7846.76.42.6682321, built on July 15, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 24
Non-Bundled Plugins: org.jetbrains.kotlin
brandonmcansh
07/27/2020, 2:21 PMtasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
}
}
Horv
07/27/2020, 2:36 PMbrandonmcansh
07/27/2020, 2:57 PMFudge
07/27/2020, 2:59 PMbrandonmcansh
07/27/2020, 3:00 PMHorv
07/27/2020, 3:30 PMallan.conda
07/27/2020, 9:21 PMChanging kotlin version in buildscript to 1.4.0-rc fixed itAwesome find, seems the problem occured due to this recent kotlin plugin update. Compose should probably update the instructions here: https://developer.android.com/jetpack/androidx/releases/compose
brandonmcansh
07/27/2020, 9:21 PMallan.conda
07/27/2020, 9:25 PM1.3.8-1.4.0-rc