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

    Daniele Segato

    07/30/2021, 9:22 AM
    I've upgraded to
    navigation-compose 2.4.0-alpha05
    and my LazyColumns were broken. I've investigated and it looks like
    rememberSaveable
    usage without a key has been broken. Upon navigation and back it is not restored because
    currentCompositeKeyHash
    has changed. This means
    rememberLazyListState()
    doesn't work if you leave a list into a detail and than back it scrolls back up cause it creates a new
    LazyListState
    @Ian Lake I'm tagging you because I saw you are on top of this kind of issues in other comments and I suppose this information can help you solve other issues with this release. If you do not want me to ping like that I won't do it again. I can (and will) create a bug report: just do not have time now and just wanted to let you guys know of the issue as fast as I could. -- I'll link it here in a response Other issues I noticed: I had a login flow working like this: routes: • EntryPoint • Login • Registration the Entry point sent directly to either login or registration with a
    LaunchedEffect
    controlled by a StateFlow in the viewmodel. When entering the screen I would mark it to exit when coming back. This allowed me to handle the logic of setting backStackEntry arguments as results of the auth flow. with the old navigation after navigating to login the launched effect didn't receive the "go back" event until the user re-entered the entry point screen while with alpha05 it immediately execute the back call. This was fixed using
    lifecycle.whenStarted { }
    to handle the navigation back -- but you might wanna mention this as side effect in the release notes.
    i
    c
    a
    • 4
    • 19
  • t

    Tgo1014

    07/30/2021, 10:34 AM
    How can I know if a
    ScrollableState
    is scrollable aka all the content is already being shown?
    m
    • 2
    • 4
  • c

    Csaba Szugyiczki

    07/30/2021, 11:12 AM
    [Poor image quality on rotated Icon] I have a compass icon that I want to rotate so that it is always pointing to north. When the rotation is 0 everything is nice, my icon is displayed sharp. But when the rotation value is different, the icon becomes heavily pixelated. The icon is a vector image loaded with
    painterResource
    Is it possible to apply antialiasing or something similar to improve image quality?
    Icon(
        painterResource(R.drawable.ic_map_compass),
        contentDescription = stringResource(R.string.map_compass_button_content_desription),
        tint = Color.Unspecified,
        modifier = Modifier.rotate(
            -bearing
        )
    )
    👀 14
    a
    a
    +6
    • 9
    • 23
  • j

    Joey

    07/30/2021, 12:52 PM
    What's the recommended way to repeat a vector as a pattern on the background of a composable? Should I convert the vector to a bitmap and draw it in a canvas with a TileMode.REPEATED Paint?
    t
    • 2
    • 1
  • t

    Thiago

    07/30/2021, 12:58 PM
    Hi folks. Will compose have your own code style guide or we must keep using Kotlin/Android style guide?
    z
    • 2
    • 2
  • a

    Aman Kapoor

    07/30/2021, 1:36 PM
    Has anyone tried compose on release build with debuggable on? I am getting crashes related to profileInstaller but not really sure what is the issue and it just print some native memory logs.
    • 1
    • 2
  • d

    Daniel Weidensdörfer

    07/30/2021, 2:17 PM
    Hello everyone, how can I get the screen width in px inside of a composable?
    s
    d
    • 3
    • 3
  • l

    loloof64

    07/30/2021, 2:44 PM
    Hi ! I am creating a custom composable, and would like to get available width/height from the given modifier : is it possible ? My goal is to implement a kind of
    FlowLayout
    using the
    Layout
    composable. But for this to work, I need the available width.
    Available_size_for__composable_from_its_Modifier.kt
    t
    z
    • 3
    • 4
  • a

    Alexa_Gal

    07/30/2021, 2:57 PM
    Hi guys just noticed something weird with compose navigation. My app crashes when i add 13
    composables
    in the
    NavHost
    have you noticed this as well? it works fine with 12 or less
    java.lang.ArrayIndexOutOfBoundsException: length=13; index=13
    😄 1
    ➕ 1
    p
    u
    +2
    • 5
    • 6
  • t

    Tin Tran

    07/30/2021, 3:28 PM
    Hi! Im using
    AnimatedVisibility
    and notice some weird behavior for
    expandVertically
    and
    shrinkVertically
    Is this expected?
    Screen_Recording_20210730-222211_GOLFTEC Clubhouse.mp4
    d
    • 2
    • 3
  • m

    MaxUt

    07/30/2021, 3:35 PM
    What would you guys recommend to stack rotated text ? I've tried simply using a column but it seems that the rotated texts are merged. In addition, I've notice that the width of the column is still equal to the initial width of the texts.
    z
    • 2
    • 5
  • n

    Norbi

    07/30/2021, 4:33 PM
    Is there a restriction for navigation hierarchies in Compose? This code works as expected:
    @Composable
    fun ApplicationRoot() {
        val navController = rememberNavController()
        MaterialTheme {
            NavHost(navController = navController, startDestination = "home") {
                composable("home") {
                    HomeScreen()
                }
            }
        }
    }
    
    @Composable
    fun HomeScreen(viewModel: ApplicationViewModel = viewModel()) {
        val applicationState by viewModel.applicationStateStore.observeAsState()
        ...
    But if I refactor
    applicationState
    as a parameter then it doesn't work correctly, no recomposition happens if
    viewModel.applicationStateStore
    is modified:
    @Composable
    fun ApplicationRoot(viewModel: ApplicationViewModel = viewModel()) {
        val applicationState by viewModel.applicationStateStore.observeAsState()
        val navController = rememberNavController()
        MaterialTheme {
            NavHost(navController = navController, startDestination = "home") {
                composable("home") {
                    HomeScreen(applicationState)
                }
            }
        }
    }
    
    @Composable
    fun HomeScreen(applicationState: ApplicationState) {
        ...
    Thanks.
    i
    • 2
    • 2
  • i

    Ian Arbuckle

    07/30/2021, 5:23 PM
    This question might have been asked before. Is there any catalogue of material components in Compose? Trying to find a Rating Bar composable like we have in the xml widgets.
    j
    g
    c
    • 4
    • 4
  • c

    Colton Idle

    07/30/2021, 8:13 PM
    Any guides to compose navigation with bottomNav with a sign in flow? I used these docs when setting up my app https://developer.android.com/jetpack/compose/navigation#bottom-nav but now when I open the app on a cold launch (and the user isn't logged in), I see my HomeScreen for a split second with my bottom nav and then I go to my sign in screen which doesn't have bottom nav and it's just kinda jarring from the user POV. Curious if there's some best practices with bottom nav and sign in combined.
    n
    i
    • 3
    • 9
  • s

    smallshen

    07/30/2021, 9:14 PM
    what should I use to make mutableList updated properly in compose?
    l
    a
    • 3
    • 2
  • r

    Rafs

    07/30/2021, 10:33 PM
    In a column with an
    animatedVisiblity
    and a
    Button
    composable, how do I prevent the Button from moving to the space occupied by the
    animatedVisiblity
    when it is invisible.
    i
    • 2
    • 1
  • a

    Abhishek Dewan

    07/31/2021, 2:10 AM
    wanted to give it one more try if anyone had some insights. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1627628600020700
    c
    • 2
    • 2
  • m

    ms

    07/31/2021, 3:14 AM
    I have a Settings screen which shows list of settings item and under each item there will be more settings which shows/hides on parent click but Compose doesn't allow to use
    NestedScrollable
    inside
    Column
    or
    LazyColumn
    code in 🧵
    c
    a
    a
    • 4
    • 10
  • l

    loloof64

    07/31/2021, 9:31 AM
    Is it possible to make an Accompanist
    FlowRow
    scrollable ? Or to add Scrollbars automatically around it ?
    c
    • 2
    • 2
  • d

    Daniel Weidensdörfer

    07/31/2021, 10:52 AM
    Let's suppose I have a
    swipeableState
    like in this example: https://developer.android.com/jetpack/compose/gestures#swiping . Since
    swipeableState.snapTo(...)
    is a suspend function, I probably need to call it from a side effect. Whats the correct way to call this function inside of a composable?
    m
    s
    • 3
    • 3
  • m

    miqbaldc

    07/31/2021, 4:23 PM
    Is it currently not supported smart-cast inside
    when
    for the
    sealed class
    with
    LiveData.observeAsState
    like this code in 🧵?
    c
    l
    • 3
    • 6
  • l

    loloof64

    07/31/2021, 5:07 PM
    What should I use in order to make a
    @Composable
    scrollable ?
    z
    • 2
    • 4
  • v

    Vsevolod Ganin

    07/31/2021, 5:18 PM
    Is there a way to measure composable without ever displaying or using it? Use case is in 🧵
    k
    • 2
    • 5
  • s

    SrSouza

    07/31/2021, 7:20 PM
    https://twitter.com/DevSrSouza/status/1421550983570669572
    👍🏾 1
    👍🏻 1
    👍🏿 1
    👍🏼 3
    👍 4
    m
    • 2
    • 1
  • m

    Mehdi Haghgoo

    07/31/2021, 9:12 PM
    How can I use a timer in Compose to for example increment a ticker? The following code does not work:
    var inc by remember{ mutableStateOf(0)}
        remember{object: CountDownTimer(100L, 1L){
            override fun onTick(millisUntilFinished: Long) {
                inc++
            }
    override fun onFinish() {
    }
    }.start() }
    d
    • 2
    • 1
  • n

    Neal Sanche

    08/01/2021, 3:31 AM
    I have a text field in a screen that is part of a navigation graph accessed through a bottom nav. When I type something in the text field, and switch to another tab, and then back again, the text field is empty. I was expecting the state to be saved, but if I need to save this text in a ViewModel or something, that's fine. Any ideas what's happening here?
    i
    c
    • 3
    • 28
  • j

    james

    08/01/2021, 5:52 AM
    is there any way to have a
    DropdownMenu
    appear in the position of a click? I'd like to capture the x, y position of a click event and have the
    DropdownMenu
    anchored to that position, rather than it just anchoring itself in the default position
    d
    r
    • 3
    • 4
  • u

    ursus

    08/01/2021, 1:03 PM
    Is it just me or is
    LazyColumn
    rather laggy on first scroll? Compared to Column with scroll (obviously since those are eagerly loaded), but also compared to RecyclerView (by feel, didnt measure though) and fling animation is also kind of messed up, but then fixes it self after few swipes up and down; as if something heavy was loading on main thread
    ➕ 13
    s
    n
    +5
    • 8
    • 18
  • y

    YASAN

    08/01/2021, 2:05 PM
    I just updated all my compose dependencies to the latest ones and my one (and only) composable screen that has a dynamic destination string and a viewmodel has issues. It launches without issues but crashes when I want to go back. I cant find how to fix it anywhere including here. Details on the thread:
    a
    i
    • 3
    • 13
  • l

    loloof64

    08/01/2021, 2:50 PM
    I am trying to set an array of
    MovesNavigatorElement
    - which is a class I've defined - as a property of my
    @Composable
    but it does not compile : more in thread
    a
    • 2
    • 10
Powered by Linen
Title
l

loloof64

08/01/2021, 2:50 PM
I am trying to set an array of
MovesNavigatorElement
- which is a class I've defined - as a property of my
@Composable
but it does not compile : more in thread
This is the sealed class
MovesNavigatorElement
Untitled.kt
This is the code which does not compile.
Untitled.kt
This is the error.
Untitled.txt
a

Adam Powell

08/01/2021, 2:54 PM
Use
=
instead of
by
👍🏾 1
l

loloof64

08/01/2021, 2:56 PM
Thank you very much. The compilation has gone. 😃 Now I am facing a different kind of error.
a

Adam Powell

08/01/2021, 2:56 PM
Property delegation is the preferred convention for
mutableStateOf
because
MutableState<T>
is essentially a collection of exactly one element and explicitly referring to its
.value
property is cumbersome/noisy. Other snapshot collection types are used as usual elsewhere.
👍🏾 1
l

loloof64

08/01/2021, 3:03 PM
Thank you, I understand. Also, is using a
SnpashotMutableList
the best way to handle a mutable array of items, in order to save them as a property of Composable, like I'm trying ? Or can I do simpler ?
Finally found that the snapshot can be converted with
.toTypedArray()
.
a

Adam Powell

08/01/2021, 4:13 PM
If composition is either a producer or consumer of mutations to this list, a snapshot list is probably the simplest solution.
👍🏾 1
l

loloof64

08/01/2021, 5:10 PM
Thank you. 😃 I think I've understood. In my current use case, I'm not particularly having Reactive Programming in mind
View count: 1