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

    alorma

    11/03/2020, 8:36 AM
    Has someone made AspectRactio composable like this one for flutter? https://api.flutter.dev/flutter/widgets/AspectRatio-class.html
    s
    • 2
    • 3
  • d

    dai

    11/03/2020, 9:12 AM
    👋 Has anyone looked into Jetpack Compose on Android TV devices yet? and is there any details on support? I see some functionality around focus but I have not dived into them yet to explore how its supported on TV 🙂
    z
    • 2
    • 4
  • m

    Mao

    11/03/2020, 9:17 AM
    Hi. I have a question about how to choose
    ambientOf
    and
    staticAmbientOf
    . Since
    staticAmbientOf
    will force all children doing recomposition, seems like
    ambientOf
    is more efficient. But after search the source code, I found that there are more occurrences of
    staticAmbientOf
    . I understand that most of them are rarely changed and the comment of
    staticAmbientOf
    says:
    A static ambient should be only be used when the value provided is highly unlikely to change.
    But why not just using
    staticOf
    ? Are there any circumstances that we must do all children recomposition? I would be very happy if there were some guides to told me how to choose between
    ambientOf
    and
    staticAmbientOf
    . Thanks!
    j
    • 2
    • 3
  • s

    Stefano Rodriguez

    11/03/2020, 9:18 AM
    Hey there, do you know if there is a composable like this one for Flutter? I’ve managed to kind of replicate the functionality that I required with a combination of a
    WithConstraints
    composable and a
    drawLayer
    modifier with scaleX and scaleY, but it was much more cumbersome to achieve my expected result https://api.flutter.dev/flutter/widgets/FittedBox-class.html
    ➕ 1
    a
    c
    • 3
    • 6
  • d

    dagomni

    11/03/2020, 11:28 AM
    NavBackStackEntry in composable() returns a different ViewModelStore every time it's called. Is it a desired behavior?
    i
    • 2
    • 7
  • a

    Arun

    11/03/2020, 11:53 AM
    What's the recommended way to load an image from an url in compose?
    j
    s
    z
    • 4
    • 4
  • m

    Mohammad Sianaki

    11/03/2020, 2:42 PM
    How can I find center coordinates of a Composable?
    z
    • 2
    • 1
  • r

    Rodri Represa

    11/03/2020, 2:54 PM
    I'm trying to implement the new compose navigation and I get this weird error:
    i
    • 2
    • 5
  • s

    subashz

    11/03/2020, 2:55 PM
    Where to find the source code of example usage samples ??
    androidx.compose.material.samples.MenuSample
    i
    • 2
    • 2
  • j

    jaqxues

    11/03/2020, 3:27 PM
    Hello, question about navigation-compose I want to add a
    composable
    destination to a NavHost at runtime. How do I do so without reloading the current Composable that is seen on the screen? By having a mutable state that is read from
    NavHost
    , the entire screen is refreshed (and animations look weird, state is reset etc)
    i
    • 2
    • 3
  • s

    Stefano Rodriguez

    11/03/2020, 3:53 PM
    Is there a way to “store” a composable function as a method of a data class/interface and call it programmatically from another composable function? I’m getting a weird java.lang.NoSuchMethodError when trying to invoke the
    render
    method
    interface TestScreen<State: Any> {
        val name: String
        val initialState: State
        @Composable
        fun render(state: State, setState: (State) -> Unit)
    }
    a
    a
    z
    • 4
    • 15
  • p

    Paul Woitaschek

    11/03/2020, 4:13 PM
    Are there any thoughts already on how to gradually migrate from a fragment only to a compose only world?
    j
    • 2
    • 3
  • a

    Afzal Najam

    11/03/2020, 4:36 PM
    Whoa, JetBrains Compose on desktop is available in the latest IDEA CE EAP! More information in this Twitter thread: https://mobile.twitter.com/iateyourmic/status/1323551064512172033
    ❤️ 1
    😮 19
    🎉 16
    s
    j
    • 3
    • 3
  • s

    subashz

    11/03/2020, 5:44 PM
    Unresolved reference: launchInComposition. Do I need external dependencies for this ??
    a
    n
    • 3
    • 2
  • s

    subashz

    11/03/2020, 6:11 PM
    Got this weird error ??
    FloatingActionButton(
            onClick = {
                LaunchedTask {
                    scaffoldState.snackbarHostState.showSnackbar(
                        "Hello World..",
                        "",
                        SnackbarDuration.Short
                    )
                }
            }
    @Composable invocations can only happen from the context of a @Composable function
    a
    • 2
    • 4
  • g

    Grigorii Yurkov

    11/03/2020, 6:35 PM
    Row
    doesn't want to get recomposed even after his child
    Text
    become bigger. Should I recompose it manually? If yes, how can I do it?
    a
    a
    +2
    • 5
    • 32
  • g

    Gabriel

    11/03/2020, 7:48 PM
    Hey folks, I'm trying to write some tests for compose but I'm not sure what dependency to include for onNodeWithText to work. I've got
    androidTestImplementation("androidx.ui:ui-test:$COMPOSE_VERSION")
    but it won't import anything or even mark it as not being imported, I'm not sure what I'm missing
    a
    o
    • 3
    • 13
  • r

    Robert Menke

    11/03/2020, 8:13 PM
    I’m running into an intermittent issue in alpha06 where `TextField`s don’t bring up the keyboard when focused. Has anyone run into this issue? Another issue I have with my
    TextField
    in alpha06 is that
    ImeAction.GO
    doesn’t seem to be working the same way it was in previous versions.
    val focusRequester = FocusRequester()
    
                TextField(
                    value = text,
                    onValueChange = viewModel::setEmail,
                    label = { Text(text = "What's your email address?") },
                    placeholder = { Text(text = "<mailto:jane.doe@gmail.com|jane.doe@gmail.com>") },
                    keyboardType = KeyboardType.Email,
                    modifier = frameFillWidth(60.dp).focusRequester(focusRequester),
                    backgroundColor = MaterialTheme.colors.background,
                    imeAction = ImeAction.Go,
                    onImeActionPerformed = { action, keyboardState ->
                        submit()
                    }
                )
    
                onActive(callback = {
                    focusRequester.requestFocus()
                })
    s
    r
    +2
    • 5
    • 11
  • g

    Gabriel

    11/03/2020, 8:43 PM
    Hey folks, I'm having a few more issue with running some tests for compose, running my rather basic test doesn't seem to launch the app
    java.lang.AssertionError: Activity never becomes requested state "[STARTED, CREATED, DESTROYED, RESUMED]" (last lifecycle transition = "PRE_ON_CREATE")
    • 1
    • 1
  • r

    Robert Menke

    11/03/2020, 9:17 PM
    So in order to avoid applying a tint to an
    Icon
    I’m using the below. Is there anything in the current compose lib that’s equivalent?
    @Composable
    fun ColorIcon(asset: VectorAsset, modifier: Modifier = Modifier) {
        val painter = rememberVectorPainter(asset = asset)
        Box(modifier.defaultSizeFor(painter).paint(painter))
    }
    
    private fun Modifier.defaultSizeFor(painter: Painter) =
        this.then(
            if (painter.intrinsicSize == Size.Unspecified || painter.intrinsicSize.isInfinite()) {
                DefaultIconSizeModifier
            } else {
                Modifier
            }
        )
    
    private fun Size.isInfinite() = width.isInfinite() && height.isInfinite()
    
    // Default icon size, for icons with no intrinsic size information
    private val DefaultIconSizeModifier = Modifier.preferredSize(24.dp)
    l
    • 2
    • 1
  • b

    Bryan Herbst

    11/03/2020, 9:35 PM
    Is there an equivalent to Android Studio’s sample resources for `@Preview`s? I would love to have preview-only resources like images. Text is relatively easy to just put in the preview function, but images are more difficult.
    w
    • 2
    • 2
  • w

    wisdom

    11/04/2020, 12:05 AM
    Who has faced this issue? https://mobile.twitter.com/Joklinztech/status/1323375378958815232
    i
    • 2
    • 1
  • m

    Mehdi Haghgoo

    11/04/2020, 5:20 AM
    I think in previous versions, we could see the source code and check out documentation for each built-in composable. Now in alpha06, when I click a composable, I see a decompiled class file. Am I missing something?
    a
    a
    • 3
    • 4
  • a

    alorma

    11/04/2020, 5:20 AM
    Has anyone used the
    BackdropScaffold
    ? I'm curious about what you've added to the backgroundLayer
    n
    • 2
    • 1
  • o

    Oussama Haff.

    11/04/2020, 8:08 AM
    I tried to generate multiple previews for a Composable using two preview parameters. It seems that having multiple preview parameters is not allowed. I’m kinda sad about it 😞 Useful use case : previewing a design system component against multiple themes & multiple sample data
    c
    • 2
    • 2
  • g

    Gabriel

    11/04/2020, 8:50 AM
    Hey folks, I'm using mockito to mock a viewmodel and then return certain values
    @Mock
    lateinit var viewModel: ImageListViewModel
    ...
    
    `when`(viewModel.imageItems).thenReturn(listOf())
    but doing this gives me an error:
    java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object androidx.compose.runtime.State.getValue()' on a null object reference
    where imageItems is
    var imageItems: List<ImageItem> by mutableStateOf(listOf())
    	private set
    would anyone know what I'm doing wrong?
    • 1
    • 1
  • s

    Slackbot

    11/04/2020, 10:10 AM
    This message was deleted.
    g
    • 2
    • 1
  • p

    Prashant Priyadarshi

    11/04/2020, 10:50 AM
    I am trying to include compose (1.0.0-alpha06) in an existing project which is using kotlin (1.4.10), But I am getting build error due to 'kotlin-android-extensions' unbound symbols not allowed for kotlinx.android.synthetic.mainActivity As of now is there any workaround to use compose without removing all the code which uses kotlinx.android.synthetic, because that is a cumbersome.
    j
    j
    • 3
    • 12
  • j

    jaqxues

    11/04/2020, 4:03 PM
    Running into the same issue (and use case): https://stackoverflow.com/questions/64675386/how-to-get-activity-in-compose
    n
    • 2
    • 2
  • r

    Robert Menke

    11/04/2020, 5:10 PM
    Is this the expected behavior for a bottom drawer layout?
    drawer_issue.m4v
    m
    n
    • 3
    • 9
Powered by Linen
Title
r

Robert Menke

11/04/2020, 5:10 PM
Is this the expected behavior for a bottom drawer layout?
drawer_issue.m4v
m

matvei

11/04/2020, 5:13 PM
Yeah, per spec BottomDrawer always open half screen since it's expected to have a lot of content with header, destinations, etc. What you are looking for is
ModalBottomSheet
, it should have the behaviour you want
r

Robert Menke

11/04/2020, 5:14 PM
Awesome, thanks @matvei!
n

Nipun Rajput

11/05/2020, 8:56 AM
@matvei Can we change the ModalBottomSheetLayout content on runtime? like to show different ui on different condition i.e show progress bar , content after fetch from network etc
m

matvei

11/05/2020, 10:13 AM
Should be possible,
ModalBottomSheetLayout
should resize itself when content changes. Let me know if it doesn't work for you.
n

Nipun Rajput

11/05/2020, 10:15 AM
If i am applying check on two composable to switch view it is throwing IllegalsateException saying snapshot has aalready been taken
m

matvei

11/05/2020, 10:59 AM
Not sure I understand the problem. What compose alpha version are you using?
n

Nipun Rajput

11/05/2020, 11:00 AM
alpha04
m

matvei

11/05/2020, 11:02 AM
I remember there was a bug with snapshot reads in alpha 04, try to update to 05
n

Nipun Rajput

11/05/2020, 11:03 AM
ok, Thanks I'll try with this version too
View count: 3