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

    Colton Idle

    08/01/2022, 5:26 PM
    Does anyone from the compose team know if the new k2 compiler is supported? https://blog.jetbrains.com/kotlin/2022/08/kotlin-1-7-20-beta/
    d
    l
    s
    • 4
    • 10
  • j

    james

    08/02/2022, 10:54 AM
    I wrote an article about a concept I discussed here with a few people some weeks ago, I hope it’s interesting to some of you 💙 https://dev.to/jamesmorrissey/velocity-based-animation-with-compose-538g Velocity Based Animation with Compose
  • c

    Can Korkmaz

    08/01/2022, 11:56 AM
    Hi, I'm trying to implement a swipe refresh behaviour in the middle of the screen, where the screen as a whole needs to be scrollable. Since Accompanist swipe refresh requires its child to be scrollable and I want the whole page to move (scroll) at once, I couldn't think of a way for days now.
    Column(
        Modifier
            .fillMaxSize()
            .verticalScroll(scrollState)
            .background(colorResource(id = R.color.colorBackground))
    ) {
               SwipeRefresh(state = swipeRefreshState, onRefresh = {
                  scope.launch {
                    pagingData.refresh()
                    delay(TradeHistoryFragment.REFRESH_ATTEMPT_DELAY)
                  }
            }) {
                   Column(Modifier.fillMaxWidth().wrapContentHeight()) {
    j
    • 2
    • 2
  • m

    Marko Novakovic

    08/01/2022, 4:10 PM
    ModalBottomSheetLayout
    sheetContent
    never leaves composition. is tracking offset the only way to observe is it visible or not?
    m
    j
    • 3
    • 4
  • s

    Stylianos Gakis

    08/01/2022, 10:28 AM
    How would you expect this to function optimally? If items are reordered there must be some time where items are on top of each other no?
    z
    a
    d
    • 4
    • 7
  • a

    agrosner

    07/29/2022, 5:29 PM
    for context, I did not grant AS full disk access. only download and documents
    k
    a
    c
    • 4
    • 50
  • p

    Piotr Prus

    07/30/2022, 8:37 PM
    I have a problem with slider and its
    onValueChangedFinished
    when use on slider with steps and snapping. It do not have a value parameter, so I am taking the parameter from my remembered field. The value that is stored in the moment of
    onValueChangedFinished
    is not the value that slider will snap to. It is the value from the moment I released the finger. I do not understand the point of this lambda and I do not know how to properly update the slider value, since I allow only these values from step point, not float from the middle. Code and example in the thread 🧵 👇
    s
    r
    z
    • 4
    • 15
  • a

    Aaron Waller

    08/02/2022, 1:54 PM
    Why is my snackbar always calling Dismissed but never ActionPerformed?
    scope.launch {
                            val snackbarResult = scaffoldState.snackbarHostState.showSnackbar(
                                "Grant permission to modify device audio",
                                actionLabel = "Settings"
                            )
                            when (snackbarResult) {
                                SnackbarResult.Dismissed -> Log.d("SnackbarDemo", "Dismissed")
                                SnackbarResult.ActionPerformed -> Log.d("SnackbarDemo", "Snackbar's button clicked")
                            }
                        }
    I want to launch an Intent on the “Settings” label click but it calls Dismissed when I click the label of the SnackBar. What am I doing wrong? When is it calling ActionPerformed?
  • k

    KotlinLeaner

    08/02/2022, 1:44 PM
    Hey guys, I asked this stack overflow but didn't get the answer. I am working on ripple effect in jetpack compose. I provide my color and after clicking on view it show some time correct color after that different type of color showing like dark grey on press state.
    o
    • 2
    • 30
  • c

    Casey Brooks

    08/02/2022, 2:09 PM
    I think your best bet would just be to find a font that’s outlined like that. Here’s a few examples on Google Fonts https://fonts.google.com/?query=outline
    g
    m
    • 3
    • 5
  • l

    Landry Norris

    08/02/2022, 2:46 PM
    You can use delay(Long) to delay a certain time. If I remember correctly, delay(Long) will cause other coroutines to immediately act like there was a delay.
    o
    z
    s
    • 4
    • 23
  • l

    Lilly

    07/29/2022, 6:18 AM
    I get "Skipped frames < 100" for some semi-heavy viewmodel operations, at least I think the reason is a viewmodel operation. I'm not sure, it also might be a light non-suspending function so I'm wondering if I should wrap every non-suspending viewmodel function into a coroutine?
    fun someViewModelCall() {
        viewModelScope.launch(Dispatchers.Default) { // light stuff }
    }
    EDIT: Alternate question would be, if it is common that skipped frames happen ocasionally?
    a
    c
    a
    • 4
    • 40
  • i

    iroyo

    08/02/2022, 3:37 PM
    Hello everyone, When working with lists which need to look good on phones and tablets, which one is the best approach? • A
    LazyColumn
    for phone and a
    LazyVerticalGrid
    for tablets. • Just a
    LazyVerticalGrid
    with a different column value (1 for phones)
    columns = GridCells.Fixed ()
    k
    • 2
    • 1
  • c

    Chuck Stein

    08/02/2022, 4:17 PM
    Is there any way to slow down the animation speed of
    LazyListState.animateScrollToItem
    ? I noticed that
    ScrollableState.animateScrollBy
    accepts an
    animationSpec
    but
    animateScrollToItem
    does not
    r
    • 2
    • 3
  • c

    Colton Idle

    08/02/2022, 5:41 PM
    How can I get the default colors for a Text label in an OutlinedTextField. I can't use
    Text
    and instead am required to use
    CustomText
    and so I need to pass in the colors. I thought
    TextFieldDefaults.textFieldColors().labelColor()
    would work.
    label = { CustomText(
       text = labelText, 
       style = MyTextStyle.body,
       TextFieldDefaults.textFieldColors().labelColor(),
       )
    },
  • k

    Kevin Worth

    08/02/2022, 6:08 PM
    Compose testing - views/recycling pagers - where each page has the same basic views but different content. I assume it's bad practice to use the Ids of semantics nodes to - for instance - assert that something that was displayed is no longer displayed... Or is it generally safe to use the Ids? Example: 1. Screen A has Title(
    Text
    with
    testTag == "title"
    ) and Image (object with
    stateDescription == "foo"
    ) 2. Swipe left to go to Screen B 3. Screen B has Title(
    Text
    with
    testTag == "title"
    ) and Image (object with
    stateDescription == "foo"
    ) So, how might one ensure that the swipe was successful (and finished)? How can we be confident we are seeing a new screen and we aren't accidentally still on Screen A? Note: We don't want to hardcode things such as "swiping from A to B means you first see 'Title A' and then you see 'Title B'", because we have many variants and many pages (not feasible to program everything through to "swiping from variantQ screen G takes you to variantQ screen H"). We just want to make sure that the user is able to swipe through all the pages (App Intro Slides) and then get to the app's home screen/activity at the end. We've found it's feasible to capture the node id of either the Title or the Image and then make sure we don't get the same node Id after the swipe...but it feels like the type of thing that would likely be discouraged. Any suggestions? Thanks for your time.
    • 1
    • 1
  • j

    Jasmin Fajkic

    08/02/2022, 6:29 PM
    Same question I have
    d
    b
    m
    • 4
    • 8
  • j

    Jasmin Fajkic

    08/02/2022, 7:15 PM
    Is there any way to get image orientation? I need to show image in original orientation so not sure is it possible to detect it?
    k
    • 2
    • 3
  • m

    Micko Cabacungan

    08/02/2022, 7:52 PM
    is there a way to specifically not decompose a particular item inside of a
    LazyColumn
    s
    c
    • 3
    • 5
  • d

    Dirk Seewald

    08/02/2022, 8:13 PM
    How would i let the row with the buttons match the width of the column without
    fillMaxWidth()
    because that would expand the column. The column doesn't have a fixed size. This is my code:
    Box(propagateMinConstraints = true) {
                    Column(Modifier.wrapContentWidth().padding(24.dp).background(Color.Green.copy(alpha = 0.5f))) {
                        Row(Modifier) {
                            CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.headlineMedium) {
                                title()
                            }
                        }
                        Spacer(Modifier.height(32.dp))
    
                        Box {
                            //rowConstraints = constraints
                            CompositionLocalProvider(Material3TextStyle provides MaterialTheme3.typography.bodyLarge) {
                                Column(verticalArrangement = Arrangement.Center) {
                                    content()
                                }
                            }
                        }
                        Spacer(Modifier.height(32.dp))
                        Row(
                            Modifier.background(Color.Red.copy(alpha = 0.4f)),
                            horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)
                        ) {
                            dismissButton(scope)
                            confirmButton(scope)
                        }
                    }
                }
    c
    • 2
    • 5
  • r

    ritesh

    08/03/2022, 4:03 AM
    Should you be collecting
    SharedFlow/PublishSubject
    in composable? When we talk about uni-directional data flow, aren't we deviating from it when we start collecting the
    Shared/Publish
    in an effect-handler or uni-directional flow just talks about events flowing from composable - up in the tree.
    l
    • 2
    • 1
  • l

    Luis Daivid

    08/03/2022, 5:41 AM
    Keyboard ime does not change when focus is changed to another text field. For eaxample, There is A TextField whose ime is
    Search
    , and there is B TextField whose ime is
    Next
    . If you click A, ime is displayed as Search, but if you click B while the keyboard is shown, it is still
    Search
    ime. Is this Compose bug? or There any way to solve it?
    c
    • 2
    • 2
  • t

    Tlaster

    08/03/2022, 7:34 AM
    About state hoisting, I have two questions: • When we build a simple screen, there will be a few states and few
    onValueChange
    , but when we build a complex screen, we will get a lot of states and lots of
    onValueChange
    , there will be many parameters for the composable method, is there any optimization we can do to reduce the parameters? • If we have
    onValueChange
    inside a very deep composable, it will pass all the way up to the top screen to actually handle the
    onValueChange
    , is there a better way to do it instead of passing it all the way up to the top screen?
    f
    • 2
    • 2
  • d

    deviant

    08/03/2022, 8:25 AM
    hey guys since
    derivedStateOf
    should be always wrapped into
    remember
    , i decided to make this helper
    @Composable
    fun <T> rememberDerived(calculation: () -> T) = remember {
        derivedStateOf(calculation)
    }
    do you see any issues with it?
    s
    f
    +2
    • 5
    • 9
  • j

    Jasmin Fajkic

    08/03/2022, 8:45 AM
    I love u!
  • p

    Piotr Prus

    08/03/2022, 10:24 AM
    I am using material navigation and bottomSheet composable in navGraph. Everything working ok so far, except one thing. The bottomSheet automatically closes when I navigate to another destination. I would like to keep it open (remember its state) when coming back to the screen with bottomSheet. Video and code in the 🧵 👇
    c
    j
    • 3
    • 13
  • d

    deviant

    08/03/2022, 12:45 PM
    i have weird behavior during developing compose app: sometimes resulted build doesn't correspond to recent source code, it rather takes some cached sources from the past (2-5 hours ago). when i rebuild it returns to normal. did anybody have such behavior? last time i saw similar bugs was 10 years ago on eclipse ide. i'm on AS canary btw
    r
    c
    • 3
    • 6
  • b

    Bino

    08/03/2022, 1:39 PM
    I’m trying to create a custom layout, where children are placed in a new line if the odd space isn’t enough. Its a similar approach like the FlowRow in accompanist. https://gist.github.com/thebino/2d7385d5b3e51c036fa1873bac7b7ac7
  • b

    Bino

    08/03/2022, 1:39 PM
    I’m trying to create a custom layout, where children are placed in a new line if the odd space isn’t enough. Its a similar approach like the FlowRow in accompanist. https://gist.github.com/thebino/2d7385d5b3e51c036fa1873bac7b7ac7
    c
    • 2
    • 7
  • c

    Can Korkmaz

    08/03/2022, 2:33 PM
    Any ideas on how I can migrate this to compose. I'm using AndroidView for amountInput (CurrencyEditText, third party). asset is livedata and I observe it with observeAsState() like normally.
    Inside fragment::
    transferWithdrawViewModel.asset.observe {
        amountInput.setMaxNumberOfDecimalDigits(it.precision.toInt())  **this line
    }
    AndroidView(
        modifier = modifier,
        factory = { ctx ->
            // Creates custom view
            CurrencyEditText(ctx, null).apply {
    a
    • 2
    • 2
Powered by Linen
Title
c

Can Korkmaz

08/03/2022, 2:33 PM
Any ideas on how I can migrate this to compose. I'm using AndroidView for amountInput (CurrencyEditText, third party). asset is livedata and I observe it with observeAsState() like normally.
Inside fragment::
transferWithdrawViewModel.asset.observe {
    amountInput.setMaxNumberOfDecimalDigits(it.precision.toInt())  **this line
}
AndroidView(
    modifier = modifier,
    factory = { ctx ->
        // Creates custom view
        CurrencyEditText(ctx, null).apply {
a

Adam Powell

08/03/2022, 2:53 PM
val asset by transferWithdrawViewModel.observeAsState()

AndroidView(
  // ...
  factory = { context ->
    CurrencyEditText(context)
  }
) { view ->
  // update block - this observes `asset` and runs when it changes
  view.setMaxNumberOfDecimalDigits(asset.precision.toInt())
}
c

Can Korkmaz

08/03/2022, 3:00 PM
Thanks a lot
View count: 8