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 Sethi

    05/13/2021, 7:34 AM
    Hey, any suggestions on this will be great: I have few composable functions, precisely 3 defined in navigation compose root composable. Each of them have their separate view models respectively. I want to have a common service layer eg m that should be shared among just these 3 view models. I am trying to use hilt and have an activity scoped dependency service. But even I inject that to view model. They get seperate instances. I don't want the service dependency to be singleton scoped. Is there anything I am missing or any solutions for this use case will be very helpful. Thanks
    a
    • 2
    • 3
  • r

    Roman Polach

    05/13/2021, 11:50 AM
    Hi, do you have any idea, how to disable Half-Expanded state in ModalBottomSheetLayout? I want to switch only between collapsed and expanded states.
    j
    • 2
    • 2
  • p

    pawegio

    05/13/2021, 12:40 PM
    Anyone experienced such issue with
    CircularProgressIndicator
    in recent beta06? It compiles fine, preview also works and it just fails in editor/kotlin frontend.
    • 1
    • 1
  • c

    Colton Idle

    05/13/2021, 12:52 PM
    If I have a column with alignment set to center. Is there a way for an item in the column to opt out of this? I want everything in my column to be centered except one item. Thoughts?
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
    a
    a
    +2
    • 5
    • 15
  • d

    Daniele B

    05/13/2021, 1:16 PM
    A Preview (not available in the repo) of the new D-KMP Navigation for Compose, which will work on any platform: Android, Web, Desktop. The navigation logic is hosted in the shared-code, and will apply also to SwiftUI. Any feedback is welcome.
    🙌🏽 1
    🙌 4
    🙌🏼 2
    :mind-blown: 2
    a
    t
    • 3
    • 12
  • r

    robnik

    05/13/2021, 5:44 PM
    What's the right way to delete an item in your model, when using
    SwipeToDismiss
    ? The example here does not show it. I'm trying
    LaunchedEffect(dismissState.currentValue) {...}
    , but there is a little delay that I don't like. More in thread...
    d
    • 2
    • 7
  • a

    allan.conda

    05/13/2021, 6:24 PM
    My team raised me a question regarding compose navigation and deeplinks which I was not able to answer. Let’s say we have 2 independent feature modules, A and B. a screen from A can navigate to a screen from B. I call the nav graph of B from the top-level module so it has access to the B’s Screen composables, without having A depend directly on B. We would like a deep link navigation to B with a simulated backstack as if B was opened from a screen in A. Is this possible with this kind of setup?
    i
    • 2
    • 10
  • a

    allan.conda

    05/13/2021, 6:32 PM
    <another topic> Not sure if this is a bug or I did something illegal, but the stacktrace is hard to understand. I’m trying to dispose the ServiceConnection but the app crashes when the composable is disposed. Code and the exception in the thread 👇
    • 1
    • 3
  • a

    alexsullivan114

    05/13/2021, 7:19 PM
    I'm trying to mimic the twitter "like count" animation (not the heart, just the count going up). I'm attempting to trigger that animation if the like count is different from the previous like count. So here's some examples code. Let's say I have some class representing likes:
    data class Like(val count: Int)
    And some composable that renders the like count:
    @Composable
    fun LikeText(like: Like) {
        Text("${like.count}"
    }
    I want to trigger some animation if the like.count value has changed. How would I go about doing that?
    k
    d
    • 3
    • 24
  • n

    Nat Strangerweather

    05/13/2021, 8:11 PM
    I also have a question about animations. I am using an infinite transition and I want my tiles to travel at the same speed. At the moment they are catching each other up because the durationMillis value is the same for all. How can I get them to all travel at the same speed? Please see gif in thread.
    d
    • 2
    • 10
  • n

    nglauber

    05/14/2021, 12:26 AM
    Dummy question… Do I have to pass my
    navController
    to all my screens (of course if I want to navigate to somewhere else from that screen)? Should I create a
    compositionLocalOf
    for it?
    a
    f
    i
    • 4
    • 20
  • t

    Tolriq

    05/14/2021, 7:00 AM
    Is there any ETA for shared transitions in Compose? That's the missing piece for me for now 😞 (By ETA I mean 1.0 or later or it will be decorrelated from 1.0 in distinct library)
    d
    • 2
    • 2
  • a

    Alexa_Gal

    05/14/2021, 8:34 AM
    Hi guys i have some issues with navigation and maybe im doing it all wrong. I have a stack app that have a bottomBar on it. All works as expected i can push from login to next screen and show the 3 screens BottomNavigationBar. My issue is that every time i change tabs. my components are recomposed eventho i have set this on the navBottomNavigationItem
    launchSingleTop = true
    . if i only run the 3 screens NavigationBar screen without any page before on the stack they are NOT recomposed every time i change the tab. have any of you seen this issue before?
    a
    i
    +2
    • 5
    • 20
  • y

    YASAN

    05/14/2021, 10:06 AM
    Is it possible to have a circular ripple/clickable effect on clickable items? the normal square one doesnt look right on some places
    a
    • 2
    • 2
  • a

    Adrian Landborn

    05/14/2021, 1:15 PM
    Are there any alternatives for Indication (other than Ripple)? Any tutorials on how to create and old-school “selectable” solution with different colors?
    l
    • 2
    • 6
  • a

    andrew

    05/14/2021, 1:23 PM
    Where we could draw content in another tree at the root above the rest, kinda mimicking the decoration layer?
    a
    z
    • 3
    • 3
  • m

    Michal Klimczak

    05/14/2021, 2:59 PM
    There's now way to customise
    Slider
    except for colors? I mean adding custom track and thumb drawables. Or at the very least change the track thickness? Didn't find a way, didn't find an issue tracker either, should I report or it's not planned?
    a
    • 2
    • 2
  • l

    Lucien Guimaraes

    05/14/2021, 3:24 PM
    Hi there, I'm having very weird and annoying UI issues with Compose running on Huawei devices, when I'm using an AndroidView to display a map. For example I have a MapView taking the whole screen and I have some Composable on top (It could be a pager or topAppBar ...). And strangely it either never draws the Composable on top of the map or make it disappears for no reason (And strangely, when the app is on landscape mode it's showing. But never on portrait mode). It's working fine on emulator or even on my pixel 3. I created a sample demo app (repository here) to demonstrate the issue. Any idea what's going on ?
    signal-2021-05-14-161938.mp4
    👀 2
    m
    h
    • 3
    • 10
  • h

    harry248

    05/14/2021, 6:29 PM
    When navigating manually to a nested navigation composable and then triggering a deeplink to a sibling composable in this navigation that is also already in the back stack we are getting an
    Attempt to invoke virtual method 'androidx.navigation.NavDestination$DeepLinkMatch androidx.navigation.NavGraph.matchDeepLink(androidx.navigation.NavDeepLinkRequest)' on a null object reference"
    exception. Anyone experiencing the same issue?
    i
    f
    • 3
    • 9
  • s

    spencer

    05/14/2021, 7:14 PM
    Is there a way to get a callback when an AndroidView is being detached before the view is detached from the window? I’m trying to get a bitmap of the last frame played in ExoPlayer before the view is removed.
    a
    • 2
    • 4
  • a

    Alex Vanyo

    05/14/2021, 7:31 PM
    Hi all! I’m wondering if there’s any discussion or guidance around having certain actions be conditioned on state, when that state may change. For an example, this snippet is an excerpt from
    SignInScreen
    in
    Jetsurvey
    . The sign-in button is only enabled when the
    emailState
    and
    passwordState
    are deemed valid, which works most of the time. However, suppose
    email
    is valid, so the button is enabled. If the
    email
    is updated to become invalid just before the sign-in button is tapped (but within the same frame),
    onSignInSubmitted
    will be called with the invalid
    email
    , bypassing the validation.
    Untitled.kt
    c
    a
    • 3
    • 10
  • e

    eschrag

    05/14/2021, 8:11 PM
    is there a way to access a
    <vector>
    resource and extract the path in order to make a shape?
    • 1
    • 1
  • c

    Colton Idle

    05/14/2021, 9:07 PM
    Is it weird to be currently using single activity with multiple fragments and now I want to convert my activity to not have xml anymore and to instead just
    setContent{ }
    ? In order to do this it looks like I'll have to use
    AndroidView
    to host a
    FragmentContainerView
    . Or does this all seem like a bad idea and should I just keep my 10 lines of xml for the activity layout. 😅
    i
    a
    b
    • 4
    • 33
  • c

    Colton Idle

    05/15/2021, 2:41 AM
    I want to create a composable that can play a video file in the same way a gif would "play". i.e. Auto play, no controls, on a loop. I got something working with ExoPlayer, but it's become a little too difficult to customize fully. (I can't get it to fill the entire screen and center crop, can't get the controls to hide if the user clicks on the video). What am I trying to do exactly? Replicate this kind of video playing in the background, similar to what spotify did a while back. Can anyone point me in the right direction? I want to bake the video file into the app. My video is only about 0.5MB large and it's what my designers want. But if anyone could point me in the right direction, it'd be much appreciated. Video attached:
    Kapture 2021-05-14 at 22.38.43.mp4
    a
    n
    • 3
    • 37
  • t

    Tracy Chou

    05/15/2021, 2:47 AM
    Hi All! Did you enjoy the last Compose Dev Challenge as much as me? Did you miss the challenge and wish you participated? Do you love bitcoin or wish you had some bitcoin? I have decided to sponsor another compose challenge with a bitcoin prize. Check out https://composechallenge.com to win $100 in bitcoin!
    🎉 1
    🏭 1
    🤔 4
    c
    l
    +2
    • 5
    • 7
  • m

    ms

    05/15/2021, 3:00 AM
    Has anyone facing NPE with
    MutableStateFlow
    ? using Compose beta06 Details in 🧵
    z
    • 2
    • 5
  • a

    Alexander Karkossa

    05/15/2021, 11:26 AM
    Hey guys, i tried to set a result with
    navigation-compose
    and
    hiltViewModel
    . Any ideas, why my example never gets a result? The
    savedStateHandle
    within my
    viewModel
    never gets the result value. I only get the result directly from
    navBackStackEntry.savedStateHandle
    . Example in second post
    i
    • 2
    • 12
  • z

    Zhelyazko Atanasov

    05/15/2021, 3:17 PM
    I'm looking at the source code of
    OutlinedTextField
    , in particular the case where the input
    value
    is of type
    String
    . The code is defining a mutable state called
    textFieldValueState
    and that's expected. But why do we need another variable -
    textFieldValue
    that's set as a value of the inner
    OutlinedTextField
    ? Why are we not using
    textFieldValueState
    as usual?
    a
    • 2
    • 1
  • e

    eschrag

    05/15/2021, 3:41 PM
    Is there a way to clip the touch area of a Surface or any other Material component? I was able to get the ripple and drawn view to clip based on a vector, but it is still touchable in its square outside the clip area.
    i
    • 2
    • 4
  • a

    Andre

    05/15/2021, 6:27 PM
    I`m struggling getting my project build using coroutines in kotlin native and jetpack compose in android.
    s
    s
    • 3
    • 5
Powered by Linen
Title
a

Andre

05/15/2021, 6:27 PM
I`m struggling getting my project build using coroutines in kotlin native and jetpack compose in android.
s

Se7eN

05/15/2021, 7:54 PM
Maybe try version
1.4.3
?
a

Andre

05/15/2021, 8:16 PM
Everything build & runs fine but as soon i add :
val commonMain by getting {
    dependencies {
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt") {
            version {
                strictly("1.4.3-native-mt")
            }
        }
    }
}
Build fails with:
Execution failed for task ':androidApp:checkDebugAarMetadata'.
        > Could not resolve all files for configuration ':androidApp:debugRuntimeClasspath'.
        > Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core:{strictly 1.4.3-native-mt}.
Required by:
project :androidApp > project :shared
        > Cannot find a version of 'org.jetbrains.kotlinx:kotlinx-coroutines-core' that satisfies the version constraints:
Dependency path 'MyApp:androidApp:unspecified' --> 'MyApp:shared:unspecified' (debugRuntimeElements) --> 'org.jetbrains.kotlinx:kotlinx-coroutines-core:{strictly 1.4.3-native-mt}'
Dependency path 'MyApp:androidApp:unspecified' --> 'androidx.compose.ui:ui:1.0.0-beta06' (releaseRuntimePublication) --> 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
Dependency path 'MyApp:androidApp:unspecified' --> 'androidx.compose.runtime:runtime:1.0.0-beta06' (releaseRuntimePublication) --> 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3' (runtimeElements) --> 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
Dependency path 'MyApp:androidApp:unspecified' --> 'androidx.compose.ui:ui:1.0.0-beta06' (releaseRuntimePublication) --> 'androidx.compose.animation:animation-core:1.0.0-beta06' (releaseRuntimePublication) --> 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
Can someone point me in the right direction ? 🙏
Got it working using the deprecated isForce:
val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt") {
                    isForce = true
                }
            }
        }
👍 1
s

ste

05/15/2021, 10:12 PM
Would you mind sharing the whole file?
a

Andre

05/15/2021, 11:14 PM
Here you go
build.gradle.kts
😊 1
View count: 8