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

    loloof64

    04/19/2021, 6:48 PM
    Hi ! Maybe a dumb question, but does
    mutableStateOf()
    has an immutable version ? Or would that have no sense ? Because I want to have a state, but that would never change : just in order to avoid to create it each time
    s
    c
    17 replies · 3 participants
  • l

    loloof64

    04/19/2021, 8:54 PM
    I have this mutable state with delegation
    var engineName by rememberSaveable { mutableStateOf("") }
    but sometimes, and initially, I want it to be null, how should I declare it ?
    a
    l
    4 replies · 3 participants
  • l

    Luis Daivid

    04/20/2021, 1:09 AM
    d
    h
    13 replies · 3 participants
  • b

    Big Chungus

    04/20/2021, 7:48 AM
    Where would you guys recommend starting to learn compose?
    f
    c
    8 replies · 3 participants
  • w

    wisdom

    04/20/2021, 7:49 AM
    Hello Kotliners, Any example available on how to implement ” Tabs” / “TabRow” or sample. I would appreciate.
    a
    2 replies · 2 participants
  • t

    Tlaster

    04/20/2021, 8:42 AM
    Seems like when using Android in LTR, Compose
    Text
    is not automatically align the text to the right when the text's language is RTL (Arabic for example), meanwhile the View base
    TextView
    does align the text to the right when the text's language is RTL, is it a bug or desired design?
    s
    5 replies · 2 participants
  • l

    loloof64

    04/20/2021, 8:52 AM
    Hi ! In my application I am using Navigation. But in one of my pushed pages, I mean in the composable which defines this page, I need to detect when application come back in the foreground, in order to update it. Let's call
    MainActivity
    the activity which defines the navigation, and
    TargetComposable
    the composable of the pushed page. How can I force a reload of
    TargetComposable
    when application is back in foreground ? Is using
    MainActivity
    's
    onStart()
    method mandatory (and can it lead to a kind a mess, coupled with Navigation) ? Or is there a simpler solution ?
    i
    24 replies · 2 participants
  • o

    Olivier Patry

    04/20/2021, 9:41 AM
    Hello 👋 I have troubles to re-trigger an animation when a state changes. I want to make a label appear from left (outside the screen bounds) to center. I can make it work the first time but when I change the state linked to this label, the animation isn't re-triggered. (code in :thread-please:)
    ✅ 1
    a
    6 replies · 2 participants
  • e

    escodro

    04/20/2021, 12:19 PM
    Hello, everyone! 👋 I’m facing some issues with
    adjustResize
    in my Compose project in landscape. The flag does work when the
    TextField
    is inside another smaller
    Composable
    , like a
    BottomSheet
    . If the the
    EditText
    is in a
    Scaffold
    , it does not seen to work. Could someone help me please? I attached a video to better explain it. Thanks a lot in advance!
    n
    4 replies · 2 participants
  • y

    YASAN

    04/20/2021, 3:40 PM
    I am trying to disable click ripple effect by
    .clickable(indication = null)
    even tho Android Studio autocompletes it, it becomes red instantly and wont build. Any ideas?
    l
    c
    9 replies · 3 participants
  • y

    YASAN

    04/20/2021, 7:39 PM
    I am trying to use 
    coroutines
     in a 
    LazyVerticalGrid
     item. I have this:
    val coroutineScope = rememberCoroutineScope()
    and this in a `Column`:
    val drawable = mutableStateOf<Drawable?>(null)
    coroutineScope.launch {
        drawable.value = app.requireIcon(activity)
    }
    But the code inside
    launch
    does not even start. What am I doing wrong? I need to load a Drawable inside each lazy item and it can take a few seconds so I cannot do it on the main thread.
    a
    s
    7 replies · 3 participants
  • c

    Chris Fillmore

    04/20/2021, 8:52 PM
    Hi, I am wondering if anyone has worked on such a problem. I have some code like this:
    @Composable
    fun WeightedBox() {
      Row {
        Box(modifier = Modifier.weight(0.3f)) {
          // Hypothetical @Composable Image
          Image(...)
        }
      }
    }
    Basically I am trying to load an image in a Box that will be weighted to 30% width of the display. The API I’m calling to fetch the image allows me to filter the url to only fetch the size of image I need. For example, if I’m fetching
    /images/pic1.jpg
    but I only need it at max 400px width/height, I could fetch
    /images/pic1_400x400.jpg
    . Is there any way for me to know the calculated width in pixels, so that I can pass this information along with my request? Fwiw I don’t need to use Box exactly. If there’s another composable that would provide this behaviour, I can use that. I guess my use case is similar to, say, if I were making a grid of images. Thanks for any help!
    s
    s
    +3
    18 replies · 6 participants
  • t

    Timo Drick

    04/20/2021, 9:22 PM
    How can i call a @Composable function from reflection. I know that the compiler plugin will add two additional parameters to the function. The question is what should i provide in this first two parameters. One needs the Composer and the second an Int (I think it is the slot). Is it possible to do this via reflection?
    z
    a
    6 replies · 3 participants
  • z

    Zach Klippenstein (he/him) [MOD]

    04/20/2021, 10:34 PM
    The amount of special-casing that seems to be needed specifically to support ripples – someone at google must have very strong feelings about them 😂 Do any other compose operations happen on the render thread (e.g.
    graphicsLayer
    changes that don’t require recomposition perhaps)?
    i
    r
    +3
    33 replies · 6 participants
  • w

    Walter Berggren

    04/21/2021, 8:24 AM
    Hi!
    onValueChangeFinished
    for Slider doesn’t seem to be behaving I expect it to. I expect it to be called a single time once the user has finished dragging, but it is also called at the very beginning of a user drag. Is this the intended behavior?
    m
    3 replies · 2 participants
  • s

    Samir Basnet

    04/21/2021, 8:53 AM
    Faced this error after upgrading to beta 04
    java.lang.NoSuchFieldError: No static field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion; in class Landroidx/compose/foundation/layout/BoxScope; or its superclasses (declaration of 'androidx.compose.foundation.layout.BoxScope' appears in /data/app/com.view9.mahal-Zh5TQ66RD7sgpFKhGyXOyg==/base.apk)
    at com.google.accompanist.pager.Pager.Pager(Pager.kt:461)
    at com.google.accompanist.pager.Pager.HorizontalPager(Pager.kt:147)
    f
    5 replies · 2 participants
  • a

    allan.conda

    04/21/2021, 9:19 AM
    Anyone know the equivalent of nested navigation arguments in Jetpack XML Navigation on compose-navigation?
    <navigation>
      <navigation>
        <argument... />
        <fragment />
      </navigation>
    </navigation>
    I know that arguments inside
    <fragment>
    can be translated as
    composable(
      route = "screenA",
      arguments = listOf(navArgument(...)),
    ) { ... }
    But I’m not sure how we can pass arguments to a nested navigation itself which encapsulates its start destination.
    :thread-please: 1
    i
    1 reply · 2 participants
  • n

    nitrog42

    04/21/2021, 9:51 AM
    Hello, I'm currently switching the main screen of my current project to Compose, and I'm looking for a way to do get the height from a composable to use it in another :
    Box {
        Column(Modifier.padding(bottom = /* height of the snackbar*/)) {
            //content
        }
        Snackbar {
            Text("My text")
        }
    }
    what is the best method to do that? a custom layout ? Do you have any resources that could show me some code sample about this?
    f
    a
    57 replies · 3 participants
  • m

    Marcin Środa

    04/21/2021, 12:02 PM
    Hi, I’m looking at the compose testing part, and thinking is it possible to check if some local providers are set.
    1 reply · 1 participant
  • y

    YASAN

    04/21/2021, 1:49 PM
    Using Compose Navigation library, I am trying to override
    onBackPressed
    to not let the user exit the app (its a launcher so that's the expected behavior). But I have not found a way to check if the current destination is the main/last destination or if back stack is empty so I dont call
    super.onBackpressed
    on that condition.
    i
    19 replies · 2 participants
  • d

    David Edwards

    04/21/2021, 2:37 PM
    Has there been any discussion as to when Compose will be implementable outside of Canary AS?
    c
    a
    +1
    7 replies · 4 participants
  • n

    nitrog42

    04/21/2021, 3:33 PM
    Btw, is there anyone here that has or is planning to use Compose in a production app ? Sorry if it's something that has already been asked/asked regularly
    👍 1
    z
    y
    +1
    16 replies · 4 participants
  • y

    Yuri Drigin

    04/21/2021, 4:33 PM
    I have a dumb question:
    val tokens = viewModel.tokens.observeAsState(listOf())
    I use mock viewModel for preview with hardcoded livedata
    override val stables: LiveData<List<StableTokenWithMetaAndRate>> = liveData {
      listOf(StableTokenWithMetaAndRate.USDp, StableTokenWithMetaAndRate.EURp)
    }
    However in the preview show me an empty list (((
    z
    d
    +1
    7 replies · 4 participants
  • p

    PHondogo

    04/21/2021, 4:34 PM
    Hello! Is there any analog for SelectBox/DropdownMenu?
    y
    z
    +1
    4 replies · 4 participants
  • j

    jefbit

    04/21/2021, 5:55 PM
    Hello all, I have 3 BottomNavigationTabs and each has its own "Container composable" that holds a navHost and controls its navigation within that tab. I am having trouble trying to retain the state of the current composable in view when I navigate to another tab and back. For instance I have tabs A,B,C. When navigating from A ->A1 -> A2 -> B and then back to A. It restarts from A when I would like it to resume from A2. Any information on how I can acheieve this?
    i
    r
    9 replies · 3 participants
  • d

    dewildte

    04/21/2021, 6:43 PM
    How does one go about hijacking the back button the same way a DropdownMenu or AlertDialog does?
    BackHandler
    ?
    ➕ 1
    i
    13 replies · 2 participants
  • d

    dewildte

    04/21/2021, 7:16 PM
    I have this scenario: Upon screen transition I want to animate an arbitrary amount of composables. I don’t want the other screen to show until all the composables have finished their exit animations. How would I go about knowing when the animations all complete? I am using
    AnimatedVisibilty
    for pretty much everything. But that composable does not have a callback, perhaps I could use a
    LaunchedEffect
    or
    DisposableEffect
    for that piece? I am not sure if this is an architectural question or a compose question. It’s kind of a cross cutting thing.
    d
    31 replies · 2 participants
  • g

    Gabriel Melo

    04/21/2021, 7:39 PM
    Hello, everyone! Does anyone know of a tool similar to Color Tool from material.io with Compose in mind? I tried using the aforementioned tool, but neither its output conform with Compose's theme structure nor was I able to infer the color names from their hex codes.
    c
    5 replies · 2 participants
  • c

    Colton Idle

    04/21/2021, 8:10 PM
    Why doesn't a disabled button have it's icon automatically tinted too? Code in 🧵
    c
    j
    +2
    16 replies · 5 participants
  • e

    eygraber

    04/21/2021, 8:59 PM
    The doc for
    staticCompositionLocalOf
    says:
    A static CompositionLocal should be only be used when the value provided is highly unlikely to change.
    What if the value provided is always the same instance, but
    provides
    would be called on each composition?
    d
    1 reply · 2 participants
Powered by Linen
Title
e

eygraber

04/21/2021, 8:59 PM
The doc for
staticCompositionLocalOf
says:
A static CompositionLocal should be only be used when the value provided is highly unlikely to change.
What if the value provided is always the same instance, but
provides
would be called on each composition?
d

Dominaezzz

04/21/2021, 9:08 PM
As long as the instance is the same it's cool.
➕ 1
:thank-you: 1
View count: 2