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

    Shivam Kumar Jha

    08/27/2021, 7:01 AM
    Hi facing an issue where tapping twice on a icon leads to navigate called twice, whats the best way to avoid it? Am Using animated NavHost. While first navigate transition is still in progress if i click again it is leading to two navigate calls
    d
    i
    +3
    • 6
    • 21
  • z

    ziv kesten

    08/27/2021, 7:30 AM
    As part of setup for compose i see that the gradle file now holds this:
    packagingOptions {
            resources {
                excludes += '/META-INF/{AL2.0,LGPL2.1}' // ??? 
            }
        }
    Does anyone know what this means?
    👀 1
    r
    c
    • 3
    • 4
  • m

    Marco

    08/27/2021, 8:38 AM
    Hello guys! Another amazing day with compose, one question I have a nested navigation graph with 3 composable like this (they are 3 step of signup screen)
    navigation(startDestination = "step1", route = "signup") {
        composable(route = "step1") {
            Step1Screen(hiltViewModel<SignUpViewModel>())
        }
        composable(route = "step2") {
            Step2Screen(hiltViewModel<SignUpViewModel>())
        }
        composable(route = "step3") {
            Step2Screen(hiltViewModel<SignUpViewModel>())
        }
    }
    
    composable(MainRoutes.ConfirmEmail) {
        ...
    }
    my goal is to have the same
    SignUpViewModel
    instance in the three composable. With the current implementation each screens have a different instance (so I lost previous steps states). Any idea to handle this scenario? Because a different solution is to use another NavHost with a different NavigatrionController, but I would avoid it
    h
    c
    • 3
    • 2
  • a

    adjpd

    08/27/2021, 11:06 AM
    Anyone had any experience of this https://en.miui.com/ and Compose? Specifically, when a phone is in dark mode, and the effect that has on MaterialTheme colours? This is my tester's problem on a MIUI device with Android 10. And it's doesn't consistently happen. (No other testers have this problem)
    Text(
      "this is not shown",
      color = MaterialTheme.colors.onSurface,
    )
    Text(
      "but this is shown,
      color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f),
    )
    s
    • 2
    • 4
  • r

    rajesh

    08/27/2021, 11:44 AM
    How do i achieve following UI with row? Code is in thread which does not produce desired output
    f
    r
    • 3
    • 8
  • r

    rsktash

    08/27/2021, 1:10 PM
    How can we know if a FocusRequester is initialized? I think this property must be exposed
    a
    • 2
    • 3
  • r

    rsktash

    08/27/2021, 1:22 PM
    Is the Compose team on a holiday ? 😄
    🤔 1
    f
    v
    +2
    • 5
    • 8
  • c

    Csaba Kozák

    08/27/2021, 1:45 PM
    I tried to update to navigation-compose 2.4.0-alpha07, but i see that it requires API level 31, which is not released, yet. This is not documented in the release notes. Is this an intentional change? cc @Ian Lake
    s
    i
    j
    • 4
    • 7
  • r

    rajesh

    08/27/2021, 3:07 PM
    I'm storing logged in user's data in local database. And I need that user id in multiple composable for future requests. Should I use
    CompositionLocal
    for this to pass userId?
    👀 1
    z
    j
    • 3
    • 3
  • m

    mattinger

    08/27/2021, 3:27 PM
    Have a quick question on navigation controller. In the past we used a base fragment with a view model to log events like “pageEnter” and “pageExit” (the latter had a duration), keyed off of onPause/onResume of the fragments. I’m thinking with the compose navController, this would have to be more of a destination listener, but is there a way to attach additional information to a route that i can access when navigating? or just in general in case someone backgrounds the app?
    i
    c
    • 3
    • 2
  • s

    Scott Kruse

    08/27/2021, 3:50 PM
    Is there a case study list for companies building production apps in compose?
    a
    • 2
    • 2
  • r

    rsktash

    08/27/2021, 5:40 PM
    There is an issue with focus restore on recomposition. When we use dynamic list of TextFields and add new TextField on last text change the focus is passed to the new TextField https://github.com/rustamsmax/compose-report
    r
    • 2
    • 25
  • n

    Nikita

    08/27/2021, 5:42 PM
    Hi guys, I faced with unexpected (in my opinion) behavior of LazyRow: I have row of N elements and I remember some state in itemContent lambda See screenshot: in logs I see "remember" every time when element appears on screen and as a result, I conclude that reusing of composables not working or I don't understand something Please tell me what am I doing wrong? thanks
    a
    • 2
    • 3
  • a

    Ashu

    08/27/2021, 8:17 PM
    My experience with compose has become really frustrating at this point. I have to create a configuration for each Preview composable I want to run due to
    PreviewActivity 404
    issue. And after that, each run requires me to first clean and rebuild the project and then run it. Seriously any help would be greatly appreciated.
    w
    e
    • 3
    • 5
  • r

    Ricardo García

    08/27/2021, 8:38 PM
    I’m experiencing some performance issues when using accompanist pager in conjunction with a LazyColumn for each one of the pages. Scrolling is noticeably laggy. I thought at first it was related to having a ConstraintLayout for each item in the LazyColumn, but I still see the same issue when using a simple Column/Row layout instead of a ConstraintLayout. Is this a known issue?
    ➕ 2
    👆 1
    s
    w
    f
    • 4
    • 13
  • c

    Chachako

    08/27/2021, 10:01 PM
    Why doesn't
    clickable
    use
    runBlocking
    to allow the click callback to be suspend internally
    d
    a
    • 3
    • 6
  • s

    Slackbot

    08/27/2021, 10:09 PM
    This message was deleted.
    ✅ 1
    d
    • 2
    • 2
  • r

    rsktash

    08/27/2021, 10:17 PM
    Hi. I’m using accompanist insets to animate navbar and ime insets padding. How can I bring an editing TextField into visible area after animation end? The TextField is in a scrollable container and there are plenty of them Now I’m waiting a bit in order to IME show animation started like this
    • 1
    • 3
  • b

    Bradleycorn

    08/27/2021, 11:52 PM
    I’m new to AndroidView interop, and have a question about the
    MapView
    (or maybe really a question about the
    LocalLifecycleOwner
    Composition Local) that is used in the *Crane Sample app*…. The app uses a separate activity for the Details screen which contains the
    MapView
    . The
    MapView
    follows the lifecycle of the
    LocalLifecycleOwner
    (by setting up an observer on the owner’s lifecycle and calling the corresponding MapView method when the lifecycle’s state changes). I guess my question is whether that setup is “binding” the MapView to the lifecycle of the Activity, or the lifecycle of the composition in which it’s used? For example, in the (parent)
    DetailsContent
    composable, say I were to setup a boolean state value that gets toggled when clicking on one of the Text composables. And then I wrap the call to the
    CityMapView
    composable to only get called when the state value is true (thus creating the ability to toggle the map display on an off). If I then click on the text and toggle the map display off (
    CityMapView
    leaves the composition), will the MapView have it’s onStop and onDestroy methods called? Or is it “bound” to the activity, and it will continue to exist (and be resumed) since the activity’s lifecycle still exists and is resumed? if that is the case, it seems like toggling it on and off would be problematic.
    • 1
    • 1
  • f

    Florian

    08/28/2021, 7:45 AM
    If I want to enable dark theme directly in the app settings (that overrides the system settings), I store a Boolean in DataStore or SharedPreferences and pass that to my Theme composable? Is this the correct approach?
    :yes: 1
    a
    • 2
    • 9
  • a

    adjpd

    08/28/2021, 10:26 AM
    If anyone's seen that about an
    NonSdkApiUsedViolation
    , I'd like to know too. Thanks.
    • 1
    • 1
  • f

    Florian

    08/28/2021, 12:32 PM
    Can you not preview AlertDialogs in Compose?
    d
    s
    +2
    • 5
    • 12
  • o

    orangy

    08/28/2021, 2:13 PM
    I have two widgets in a Row, one is box with image (with some paddings), and another one is just text. How do I set vertical alignment for the Row, so that baseline of text and bottom of the image are aligned?
    d
    t
    • 3
    • 5
  • s

    Shakil Karim

    08/28/2021, 3:23 PM
    Is there any examples of using NavController within Hilt Viewmodel and also using SaveHandler for handling Process restart? It would be so much simpler if there is a way to merge all the remember*State with State in ViewModel.
    t
    f
    i
    • 4
    • 20
  • j

    Jan Skrasek

    08/28/2021, 4:24 PM
    Navigation: Why is not the
    bottomSheet() {}
    navigation implemented the same way as the
    dialog {}
    one -> i.e. via the Window API? https://github.com/google/accompanist/tree/main/navigation-material
    ➕ 1
    i
    • 2
    • 6
  • t

    theapache64

    08/28/2021, 4:35 PM
    This value is not likely to be unique but is not guaranteed unique
    OR
    This value is likely to be unique but is not guaranteed unique
    ?? 🤔 Source
    j
    l
    • 3
    • 4
  • f

    Florian

    08/28/2021, 7:36 PM
    Is this the correct approach to programmatically switch dark/light theme from a user setting? I just recompose the whole activity (which contains all screens of the app)
    @AndroidEntryPoint
    class MainActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContent {
                val selectedTheme by appPreferencesViewModel.selectedTheme.collectAsState(null)
    
                selectedTheme?.let { selectedTheme ->
                    val darkTheme = when (selectedTheme) {
                        ThemeSelectionValues.LIGHT -> false
                        ThemeSelectionValues.DARK -> true
                        ThemeSelectionValues.SYSTEM -> isSystemInDarkTheme()
                    }
                    MyAppTheme(darkTheme = darkTheme) {
                        // ActivityBody with NavHost
                    }
                }
            }
        }
    }
    a
    a
    • 3
    • 6
  • r

    rsktash

    08/28/2021, 10:05 PM
    [SOLVED] Hi. How can I achieve that the context menu items draw over the column rows?
    f
    m
    • 3
    • 13
  • s

    Sanendak

    08/28/2021, 10:59 PM
    Hello everyone! Small question: It is normal to use Scaffold inside another Scaffold? For example I have main Scaffold with BottomNavigation and NavHost, inside NavHost there another screen that uses Scaffold because need to show Snackbar.
    z
    f
    • 3
    • 5
  • a

    adjpd

    08/28/2021, 11:32 PM
    https://developer.android.com/codelabs/jetpack-compose-basics and https://developer.android.com/codelabs/jetpack-compose-state ...talk about using `TextField`s and
    remember
    . But they don't mention that, if you want the content to persist after configuration changes (screen rotation), you need
    rememberSaveable
    The docs do mention it, of course. But the pathway doesn't. If anyone from Google reads this, it may be worth mentioning it in the pathway. I completely forgot about it and released an app.
    a
    • 2
    • 8
Powered by Linen
Title
a

adjpd

08/28/2021, 11:32 PM
https://developer.android.com/codelabs/jetpack-compose-basics and https://developer.android.com/codelabs/jetpack-compose-state ...talk about using `TextField`s and
remember
. But they don't mention that, if you want the content to persist after configuration changes (screen rotation), you need
rememberSaveable
The docs do mention it, of course. But the pathway doesn't. If anyone from Google reads this, it may be worth mentioning it in the pathway. I completely forgot about it and released an app.
a

Albert Chang

08/29/2021, 10:49 AM
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1622217146183800?thread_ts=1622216960.183000&amp;cid=CJLTWPH7S
a

adjpd

08/29/2021, 11:16 AM
Hmm. Won't that prevent app rotation?
a

Albert Chang

08/29/2021, 11:22 AM
No.
compose will react and update granularly for any of them
a

adjpd

08/29/2021, 11:23 AM
Interesting. Thanks. I should try it.
What if your apps in the background, killed by android, and is recreated? Then your text field will be empty, surely.
a

Albert Chang

08/29/2021, 11:25 AM
In that case you need
rememberSaveable
, yes.
a

adjpd

08/29/2021, 11:27 AM
Still, the pathway should mention
rememberSaveable
really. In apps which aren't compose first, or apps which the system kills, then the user will be confused why their text field text, or whatever, has been obliterated.
Also, if you use
configChanges="orientation"
etc in compose-first apps then `AndroidView`s won't get alternative XML styles, and I've found I need to use those for things like
CalendarView
which demands certain styling be done via the theming system alone.
View count: 5