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

    Gabriel

    02/28/2021, 2:30 PM
    Any idea why my buttons are so huge, I expected them to match the icon size kinda, but they seem to be taking as much room as possible
    s
    • 2
    • 3
  • r

    robnik

    02/28/2021, 3:03 PM
    I'm trying to drag a shape on a
    Canvas
    . I use
    Modifier.draggable
    , but the handler does not have access to the Canvas's width, to constrain the drag. How can I pass the Canvas's width to the drag handler? Example in thread...
    s
    a
    • 3
    • 4
  • s

    Se7eN

    02/28/2021, 4:30 PM
    I'm using
    ModalBottomSheetLayout
    with
    BottomSheetScaffold
    . I have a
    TextField
    in the sheetContent of
    BottomSheetScaffold
    but I'm getting a crash when the
    TextField
    goes out of focus or I hide the keyboard. Is this a bug or am I not supposed to use
    ModalBottomSheet
    and
    BottomSheetScaffold
    together?
    b
    z
    j
    • 4
    • 7
  • b

    Bradleycorn

    02/28/2021, 4:37 PM
    While we're on the subject of
    ModalBottomSheetLayout
    ... I have one setup to show a simple
    Text
    composable in the bottom sheet. But if I try to pass in the text to show, it doesn't work. The bottom sheet doesn't even show up. But if I "hard code" the text, it works fine. Code posted in the thread ...
    s
    j
    +5
    • 8
    • 72
  • m

    Mini

    02/28/2021, 4:44 PM
    I am trying to combine multiple flows in a viewmodel, including a snapshotFlow. This seems to work fine when i reference the state value in a composable, however when writing unit tests for the viewmodel, the combine does not seem to be triggered by changes to the state value. Is this because the state does not currently have an active observer in my unit test?
    combine(snapshotFlow { myMutableStateMap.toMap() }, stateFlowA, stateFlowB)
    a
    • 2
    • 6
  • d

    Daniel

    02/28/2021, 4:50 PM
    Can I access the laid out width or the constraints from within a modifier?
    a
    s
    • 3
    • 14
  • s

    Slackbot

    02/28/2021, 5:35 PM
    This message was deleted.
    j
    • 2
    • 1
  • j

    Jordi Saumell

    02/28/2021, 5:50 PM
    Navigation: I forgot to declare the default value of an optional parameter and when I tried to navigate (without providing the parameter) the app got stuck. When I tried to perform another action it crashed with a stacktrace that does not point to the app code and does not help find the issue (I attach it in the thread).  • It would be helpful if the app crashes right away and with a descriptive message 🙂 • Also, it would be nice if how to provide optional parameters or how to skip them was explained here.
    a
    i
    • 3
    • 7
  • z

    Zhelyazko Atanasov

    02/28/2021, 6:37 PM
    Is there something particular about
    Image
    and
    Modifier.shadow
    ? I'm applying a shadow to an image, but no shadow is drawn.
    d
    • 2
    • 2
  • r

    robnik

    02/28/2021, 8:17 PM
    Anyone know how to select all the text in a text field, when it gets focus? I've tried using
    TextFieldValue.selection
    and changing it in
    Modifier.onFocusChanged
    but no luck so far.
    r
    • 2
    • 1
  • b

    Blundell

    02/28/2021, 9:37 PM
    I’m passing in a NavController to a Column inside a LazyColumn and using the Columns onClick to navigate. (i.e. navigation from a list item.) I’ve logged & debugged inside the receiving composable and the navigation works, but the screen does not update. The old screen stays visible and all the list items still look clickable. Can’t see anything in the logs. How do I go out debugging this?
    i
    • 2
    • 7
  • v

    Vinay Gaba

    03/01/2021, 1:55 AM
    Noticing some weird issues as I’m trying to upgrade my library to beta-01. Think that some mutable state values are only being propagated once I minimize the app and open it again. Anyone notice something of this flavor or an existing bug that might’ve been discussed already?
    🤔 1
    a
    • 2
    • 6
  • s

    Shivam Sethi

    03/01/2021, 2:43 AM
    any idea, why getting a context is giving an error here:
    k
    • 2
    • 3
  • a

    aherbel

    03/01/2021, 3:20 AM
    Hi, can someone tell me what are the replacements for these functions?
    k
    v
    • 3
    • 5
  • s

    Samir Basnet

    03/01/2021, 8:01 AM
    @Composable
    fun ProgressStep(modifier:Modifier,max: Int, current: Int) {
        Layout(modifier = modifier,
            content = {
                for (i in 1..max)
                    StepCircle(step = i, color = if (i <= current) purple else Color.Gray)
    
            }) { measurables, constraints ->
    
            val startPoint = (constraints.maxWidth/max)/2
    
    
            val placeables = measurables.map { measurable ->
                measurable.measure(constraints.copy(minWidth = 0))
            }
            layout(constraints.maxWidth, constraints.minWidth) {
                var xPosition = startPoint
                placeables.forEachIndexed { index, placeable ->
                    placeable.place(x = xPosition-11, y = constraints.maxHeight / 2)
                    xPosition += (startPoint * 2)
                }
            }
        }
    }
    i noticed the mesurements here are accepted in Integer so the gap after the last item in less compared to others. how am i supposed to gap equally here?
    • 1
    • 1
  • s

    Samir Basnet

    03/01/2021, 9:09 AM
    Also has anyone built a ProgressSteps View in Compose?
    l
    • 2
    • 3
  • l

    Lukasz Burcon

    03/01/2021, 10:03 AM
    Hey, I was working on implementing a wrappable Text compose function that doesn’t overlap any other view in the same row and instead takes all the available space and becomes a multiline text view. The problem is that even if it was wrapContent, it took all the available space while measuring (typical behaviour). I needed the width of multiline text to be the same as the X coordinate of the last letter in the longest row to match my design’s paddings. I had to create a custom
    Layout
    and measure it in multiple layout passes as you can’t call
    measurables.measure()
    multiple times in the same
    layout
    section. Do you guys plan on opening MultiMeasureLayout API that’s internally used in ConstraintLayout so I don’t have to do multiple layout passes and just remeasure my view in one layout pass? Or is there any better solution to my problem you know about?
    h
    z
    • 3
    • 2
  • g

    Gabriel

    03/01/2021, 10:51 AM
    How comes AlertDialogs don't show in previews? Should I be using straight Dialog? Or would that have the same issue?
    a
    • 2
    • 1
  • a

    Adriano Celentano

    03/01/2021, 11:20 AM
    Is it possible to know the ime padding before the ime is shown ? would be cool to use the keyboard as source of truth for animations.
    ➕ 1
    j
    s
    c
    • 4
    • 15
  • d

    Daniel

    03/01/2021, 12:10 PM
    I'm writing an ebook reader. I needed custom text drawing, so I needed to implement my own text selection. I've got that mostly working using ~700 lines of code copied from Jetpack compose internal and private functions and lightly modified. My current problem is that I detect drag events on the handles, but the handles are very small. The unit of selection is the character or word, and the handles should be at the start and end of the selection. That means the handles should jump as you drag them. The problem is then that as you drag the pointer goes temporarily out of the touch area for the handle between snaps, and thus I don't get drag events. I could just add some padding around the handles to increase the touch area, but that wouldn't have quite the behavior I want. I want to specify that a drag event must start with a pointer down in a small area, but can continue with a pointer move in a larger area. I could also just implement that myself (looking at the source PointerInputScope.detectDragGestures, it seems relatively straightforward) but I want to make sure there isn't a better way to do this. I'm also a bit puzzled by why Jetpack's implementation of handles doesn't run into the same issues, as it's almost the same code as I'm using.
    drag-handle-pointer-out-of-target-area.mp4
    j
    • 2
    • 2
  • s

    Shivam Sethi

    03/01/2021, 12:20 PM
    Hello, how can I create a viewModel as in documentations using =viewModel() as default with a ViewModel with dependencies injected to it with Hilt ?
    a
    z
    +2
    • 5
    • 13
  • s

    Samir Basnet

    03/01/2021, 12:55 PM
    Is it possible to change OutlinedTextField height without cutting the content??
    d
    • 2
    • 2
  • o

    Orhan Tozan

    03/01/2021, 1:13 PM
    I'm currently on Kt 1.4.31 and getting the following error: `This version (1.0.0-alpha13) of the Compose Compiler requires Kotlin version 1.4.30 but you appear to be using Kotlin version 1.4.31 which is not known to be compatible. Please fix your configuration (or
    suppressKotlinVersionCompatibilityCheck
    but don't say I didn't warn you!).` Is it recommended to use
    suppressKotlinVersionCompatibilityCheck
    or revert from 1.4.31 to 1.4.30?
    c
    j
    s
    • 4
    • 10
  • g

    giorgos

    03/01/2021, 1:51 PM
    Material text field has a prefix text property:
    app:prefixText
    I cannot find it in
    androidx.compose.material.TextField
    Could it be it is not implemented yet?
    k
    • 2
    • 2
  • u

    Utkarsh Tiwari

    03/01/2021, 1:54 PM
    Is there any way to make the ModalDrawer pull out from the right side of the screen?
    k
    j
    • 3
    • 9
  • a

    Adriano Celentano

    03/01/2021, 2:26 PM
    Made some swipe cards 🐶 Code https://twitter.com/SophosAdriano/status/1366379033273982979
    :kotlin-intensifies: 12
    😎 2
    k
    a
    p
    • 4
    • 4
  • g

    grandstaish

    03/01/2021, 3:12 PM
    ❔ Does anyone know why the source code for things in
    androidx.compose.ui.input.pointer
    don’t show up in Android Studio? Almost all other compose modules download and show sources correctly.
    • 1
    • 1
  • n

    Nikola Drljaca

    03/01/2021, 4:54 PM
    I'm working on a project in Compose and running the app on a device. I'm getting this weird error which causes the app to crash if the app is open and I'm editing the code
    JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NoSuchMethodError: no non-static method "Landroidx/compose/runtime/HotReloader$Companion;.saveStateAndDispose(Ljava/lang/Object;)V"
    . The trace is pretty extensive after that first line. Is anyone else having this issue? Been googling a bit but can't find anything.
    👍 1
    a
    o
    +3
    • 6
    • 6
  • o

    Olivier Patry

    03/01/2021, 5:56 PM
    If I want to display a master/detail on tablet with Jetpack Compose, do you have some guidelines? For now, I went to something like:
    @Composable
    fun MainLayout(catRepository: CatRepository = (CatRepository((FakeCatDataSource())))) {
        val catsViewModel = viewModel<CatsViewModel>(factory = CatsViewModelFactory(catRepository))
        Surface(color = MaterialTheme.colors.background) {
            when {
                !booleanResource(R.bool.is_tablet) -> MainLayoutTabletPhone(catsViewModel)
                booleanResource(R.bool.is_portrait) -> MainLayoutTabletPortrait(catsViewModel)
                else -> MainLayoutTabletLandscape(catsViewModel)
            }
        }
    }
    • 1
    • 6
  • t

    Timon Bohn

    03/01/2021, 5:57 PM
    Hey folks! Any idea on how to properly auto format decimal numbers inside a TextField based on the locale? Right now we figured out a half working solution using number formatter. But the cursor does not stay at the end of the number and periodically moves one step further to the front.
    d
    • 2
    • 4
Powered by Linen
Title
t

Timon Bohn

03/01/2021, 5:57 PM
Hey folks! Any idea on how to properly auto format decimal numbers inside a TextField based on the locale? Right now we figured out a half working solution using number formatter. But the cursor does not stay at the end of the number and periodically moves one step further to the front.
d

Daniel

03/01/2021, 7:15 PM
Is the issue that the length of the number changes @Timon Bohn? If so, you can compute the new cursor position and set the TextField's cursor position in the TextFieldValue you pass in
(You would check and see if you're adding text before the cursor, and if so subtract the amount you're adding from the cursor position)
It's not intuitive, but if you set the selection range start and end to the same position it apparently represents the cursor being at that position
t

Timon Bohn

03/01/2021, 9:30 PM
Thank you @Daniel I’ll look into it!
👍 1
View count: 4