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

    Michal Bacik

    10/30/2019, 9:54 PM
    Will Compose solve also animations? Like moving widget from one position to another, or change scale, etc.
    j
    • 2
    • 1
  • k

    katz

    10/30/2019, 11:28 PM
    Hi all. the question might be a bit stupid, yet i want to ask it. 1)How does compose resolve layout? (each frame, build + cache, some kind of states), is it somehow relate to
    onLayout
    onMeasure
    or so. Is it just a single view with 'draw' instructions genereated by compose? 2) Am i righre
    +memo
    - just cache for some kind of date to reuse and not to stere in memory twise,
    +state
    -some kind of 'model' that reatain state regardless activity state. And what is differences in those
    g
    • 2
    • 1
  • m

    Michal Bacik

    10/31/2019, 1:51 PM
    Feedback on JetNews sample app: Many in-app composables use direct read access to global variables such as
    posts
    . This may work fine for simple app, but for complex app, the in-app widgets should be reusable and independent on some global state. Rather the data on which widget works should be passed as parameters. Even codelabs mention this: https://codelabs.developers.google.com/codelabs/jetpack-compose-basics/#4 I suggest that you keep actual
    posts: List<Post>
    as property of
    MainActivity
    (or its persisten state if needed), and pass this to widgets in parameters. Accessing global variables in widgets is antipattern by my opinion. I tried and it's easy achievable.
    class MainActivity : AppCompatActivity() {
        private val posts: List<Post> = listOf(
            ...
        )
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    		// load or transform posts
            val posts = getPostsWithImagesLoaded(posts, resources)
            setContent {
                JetnewsApp(posts)
            }
        }
    }
    Same for
    topics
    and other globals.
    p
    b
    • 3
    • 3
  • r

    romainguy

    10/31/2019, 2:13 PM
    Jetnews is mostly a showcase for widgets, not an example of how to architecture and app (see navigation for instance)
    ✔️ 2
    🙄 1
    m
    • 2
    • 2
  • m

    Michal Bacik

    10/31/2019, 2:36 PM
    Won't we get some context into each composable function? Current
    View
    has
    Context
    which allows to load resources (strings, images), read configuration or even get
    Application
    object. Now I wonder if similar context may be there automatically, or we must pass it ourselves as paramater?
    l
    a
    +3
    • 6
    • 24
  • k

    katz

    10/31/2019, 3:19 PM
    Compose seems legit to be crossplatform
    f
    w
    m
    • 4
    • 6
  • g

    Grigorii Yurkov

    10/31/2019, 6:19 PM
    In noble future when compose is released, activities, fragments, views will be annotated with
    @Deprecated
    ?
    👍 1
    🇳🇴 1
    😆 3
    f
    l
    +3
    • 6
    • 19
  • g

    Giorgos Neokleous

    10/31/2019, 7:51 PM
    Hello, does anyone have issue with kapt and compose? I cannot make it work within the same module but I can if kapt doesn't coexist in the same module with compose. I am getting
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    j
    • 2
    • 4
  • m

    Michal Bacik

    10/31/2019, 8:19 PM
    What is the official name of these
    @Composable
    functions (or result that they create on UI tree)? Widget, node, component or else?
    l
    j
    +4
    • 7
    • 32
  • r

    romainguy

    10/31/2019, 8:24 PM
    Components, composables, composable functions
    :yes: 7
    p
    • 2
    • 1
  • f

    fengdai

    11/01/2019, 3:08 AM
    How to understand
    measurement
    and
    intrinsic measurement
    ?
    a
    p
    • 3
    • 12
  • m

    Manuel Wrage

    11/01/2019, 10:32 AM
    Why is compose using framework dialogs and popup windows instead of replicate them with composable functions?
    l
    g
    +2
    • 5
    • 8
  • m

    Manuel Wrage

    11/01/2019, 10:37 AM
    I'm trying to replicate flutters Listview widget but don't really know how to do it. Is it possible with the current apis? I already tried to only layout placeables that are in a specific range and it kind of works but is really slow. So i guess thats not the way to go.
    l
    l
    • 3
    • 4
  • i

    Ionut Costan

    11/01/2019, 11:51 AM
    Any idea when Compose will be production ready? I am starting a new project and first customer review is December 2020. Should I start it with Compose, or ...?
    l
    a
    +4
    • 7
    • 18
  • l

    Luca Nicoletti

    11/01/2019, 12:24 PM
    @Preview
    annotation is not available in
    android-x-master
    repo, is it? Just synced, AS 4.0 is now bundled 👏🏼
    f
    • 2
    • 5
  • t

    themishkun

    11/01/2019, 2:48 PM
    I noticed that some questions are getting asked again and again at this channel and it is really hard to dig into numerous threads to find an answer without posting, so I decided to create a FAQ about jetpack compose. Feel free to contribute, if you think that I missed something important. Let’s make a good ground for others to start from https://github.com/Mishkun/jetpack-compose-faq
    👏 9
    👍 15
    k
    l
    b
    • 4
    • 3
  • l

    Luca Nicoletti

    11/01/2019, 3:51 PM
    Am I the only one getting this?
    Untitled
    l
    • 2
    • 16
  • a

    aballano

    11/01/2019, 4:12 PM
    Hi there, I'm currently doing a small pet project and trying out compose. For what I've seen so far, also including the JetNews app in google samples repo, it seems that the way of using Models is by putting them in some global scope and accessing them from the calling site + modifying with mutable states. Is this the intended behaviour? Or would it be possible to use a more direct functional/reactive approach of passing updated states from an upstream?
    l
    g
    +3
    • 6
    • 100
  • a

    aballano

    11/01/2019, 6:35 PM
    changed the approach as Leland suggested
    updated-compose-sample.kt
    l
    f
    +4
    • 7
    • 37
  • d

    dambakk

    11/02/2019, 1:55 PM
    I am getting this error when trying to import the Jetnews sample app. Does anyone know why?
    l
    g
    • 3
    • 16
  • g

    Grigorii Yurkov

    11/03/2019, 4:44 PM
    What architecture is better to use with compose. I think MVP looks not bad
    b
    l
    s
    • 4
    • 6
  • v

    voddan

    11/03/2019, 6:48 PM
    Can I use intelij with some version of Android plugin to compile Compose insisted of Android Studio?
    l
    • 2
    • 2
  • s

    Saiedmomen

    11/03/2019, 7:58 PM
    Currently compose needs minSdk 21. Will the final released version support lower API levels?
    a
    r
    +3
    • 6
    • 6
  • b

    bmo

    11/04/2019, 9:00 AM
    Hello everybody, I'm trying to make a little PoC with Compose and I have encountered something I cannot explain. The code can be found here : https://github.com/bmonjoie/ComposeTipsCalculator/blob/master/app/src/main/java/be/xzan/composetipscalculator/MainActivity.kt As you can see, I have my
    @Composable
    functions as top level functions. but it brings a weird behavior. Before, those functions were part of
    MainActivity
    and the behavior was the one you can see in attachment. Meaning, when I would change a
    TextField
    , it would stay focused. If I move the function as top level functions, it adds a new line on top but keep it focused on the empty one. The only difference between the two are were the functions are. Can somebody explain ? PS : I have tried adding
    @Pivotal
    or
    key(position) { ... }
    around the
    Entry
    but it doesn't change anything.
    🔥 1
    p
    a
    • 3
    • 5
  • d

    dimsuz

    11/04/2019, 10:56 AM
    Hi! Going through Compose Tutorial. Few things strike me (naming related): •
    DrawImage
    component name feels a bit weird when used in a declarative framework. It sounds like a command to be executed rather than something describing a component. Following this we should've had
    DrawText
    instead of
    Text
    , no? 🙂 •
    Column(modifier = ...)
    . Here
    modifier
    also feels like a name that is way too generic. I mean isn't each and every argument of
    Column
    component a modifier in some sense (it modifies its behavior/view)? I wish it would be more specific into what exactly it modifies
    k
    r
    +2
    • 5
    • 19
  • r

    romainguy

    11/04/2019, 11:04 AM
    APIs aren't final yet :)
    d
    • 2
    • 3
  • b

    Blundell

    11/04/2019, 1:45 PM
    what about
    .toDp()
    are we going to get a
    toDip()
    ? 😆 did anyone raise this at the time? 🙂
    i
    s
    r
    • 4
    • 5
  • l

    louiscad

    11/04/2019, 3:11 PM
    Is there any example of lists sticky headers and footers (horizontal and vertical), and multi-level sticky headers/footers (like one sticky header, plus a second one for a subset of the bigger data chunk for very long lists)?
    r
    • 2
    • 1
  • b

    Bruno_

    11/04/2019, 6:31 PM
    I have to display a stream of data (at least 1000 items), every
    add
    to
    ModelList
    reloads the view, no? Because of that while the items are being loaded the app lags quite a lot, do I have to implement something like a pagination myself or is there a way to optimize such thing out of the box?
    l
    l
    r
    • 4
    • 11
  • n

    nglauber

    11/05/2019, 1:51 AM
    Last week I saw a question regarding
    DrawVector
    alignment. I’m not sure if it is related but, I’m trying to do this:
    FloatingActionButton(
        onClick = { ... }
    ) {
        DrawVector(+vectorResource(R.drawable.ic_baseline_add))
    }
    The icon (which is an
    vector
    drawable) is aligned on the top left. And using this code is throwing an exception.
    FloatingActionButton(
        icon = imageFromResource(resources, R.drawable.ic_baseline_add),
        onClick = { ... }
    )
    My suggestion would be: 1) the
    icon
    parameter supports a
    vector
    drawable; or 2)
    Image
    component supports a
    vector
    drawable.
    a
    • 2
    • 6
Powered by Linen
Title
n

nglauber

11/05/2019, 1:51 AM
Last week I saw a question regarding
DrawVector
alignment. I’m not sure if it is related but, I’m trying to do this:
FloatingActionButton(
    onClick = { ... }
) {
    DrawVector(+vectorResource(R.drawable.ic_baseline_add))
}
The icon (which is an
vector
drawable) is aligned on the top left. And using this code is throwing an exception.
FloatingActionButton(
    icon = imageFromResource(resources, R.drawable.ic_baseline_add),
    onClick = { ... }
)
My suggestion would be: 1) the
icon
parameter supports a
vector
drawable; or 2)
Image
component supports a
vector
drawable.
a

Andrey Kulikov

11/05/2019, 11:35 AM
Thanks! We have it in our roadmap, some unified components which works with both bitmaps and vectors and so you could be able to provide both into such slots. Also we have a bug for imageFromResource to improve the behavior about this exception. For now you can use another overload of FloatingActionButton which accepts children: @Composable() () -> Unit. this allows you to pass any content you want inside the FAB, for example vectors
n

nglauber

11/05/2019, 12:36 PM
Thanks @Andrey Kulikov! I think it is the first one I mentioned, isn’t it? The problem with it is: I can’t align the icon inside the FAB
a

Andrey Kulikov

11/05/2019, 1:04 PM
yeah, the variant you had, but with some modifications.
you need to add centering, we can do it like this right now
Wrap(alignment = Alignment.Center) { Container(width = 24.dp, height = 24.dp) { DrawVector(+vectorResource(R.drawable.myId)) } }
n

nglauber

11/05/2019, 3:26 PM
it worked 😉 thanks @Andrey Kulikov
View count: 1