https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose
  • l

    Lilly

    06/12/2020, 9:28 PM
    Did someone notice that 
    Scaffold(bodyContent = { // code here is called twice })
     is called twice? I'm using dev13 but same problem with dev12. I can't test the other versions because my project fails otherwise.
    m
    • 2
    • 6
  • n

    nonameden

    06/12/2020, 9:56 PM
    Hi all, is there any way to disable text selection for
    Text()
    composable?
    ➕ 1
    a
    a
    s
    • 4
    • 3
  • l

    Lilly

    06/12/2020, 10:18 PM
    On Start
    ScannerScreenContent
    ist called twice and everytime
    val state by viewModel.device.observeAsState()
    is triggered,
    ScannerScreenContent
    is called again which leads to a list with always 1 item. Does someone have an idea?
    Unbenannt.kt
    z
    • 2
    • 28
  • d

    Diego Marulanda

    06/12/2020, 10:35 PM
    hi, I get that
    This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.2 or newer.
    but I already have the latest version of canary installed, what should I do?
    v
    • 2
    • 3
  • o

    Octave Decaux

    06/13/2020, 10:55 AM
    I've tried peeking at the internals of the layout system but can't figure out where the rule is and how to override it.
    a
    k
    • 3
    • 11
  • j

    John O'Reilly

    06/13/2020, 12:02 PM
    I'm trying to update project here (that's using dev13 of Compose) to 1.4-M2 but getting
    Class 'kotlin.Unit' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
    I'm using AS 4.2 Canary 1.....and if I just use new project option to create "Empty Compose Activity" I see same issue (it also creates project with dev13 of Compose and Kotlin 1.4-M2). If I create say basic fragment/viewmodel project then it builds/runs fine. Anyone else seeing this?
    z
    • 2
    • 3
  • m

    Merhawifissehaye

    06/13/2020, 1:16 PM
    Could compose by any chance cause problem when used along with data binding. There is another part of the code that uses data binding. I am getting an error related to data binding after installing compose. I have created a gist of the stack trace here. I am still struggling to make compose work with my existing project. Any clue would be appreciated. I have added the following to my build.gradle
    composeOptions {
            kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
            kotlinCompilerExtensionVersion "0.1.0-dev13"
        }
    I am on a multi module project, and I have added the option to both build.gradle files.
    m
    • 2
    • 2
  • z

    zalewski.se

    06/13/2020, 5:46 PM
    Is there any way to do something like
    notifyItemMoved()
    from RecyclerView with Compose
    AdapterList
    ?
    m
    • 2
    • 4
  • m

    Mark Murphy

    06/13/2020, 8:57 PM
    Is there a trick to using composable function references?
    @Preview
    @Composable
    fun ListifyLambda() {
      AdapterList(data = listOf("foo", "bar", "goo")) {
        ListItem(it)
      }
    }
    
    @Preview
    @Composable
    fun ListifyFnRef() {
      AdapterList(data = listOf("foo", "bar", "goo"), itemCallback = ::ListItem)
    }
    
    @Composable
    fun ListItem(item: String) {
      Text(item)
    }
    Here,
    ListifyLambda()
    and
    ListifyFnRef()
    seem like they should be equivalent.
    ListifyLambda()
    compiles and runs without issue.
    ListifyFnRef()
    fails to compile, with:
    Type mismatch: inferred type is KFunction1<String, Unit> but (String) -> Unit was expected
    (
    dev13
    and AS 4.2 C1) It doesn't seem like the Kotlin itself is flawed. Function references that match the function type should be usable, and
    ListItem()
    seems to match the
    itemCallback
    . If you try swapping compatible lambda expressions and function references outside of composables, it works as expected. I have run into this a few times and just wrote it off as being glitchy prerelease stuff, but https://stackoverflow.com/q/62362663/115145 spurred me to try to get to the bottom of this. Are we doing something wrong, or is this a bug/limitation of something (e.g., Kotlin compiler plugin)?
    a
    l
    • 3
    • 8
  • a

    Andrew Kuryan

    06/14/2020, 11:46 AM
    Hey guys, could someone tell me, how to draw a dotted or dashed
    Border
    ?
    k
    • 2
    • 1
  • e

    enighma

    06/14/2020, 6:32 PM
    @kenkyee isn't the state stuff actually going against unidirectional data flow? Since events are not upstreamed to the data source and instead handled inside the component.
    k
    z
    • 3
    • 6
  • k

    Kazemihabib1996

    06/14/2020, 7:21 PM
    interface LayoutModifier : Modifier.Element {
        fun MeasureScope.measure(
            measurable: Measurable,
            constraints: Constraints,
            layoutDirection: LayoutDirection
        ): MeasureScope.MeasureResult
    How exactly LayoutModifier works? instead of list of measurables for each child, there is only one measurable. and I've playing with it, when I tried
    placeable.place(50.ipx, 50.ipx)
    it applied for all children. I think there is some thing I misunderstood about it.
    a
    • 2
    • 8
  • z

    Zach Klippenstein (he/him) [MOD]

    06/15/2020, 3:44 AM
    Spent some time this weekend hacking on my text formatting experiment project and finally implemented support for links and stuff. My general goal here is to get a feel for what a sort of Compose-based markup DSL for creating fancy text (roughly on the same level of flexibility as Markdown) could be like, while keeping formatting details consistent and centralized. It’s super rough, and there are some gross hacks here, and no tests, but the API turned out kinda nice. https://github.com/zach-klippenstein/compose-richtext/pull/3
    👍 18
    t
    l
    • 3
    • 11
  • v

    Vinay Gaba

    06/15/2020, 4:07 AM
    Used the weekend to learn some React and I obviously had to make it about Jetpack Compose somehow. So I created this tool that makes recommendations for the right Compose API to use based on what you use today with the current Android UI Toolkit. Very IFTTT-eque if you will! You can find it here - https://jetpackcompose.app/. More details and demo here - https://twitter.com/vinaygaba/status/1272378671974645760
    👍 3
    👏 2
    🆒 33
    z
    m
    +3
    • 6
    • 7
  • k

    kclerc

    06/15/2020, 11:54 AM
    👋 I have 2 questions about animating things : 1️⃣ How to animate a Composable height from “wrap-content” to 0dp ? We could use the animate api to update scaleY from 1 to 0 but in a Column, the view would just be like “invisible” and not “gone” right ? I mean, elements after the resized one will not go up as the scaleY is changed 2️⃣ How to animate a Composable height update if its child height changes
    d
    • 2
    • 6
  • l

    Lilly

    06/15/2020, 3:41 PM
    Did someone notice that onClick callback of
    DropdownMenuItem
    is not fired?? I'm on dev13. Is it a bug or did I miss something?
    Unbenannt
    m
    • 2
    • 2
  • a

    allan.conda

    06/15/2020, 5:47 PM
    Am I the only one frequently getting this error? I just re-run and it disappears, but it’s annoying as I have to build twice.
    > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
       > java.lang.reflect.InvocationTargetException (no error message)
    l
    s
    g
    • 4
    • 3
  • o

    Octave Decaux

    06/16/2020, 8:39 AM
    Is there a resource out there to understand how the layout, measurable, placeable, etc stuff work ? I find these things hard to reason about right now
    z
    k
    • 3
    • 4
  • g

    gsala

    06/16/2020, 8:55 AM
    What are good resources to understand how Compose helps separate UI and business logic? I feel like most examples use mutable local state, instead of state that is updated externally to the composable
    z
    n
    j
    • 4
    • 9
  • a

    Artur Matsehor

    06/16/2020, 2:45 PM
    Hi everyone I'm making a Compose-MVVM application and trying to implement network requests and make UI react to responses. And now I'm struggling on how to do it properly So here's my pseudo-code
    @Composable
    fun SampleScreen() {
        SampleScreenBody(viewModel = SampleViewModel())
    }
    
    @Composable
    fun SampleScreenBody(viewModel: SampleViewModel) {
        Button(onClick = {
            viewModel.doSmth("Parameter") { response ->
                if (response == "Success") {
                    //TODO: this is where I want to, for ex, move to another screen
                    //or show a dialog.
                    //How?
                }
            }
        }) {
            Text("Text")
        }
    }
    a
    h
    • 3
    • 13
  • g

    Guy Bieber

    06/16/2020, 4:57 PM
    Which version of android studio should we use going forward for jetpack compose 4.1 Beta 1 or 4.2 Canary 1? Which versions of compose will work on 4.1 vs 4.2 (I am currently on dev11)?
    z
    l
    • 3
    • 2
  • z

    zalewski.se

    06/16/2020, 6:00 PM
    Is it possible to scroll the
    AdapterList
    to the top? I can’t find any way to get access to scrollable modifier
    k
    • 2
    • 1
  • s

    Sam Woodall

    06/16/2020, 9:02 PM
    Why can a measurable only be measured once? Isn’t it possible that a measurable in a layout might need to be measured more than once with different constraints? Or is this discouraged?
    j
    • 2
    • 1
  • b

    bohregard

    06/16/2020, 10:35 PM
    I’m having an issue with Vector Images overlap during recomposition.
    val savedIcon = state { post.saved.icon }
    Image(
                modifier = Modifier.weight(1f) + Modifier.clickable(onClick = {
                    post.toggleSave()
                    savedIcon.value = post.saved.icon
                }),
                asset = vectorResource(id = savedIcon.value)
            )
    On toggle, the icon resource should swap. It works the first time (outline to solid) but on the second time the outline shows on top (shown in the pictures below). Any reason why this is happening?
    l
    • 2
    • 5
  • a

    Ash

    06/17/2020, 12:09 AM
    Building MVI with Kotlin StateFlow.
    val intentChannel = Channel<Intent>()
    val state: StateFlow<ChannelState>
    // Setup Ambient
    val CurrAppState = ambientOf<ChannelState> { ChannelState.Edit }
    In a Composable want to use the Ambient
    @Composable
    fun Foo(appState: StateFlow<ChannelState>){
       val currState by appState.collectAsState(initial = ChannelState.NotEdit)
       CurrAppState.provides(currState)
    Passing
    currState
    down the tree everything works perferct but if use
    CurrAppState.current
    get the wrong state. Think I am doing something dumb. Thanks for the help.
    a
    a
    z
    • 4
    • 6
  • v

    Val Salamakha

    06/17/2020, 4:25 AM
    @andylamax What is your build.gradle(Module:..
    a
    h
    • 3
    • 4
  • b

    bohregard

    06/17/2020, 4:43 AM
    Is this a known issue?
    a
    • 2
    • 2
  • m

    Mantas Varnagiris

    06/17/2020, 8:29 AM
    Currently we can show classic Android views with
    AndroidView()
    composable. I'm curious if there will be a way to show `Fragment`s in composables? Maybe it's already possible (I haven't tried yet). Maybe we can wrap fragment within a
    FrameLayout
    or something? The reason why I'm asking is that we're thinking of moving our app navigation to be within composables. All our screens are
    Fragment
    s at the moment and ideally we would like to avoid converting each fragment to a custom view (before we can convert each of them to be composables)
    y
    a
    • 3
    • 5
  • e

    E Smits

    06/17/2020, 9:32 AM
    Hi I'm new to Jetpack Compose, I wonder if there is anybody that found a way to handle navigation backstack with the hardware button? And now while we are at it, is the navigation lib going to be connected with Jetpack Compose later on? For now I am using the method from the sample:
    object NavStatus {
        var currentScreen by mutableStateOf<Screen>(Screen.Home)
    }
    
    fun navigateTo(destination: Screen) {
        NavStatus.currentScreen = destination
    }
    This is fine if you specify onclicks in the UI. However the hardware button closes the app. Usually you would handle an onKeyListener in your fragments or onBackPress in an activity. I could imagine that you could keep an array of recent navigated screens and just pop one using the onbackpress listener in the MainActivity.
    t
    i
    v
    • 4
    • 6
  • z

    Zsolt

    06/17/2020, 10:51 AM
    Hey! I’m trying to add Compose to an existing project, and I get this compilation error:
    java.lang.IllegalStateException: new updateScope not found in result type of endRestartGroup
    This happens as soon as I add the first @Composable annotated fun to the code (even if it’s completely empty). Any idea what I’m doing wrong?
    s
    j
    • 3
    • 4
Powered by Linen
Title
z

Zsolt

06/17/2020, 10:51 AM
Hey! I’m trying to add Compose to an existing project, and I get this compilation error:
java.lang.IllegalStateException: new updateScope not found in result type of endRestartGroup
This happens as soon as I add the first @Composable annotated fun to the code (even if it’s completely empty). Any idea what I’m doing wrong?
In case anyone else runs into this: this was caused by mismatched compose version numbers in dependencies across gradle files
🎖️ 4
s

stewemetal

09/05/2020, 6:48 AM
Just ran into this... you deserve a medal. 😄
j

Javier

09/10/2020, 12:20 AM
I am having this issue but I am using the same dependency for all compose artifacts, but, for some reason, it is using in the compiler artifact the version alpha01 instead of alpha02. Maybe a transitive dependency?
I need to add the next snippet because
kotlin("android")
plugin is implementing alpha01
android {
    composeOptions {
        kotlinCompilerVersion = versions.kotlin
        kotlinCompilerExtensionVersion = versions.compose
    }
}
👍 2
View count: 4