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
  • m

    mon

    02/07/2020, 2:46 PM
    Is there a way to "detach" a value from a
    @Model
    so that it stops getting updated when the field it is read from changes?
    c
    l
    • 3
    • 5
  • l

    Loránd

    02/07/2020, 4:46 PM
    Just curious, are there any recommendations on how navigation should be handled in a compose app?
    z
    • 2
    • 2
  • t

    Thierry

    02/07/2020, 5:09 PM
    Align + Column behaviour isn't working as i would expect it to
    p
    a
    • 3
    • 7
  • s

    sindrenm

    02/07/2020, 9:34 PM
    Are there any plans to make something similar to XML's
    @tools:sample
    with tools-provided sample data that are only available in
    @Preview
    Composables and that aren't shipped to the actual builds? 😍 I'd especially like this with regards to image resources. Strings I can hard code in my previews. 🙂
    l
    z
    t
    • 4
    • 9
  • t

    Thierry

    02/07/2020, 9:34 PM
    Editor is a bit flaky at times
    • 1
    • 1
  • m

    mon

    02/08/2020, 4:24 AM
    Is there a way to batch
    @Model
    mutations so that the component sees multiple var changes at the same time?
    a
    l
    • 3
    • 4
  • s

    sindrenm

    02/08/2020, 2:52 PM
    Tooling question: I like that it's easy to navigate specifically to classes in Studio (Ctrl-N) as separate from navigating to a file (Ctrl-Shift-N). Will there be first-party support for navigating specifically to a
    @Composable
    by name in the future, you reckon?
    a
    s
    • 3
    • 3
  • l

    Loránd

    02/08/2020, 5:28 PM
    For some reason i keep getting the following exception each time i add a call to the function
    vectorResouce
    or
    stringResource
    java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    Has anyone had the same issue before?
    l
    p
    • 3
    • 7
  • b

    Bruno_

    02/08/2020, 9:41 PM
    during gradle sync in IDEA (latest eap version)
    Cannot convert string value 'JETPACK_COMPOSE' to an enum value of type 'com.android.builder.model.AndroidGradlePluginProjectFlags$BooleanFlag' (valid case insensitive values: APPLICATION_R_CLASS_CONSTANT_IDS, TEST_R_CLASS_CONSTANT_IDS, TRANSITIVE_R_CLASS)
    happened to anyone? build itself succeeds
    • 1
    • 1
  • l

    Loránd

    02/09/2020, 10:48 AM
    Is there any way to add a background color to a Column or Row without wrapping them in a surface?
    z
    • 2
    • 1
  • m

    mon

    02/09/2020, 1:30 PM
    The compiler chokes on when-in expressions.
    m
    • 2
    • 3
  • n

    Neal Sanche

    02/09/2020, 7:24 PM
    So, effects and the unaryPlus have been removed. How would the following code be rewritten to follow the latest fashion in Compose? I think it was originally written in an article by @Luca Nicoletti and doesn't compile anymore on Dev04:
    // general purpose observe effect. this will likely be provided by LiveData. effect API for
    // compose will also simplify soon.
    fun <T> observe(data: LiveData<T>) = effectOf<T?> {
        val result = +state<T?> { data.value }
        val observer = +memo { Observer<T> { result.value = it } }
    
        +onCommit(data) {
            data.observeForever(observer)
            onDispose { data.removeObserver(observer) }
        }
    
        result.value
    }
    Ref: https://medium.com/swlh/android-mvi-with-jetpack-compose-b0890f5156ac
    a
    z
    • 3
    • 8
  • c

    codeslubber

    02/09/2020, 7:33 PM
    So I know there was a session, I think that @Leland Richardson [G] did at DevSummit about how Compose actually implements its Builders, is there a document? also, lemme cast a vote for an example that shows a builder (domain-specific) that fronts compose…
    a
    • 2
    • 25
  • t

    Thierry

    02/09/2020, 9:52 PM
    any known issues with DrawVector?
    s
    j
    • 3
    • 12
  • m

    Mohamed Ibrahim

    02/10/2020, 5:15 PM
    in term of future plans, could compose be used in iOS?
    👀 3
    s
    s
    +4
    • 7
    • 6
  • t

    Thierry

    02/10/2020, 11:13 PM
    which sample apps and tutorials are you guys using to get the hang of compose so far?
    z
    a
    m
    • 4
    • 11
  • t

    Thierry

    02/11/2020, 2:01 AM
    z
    m
    a
    • 4
    • 9
  • l

    Leland Richardson [G]

    02/11/2020, 7:17 PM
    i think someone else also reported this bug. i believe it is a bug in IR implementation (specifically, using the
    in range
    syntax in a when expression)
    👍 1
    m
    p
    • 3
    • 4
  • p

    Paolo Achdjian

    02/11/2020, 7:32 PM
    There is a way to rotate a text ? Something like: Rotate(90){ Text("This is a test") }
    z
    l
    +2
    • 5
    • 7
  • m

    molikto

    02/12/2020, 2:43 PM
    @Composable fun Outer(i: Int, onClick: () -> Unit) {
            @Composable fun Capturing() {
                Text(i.toString())
            }
            Capturing()
            Button(onClick = onClick) {
                Text("me " + i)
            }
        }
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContent {
                Column {
                    var i by state { 0 }
                    Outer(i, {
                        i += 1
                    })
                }
            }
    it seems nested functions can be defined but they are not working properly,
    Capturing
    is considered not depending on any parameters, so it will not update when recompose
    👌 2
    a
    • 2
    • 1
  • k

    Kevin Hester

    02/13/2020, 3:05 AM
    hi ya'll! I'm a compose noob (but a fair amount of kotlin experience) who is trying to convert my app over to compose - partly as an experiment and partly because I love reactive frameworks. A question: What is the best "compose way" to run code when the view changes? i.e. based on changes to a "screen" model variable it nicely changes which content gets generated. But when I change to my "bluetooth scan screen" I need to start the android BTLE scan operation (with a callback that gets invoked to add elements to my model "list of bluetooth devices"). When that screen goes away (because the screen variable got changed). I need to run some code to stop and destroy the BLE scanner class.
    when (screen) {
        is Screen.Home -> HomeContent()
        is Screen.SelectRadio -> BTScanScreen()
        // Question: how to get hooks invoked when this screen gets shown/removed?
        // i.e. I need to start/stop a bluetooth scan operation. depending on the
        // appearance/disappearance of this screen.
    }
    a
    • 2
    • 4
  • m

    mon

    02/13/2020, 7:31 AM
    Is it not possible to read from a
    @Model
    var outside a
    @Composable
    ?
    a
    • 2
    • 5
  • p

    Pierfrancesco Gulinelli

    02/13/2020, 11:15 AM
    does it recycle?
    l
    i
    r
    • 4
    • 5
  • k

    Kevin Hester

    02/13/2020, 3:55 PM
    before I make something (possibly ugly) myself, is there something like a WithActivity {} or WithApplication {} Compose functions to provide the current activity or application context (which is sometimes needed for low level android calls). I've looked through https://developer.android.com/reference/kotlin/androidx/compose but so far no luck.
    z
    l
    • 3
    • 12
  • k

    Kevin Hester

    02/14/2020, 2:11 AM
    Another question (heh): How do I enable/disable a component in compose? Is there some sort of Composable I nest it inside or some other concept? (In my case I have a list of bluetooth devices RadioGroupTextItems inside of a RadioGroup. And I want some of those items to be drawn grey/disabled because they are not yet paired with the phone (so I want the user to know they exist, but you can't yet select them)
    l
    r
    a
    • 4
    • 27
  • j

    jolo

    02/14/2020, 8:51 AM
    I noticed there’s a
    Padding
    composable, but also a modifier
    LayoutPadding
    . When would you use one over the other? Are there plans to deprecate one of them?
    m
    a
    • 3
    • 2
  • j

    jolo

    02/14/2020, 9:07 AM
    And another question: What’s the current way to add Opacity to a text?
    dev-03
    used
    withOpacity
    but that was marked as a hack. Is the
    Opacity
    composable the only way to do it in
    dev-04
    ?
    a
    a
    l
    • 4
    • 5
  • a

    abbic

    02/14/2020, 2:26 PM
    hi, this may well be nothing but the Jetpack Compose tutorial (https://developer.android.com/jetpack/compose/tutorial) at one point outlines using a
    DrawImage
    compose call inside another composable. No issue up until this point but
    DrawImage
    comes up as an unresolved reference. Is the tutorial not up to date?
    p
    • 2
    • 3
  • k

    Kevin Hester

    02/14/2020, 2:53 PM
    So in my app which I'm Composemotizing, I've been using the Google sign View (which looks like a button but from looking at the .class file is actually a FrameLayout. the xml style instantiation looks like:
    <com.google.android.gms.common.SignInButton
     android:id="@+id/sign_in_button"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content" />
    Is there any way in Compose for me to create View instances as a child of a Compose frame? From looking at the docs, I see https://developer.android.com/reference/kotlin/androidx/compose/adapters/package-summary which sounds interesting, but I'm not sure what the intended usage is?
    a
    • 2
    • 3
  • i

    Ian Warwick

    02/15/2020, 11:10 AM
    Greetings composers! still messing with compose quite a bit, was wondering what you guys think of making more complex UI such as this fretboard chart in screenie. Questions is - Should be done using high level composables
    Container
    ,
    ColoredRect
    etc or should something like this be done with low level
    Canvas
    draw routines?
    👍 2
    💡 2
    🎸 6
    z
    • 2
    • 2
Powered by Linen
Title
i

Ian Warwick

02/15/2020, 11:10 AM
Greetings composers! still messing with compose quite a bit, was wondering what you guys think of making more complex UI such as this fretboard chart in screenie. Questions is - Should be done using high level composables
Container
,
ColoredRect
etc or should something like this be done with low level
Canvas
draw routines?
👍 2
💡 2
🎸 6
z

Zach Klippenstein (he/him) [MOD]

02/15/2020, 9:08 PM
Do whatever makes the code simpler and easier to read and maintain.
👍 3
i

Ian Warwick

02/17/2020, 10:51 AM
Going to stick with high level composables as opposed to canvas draw routines https://medium.com/@fluxtah/a-guitar-chord-widget-for-jetpack-compose-87265e74cd43?source=friends_link&amp;sk=a806375cf8b0d66af9d63004f1f2e9c3
👏 2
View count: 1