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

    galex

    07/29/2020, 8:21 PM
    Ok I might be too tired to work on this at 11pm instead of going to sleep, but what is wrong with this that the load of the value doesn’t trigger recomposition?
    @Composable
    fun ProfileScreen(userUid: String) {
    
        val userRepository = UserRepository()
        val user = mutableStateOf<User?>(null)
    
        launchInComposition {
            user.value = userRepository.get(userUid)
            Log.d(TAG, "url = ${user.value?.profileUrl}")
        }
    
        user.value?.profileUrl?.let { CoilImage(data = it) } ?: Text("No Image!")
    }
    z
    • 2
    • 5
  • b

    brandonmcansh

    07/30/2020, 1:03 AM
    Is there an opt-in or field that I'm missing for TextField's to accept hardware keyboard inputs (e.g keyboard using emulator)?
    m
    n
    • 3
    • 5
  • y

    Yashovardhan

    07/30/2020, 1:29 PM
    Is there a way to add update animations in
    AdapterList
    when items are added/removed/moved I have a simple tasks list function where checked items move to the bottom. However, it happens almost instantly without any delay at all.
    @Composable
    fun TaskList(taskHandler: TaskHandler) {
        AdapterList(data = taskHandler.list.sortedBy { it.isChecked }) {
            TaskItem(task = it, taskHandler = taskHandler)
        }
    }
    a
    • 2
    • 2
  • m

    Mehdi Haghgoo

    07/30/2020, 6:07 PM
    @Devesh Sanghvi what do you mean by BottomDrawableLayout? Is it a composable in Jetpack Compose? How do you create it? Could you please share some code?
    d
    • 2
    • 1
  • h

    Horv

    07/30/2020, 8:00 PM
    Are there any nice samples out there showing how to combine Kotlin's Flow and Composables? I.e. what's best practice on how to render data from a Flow in a compose-friendly way
    • 1
    • 1
  • b

    brandonmcansh

    07/30/2020, 9:37 PM
    The DI should be decoupled from it all imo if possible
    u
    • 2
    • 2
  • b

    Brett Best

    07/30/2020, 10:06 PM
    Posting this here because assume you’ll all be on the canary version of Android Studio (let me know if better place to post it), I’m having trouble getting my Android Emulator to work. I’ve reset all the AVD devices and created a new one but it just launches with a black screen.
    t
    • 2
    • 1
  • d

    Dima Avdeev

    07/30/2020, 10:22 PM
    Where can i found jetpack compose compiler plugin source code?
    j
    • 2
    • 2
  • d

    Devesh Sanghvi

    07/31/2020, 12:30 AM
    Can I get the height of a child composable function if I pass it as a parameter? example:
    fun CustomBottomDrawerLayout(
            drawerState: DrawerState,
            onStateChange: (DrawerState) -> Unit,
            gesturesEnabled: Boolean = true,
            drawerShape: Shape = MaterialTheme.shapes.large,
            drawerElevation: Dp = DrawerConstants.DefaultElevation,
            drawerContent: @Composable() () -> Unit,
            bodyContent: @Composable() () -> Unit
    ) {
    Can I calculate the height of the drawerContent?
    j
    t
    • 3
    • 2
  • b

    brandonmcansh

    07/31/2020, 2:17 AM
    WithConstraints
    might get you there I would think
    j
    • 2
    • 2
  • b

    brandonmcansh

    07/31/2020, 12:18 PM
    Created a swipeToDelete modifier with
    draggable
    :)
    screen-20200731-081624~2.mp4
    👍 9
    👍🏼 8
    m
    h
    +2
    • 5
    • 21
  • l

    Loboda Deni

    07/31/2020, 12:33 PM
    Hello, can I put the code in a class? something like that:
    abstract class BaseState(
        private val textState: String
    ) {
    
        @Composable
        fun render() {
            Text(
                modifier = Modifier.padding(8.dp),
                text = textState
            )
            renderChild()
        }
    
        @Composable
        protected abstract fun renderChild()
    }
    I get an error: e: java.lang.IllegalStateException: Cannot find the Composer class
    t
    • 2
    • 2
  • p

    Philip Blandford

    07/31/2020, 12:40 PM
    I'm clearly missing something about scaling canvases - I have a circle who's center offset is the same as its radius, so it should touch the side of the canvas, and indeed it does when the scale is 1f.
    @Composable
    private fun QuickView() {
      Box(Modifier.wrapContentSize(), border = Border(2.dp, Color.Black)) {
        Canvas(modifier = Modifier.size(200.dp, 200.dp)) {
          val scale = 1f
          scale(scale) {
            drawCircle(Color.Green, 100f, Offset(100f, 100f))
          }
        }
      }
    Putting the scale at 0.5f however reduces the radius as expected, but increases the center offset.
    s
    • 2
    • 2
  • l

    Loboda Deni

    07/31/2020, 1:04 PM
    I understand correctly that it is impossible to implement a state machine here?
    • 1
    • 1
  • s

    Siyamed

    07/31/2020, 4:47 PM
    So leaning to yes for your question :)
    m
    z
    • 3
    • 9
  • z

    Zach Klippenstein (he/him) [MOD]

    07/31/2020, 5:08 PM
    Unrelated text input question: the kdoc for text fields say that
    onValueChanged
    should not be used to change the value of the text field to anything other than what the IME sent. This implies it shouldn't be used to implement something like
    InputFilter
    for eg phone numbers. Is this a temporary limitation, or is there a plan to address this use case another way?
    s
    • 2
    • 7
  • g

    galex

    07/31/2020, 5:54 PM
    Is there a way to tell an Image to be round?
    b
    a
    e
    • 4
    • 7
  • g

    galex

    07/31/2020, 6:28 PM
    Wow devs will have so much to unlearn with Compose! The fact that my ‘root layout’ is not in
    .fillMaxSize()
    by default is giving me headaches. I’m so used to create a layout and it being set to
    match_parent
    /
    match_parent
    , it is mind blowing! This piece of gold helps me a lot:
    fun <http://Modifier.help|Modifier.help>() = drawBackground(Color.Red)
    b
    a
    • 3
    • 4
  • k

    KamilH

    07/31/2020, 7:16 PM
    I’m trying to give Compose a try in my current project and I’m facing a problem. I’m trying to use
    0.1.0-dev14
    version, because in the project I’m using SQLDelight also which is not ready for Kotlin 1.4. Here is the log I’m getting when trying to compile:
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    
    w: /Users/kamilh/.gradle/caches/transforms-2/files-2.1/04a413422729efc3d813c1e8dc458522/jetified-kotlin-stdlib-common-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    
    w: /Users/kamilh/.gradle/caches/transforms-2/files-2.1/73c968e8b7f491e4cb989ea68f190ec5/jetified-kotlin-stdlib-jdk8-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    
    w: /Users/kamilh/.gradle/caches/transforms-2/files-2.1/c8b4b27cd3b0ad6090a0f2b1484265be/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
    
    w: /Users/kamilh/.gradle/caches/transforms-2/files-2.1/f52a3d8d13292768bb64d9bd79c13058/jetified-kotlin-stdlib-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    I don’t understand what require 1.4 version
    b
    z
    m
    • 4
    • 5
  • h

    huannguyen

    08/01/2020, 5:26 AM
    Hi all, I'm doing a spike on integrating
    Compose
    into an existing project. Trying to answer some questions like is it possible to create a new Compose-based
    Fragment
    in a multi-tab
    Activity
    and in general how such integration would look like. I notice most of the Jetpack examples right now are Fragment-free so wondering if that is even doable. If anyone has gone through a similar journey can you please give me some pointers? Thanks
    s
    • 2
    • 2
  • a

    Afzal Najam

    08/01/2020, 6:42 AM
    It seems like if I start an external activity (like the
    ACTION_VIEW
    Intent with a Uri) and then press back to come back to my compose-based app, the Composable parts aren't recomposed. The containing activity gets onStart and onResume called as expected. Does that mean I should be creating my app in onStart instead of onCreate? Or is there a way to detect this from within composables? I'm expecting a state change upon returning to the app, based on something that happens in the activity's onStop when the app loses focus. Edit: Is the right way to use
    LiveData.observeAsState()
    ? It seems like that works.
    StateFlow.collectAsState()
    didn't work as well, seems like some weird race condition in my code.
    j
    • 2
    • 4
  • g

    galex

    08/01/2020, 6:54 AM
    Wouuuahhhh you can’t set
    .dp
    on a
    TextStyle
    ? Bold of Compose to fight directly the designers of the world 😂
    Text(
        text = "Save this dough recipe!",
        style = TextStyle(fontSize = 16.dp) // doesn't compile
    )
    😀 2
    j
    c
    s
    • 4
    • 4
  • m

    MBegemot

    08/01/2020, 9:13 AM
    Is it possible to load an image from file? Like the ImageView.setImageBitmap? without having to use glide or Picasso , if so which will be the preferred type of image png jpeg? Thanks a lot!!
    n
    • 2
    • 1
  • l

    Loboda Deni

    08/01/2020, 9:15 AM
    Hello. Does anyone know an analogue of SwipeToRefreshLayout?
    g
    • 2
    • 2
  • m

    mzgreen

    08/01/2020, 9:29 AM
    Woah this looks cool! https://zeromod.in/posts/jetpack-compose-desktop/
    😎 4
    😃 7
    a
    • 2
    • 1
  • a

    andylamax

    08/01/2020, 12:43 PM
    The compose compiler treats compose functions in much similar way the kotlin compiler does to suspend functions. Correct? My curiosity is, why did the Compose Dev team decide to go with annotations (i.e.
    @Compose
    ) instead of making compose a reserved word, similar to suspend functions? Knowing this was much influenced by JB, if the annotations approach seemed more convenient, why didn't they go with it for suspend functions? (i.e
    @Suspend
    )
    s
    j
    • 3
    • 5
  • d

    divyanshunegi

    08/01/2020, 10:43 PM
    Hi, Everyone I just started exploring Compose and coming from SwiftUI this feels at home, I tried looking for documentation on all the available API but could not find it, can someone please guide me to the Compose API docs (If they exist) ?
    v
    • 2
    • 1
  • a

    amar_1995

    08/02/2020, 4:08 AM
    I am trying to implement refreshing in a composable list. But after refreshing clickable stops working. I think there is some issue with my approach but I am unable to get it. https://github.com/amar1995/ModularNewsApp/blob/main/app/src/main/java/com/amar/modularnewsapp/ui/article/ArticleView.kt#L51
    👍 3
    g
    • 2
    • 2
  • g

    galex

    08/02/2020, 5:56 AM
    Hello, is there a way to blur a Composable? 😱 If not, how could I achieve that?
    a
    m
    z
    • 4
    • 5
  • y

    Yashovardhan

    08/02/2020, 8:56 AM
    Checkbox has this weird white dot in the center when using dark theme colour pallete. It works fine otherwise. It even looks fine with the light theme colours.
    n
    m
    • 3
    • 5
Powered by Linen
Title
y

Yashovardhan

08/02/2020, 8:56 AM
Checkbox has this weird white dot in the center when using dark theme colour pallete. It works fine otherwise. It even looks fine with the light theme colours.
Here's the code for the checkbox:-
Checkbox(
    checked = task.isChecked, onCheckedChange = {
        taskHandler.checkItem(task)
    }, color = MaterialTheme.colors.secondary,
    modifier = Modifier.gravity(Alignment.CenterVertically)
)
And the theme is a simple MaterialTheme with
colors = darkColorPalette()
n

Nader Jawad

08/02/2020, 7:05 PM
Which version of compose are you running? Looks similar to an issue we had in an earlier dev release
y

Yashovardhan

08/03/2020, 7:12 AM
I'm on dev13 right now
m

matvei

08/03/2020, 9:59 AM
Checkbox appearance and animations has been reworked in dev14, starting from dev14 this should not be the case 🙂 Please, let me know if you still can see it after the update
y

Yashovardhan

08/03/2020, 12:17 PM
Thanks! It got fixed with dev14
👍 2
View count: 1