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

    romainguy

    01/30/2021, 10:09 PM
    Not quite yet
    👍 2
    l
    a
    +2
    6 replies · 5 participants
  • s

    Shakil Karim

    01/31/2021, 5:56 PM
    Hi, Does anyone know how I can disable Split mode which is the default option, to Code only in Android Studio?
    j
    5 replies · 2 participants
  • m

    Mark Murphy

    01/31/2021, 7:43 PM
    Is there a pattern for use by libraries of composables, so the library knows how to create composables from the app's design system? I am not worried about simple parent-child relationships, where we can get away with a
    content
    composable lambda. I am more worried about cases where the library itself should be calling composable functions for certain roles, but it has no a priori way of knowing what those functions are. For example, if a library wants to render a button, it needs some composable for that. But
    Button()
    is a Compose Material thing, and the argument made here on several occasions is that Compose Material is just one possible design system. Somehow, the library needs a way to know "this is how I build a button", in such a way that it uses the app's chosen design system. Do we have a pattern for doing this? For apps themselves, they can simply use the right composable functions, but published libraries do not have that option, as they will be used by many apps. My fear is that, in the absence of such a pattern, libraries will tend towards "you can have any design system you want, so long as it is Compose Material".
    👍 2
    a
    d
    +3
    33 replies · 6 participants
  • v

    Vincent Williams

    02/01/2021, 1:30 AM
    When I add this to my project
    buildFeatures {
            compose = true
        }
    I get the following error:
    com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not create task ':app:compileDebugKotlin'.
    org/jetbrains/kotlin/gradle/tasks/KotlinCompile
    Any ideas why? Im trying to use compose alpha 10 on the latest canary AS and kotlin 1.4.21
    t
    3 replies · 2 participants
  • p

    Photoxor

    02/01/2021, 2:41 AM
    The behavior of
    Popup
    has changed in alpha11. Width is now limited to parent width. Is this intended?
    m
    l
    +1
    9 replies · 4 participants
  • a

    Archie

    02/01/2021, 6:40 AM
    Hi @Doris Liu, I was reading around Transition Samples and found this:
    @Composable
    fun PoppingInCard() {
        // Creates a transition state with an initial state where visible = false
        val visibleState = remember { MutableTransitionState(false) }
        // Sets the target state of the transition state to true. As it's different than the initial
        // state, a transition from not visible to visible will be triggered.
        visibleState.targetState = true
        ...
    }
    I was wondering whether doing:
    visibleState.targetState = true
    is fine? Like to create an "Intro Animation"? or is it better to put that inside a
    SideEffect
    ? or is there a better way?
    d
    27 replies · 2 participants
  • r

    Rafs

    02/01/2021, 7:48 AM
    Is there any update on supporting transitions in compose-navigation
    👀 3
    d
    c
    +1
    5 replies · 4 participants
  • h

    Hatice Sarp

    02/01/2021, 11:30 AM
    In alpha-09 and compose paging alpha-05, I was collecting like in the code snippet below:
    val paginatedBlockedUsers = settingsViewModel.fetchBlockedUsers().collectAsLazyPagingItems()
     LazyColumn {
        itemsIndexed(paginatedBlockedUsers) { index, item ->
            if (item != null) {
                UserListItem(
                    item = item
                )
            }
        }
    After upgrading from Alpha 9 to Alpha 11 when paging is on alpha-05, I get following error:
    one of the following functions can be called with the arguments supplied:
    public inline fun <T> LazyListScope.itemsIndexed(items: Array<TypeVariable(T)>, crossinline itemContent: LazyItemScope.(index: Int, item: TypeVariable(T)) -> Unit): Unit defined in androidx.compose.foundation.lazy
    public inline fun <T> LazyListScope.itemsIndexed(items: List<TypeVariable(T)>, crossinline itemContent: LazyItemScope.(index: Int, item: TypeVariable(T)) -> Unit): Unit defined in androidx.compose.foundation.lazy
    How do I use .collectAsLazyPagingItems() and itemsIndexed(paginatedItem) { index, item -> } in alpha 11 ?
    c
    4 replies · 2 participants
  • s

    Se7eN

    02/01/2021, 11:30 AM
    I'm getting a crash when doing this:
    val items = viewModel.items.collectAsState(initial = listOf())
    LazyColumn {
        items(items.value.size) { index ->
            ...
        }
    }
    But if I do
    val items = viewModel.items.collectAsState(..).value
    and
    items(items.size)
    , it works fine. Why doesn't the first snippet work?
    c
    k
    4 replies · 3 participants
  • y

    Yasin Kaçmaz

    02/01/2021, 11:32 AM
    Hi, does LazyGrid have span strategy. I' ve asked a question at Stackoverflow: https://stackoverflow.com/questions/65981114/does-jetpack-composes-lazyverticalgrid-have-span-strategy We can change grid count dynamically, but I want to have a full width footer when loading happens. Is there a way I can set span count for specific item?
    s
    1 reply · 2 participants
  • d

    darkmoon_uk

    02/01/2021, 12:15 PM
    Is anyone running Instrumented Tests against Compose Layouts... or doing so in Firebase Test Lab?
    👋 1
    m
    2 replies · 2 participants
  • p

    Piotr

    02/01/2021, 1:54 PM
    Hi, If someone could take a look at my problem, i’d be grateful https://stackoverflow.com/questions/65993932/dynamic-row-width-compose Cannot get row with basic text field to “shrink” properly and add another element to the right side
    k
    3 replies · 2 participants
  • l

    loloof64

    02/01/2021, 3:32 PM
    Hi all ! I'm trying to update my Jetpack Compose project, but I still get this error
    Execution failed for task ':app:checkDebugAarMetadata'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Could not find androidx.ui:ui-tooling:1.0.0-alpha11.
         Searched in the following locations:
           - <https://dl.google.com/dl/android/maven2/androidx/ui/ui-tooling/1.0.0-alpha11/ui-tooling-1.0.0-alpha11.pom>
           - <https://jcenter.bintray.com/androidx/ui/ui-tooling/1.0.0-alpha11/ui-tooling-1.0.0-alpha11.pom>
         Required by:
             project :app
    
    Possible solution:
     - Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
    Here my build.gradle
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        ext {
            compose_version = '1.0.0-alpha11'
        }
        ext.kotlin_version = "1.4.21"
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:7.0.0-alpha05'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    Here my app build.gradle
    plugins {
        id 'com.android.application'
        id 'kotlin-android'
    }
    
    android {
        compileSdkVersion 30
    
        defaultConfig {
            applicationId "com.loloof64.chessexercisesorganizer"
            minSdkVersion 21
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
            vectorDrawables.useSupportLibrary = true
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '<http://proguard-rules.pro|proguard-rules.pro>'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = '1.8'
            useIR = true
        }
        buildFeatures {
            compose true
        }
        composeOptions {
            kotlinCompilerExtensionVersion compose_version
            kotlinCompilerVersion '1.4.10'
        }
    }
    
    dependencies {
    
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        implementation 'androidx.core:core-ktx:1.3.2'
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'com.google.android.material:material:1.2.1'
        implementation "androidx.compose.ui:ui:$compose_version"
        implementation "androidx.compose.material:material:$compose_version"
        implementation "androidx.ui:ui-tooling:$compose_version"
        implementation "androidx.compose.material:material-icons-extended:$compose_version"
        def nav_compose_version = "1.0.0-alpha06"
        implementation "androidx.navigation:navigation-compose:$nav_compose_version"
        implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-rc01'
        testImplementation 'junit:junit:4.13.1'
        androidTestImplementation 'androidx.test.ext:junit:1.1.2'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    }
    I've just downloaded the latest Android Studio canary today
    :thread-please: 5
    l
    3 replies · 2 participants
  • j

    JulianK

    02/01/2021, 4:05 PM
    We're using a Crossfade inside a top-level Scaffold to fade between "screens". However, different screens need different TopBar icons and onClickListeners, which we currently set-up inside the screens using onActive(). This would translate to DisposableEffect without a key, which is declared as sign of a bug. Since crossfade renders stuff in weird order, how are we supposed to ensure the set-up code for the topbar is only launched "onActive"? Or in general: aren't there things that are supposed to run once when components become visible? Setting focus is another example. I guess the whole pattern we use may be wrong (setting up the top-bar from within subcomponents), so I'd be happy to hear about other solutions, too.
    j
    3 replies · 2 participants
  • l

    loloof64

    02/01/2021, 4:30 PM
    Is there a simple way to convert the following (from alpha07) ?
    Image(asset = vectorResource(id = imageRef), modifier = modifier)
    m
    6 replies · 2 participants
  • s

    spierce7

    02/01/2021, 4:36 PM
    How would I access the current theme settings in a compose application? i.e. Right now I use
    MaterialTheme.typography.h1
    statically when I want to set an h1, but how would I gain access to the theme that is actually set to get it’s typography, and potentially overridden styles?
    j
    2 replies · 2 participants
  • r

    Rick Regan

    02/01/2021, 5:21 PM
    In this code (see thread), when a button is pressed, the message "Key() composed ..." prints four times, one for each Key. I wasn't expecting anything to print at all, since Key doesn't read "buttonPressed".
    a
    z
    +1
    12 replies · 4 participants
  • m

    Mehdi Haghgoo

    02/01/2021, 5:23 PM
    How to undo a click in Compose? Let's say we want to set a variable to A when a UI is clicked and to B when it is released?
    z
    1 reply · 2 participants
  • s

    Sinan Gunes

    02/01/2021, 6:01 PM
    I see some performance improvement on LazyColumn when using a big list filled with cards on alpha-11. I personally thank you compose team 👍
    🎉 4
    👍 8
    a
    s
    5 replies · 3 participants
  • z

    Zach Klippenstein (he/him) [MOD]

    02/01/2021, 7:17 PM
    Question about the requirement for a
    ViewTreeViewModelStoreOwner
    to be configured when
    AbstractComposeView
    is attached: Is that requirement just there to ensure that the
    viewModel()
    composable function always works, if any code in the composition happens to call it? Or is there actually something in the Compose foundation that’s relying on a
    ViewModel
    ?
    a
    3 replies · 2 participants
  • k

    krzysztof

    02/01/2021, 8:01 PM
    Does anyone got to work
    @Preview
    on
    alpha10
    ? Marking composable with
    Preview
    gets me
    androidx.ui.tooling.preview.PreviewActivity is not an Activity subclass or alias
    . Using AS 4.2 Beta 4.
    j
    l
    5 replies · 3 participants
  • m

    Maryam Alhuthayfi [MOD]

    02/01/2021, 8:20 PM
    Hi! I built an app using Compose completely. It is sort of a simple game though. My question here is: I have multiple cards and those cards are swiped until the end. At the very end, there is a button to play again. I cannot find any samples on how to draw the cards again on the screen. How can I do that?
    j
    2 replies · 2 participants
  • k

    krzysztof

    02/01/2021, 8:40 PM
    Say I have a data class with two properties - one that is declared in primary constructor, one as “normal” property. A
    livedata
    of said data class was part of state in my view model. I started to observe it as state. What I found out is, I believe, is an optimisation that compose is applying, but correct me if I’m wrong here. When I
    postValue
    with a new data class, with changed property that is declared in primary constructor,
    compose
    catches that and triggers recomposition on state - so that’s correct. Now,
    postValue
    with my data class with a change to a property that was not part of the primary constructor -
    compose
    does not trigger recomposition, even if observer in
    observeAsState
    is triggered.
    m
    5 replies · 2 participants
  • j

    Jordi Saumell

    02/01/2021, 9:08 PM
    I’ve seen this topic mentioned only once or twice with barely any discussion and I think it could be quite useful debating about this: I believe in compose-only android projects (for UI, ofc) we should handle config changes instead of recreating the activity. And, as a consequence, I also believe we should avoid using the Android ViewModel. Thread with discussion:
    👍 1
    s
    5 replies · 2 participants
  • j

    Jeisson Sáchica

    02/01/2021, 10:01 PM
    Has anyone experienced a
    java.lang.NullPointerException: null cannot be cast to non-null type androidx.compose.ui.graphics.AndroidPathEffect
    when using a
    androidx.compose.ui.graphics.PathEffect
    on a
    ContentDrawScope.drawCircle
    ?
    n
    7 replies · 2 participants
  • v

    Vincent Williams

    02/02/2021, 12:15 AM
    Does anyone here use compose in a multimodule project? It seems to work fine in single module but I get the above error in a multimodule setup
    👍🏻 1
    j
    4 replies · 2 participants
  • s

    Slackbot

    02/02/2021, 2:38 AM
    This message was deleted.
    k
    1 reply · 2 participants
  • s

    spierce7

    02/02/2021, 3:17 AM
    Why is there a separation between Alignment and Arrangement. It’s a little annoying that I have to import 2 separate types to be able to center the content with a Row or Column.
    a
    1 reply · 2 participants
  • s

    Shakil Karim

    02/02/2021, 7:56 AM
    Is it possible to bind ViewModel with NavHost/NavGraph in Compose only app with zero fragments?
    :yes: 1
    s
    d
    3 replies · 3 participants
  • a

    Albert Chang

    02/02/2021, 8:15 AM
    Is there any way to override the fling logic in
    ScrollableController
    for scrollable modifier? I'm trying to implement something similar to the
    PagerSnapHelper
    of RecyclerView but found it difficult using
    FlingConfig
    because I have to know current offset, page size, etc to calculate fling distance and if I implement it using
    FloatDecayAnimationSpec
    then it can't be stateless.
    👀 2
    ❤️ 1
    s
    5 replies · 2 participants
Powered by Linen
Title
a

Albert Chang

02/02/2021, 8:15 AM
Is there any way to override the fling logic in
ScrollableController
for scrollable modifier? I'm trying to implement something similar to the
PagerSnapHelper
of RecyclerView but found it difficult using
FlingConfig
because I have to know current offset, page size, etc to calculate fling distance and if I implement it using
FloatDecayAnimationSpec
then it can't be stateless.
👀 2
❤️ 1
I have uploaded my implementation of Pager in case anyone needs it. The fling animation part is a little bit tricky but as I said in the main post, I didn't find a better way. Advice welcomed. https://gist.github.com/mxalbert1996/e8c9b08d7f234e8461977d59d0327f63
s

Smorg

02/26/2021, 8:40 AM
Hey @Albert Chang, thanks for coming up with this. It seems outdated for beta01 though, do you plan updating it soon?
a

Albert Chang

02/26/2021, 8:45 AM
Pager.kt
@Smorg The update was almost finished except this problem which I believe can't be solved now. Here's the updated version without the problem solved, if you need.
s

Smorg

02/26/2021, 8:49 AM
Thanks @Albert Chang. I will make do with this if it at least behaves like the required pager.
View count: 3