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

    georgiy.shur

    08/10/2021, 1:13 PM
    I’m trying to add a custom designed bottom sheet using
    ModalBottomSheetLayout
    . But I’m struggling to add a dragging indicator above the sheet (see the image). In the old framework I could use anchor for this, but it seems there’s nothing like this in Compose. I know that I could always achieve the same effect using custom content and not use the shape for bottom sheet, but it doesn’t seem very clean. The screenshot of what I’m trying to achieve is in the thread.
    👋 1
    s
    • 2
    • 4
  • l

    lhwdev

    08/10/2021, 2:20 PM
    Does SAM conversion for
    fun interface
    with
    @Composable
    works or still WIP? I encountered this:
    fun interface SomeComposable {
        @Composable fun Content()
    }
    
    val content = SomeComposable { Text("hi") } // <- @Composable invocations can only happen from the context of a @Composable function
    val content = SomeComposable @Composable { Text("hi") } // <- type mismatch: inferred @Composable () -> Unit but () -> Unit is expected
    h
    j
    • 3
    • 5
  • a

    Akram Bensalem

    08/10/2021, 3:04 PM
    I want to try the new AnimatedNavHost but I encounter this error !!! Any help
    java.lang.IllegalStateException: Could not find Navigator with name "animatedComposable". You must call NavController.addNavigator() for each navigation type.
    c
    i
    • 3
    • 3
  • f

    Florian

    08/10/2021, 3:08 PM
    Is it normal that
    collectAsState
    has some small delay to it before views are populated even if the underlying
    Flow
    is cached using
    stateIn
    ? It's quite noticeable in the UI.
    👀 1
    d
    c
    s
    • 4
    • 11
  • s

    Shivam Kumar Jha

    08/10/2021, 3:24 PM
    Hi, do tabs have inbuilt badge support to show some text?
    d
    • 2
    • 2
  • a

    Anthony

    08/10/2021, 3:42 PM
    When Navigating with Nested Graphs in Compose using Hilt, why does my savedStateHandle not contain the navigationArg? Code in 🧵.
    c
    i
    • 3
    • 5
  • f

    Florian

    08/10/2021, 3:48 PM
    Whats the correct way to pass a string resource (as an Int) to
    scaffoldState.snackbarHostState.showSnackbar
    ? I can't use
    stringResource
    there since that's a Composable.
    d
    m
    • 3
    • 15
  • p

    PHondogo

    08/10/2021, 4:13 PM
    Hello! Does Jetpack Compose contain any composables/templates for 'crud' operations? Like Scafold is a good template for whole application. I mean that there is standard behaviour for view list elements, tap on any to edit, etc.
    z
    • 2
    • 1
  • d

    dimsuz

    08/10/2021, 4:46 PM
    I have a horizontal
    LazyRow
    inside a particular page on an accompanyist
    Pager
    and while this lazy row is being horizontally scrolled I want to disable horizontal swipe of `Pager`'s pages. How can this be achieved?
    ➕ 2
    r
    b
    • 3
    • 4
  • c

    Casey Brooks

    08/10/2021, 5:00 PM
    Is there a guide anywhere for using Compose for non-UI stuff? I’m not quite sure where to even begin
    e
    • 2
    • 1
  • f

    Florian

    08/10/2021, 6:10 PM
    Is there a way to have a snackbar, shown via
    scaffoldState.snackbarHostState.showSnackbar
    appear above the keyboard without changing the
    windowSoftInputMode
    in the manifest?
    b
    • 2
    • 3
  • f

    Florian

    08/10/2021, 6:26 PM
    What is the right way to create an error state for TextFields similar to the old TextInputEditText? I see there is an
    isError
    argument. Do I have to add the error message manually as a
    Text
    below my TextField?
    a
    c
    s
    • 4
    • 12
  • n

    nglauber

    08/10/2021, 6:37 PM
    I’m trying to replace the
    NavHost
    by
    AnimatedNavHost
    , but I’m having an issue… Using
    NavHost
    I have this structure:
    @Composable
    fun AppNavHost(...){
        val navController = rememberNavController()
        NavHost(navController = navController, ...) {
            composable("A") { ScreenA() }
            composable("B") { Feature1NavHost() }
        }
    }
    In
    Feature1NavHost
    I have another
    NavHost
    which takes control of the feature navigation. So,
    ScreenA
    calls “B” and pops out of the stack. Everything works fine here. Using
    AnimatedNavHost
    , when I press back in the first screen of
    Feature1NavHost
    , the display blinks and the application does not finish… 😕 I have to press a lot to close the app.
    i
    c
    • 3
    • 17
  • b

    Billy Newman

    08/10/2021, 7:02 PM
    Hello all, I am having some issues with a recompose not running when replacing an immutable list
    c
    r
    • 3
    • 11
  • c

    Colton Idle

    08/11/2021, 12:59 AM
    I've got an interesting use case when it comes to viewModels and scoping. I've got a NewCreditCardScreen and it has it's own NewCreditCardViewModel. Everything works great. Now I want to add in a secret panel (in debug builds) where it can tell what screen you're on, and it'll provide additional actions for you. Internally we call it a debug panel with "screen shortcuts". The idea is when you're on the NewCreditCardScreen, you activate this debug panel (via shaking the phone) and then click a button for "Enter card data" and it'll update NewCreditCardViewModel with the info. 1. NewCreditCardScreen and NewCreditCardViewModel all work correctly by themselves ✅ 2. Implemented shake to show DebugPanelBottomSheet ✅ 3. cardNumber input field auto-fills 🚫 I thought this would work because ViewModels have a larger scope than a single composable so I thought calling hiltViewModel() will give me the same NewCreditCardViewModel instance that my NewCreditCardScreen is using. Can anyone correct me where my line of thinking is wrong? I think in a typical app I would say "okay, well this state just clearly needs to live somewhere higher up", but because this is a debug only panel I really did think that just requesting a VM that already should be existing would work.
    @Composable
    fun DebugPanelBottomSheet(viewModel: NewCreditCardViewModel = hiltViewModel()) {
        val myClickLambda = {
            viewModel.state.cardNumber = "1234 1234 1234 1234"
        }
    //button that passes myClickLamda
    i
    b
    • 3
    • 29
  • b

    Berkeli Alashov

    08/11/2021, 1:55 AM
    Is there a way to animate Brush/gradient changes?
    n
    в
    • 3
    • 5
  • t

    theapache64

    08/11/2021, 4:51 AM
    🧭 Compose Navigation : Currently, the
    launchSingleTop
    flag works based on the
    route
    pattern, but not route launched. For eg: if I’ve
    composable("page/{pageId}"){...}
    and if i
    navigate("page/1")
    and
    navigate("page/2")
    with
    launchSingleTop = true
    , only the
    page/1
    will load. Is there anyway to make it route based rather than router pattern based ? or How can I handle this scenario?
    i
    • 2
    • 6
  • p

    Pardeep Sharma

    08/11/2021, 6:48 AM
    Any recommendation here, please?
    c
    • 2
    • 3
  • n

    Napa Ram

    08/11/2021, 7:38 AM
    Hi Everyone is there any update on this issue Caused by: java.lang.IllegalStateException: Unexpected SMAP line: *S KotlinDebug at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.getFirstGeneratedLineNumber(KotlinInlineFilter.java:98) at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.filter(KotlinInlineFilter.java:43) at org.jacoco.core.internal.analysis.filter.Filters.filter(Filters.java:57) at org.jacoco.core.internal.analysis.ClassAnalyzer.addMethodCoverage(ClassAnalyzer.java:110) at org.jacoco.core.internal.analysis.ClassAnalyzer.access$100(ClassAnalyzer.java:31) at org.jacoco.core.internal.analysis.ClassAnalyzer$1.accept(ClassAnalyzer.java:99) at org.jacoco.core.internal.flow.ClassProbesAdapter$2.visitEnd(ClassProbesAdapter.java:89) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1279) at org.objectweb.asm.ClassReader.accept(ClassReader.java:679) at org.objectweb.asm.ClassReader.accept(ClassReader.java:391) at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:122) at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:138) ... 42 more
    c
    l
    • 3
    • 3
  • a

    Attila Blenesi

    08/11/2021, 8:19 AM
    ❓ Is it possible to make
    swipeable
    /
    draggable
    only from a portion of a view?
    a
    • 2
    • 5
  • k

    K Merle

    08/11/2021, 8:37 AM
    I have to use Scaffold top and bottom bar across the screens. SignIn and Splash screen do not need top and bottom bar. How do I use navController with Scaffold? Do I hoist Scaffold above NavHost and hide top and bottom bar on certain screens? Is it possible to have NavHost inside NavHost to manage screens that use Scaffold?
    j
    i
    • 3
    • 2
  • a

    Android developer

    08/11/2021, 9:15 AM
    👋 I am migrating an existing app to jetpack compose. We use apart from the existing Material colors a lot of additional colors all of them defined in the theme xml. I was wondering if there is a way of using these colors directly from the xml file instead of duplicating these colors in a custom theme. I cannot find any example about this...hopefully this isn't a to dumb question here.
    b
    a
    +2
    • 5
    • 9
  • p

    PHondogo

    08/11/2021, 10:08 AM
    How does Composable listen on a State?
    c
    • 2
    • 1
  • a

    Akram Bensalem

    08/11/2021, 10:16 AM
    How to add a leading Icon to BasicTextField ?
    e
    • 2
    • 3
  • b

    batuhan ardor

    08/11/2021, 12:24 PM
    Hi there, i've a problem with Compose+PagingData. In the viewModel I make the paging request and get the flow of pagingData. Then using the collectAsLazyPagingItems() I pass it to Composable. In the Compose I listen its loadStates. On loading i show a loading indicator, on notLoading i check the snapshot list size and if its empty i show the empty screen, if it is not empty i show the actual list with lazyColumn. So here the problem, when open the screen, first -> empty screen shows up, second -> loading indicator and finally the list comes up. So it kind of flicks and looks ugly. I want that the empty screen should only shows up when the request is over and no data. Thanks.
    j
    s
    • 3
    • 9
  • n

    Nacho Ruiz Martin

    08/11/2021, 1:16 PM
    Hey 👋 Is there any substitute to
    adjustViewBounds
    in Compose’s
    Image
    ? I want an image’s height to be driven by the width + keep original aspect ratio so I’m using
    alignment = Alignment.Center,
    contentScale = ContentScale.FillWidth,
    but this creates vertical padding that I want to get rid of. In traditional view system I would just ad
    adjustViewBounds=true
    .
    c
    • 2
    • 5
  • m

    Mjahangiry75

    08/11/2021, 1:25 PM
    is this an bad idea?
    @Composable
    fun networkState(): State<Boolean> {
    
        val context = LocalContext.current
    
        return context.networkStateFlow().collectAsState(initial = false)
    }
    Actually I'm trying to observe the network state in composables
    a
    • 2
    • 4
  • s

    Stefan Oltmann

    08/11/2021, 1:44 PM
    If I want to use "AnimatedVisibility" inside a "Box" it states "Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary". What does that mean?
    z
    • 2
    • 1
  • c

    Cicero

    08/11/2021, 2:32 PM
    Good afternoon people. I got tired of trying to understand how this does not work: It's navigation related, I wanna make a navigation router out of my splash screen and I keep getting into this infinite loop where the splash screen keeps getting triggered and every interaction the access to my second destination increases in one.
    c
    i
    t
    • 4
    • 37
  • t

    Tin Tran

    08/11/2021, 2:56 PM
    Hi. How can I apply gradient from start to end of an arc only? I want to draw an arc like the image and animate it to rotate in a circle
    ❤️ 1
    c
    t
    • 3
    • 4
Powered by Linen
Title
t

Tin Tran

08/11/2021, 2:56 PM
Hi. How can I apply gradient from start to end of an arc only? I want to draw an arc like the image and animate it to rotate in a circle
❤️ 1
c

Colton Idle

08/11/2021, 3:38 PM
I asked a similar question in the past and got an answer of "you can draw the path with a sweepGradient with the starting and ending colors being the faded/non faded colors respectively" I looked at my code and I didn't end up working with a sweep for some reason, but chose a linear gradient instead.
drawPath(
    path = path,
    brush =
        Brush.linearGradient(
            colorStops =
                arrayOf(
                    0.1f to Color(0x00ff0000),
                    .2f to Color(0xFFff0000),
                    .8f to Color(0xFFff0000),
                    .9f to Color(0x00ff0000),
                ),
        ),
t

Tash

08/11/2021, 9:36 PM
you could do the same with
sweepGradient
by making sure color stops are passed instead of just a list of colors
Brush.sweepGradient(
             0.0f to Color.Red,
             0.3f to Color.Green,
             1.0f to Color.Blue,
             center = Offset(0.0f, 100.0f)
)
sweepGradient
helps especially if you want the leading edge to go back to the starting color when it completes the arc
:today-i-learned: 2
t

Tin Tran

08/12/2021, 6:17 AM
Thanks guys! I ended up export the circle vector and animate the rotation 😅. I’ll try your solution to night.
View count: 11