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

    Orhan Tozan

    04/07/2021, 8:31 AM
    Is it correct to assume that with each Compose beta release, it gets more stable everytime? (Generally speaking)
    :yes: 7
    f
    j
    e
    • 4
    • 3
  • t

    Timo Drick

    04/07/2021, 9:47 AM
    How can i invalidate a complete tree of composables. So i want to force that all childs gets rendered again. (I have a very special use case where this is necessary) My problem is that compose optimizes to much 😄
    f
    a
    +3
    • 6
    • 54
  • c

    Colton Idle

    04/07/2021, 9:49 AM
    If anyone wants to quickly surround some composables with a row or column, I found a way to do it without any plugins or anything. just use the typical "surround with" shortcut (alt cmd t on mac bindings)
    🤔 1
    f
    s
    c
    • 4
    • 5
  • w

    Walter Berggren

    04/07/2021, 11:36 AM
    Hi! I’m running into the following exception when executing
    hiltNavGraphViewModel()
    in a NavHost:
    Expected an activity context for creating a HiltViewModelFactory for a NavBackStackEntry but instead found: android.app.ContextImpl@78d1695
    f
    a
    i
    • 4
    • 11
  • h

    Hatice Sarp

    04/07/2021, 12:37 PM
    Hi everyone, I'm doing fade out/in and slide with animation. But while doing these, the content size also needs to change. While fade out in the code I wrote, I slide the items under it. I am also changing the parent's content size. But the bottom item disappears without slide (
    near my age item in the video
    ). Another problem is that if I slide the top group on the screen so that they do not appear on the screen and run the animation, the top group items disappear from the screen. My code is like this:
    d
    • 2
    • 5
  • r

    Rahul Sainani

    04/07/2021, 2:18 PM
    Hello, is there a way to clear the whole back stack when using navigation with compose? sometimes the start/initial route might be already popped, in that case:
    popUpTo(Route.initial) { inclusive = true }
    doesn't seem to work and all the routes after initial are still present. Is there a way to make sure we clear the back stack without knowing about the first route in the graph?
    j
    i
    • 3
    • 8
  • t

    Tolriq

    04/07/2021, 2:29 PM
    I'm starting to evaluate the impact of a slow migration to Compose but I'm having an hard time understanding the values in https://medium.com/androiddevelopers/jetpack-compose-before-and-after-8b43ba0b7d4f. How adding 4k methods results in a smaller dex size? Is there any other documents about the "weight" of compose during transition?
    a
    b
    • 3
    • 11
  • a

    allan.conda

    04/07/2021, 4:05 PM
    I’m currently migrating our code to use
    compose-navigation
    . Are there any guidelines currently about multi-module with this? Let’s say I have two feature modules, what’s a good way to navigate screens between them without depending on each other? I’m thinking to put hoist the actual navigation into the top-level navigation (where the NavHost is), I wonder if I should be putting all those instances in there, which would be a lot for a highly-modular application.
    i
    • 2
    • 9
  • j

    julioromano

    04/07/2021, 5:08 PM
    Looks like beta04 is among us… 🤓 https://developer.android.com/jetpack/androidx/releases/compose
    🥳 1
    :party-parrot: 5
    🎉 22
    c
    a
    • 3
    • 3
  • j

    julioromano

    04/07/2021, 5:38 PM
    For some reason my project insists on using
    navigation-compose:1.0.0-alpha08
    event though my build.gradle.kts explicitly says
    "androidx.navigation:navigation-compose:1.0.0-alpha10"
    . Any hint on how can I troubleshoot this?
    👀 1
    j
    i
    • 3
    • 11
  • g

    Gabriel

    04/07/2021, 7:40 PM
    I have a columns with 3 items in, a button that stick at the top, a LazyColumn for scrolling item, and another button that I want to stick to the bottom, how can I stick the button to the bottom if the scrollable column only has a couple if items in?
    a
    • 2
    • 3
  • t

    Timon Bohn

    04/07/2021, 8:28 PM
    Any idea on how to adjustPan the software keyboard when a BasicTextField with decorationBox comes into focus? The keyboard appears --> the content scrolls up, but only until the TextField input area. It does not observe the extra padding provided by the decorationBox. Is there either a none jetpack compose specific windowSoftInputMode solution that let me add some extra offset, or is there a decorationBox configuration that I’m missing?
    s
    t
    j
    • 4
    • 9
  • j

    julioromano

    04/07/2021, 9:30 PM
    Can
    LocalSoftwareKeyboardController
    and
    AndroidView
    work together? I’m trying to show the keyboard when the only editable text is inside an
    AndroidView
    . In the update block of
    AndroidView
    I first call
    it.requestFocus()
    then
    keyboardController?.show()
    but nothing happens. If instead of
    it.requestFocus()
    on the view I try to set a
    focusRequester
    modifier on the Android view and then call
    focusRequester.requestFocus()
    I get an IllegalStateException: FocusRequester is not initialized. But I’d love the keyboard to show up as soon as the composable is first shown on screen.
    r
    s
    • 3
    • 8
  • b

    Bryan L

    04/07/2021, 9:46 PM
    Does anyone know of any examples that use Firebase Authentication in pure compose? I'm having a difficult time building it from scratch without finding any concrete examples as the examples all(including docs) utilize multiple activities, xml, & have deprecated functions (i.e
    onActivityResult
    ). Perhaps it's better to interop and utilize multiple acitivites and break the app from being pure Compose? Any guidance/advice is greatly appreciated!
    i
    c
    • 3
    • 5
  • c

    Colton Idle

    04/07/2021, 10:44 PM
    I'm working on a kiosk app that will use a single activity and mostly fragments with composables, and I have a requirement to build in a "admin" alert dialog that shows up any time you click 5 times in a single spot of the app. I see two ways forward. 1: Try to write this on the activity level (I tried onTouchEvent but it seems like it doesn't get triggered because I have FragmentContainerView and that seems to get the events) 2. Write a composable theme that can intercept all touch events, but still let events pass through. Has anyone had experience with trying to have this kind of global x user tap listener? I know a lot of people have created debug menus, etc.
    t
    • 2
    • 2
  • t

    thequinneffect

    04/07/2021, 11:49 PM
    Hi everyone. I'm hoping someone can help me with an issue i'm having with DropDownMenu. I made a stackoverflow post here: https://stackoverflow.com/questions/66965883/jetpack-compose-how-to-force-a-dropdownmenu-to-be-anchored-underneath-its-paren The TLDR of it is that my dropdown menu is too large to remain anchored under the button that opens it (or it is anchored but centered vertically). How can I force it to expand in height from the bottom of the button it is anchored to, to the bottom of the screen? I've tried playing around with wrapContentSize but that allows it to be too tall. The only thing that has kind of worked but seems like a hacky solution was to just manually set the height to 200.dp (but this is not exactly to the bottom of the screen). Any help would be very much appreciated, I've been stuck on this for days...
    g
    • 2
    • 1
  • d

    Deepak Gahlot

    04/08/2021, 2:54 AM
    Hello All,
    z
    a
    d
    • 4
    • 14
  • t

    Tuba Kesten

    04/08/2021, 6:10 AM
    Hello 🙂 Since I changed to version "beta03" I get the following error message when I try to backpress in a suspend function. How can I fix this error?
    java.lang.IllegalStateException: A MonotonicFrameClock is not available in this CoroutineContext. Callers should supply an appropriate MonotonicFrameClock using withContext.
    lifecycleScope.launch { bottomBarManager?.onBackPressed() }
    super.onBackPressed()
    i
    j
    +2
    • 5
    • 14
  • p

    pawegio

    04/08/2021, 7:08 AM
    Are there any release notes for Arctic Fox 13 & 14? 🤔 Both are missing on: https://androidstudio.googleblog.com/
    ☝️ 4
    h
    i
    • 3
    • 10
  • j

    julioromano

    04/08/2021, 7:40 AM
    How to show the software keyboard on composition (i.e. when a screen composable is first displayed)?
    f
    a
    +2
    • 5
    • 26
  • j

    Jason Ankers

    04/08/2021, 7:51 AM
    If a bottom tab acts as a top level destination for a series of different screens, would this be the correct use-case for a nested graph? If so, how is it possible to determine if the current route belongs to this nested graph? The docs show an example determining if the bottom tab icon is selected by checking if
    currentRoute == screen.route
    , but what if we’re on a nested route beneath this? https://developer.android.com/jetpack/compose/navigation#bottom-nav
    i
    • 2
    • 2
  • s

    Smorg

    04/08/2021, 7:53 AM
    Any pointers to why AS Canary on my laptop (MacBook Pro., 16GB Memory, Core i5) get stuck at completing analysing source files. This has been happening since I added Compose dependencies to the project and across multiple updates of the IDE. I have had to do “Invalidate Caches and Restart” countless of times to resolve it, but the issue returns few minutes after each one. Any ideas how to fix this please?
    j
    • 2
    • 6
  • d

    darkmoon_uk

    04/08/2021, 8:47 AM
    Looks like there's a bug in the Crane Compose sample, here: See this line where the map is updated e.g. by a change in zoom. The map preparation coroutine will run with every recomposition. Firstly it feels to me like running
    getMapAsync
    every time is rather inefficient, the first returned instance could be cached? But ok, if we let that pass and assume that the same Map instance will be returned each time... then this code is continually adding more MapMarkers to the map and never removing them?
    a
    m
    • 3
    • 4
  • m

    MBegemot

    04/08/2021, 10:12 AM
    Nice!!! all my theming problems went away !! than you!
    🎉 1
    s
    • 2
    • 2
  • a

    allan.conda

    04/08/2021, 10:25 AM
    I have been thinking about how I could handle full screen navigations (screens that show on top of the bottom navigation screens. I’m thinking of using nested NavHost, but I read somewhere here that it’s not a good idea. I’m also not sure if sharing
    navController
    (bottom navigation triggers a fullscreen navigatino) in multiple NavHost is a supported thing 😅. How is everyone handling fullscreen navigations?
    d
    i
    • 3
    • 11
  • a

    allan.conda

    04/08/2021, 12:02 PM
    Do you guys just define a
    TopAppBar
    for each of your screen? Or share a single one and somehow manage to customize it (set title, navigation icon)? I’m trying to do the latter with
    compose-navigation
    in a multi-modular context, and now contemplating whether this is really a good idea…
    k
    l
    +2
    • 5
    • 5
  • i

    Indu

    04/08/2021, 3:19 PM
    I read a few threads which gave me more info to choose between Layout and BoxwithConstraints. I used Layout for constructing the following screen. Basically I'm changing the number of elements in a row depending on the width of the screen.
    a
    • 2
    • 5
  • n

    Nthily

    04/08/2021, 5:44 PM
    How do I get the specific coordinates of a control?
    k
    • 2
    • 26
  • a

    Altynbek Nurtaza

    04/08/2021, 6:54 PM
    hi guys, does anybody know if there is an easy way to do the following:
    var var1 = rememberSaveable { mutableStateOf(Bundle()) }
    var var2 = rememberSaveable { mutableStateOf(Bundle()) }
    var var3 = rememberSaveable { mutableStateOf(Bundle()) }
    var var4 = rememberSaveable { mutableStateOf(Bundle()) }
    var var5 = rememberSaveable { mutableStateOf(Bundle()) }
    var var6 = rememberSaveable { mutableStateOf(Bundle()) }
    j
    i
    • 3
    • 34
  • m

    Mini

    04/08/2021, 7:15 PM
    I want to test composables without the need for an emulator/device. Theres been talk in this channel of using robolectric, with custom runners etc. and people have reported partial success, however I have not been able to set it up properly. I have also tried to add the compose-desktop version of the compose testing library to my android project, also with no success. Could anyone shed some light on what would be the best way to go about running compose tests on JVM?
    j
    f
    j
    • 4
    • 15
Powered by Linen
Title
m

Mini

04/08/2021, 7:15 PM
I want to test composables without the need for an emulator/device. Theres been talk in this channel of using robolectric, with custom runners etc. and people have reported partial success, however I have not been able to set it up properly. I have also tried to add the compose-desktop version of the compose testing library to my android project, also with no success. Could anyone shed some light on what would be the best way to go about running compose tests on JVM?
j

jim

04/08/2021, 7:34 PM
I think using Compose for Desktop would be your best bet, but it is kinda self-service at the moment, as we don't have an official set of test rules at the moment. Such a thing will likely come at some point after Compose 1.0 is released.
We have a bunch of unit tests in the androidx library (see: https://cs.android.com/search?q=DesktopScreenshotTestRule). It would likely take some effort to extract the relevant pieces for your own usage though.
Until such time as a more official solution is released.
💯 1
m

Mini

05/10/2021, 5:54 PM
Jim, I have been playing around with this for a while now, but I dont seem to be getting anywhere. Honestly I think my understanding of multiplatform is quite lacking. Ideally I would just add testImplementation org.jetbrains.compose.ui:ui-test-junit4 to my android project and run composable tests that do not require anything android from my test folder. However that dependency seems to provide the aar i would get from an androidx dependency (assuming this is simply a proxy for multiplatform projects??) Then I tried extracting parts of the DesktopComposeTestRule but realised I would basically be reimplementing compose for desktop, which seems silly. I figured another option would be to create a jvm library that depends on the jetbrains version and then exposes the rule I need to the rest of my project. So, I am pretty much just guessing at where to start, and failing miserably 😅 Could you elaborate on what you mean by extract the relevant pieces, and point me in the right direction? 🙏
j

jim

05/10/2021, 6:01 PM
I figured another option would be to create a jvm library that depends on the jetbrains version and then exposes the rule
When I said "using Compose for Desktop would be your best bet", that does mean taking a dependency on the jetbrains version. You may want to look at the work @cb did with Accompanist to see how he introduced tests using desktop: • Tweet: https://twitter.com/chrisbanes/status/1390653509146660864 • Source code: https://github.com/google/accompanist/pull/393
👀 2
m

Mini

05/10/2021, 6:16 PM
Well, seems like he has done exactly what I want.. 🤔 Thank you Jim!
👍 1
f

fabio.carballo

10/12/2021, 3:24 PM
hey @jim - is there any update on this topic? I was now looking into the possibility of running compose tests without the resort to the emulator.
j

jim

10/12/2021, 4:44 PM
I don't think there is any news here yet. cc @Jelle Fresen [G]
🙏 1
j

Jelle Fresen [G]

10/12/2021, 5:19 PM
Correct, no news yet
m

Mini

10/12/2021, 5:26 PM
@fabio.carballo you can however use robolectric now
f

fabio.carballo

10/13/2021, 7:08 AM
hmm - really @Mini? do you have any sample on the web or so? yesterday I had tried to run it on top of
FragmentScenario
with no success.
m

Mini

10/13/2021, 7:50 AM
I do something like this:
class TestApplication : Application()

@RunWith(AndroidJUnit4::class)
@Config(application = TestApplication::class)
class SomeTest {

    @get:Rule
    val rule = createComposeRule()
    
    @Test
    fun someTest() {

        rule.setContent { 
            Text("Hello")
        }

        rule.onNodeWithText("Hello").assertIsDisplayed()
    }
}
🙏 1
j

Jelle Fresen [G]

10/13/2021, 2:49 PM
Yes, this should work. A few things to keep in mind: nothing is rendered (so no captureToImage()); no access to Bitmap (so no ImageBitmap); text is measured with default values (so can't assert size of components that wrap around text); and custom test runners are not yet supported
AFAIA these are mostly the same limitations as non-compose Robolectric tests
f

fabio.carballo

10/13/2021, 6:20 PM
okok, perfect! thanks for the clarifications
View count: 4