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

    Tgo1014

    07/29/2021, 9:25 AM
    What’s the best way to scope a VM inside a composable? I’ve a Pager with x screen and they all use the same VM, but I need a different instance for each screen. Any ideas?
    a
    • 2
    • 2
  • d

    dimsuz

    07/29/2021, 9:48 AM
    What is an idiomatic way to write "slot-based" custom layouts? For example I want to have 3 slots:
    Layout(content = { leftSlot(); centerSlot(); rightSlot(); }) { measurables, constraints -> ... }
    And layout logic is based on the assumption that I'll have 3 measureables: for example I want to always expand
    centerSlot
    . But I've found that if a
    centerSlot()
    composable will not emit any UI (return Unit), I'll have
    measurables.size == 2
    , and also I won't know which one of them is missing. For now I solved this by wrapping each slot in a box (e.g.
    Box { leftSlot() }
    ), but I'm not sure if this is the best way.
    r
    a
    • 3
    • 3
  • f

    fuhao

    07/29/2021, 10:17 AM
    Why my
    Image
    sometimes can't load Uri? This Uri(
    <content://xxx>
    ) can be loaded by
    Glide
    but can't be loaded by
    Coil
    . The coil only show white screen. And when they load
    android.resource:// xxxx
    , both of them can show picture.
    b
    • 2
    • 2
  • c

    Can

    07/29/2021, 10:24 AM
    I feel like there is a ton of haptic feedback types missing here. Should I just assume this list will be completed in the future and refrain from adding haptic feedback now or am I searching at the wrong place? I’m trying to implement a haptic feedback for switches
    a
    • 2
    • 4
  • t

    Tin Tran

    07/29/2021, 10:37 AM
    Has anyone tried to create a chart in compose?
    👀 2
    h
    d
    s
    • 4
    • 6
  • p

    Peter Marogna

    07/29/2021, 10:48 AM
    Hi! I am trying to put Composable views as Markers on Google Maps, but it seems to be a pretty challenging exercise. I used this article to create Bitmaps from Composables, then used an
    AndroidView
    to be able to render them on the map. It appears that some modifiers are interpreted differently during the transformation and for example `clip`ping is ignored as you can see in the image. (However using the
    background
    modifier with a
    Shape
    is working, but it isn't a full solution for the problem.) Did anyone try this before? Any other solution ideas on how to put Composables on Google Maps?
    👀 6
    u
    • 2
    • 1
  • r

    Rafs

    07/29/2021, 11:16 AM
    I am trying to drag a small circle around the screen but it seems the
    DraggableCircle
    is not getting composed with the updated position received from the lambda.
    @Composable
    fun DraggableSample() {
        Box(
            modifier = Modifier
                .fillMaxSize()
        ) {
            var position by remember { mutableStateOf(IntOffset.Zero) }
    
            DraggableCircle(position = position, onPositionChanged = { position = it })
        }
    }
    
    @Composable
    fun DraggableCircle(
        modifier: Modifier = Modifier,
        position: IntOffset,
        onPositionChanged: (position: IntOffset) -> Unit
    ) {
        Box(
            modifier = modifier
                .offset { position }
                .size(100.dp)
                .background(color = Color.Green, CircleShape)
                .pointerInput(Unit) {
                    detectDragGestures { change, dragAmount ->
                        onPositionChanged(dragAmount.toIntOffset + position)
                        change.consumeAllChanges()
                    }
                }
        )
    }
    m
    a
    • 3
    • 3
  • m

    Marcello Galhardo

    07/29/2021, 11:29 AM
    Hey, I have few doubts about Navigation with Compose (my first time using it) - maybe someone can help me with: 1. Should we reuse the NavController or each NavHost should have one? E.g., a NavHost that internally has a screen with a tab and another NavHost. 2. Is there a way to create a NavGraphBuilder without a NavController? I would like to create one using Dagger + Multibinding and reuse it in 2 NavHost. Thank you in advance.
    👍 1
    👍🏼 1
    i
    • 2
    • 8
  • v

    Vitaliy Zarubin

    07/29/2021, 12:30 PM
    Compose tests don't work. Error `Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`` . Do you know how to win?
    j
    z
    s
    • 4
    • 7
  • a

    Alexander Sitnikov

    07/29/2021, 2:10 PM
    Until Kotlin makes compiler plugin APIs stable, Compose version is tied to Kotlin version and vice-versa. Traditionally, active development in Jetpack libraries is done in alpha/beta channel, leaving stable channel for bug fixes only. When Compose was in alpha/beta, it had biweekly releases, and support for new Kotlin version was added to Compose in next release or two. I have a concern that latest stable Compose will fall behind the Kotlin version. Will new Kotlin releases be supported in stable channel of Compose in future?
    a
    k
    s
    • 4
    • 5
  • u

    Utkarsh Tiwari

    07/29/2021, 2:13 PM
    How can I achieve a TextField that’s aligned to the bottom of the screen and floats above the keyboard?
    d
    • 2
    • 2
  • o

    Odin

    07/29/2021, 2:14 PM
    Hi this might be a silly question, but is there something fancy you have to do to make testing in compose work? I have this test (see code in thread) but it looks like it just stalls and then after 45 sek it gives the error
    java.lang.AssertionError: Activity never becomes requested state "[RESUMED, CREATED, STARTED, DESTROYED]" (last lifecycle transition = "PRE_ON_CREATE")
    I saw that someone here had this problem before and solved it by adding a ComponentActivity in their manifest, but I just get the same result. Has anyone here had the same experience? 😄 🤔
    t
    • 2
    • 4
  • m

    MaxUt

    07/29/2021, 2:28 PM
    Hi there, is there a way to use offset/absoluteOffset in a Column and force the column to fit the content ?
    a
    • 2
    • 4
  • m

    mattinger

    07/29/2021, 2:37 PM
    Has anyone tried compiling compose content with kotlin 1.5.10, and then using that in a project as an external dependency (aar) which uses kotlin 1.5.20? I’m wondering if it’s just the compiler that needs 1.5.10 or will the runtime engine have issues?
    a
    • 2
    • 5
  • t

    Tash

    07/29/2021, 3:00 PM
    Do we have any indication of which Compose version will support Kotlin 1.5.21?
    w
    • 2
    • 1
  • l

    Landry Norris

    07/29/2021, 3:04 PM
    I get this when trying to run a preview on the device Error running 'TodoRowPreview': androidx.compose.ui.tooling.PreviewActivity is not an Activity subclass or alias
    t
    • 2
    • 4
  • a

    alorma

    07/29/2021, 3:49 PM
    Is there any "official" connection between Datastore and compose?
    c
    z
    • 3
    • 3
  • f

    FunkyMuse

    07/29/2021, 4:53 PM
    hey guys, I'm fighting with this error, any help would be appreciated I only bumped the compose version to 1.0.0, my gradle file link https://github.com/FunkyMuse/Aurora/blob/main/build.gradle Using the latest stable arctic fox studio
    androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0) expects a minimum runtime version of 1.0.0. The version of the runtime on the classpath currently is 1.0.0-rc01.
    z
    • 2
    • 1
  • f

    Fanilog

    07/29/2021, 5:43 PM
    Trying to understand how LazyList works under the hood but it’s not that easy. 🤔 Is there anyone knows how the recycling works in a LazyColumn? Do items get recomposed or do they just exit the composition and new one are created ? And finally what would be the effect of using
    DisposableEffect
    inside a composable used by a LazyList in the case the items are reused? 🙏
    c
    c
    +2
    • 5
    • 11
  • c

    Csaba Kozák

    07/29/2021, 6:09 PM
    Hey everyone, I am implementing a map-heavy application. I am following the Crane sample to set up the
    MapView
    . I am trying to move the camera as the user is sliding up a bottom sheet. The problem is that if i change the camera position according to the offset with
    GoogleMap.moveCamera()
    , the maps moves really laggy. Calling
    GoogleMap.setPadding()
    is smooth though. Can anyone help me with this? Thanks in advance!
    ⬆️ 1
    👀 1
    👍 1
    • 1
    • 1
  • c

    Colton Idle

    07/29/2021, 6:41 PM
    I have a question about a behavior that I didn't expect. 1. I have a
    @Composable
    fun ForgotPasswordScreen(successEvent: () -> Unit, vm: ForgotPasswordScreenViewModel){
    ...
      ~buttonOnClick {
        vm.makeNetworkCall(successEvent)
      }
    ...
    }
    2. successEvent: () -> Unit, is a navigational event that takes me back to SignInScreen 3. ForgotPasswordScreenViewModel has
    fun makeNetworkCall(onNetworkCallCompletedSuccessfully: () -> Unit)
    and on completion of the network call,
    if (call.isSuccessful) successEvent()
    When I throttle the network call (for testing) it takes like 10 seconds, and I background the app, wait 20+ seconds... and I come back in the app, I can see that the app navigated successfully and the SignInScreen is showing. I guess I was wrong in thinking that the successEvent() wouldn't have any action since the app was backgrounded?
    a
    • 2
    • 2
  • i

    Ink

    07/29/2021, 7:00 PM
    I want to create view like that below. I try:
    @Composable
    fun SearchBar(label: String) {
        RateMeAppTheme(isSystemInDarkTheme()) {
            Row(
                modifier = Modifier
                    .fillMaxWidth()
                    .wrapContentHeight()
                    .background(MaterialTheme.colors.onBackground)
                    .clip(RoundedCornerShape(20.dp))
                    .padding(20.dp)
            ) {}
        }
    }
    but I get rectangle max width without rounded corners. Why?
    c
    a
    • 3
    • 3
  • k

    K Merle

    07/29/2021, 7:03 PM
    Compose question. Once user authenticates, how do I remove authentication compose screens to not be in stack anymore? Multiple activities (e.g. AuthenticationActivity, ContentActivity) ?
    c
    n
    z
    • 4
    • 7
  • s

    Shakil Karim

    07/29/2021, 10:11 PM
    Is there any performance Improvement in Compose 1.0? I just update my App on Play Store and I noticed slightly better performance. btw I am not using Lazy* Composable, the last time I used it had poor performance on older devices hopefully it improved as well 👍
    m
    r
    +4
    • 7
    • 9
  • c

    Colton Idle

    07/30/2021, 12:51 AM
    I'm an animation noob so please excuse me if this comes off as trivial. I have a little tutorial screen I'm making and there is a rubber duck in the center :rubber_duck: and my requirements are to make it "bob" up and down slightly, on an infinite loop. I would have typically maybe considered this using MotionLayout, but is there an easy way to animate this kind of bobbing effect in compose?
    t
    d
    +2
    • 5
    • 45
  • n

    nonameden

    07/30/2021, 4:31 AM
    Hello, I have tried to rebuild my custom progress bar in compose but faced issue, delay in TweenSpec works not as expected:
    val transition = rememberInfiniteTransition()
    val value = transition.animateFloat(
            0.5f,
            1f,
            infiniteRepeatable(
                repeatMode = RepeatMode.Reverse,
                animation = tween(
                    durationMillis = 650,
                    delayMillis = 160,
                    easing = BezierEasing
                )
            )
        )
    it applies delay on each iterate, is there any legit way to delay only first iterate? like startDelay in ValueAnimator?
    d
    • 2
    • 6
  • i

    iamthevoid

    07/30/2021, 4:40 AM
    If i pass boolean inside compose navigation route like url encoded param (ex:
    login?authorized=true
    ) then later when i extract it from navigation arguments (Bundle) it appear there as
    String
    but not an as
    Boolean
    . It is a bug or feature? How can i pass
    Boolean
    between nav destinations without converting?
    k
    • 2
    • 1
  • a

    Abhishek Dewan

    07/30/2021, 7:03 AM
    can someone help me understand what I might be doing wrong. I am using insets v0.13 (haven't upgraded to compose 1.0 yet). Whenever I tap the TextField, the first time the padding from the inserts work perfectly however, on subsequent runs the padding seems like it's doubled somehow. (Code in thread)
    device-2021-07-30-000021.mp4
    d
    t
    b
    • 4
    • 6
  • b

    Brett May

    07/30/2021, 7:57 AM
    I was wondering if it is possible to use MutableStateOf with a Delegates.observable ? I want to know inside my ViewModel() subclass when my MutableState variable changes. I am looking for an equivalent of the following SwiftUI code:
    @Published var meInformation : Me? {
            didSet {
               print("MeInformation changed: \(meInformation)")
            }
        }
    This doesn’t compile for me: (unresolved reference: by)
    class AuthenticatedUser(val context: Context) : ViewModel() { 
        var meInformation: MutableState<MeInformation?> = mutableStateOf(null) by Delegates.observable("<no name>") {
            prop, old, new ->
            println("$old -> $new")
        }
    }
    I’m not sure if it matters (being new to Kotlin), but meInformation is a @Serializable object
    d
    a
    • 3
    • 4
  • n

    Nabeel

    07/30/2021, 9:10 AM
    Any guide or tutorial on transition animations when using navigation component?
    v
    • 2
    • 2
Powered by Linen
Title
n

Nabeel

07/30/2021, 9:10 AM
Any guide or tutorial on transition animations when using navigation component?
v

Vitaliy Zarubin

07/30/2021, 9:16 AM
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1627469451309900
n

Nabeel

07/30/2021, 9:18 AM
Can we use MaterialSharedAxis by this method?
View count: 2