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

    Luca Nicoletti

    10/26/2019, 11:46 AM
    Would it be possible to have
    @Preview
    working on functions with parameters all with default values? That would be great
    j
    a
    • 3
    • 18
  • p

    Pierfrancesco Gulinelli

    10/26/2019, 1:26 PM
    How to use
    @Preview
    when i need context object?
    l
    • 2
    • 9
  • k

    Kevin Janvier Chinabalire

    10/26/2019, 1:39 PM
    Hello guys i have just started #compose journey today and i will like to get some tutorial . like how to use
    recyclerview
    will fetch data from remote using retrofit . Can i use it to generate ios app like flutter ?
    l
    p
    +2
    • 5
    • 8
  • p

    pavi2410

    10/26/2019, 2:56 PM
    How are we supposed to use design-time sample data? https://developer.android.com/studio/write/tool-attributes#toolssample_resources
    a
    • 2
    • 1
  • a

    andrew

    10/26/2019, 3:52 PM
    So I’m just wondering, but how does ambient work? It seems to be kinda similar to react’s context but I’m not sure if I’m right. How would I make my own ambient things, and would it be appropriate to use it for things like network?
    a
    • 2
    • 9
  • s

    SrSouza

    10/26/2019, 4:27 PM
    You guys are planing in the future wrap the code from androidx.ui to a commonMain? Like compose runtime?
    a
    f
    • 3
    • 13
  • f

    Fredrik Larsen

    10/26/2019, 5:18 PM
    Forgive me if this is already talked about, but seeing as
    @Composable
    is a type similar to
    suspend
    and not an annotation, can we except
    composable fun foo
    ? In that case, what about
    @Preview
    ? And while we're at it, is the unary plus override going to change? Thank you so much for this massive undertaking. Really exciting times. 🙂
    f
    w
    +3
    • 6
    • 10
  • i

    ianrumac

    10/27/2019, 12:07 PM
    Hey people, trying to get image loading from network to work: So I have a
    Container{
    val state = +model{ NetworkImagemodel(bitmap: null); } // this is a @Model annotated data class
    
    glideBitmapReady(src,context) {
     state.bitmap = it //this is callback from Glide's onResourceReady
    }
    onCommit(state) {
     println("Loaded)"
    }
    }
    I get a
    IllegalStateException: Not in a frame
    pointing to the change of state model (
    state.bitmap = it //this is callback from Glide's onResourceReady
    )
    a
    l
    • 3
    • 41
  • a

    andrew

    10/27/2019, 3:33 PM
    I saw in the Whats new in compose talk, that Romain Guy was running the emulator inside Android Studio, as opposed to a separate window. Is there a way to do that in the public canary builds?
    b
    w
    r
    • 4
    • 4
  • b

    Bruno_

    10/27/2019, 6:12 PM
    Where can I report a bug? there's nothing about compose in here https://source.android.com/setup/contribute/report-bugs
    interface Foo {
        fun foo() =
            Stream.of(null) // null or any object
                .map { it }
    }
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    also throws that error when using
    Flowable.fromIterable
    from rxJava
    w
    l
    +3
    • 6
    • 9
  • s

    Sami Eljabali

    10/28/2019, 7:19 AM
    Does anyone know why Compose needed its own custom Kotlin compiler?
    n
    w
    +4
    • 7
    • 7
  • a

    audriusk

    10/28/2019, 7:54 AM
    Is there
    suspend fun support on IR backend
    issue ticket on KT tracker which I can follow? On google issuetracker https://issuetracker.google.com/issues/134993205 this one doesn't have any crossref
    👀 1
    s
    • 2
    • 1
  • f

    fengdai

    10/28/2019, 8:36 AM
    Does anyone know the difference between
    ViewGroup.setContent
    (in Wrapper) and
    ViewGroup.setViewContent
    (in Compose)?
    l
    a
    • 3
    • 8
  • n

    nglauber

    10/28/2019, 5:09 PM
    Just starting with compose, so sorry for the dumb question but… I’m adding a
    TextField
    but it has no background or the bottom line like existing in
    EditText
    . Do you guys know how can I set it? This is what I’m doing.
    TextField(
                value = currentPerson.name,
                onValueChange = { currentPerson.name = it },
                editorStyle = EditorStyle(
                    textStyle = TextStyle(
                        fontSize = (16.sp)
                    )
                )
            )
    Also, I’m trying to add two
    TextFields
    inside a
    Row
    and no luck so far… I’m getting this error:
    java.lang.IllegalArgumentException: minWidth 2147483647.ipx should be finite
    l
    r
    a
    • 4
    • 10
  • a

    andrew

    10/28/2019, 8:50 PM
    I have an ambient value, that updates everywhere else in the UI, but inside here.
    r
    t
    • 3
    • 12
  • a

    andrew

    10/28/2019, 11:08 PM
    How can I shim ambient to act like state?
    k
    r
    l
    • 4
    • 11
  • m

    matt tighe

    10/29/2019, 5:11 AM
    I’ve run into this issue while trying to import Compose into two separate existing projects. It’s not immediately apparent what is causing the issue when I look at file it’s complaining about. Does anyone have suggestions on how to debug this?
    Untitled
    l
    k
    t
    • 4
    • 6
  • m

    Mihai Hrincescu

    10/29/2019, 12:33 PM
    Is there a way to align a
    DrawVector
    inside a container or i need to wrap the
    DrawVector
    with another container that gets its dimensions from the
    vectorAsset
    ? I feel like I'm missing something.
    j
    a
    • 3
    • 3
  • r

    R Brian Amesbury

    10/29/2019, 2:14 PM
    In my single activity app, I am trying to replace the UI that I currently inflate with
    Databinding
    with
    compose
    in my fragments. I am doing this:
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
        container.apply {
          this?.let {
            it.setContent {
              Text("Compose")
            }
          }
        }
    It is failing with this exception:
    java.lang.IllegalStateException: Views added to a FragmentContainerView must be associated with a Fragment. View androidx.ui.core.AndroidComposeView{99eebb1 VFED..... ......I. 0,0-0,0} is not associated with a Fragment.
    The
    container
    that is passed in to
    onCreateView
    is a
    FragmentContainerView
    which I am guessing is the view that is inflated in the activity to host the
    NavGraph
    . How can compose my UI in my fragment, and set it as the content?
    m
    • 2
    • 3
  • m

    Michal Bacik

    10/29/2019, 4:19 PM
    Why are
    @Compose
    methods starting with uppercase, when Kotlin has lower-case rules for functions? Kotlin lists exception for factory function creating class of same name, but this is not case of Compose. And Compose uses upper-case for its functions, and it's even not tagget in IDE with warning, while ordinary functions show correct warning. https://kotlinlang.org/docs/reference/coding-conventions.html#naming-rules
    f
    s
    +12
    • 15
    • 37
  • s

    SrSouza

    10/29/2019, 6:57 PM
    Hi guys, anyone getting crash changing the button style when is clicked? My code:
    @Model
    object MyHomeState {
        var isDoingSomething = false
    
        fun turnDoingSomething() {
            isDoingSomething = !isDoingSomething
        }
    }
    
    @Composable
    private fun MyHomeContent() {
        Padding(32.dp) {
            Row {
                Button(
                    style = if(!MyHomeState.isDoingSomething) ContainedButtonStyle() else OutlinedButtonStyle(),
                    onClick = if(MyHomeState.isDoingSomething) null else MyHomeState::turnDoingSomething
                ) {
                    Text("START")
                }
                WidthSpacer(width = 16.dp)
                Button(
                    style = if(MyHomeState.isDoingSomething) ContainedButtonStyle() else OutlinedButtonStyle(),
                    onClick = if(!MyHomeState.isDoingSomething) null else MyHomeState::turnDoingSomething
                ) {
                    Text("STOP")
                }
            }
        }
    }
    Untitled
    j
    c
    • 3
    • 4
  • b

    Bruno_

    10/29/2019, 7:34 PM
    anyone found a way to use kodein with compose in a fancy way?
    t
    • 2
    • 1
  • m

    Michal Bacik

    10/29/2019, 8:24 PM
    Thought on internals: I see that during composition, there is static variable
    currentComposer
    used; this is probably referenced by the Compose plugin as it transforms @Composable functions. (global variables are evil 😉 ) Wouldn't it be better to omit magic code transformations, and follow style of Kotlin coroutines which are implemented purely as library (except of compiler
    suspend
    keyword)? Coroutine builders pass
    CoroutineScope
    as receiver parameter to body of couroutine, and there is no hidden magic behind this, we can study all state of coroutine in debugger. Instead of global
    currentComposer
    variable, Compose would work on a composer build state as normal reveicer variable into
    @Composable
    function . Do Compose designers fear that developers would mess with the build state and make more mistakes, or want hide implementation, or what's purpose of this rather complicated implementation wich needs special plugin and reworked Kotlin compiler?
    j
    s
    +2
    • 5
    • 7
  • m

    Michal Bacik

    10/30/2019, 10:35 AM
    How will Compose handle resource variants as we used them with Views? Like different layout for landscape in layout-land folder, or different dimension for small screens in values-small ?
    w
    a
    s
    • 4
    • 6
  • s

    SrSouza

    10/30/2019, 2:54 PM
    Hi guys, three is something wrong with my code? Because is crashing, I reported it at https://issuetracker.google.com/issues/143595001
    Untitled
    k
    l
    c
    • 4
    • 18
  • m

    Michal Bacik

    10/30/2019, 4:43 PM
    Is there some preliminary documentation with list of all Composable widgets that we can try (Text, Draw, Surface, etc)? For now I use "Find usages" on Composable annotation, and it gives me hint on where I can find these. But I wonder if there's better method to learn about available/planned widgets.
    b
    l
    g
    • 4
    • 3
  • g

    Grigorii Yurkov

    10/30/2019, 4:58 PM
    What's EditText analog in compose? I've tried TextField but it throws NotImplementedError when I click on it
    l
    l
    f
    • 4
    • 21
  • g

    Grigorii Yurkov

    10/30/2019, 7:23 PM
    Can composable functions return something? I ran this code and got
    java.lang.ClassCastException: kotlin.Unit cannot be cast to java.lang.Boolean
    l
    m
    +5
    • 8
    • 41
  • m

    Michal Bacik

    10/30/2019, 7:59 PM
    Please help - how can I make "local state" of widget that reflects to change and rebuilds the widget when changed? Here I want to change color of rectangle after click on it. But it's not rebuilt. I suppose I don't need global
    @Model
    class for this scenario.
    @Composable
    fun MyRect(){
        var color = +memo{ Color.Green }
        Clickable(onClick = {
            color = Color.Red
        }) {
            ColoredRect(brush = SolidColor(color), height = 100.dp)
        }
    }
    l
    g
    +3
    • 6
    • 54
  • m

    Michal Bacik

    10/30/2019, 9:09 PM
    How will dialog and popup window work? They need own Window, will this window be managed by Compose, or we need to use framework's Dialog and PopupWindow and create Compose into its content view?
    l
    r
    a
    • 4
    • 8
Powered by Linen
Title
m

Michal Bacik

10/30/2019, 9:09 PM
How will dialog and popup window work? They need own Window, will this window be managed by Compose, or we need to use framework's Dialog and PopupWindow and create Compose into its content view?
l

Leland Richardson [G]

10/30/2019, 9:10 PM
compose dialogs will appeal to the windowmanager under the hood
versions of this shipped in compose
Popup and friends IIRC
m

Michal Bacik

10/30/2019, 9:36 PM
All changed 🙂 But good old
Activity
hopefully remains.
l

Leland Richardson [G]

10/30/2019, 9:37 PM
as does WindowManager 🙂
but yes, i get your point
r

romainguy

10/30/2019, 10:23 PM
There's a DropdownPopup already
💯 1
a

Anna-Chiara Bellini [G]

10/31/2019, 1:57 AM
There is an usage example of an alert dialog in the sample app, Jetnews. Go and see what happens in the ArticleScreen when you click on the font icon or the heart icon.
👍 2
View count: 6