https://kotlinlang.org logo
Docs
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

    Mikołaj Kąkol

    06/09/2020, 9:56 AM
    hi, rather broad question. Having compose, will it be ok to do layout animations? will it be less invasive for performance?
    j
    • 2
    • 1
  • m

    Mikael Alfredsson

    06/09/2020, 2:52 PM
    Is it possible to add a modifier or wrap all child composeables in for example a Column. What I want to achieve right now is to be able to add padding around each component but the question is a bit broader.
    z
    • 2
    • 7
  • m

    manueldidonna

    06/09/2020, 3:40 PM
    I want to update the UI every X seconds. I could 
    launch
     a coroutine, 
    delay
     it and then mutate the state. How can I correctly handle the lifecycle of the composition?
    l
    z
    +2
    • 5
    • 15
  • j

    jim

    06/09/2020, 4:55 PM
    Not easily, the compiler version is swapped in via AGP which assumes the project is Android (not Desktop), and we fake out some Android APIs to make the apps run because we still have some modules that aren't fully/properly generalized. Also, most things don't yet draw properly; we're literally just merging Desktop support for Text and Images. It's not yet ready for public consumption, still in an experimental/research stage.
    j
    • 2
    • 2
  • k

    Klaas Kabini

    06/09/2020, 6:34 PM
    I know this is a nice to have but not something of priority. When compose has reached beta, can you guys look into implementing a composable that can render lottie animations just like LottieAnimationView when passed a lottie.json file. Maybe this might be a lot of work for you but it would be nice to have this in compose
    l
    • 2
    • 2
  • a

    allan.conda

    06/09/2020, 11:38 PM
    any way to load a non-vector drawable xml into an ImageAsset?
    v
    t
    • 3
    • 11
  • s

    Siyamed

    06/10/2020, 2:50 AM
    I have absolutely no idea 😳 can't even reason
    m
    v
    • 3
    • 2
  • v

    Val Salamakha

    06/10/2020, 3:17 AM
    It is the same behaviour on an emulator and on a samsung device when I am changing focus only.
    m
    • 2
    • 1
  • p

    pavi2410

    06/10/2020, 2:52 PM
    I made a Text editor using VisualTransformation. It shows line numbers on the side. It was really tricky for me to write the offset translator, but Kotlin makes it super easy.
    v
    l
    • 3
    • 4
  • p

    pavi2410

    06/10/2020, 2:54 PM
    How do I un-wrap lines in a TextField?
    z
    • 2
    • 1
  • a

    Apex

    06/10/2020, 6:50 PM
    The "What's new in Compose" youtube link in the https://medium.com/androiddevelopers/whats-new-in-jetpack-1891d205e136 is private

    https://youtu.be/2Nn4ahU-4tE▾

    z
    t
    • 3
    • 2
  • j

    John O'Reilly

    06/10/2020, 7:02 PM
    are there any more details yet on "Sample Data API for Compose" that was mentioned in https://android-developers.googleblog.com/2020/06/unwrapping-android-11-beta-plus-more.html ?
    ➕ 3
    • 1
    • 4
  • d

    Diego Marulanda

    06/10/2020, 8:12 PM
    hi, i have next code:
    @Composable
    fun Residencelist(){
        coreApiService.get("${BASE_URL}list/") { response: String ->
            val response = Gson().fromJson(response, ResponseResidences::class.java)
            MaterialTheme {
                Column(Modifier.padding(bottom = 1.dp).fillMaxWidth()) {
                    VerticalScroller() {
                        Column(Modifier.padding(3.dp).fillMaxWidth()) {
                            response.residences!!.forEach {
                                if (it != null) {
                                    newCarrouselCard(it.name!!,
                                        it.mainImage!!,
                                        it.additionalInformation!!.images,
                                        it.residenceDescription!!,
                                        "${it.price} ${it.currency}")
                                        Divider(height = 10.dp)
                                } else newCard("Residences not found")
                            }
                        }
                    }
                }
            }
        }
    }
    and when I try to compile, get this error:
    Functions which invoke @Composable functions must be marked with the @Composable annotation
    in the
    val
    line, but I don't understand why? because I call other normal functions from Glide library and it works,
    a
    j
    z
    • 4
    • 11
  • v

    Vinay Gaba

    06/10/2020, 8:53 PM
    Random discussion 👇🏼
    m
    r
    • 3
    • 8
  • g

    Guy Bieber

    06/10/2020, 10:51 PM
    Is there a way to get BottomDrawerLayout to animate open all the way when activated. Right now it seems to be hard coded to open half way.
    m
    • 2
    • 3
  • r

    romainguy

    06/11/2020, 1:45 AM
    In case you’re interested, I’ve published the source code of the demo from today’s videos: https://github.com/romainguy/sample-materials-shop
    🎉 19
    🙏 20
    m
    • 2
    • 2
  • m

    manueldidonna

    06/11/2020, 10:52 AM
    I've created an animated stepper with ~100 lines 🤯 The next step is animate the stepper value changes, but I still don't know how 😂 Source
    20-06-11-12-36-59_01.mp4
    👏 2
    👍 8
    t
    z
    m
    • 4
    • 7
  • k

    krtko

    06/11/2020, 6:28 PM
    I've spent sometime looking at the different declarative UI frameworks (Compose, SwiftUI, and Flutter) coming out and I really appreciate Compose's dedication to not embedding application logic in the view.
    t
    c
    j
    • 4
    • 78
  • d

    Daniele B

    06/11/2020, 7:56 PM
    can anyone suggest any article/sample showing how JetpackCompose can be used with StateFlow?
    z
    v
    • 3
    • 29
  • h

    Hanzhen

    06/11/2020, 8:33 PM
    Can TextField support AnnotatedString?
    p
    • 2
    • 2
  • m

    manueldidonna

    06/11/2020, 10:57 PM
    Which is the best way to expand the touchable area of a composable that has a `clickable`/`draggable` modifier?
    ➕ 1
    s
    m
    s
    • 4
    • 4
  • c

    codeslubber

    06/12/2020, 3:50 AM
    The Compose template is gone in the latest 4.1?
    z
    l
    +2
    • 5
    • 7
  • k

    Kazemihabib1996

    06/12/2020, 8:22 AM
    What happens when we
    return the amount of the [dragDistance] that has been consumed.
    ? I'm trying to understand the below sentence
    consume all delta no matter the bounds to avoid nested dragging (as example)
    https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DraggableSamples.kt#100
    m
    • 2
    • 5
  • m

    manueldidonna

    06/12/2020, 2:15 PM
    I've a doubt on the diff alghoritm used by compose with
    AdapterList
    . The composable receives a read-only
    List
    , each item has a proper equals method. If an item must change, the composable is invoked with a new list.
    var items by state { emptyList<Item>() }
    
    AdapterList(items) { item -> 
        ItemUI(item, onClick = { items = /** new read-only List with only one item changed**/ }) 
    }
    Should I replace the
    MutableState
    with a
    ModelList
    ?
    z
    c
    • 3
    • 10
  • h

    Hanzhen

    06/12/2020, 2:59 PM
    Hi, I tried to import support/ui in AS but got ‘Basedir support/ui/annotation does not exist’ error. I followed the steps in README.md in the same folder. AS version is 4.1 Canary 10.
    a
    • 2
    • 19
  • d

    Diego Marulanda

    06/12/2020, 4:58 PM
    hi, ca you help me?
    e: java.lang.AbstractMethodError: androidx.compose.plugins.kotlin.ComposeIrGenerationExtension.generate(Lorg/jetbrains/kotlin/ir/declarations/IrModuleFragment;Lorg/jetbrains/kotlin/backend/common/extensions/IrPluginContext;)V
    Execution failed for task ':app:compileDebugKotlin'.
    > Internal compiler error. See log for more details
    w: C:\Users\quind\.gradle\caches\transforms-2\files-2.1\beeb88e94e944fd412bff1cbd6499676\jetified-kotlin-stdlib-jdk7-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    I get that when try to run my project, I went back to a previous commit where it was working fine and keeps throwing me the same error
    j
    i
    a
    • 4
    • 5
  • v

    Vinay Gaba

    06/12/2020, 5:11 PM
    I’m curious about how you’ll have been referring to the current UI Toolkit when speaking in comparison to Jetpack Compose? Legacy? Old? Current UI system? Looking for ideas
    ➕ 3
    f
    j
    +4
    • 7
    • 12
  • r

    romainguy

    06/12/2020, 8:08 PM
    Composable previews run in a limited environment
    l
    • 2
    • 1
  • g

    grandstaish

    06/12/2020, 8:20 PM
    I’m trying to use
    collectAsState
    but it is resulting in an infinite composition loop. When I call
    collectAsState
    it seems to just get the latest state and then trigger a recomposition, and then repeats that loop forever. Does anyone know what I am missing? I’m new to both technologies so it’s probably something really obvious!
    l
    t
    +2
    • 5
    • 16
  • m

    Merhawifissehaye

    06/12/2020, 8:30 PM
    How do I use compose inside a Fragment?
    setContent
    doesn't seem to be available outside of an Activity? I also learned in a comment inside this stackoverflow question that there is a work in progress to add support for Fragments. Are there any updates on that? Or else what options do I have to be able to use compose inside fragments?
    z
    a
    +2
    • 5
    • 12
Powered by Linen
Title
m

Merhawifissehaye

06/12/2020, 8:30 PM
How do I use compose inside a Fragment?
setContent
doesn't seem to be available outside of an Activity? I also learned in a comment inside this stackoverflow question that there is a work in progress to add support for Fragments. Are there any updates on that? Or else what options do I have to be able to use compose inside fragments?
z

Zach Klippenstein (he/him) [MOD]

06/12/2020, 8:44 PM
You can set a
FrameLayout
as your content view and then call
setContent
on the
FrameLayout
.
➕ 1
☝️ 2
a

Andrey Kulikov

06/12/2020, 9:05 PM
yes. it is basically just
abstract class ComposableFragment : Fragment() {
override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ) = FrameLayout(requireContext()).apply {
        setContent(Recomposer.current()) {
            Content()
        }
    }
@Composable
    abstract fun Content()
}
👍🏼 1
👍 2
but we are still considering to add it in the library to make gradual migration as simple as possible
j

Javier

06/12/2020, 9:23 PM
@Andrey Kulikov compose will not be based on just a single activity and composable functions?
l

Leland Richardson [G]

06/12/2020, 9:27 PM
@Javier you can do the single activity/composable approach, but it won’t be required as this would prevent a lot of people from easily migrating
👍 1
j

Javier

06/12/2020, 9:28 PM
@Leland Richardson [G] the jetpack navigation library will include the single activity with no fragments approach?
l

Leland Richardson [G]

06/12/2020, 9:30 PM
the compose extension to the navigation arch component library will allow for routes to be defined by a composable function. it will allow other routes to also be defined by fragments if you have them (for easy incremental migration). If you only have composable routes, it is not yet clear if it will end up using fragments as an implementation detail or not, but i think there’s a decent chance that it won’t
👍 2
but in any event, it should just be an implementation detail
there may at some point be a way to define your navigation graph from inside of a composable (similar to the open source compose-router library’s API) but these areas are still being explored by our team since we want to make sure that we believe it is a good approach before releasing something like that
j

Javier

06/12/2020, 10:03 PM
Thank you for all the info :)
m

Merhawifissehaye

06/13/2020, 10:41 AM
Thank you all. 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.
View count: 8