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

    iamthevoid

    08/09/2021, 9:00 AM
    Hi! I want to create transition animation like this: next screen appears from bottom (and it less than previous), then it is increasing and slide to previous screen bounds. Like a plate when you put in plate stack. Seems that i can do it with AnimatedVisibility.
    expandIn + slideInVertically
    will do the thing. But whatever alignment param looks like it not working at all, i set it as
    Center
    , but next screen expands from side (video, gray background for better vision). Why can be that? (Code in Thread)
    device-2021-08-09-120016.webm
    • 1
    • 5
  • i

    iamthevoid

    08/09/2021, 10:06 AM
    How to correct use animation with compose navigation? If i wrap
    composable
    content of navigation graph in animation then animations will always the same whether
    composable
    content appears on first open or it appear from bacstack. What if i want forward animation on first open, but it must be backward when screen appears from backstack?
    s
    i
    • 3
    • 3
  • r

    RE

    08/09/2021, 10:33 AM
    Can the TabRow in compose be able to customize the width of the Tab? I am trying to adapt the width of the tab to the width of its inner content
    e
    • 2
    • 1
  • n

    Napa Ram

    08/09/2021, 10:43 AM
    Hello i want to create UI for both English and Arabic, can anyone share regarding font
    n
    • 2
    • 2
  • f

    Florian

    08/09/2021, 10:53 AM
    What's the approach in Compose when you have a bottom nav hosted in the activity but want a full-screen screen in some destinations? Just hide the bottom nav through a callback + a state variable? I'm worried if this could get out of sync somehow.
    s
    c
    • 3
    • 40
  • f

    Florian

    08/09/2021, 11:36 AM
    Is there a bug in the bottom nav docs? https://developer.android.com/jetpack/compose/navigation#bottom-nav I've checked it a dozen times and when I click a bottom nav destination twice, the screen goes empty (except for the starting destination)
    ➕ 1
    j
    i
    +2
    • 5
    • 10
  • i

    iamthevoid

    08/09/2021, 11:37 AM
    Why can throws illegal argument exception when i call 
    rememberAnimatedNavController()
     from accompanist library? Looks like bug
    c
    n
    • 3
    • 7
  • a

    Abdalla Hassanin

    08/09/2021, 12:21 PM
    I want to see a complex example of AndroidView include update
    AndroidView(
        factory = { context ->
    
            TextView(context).apply {
                text = "Initial Value"
            }
        },
        update = {
            it.text =  message
        }
    )
    n
    • 2
    • 4
  • n

    Napa Ram

    08/09/2021, 12:40 PM
    HI Everyone, is there any reference how to support Arabic and English in compose
    a
    l
    • 3
    • 6
  • m

    Mohammad Jahidul Islam

    08/09/2021, 12:48 PM
    How can I use Line chart 📉 in compose ?
    d
    s
    • 3
    • 4
  • m

    MaxUt

    08/09/2021, 12:55 PM
    Is there a way to disable the default enter/exit crossfade transition ? I'm using AnimatedNavHost to animate the transition between my Composable however I wanted to have transition only for the subscreen of my app
    c
    i
    • 3
    • 4
  • c

    Chris Miller

    08/09/2021, 1:58 PM
    I'm sometimes getting an IllegalStateException when rapidly navigating between items on my BottomNavigation. The exception is:
    java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels until it is added to the NavController's back stack (i.e., the Lifecycle of the NavBackStackEntry reaches the CREATED state).
    My BottomNavigation code is:
    @Composable
    fun BottomNavBar(navController: NavHostController, bottomNavItems: List<AppScreen>) {
      BottomNavigation {
        val currentRoute = navController.currentDestination?.route
        bottomNavItems.forEach { screen ->
          val selected = currentRoute == screen.route
          BottomNavigationItem(
            icon = { Icon(painter = painterResource(id = screen.iconId), contentDescription = null) },
            label = { Text(screen.name) },
            selected = selected,
            onClick = {
              if (!selected) {
                navController.navigate(screen.route) {
                  popUpTo(navController.graph.findStartDestination().id)
                  launchSingleTop = true
                }
              }
            }
          )
        }
      }
    }
    It seems to be due to the combination of calling popUpTo() and setting launchSingleTop. If either or both of those lines are removed, the problem goes away. Any ideas what I can do to fix this? Is the problem here, or maybe due to something I'm doing in one of my screens?
    t
    i
    s
    • 4
    • 17
  • i

    iamthevoid

    08/09/2021, 3:22 PM
    I asked today this question, but from a bit different side 🙂 But i didn’t get any answers, and should to expand it Why this
    EnterTransition
    [thread] doesn’t run animation, that i expect: screen appears from bottom, and change size from 90% to 100%, but run another animation: screen appears from side. I think this happens because animation runs in container that size is not match the screen. For example if i pass this transition into
    AnimatedVisibility
    and wrap it with
    Box(Modifier.fillMaxSize, contentAlignment = Center)
    then animation runs exactly as i expect. But now i use
    AnimatedNavHost
    from
    accompanist
    lib and same wrapping impossible, because i pass transitions right in graph, not wrap anything with
    AnimatedVisibility
    . So question is - how to avoid incorrect animation behavior when it runs in default container? Is this behavior really incorrect or am i use api incorrectly?
    d
    • 2
    • 6
  • l

    Lucien Guimaraes

    08/09/2021, 4:09 PM
    Is it possible to adjust the padding between a TextField and Keyboard ? Detail in 🧵
    ➕ 1
    c
    h
    • 3
    • 4
  • d

    dimsuz

    08/09/2021, 4:51 PM
    I have
    Box(modifier = Modifier.heightIn(min = 40.dp)) {
      Canvas(modifier = Modifier.fillMaxHeight()) { ... }
      OtherContent()
    }
    and
    Canvas
    composable doesn't fill
    40.dp
    , and is
    0.dp
    in height actually. If I swap
    heightIn
    with
    height(40.dp)
    , then it works. How do I make it so that child either fills
    40.dp
    or more if total Box height ends up to be larger (due to
    OtherContent
    )?
    l
    • 2
    • 17
  • a

    Azam Khan

    08/09/2021, 7:05 PM
    I have a
    LazyVerticalGrid
    inside a
    Column
    , I want to make the whole
    Column
    scrollable, how can I do that? I tried using
    Modifier.nestedScroll
    but not sure how it works
    Column {
        SomeButtons()
        SomeImages()
        LazyVerticalGrid()
    }
    c
    t
    • 3
    • 2
  • f

    Florian

    08/09/2021, 8:38 PM
    I want to hide my bottom nav on certain screens. Right now I'm using the route to compare destinations. This doesn't work with optional arguments anymore, because the
    route
    property of the `navBackStackEntry`'s
    destination
    contains the argument syntax. But in order to add arguments later, my own route string needs to be the "base" route without arguments.
    val navBackStackEntry by navController.currentBackStackEntryAsState()
    val currentDestination = navBackStackEntry?.destination
    val hideBottomNav = fullScreenDestinations.any { destination ->
        destination.route == currentDestination?.route
    }
    So here
    destination.route
    =
    "AddEditTask"
    while
    currentDestination.route
    =
    "AddEditTask?taskId=taskID"
    . How else could I check what destination we are currently on? using
    contains
    to compare a sub-string seems error-prone.
    i
    • 2
    • 8
  • d

    Dominaezzz

    08/09/2021, 10:18 PM
    Modifier.animateContentSize
    . Is there a version of this like
    Modifier.animateContentPosition
    ? Or how would I go about writing my own?
    Modifier.layout
    doesn't provide a position.
    d
    • 2
    • 19
  • c

    Colton Idle

    08/09/2021, 10:39 PM
    Going out on a limb, but after upgrading from compose 1.0 I'm getting some weird R8 errors that are occurring only in release builds and I can't quite pinpoint what happened. Are there any known issues for compose 1.0+ (maybe related to kotlin 1.5.21?)
    e
    • 2
    • 6
  • n

    Napa Ram

    08/09/2021, 11:55 PM
    Hello Everyone, I am facing issue to generate JococoTestReport after upgrading UI to Compose but all test case are getting passed for reference attaching error screenshot
    • 1
    • 2
  • j

    Jason Inbody

    08/10/2021, 12:40 AM
    I'm trying to integrate a bluetooth accessory into my compose app. The sample code is written in java and utilizes a ServiceConnection and a ServiceListener. Should I use a view model to house the service listener? Or should I just try to kotlin-fy the java code and run it in the background as a service connection + listener. The service listerner will need to update my composable view through out the bluetooth connection process.
    d
    • 2
    • 2
  • m

    Mohammad Jahidul Islam

    08/10/2021, 5:08 AM
    Does jetpack compose have video player 🙃
    h
    c
    • 3
    • 4
  • a

    Adib Faramarzi

    08/10/2021, 5:38 AM
    I'm getting the weirdest error in compose navigation. If I add more than 12 navigation destinations in
    NavHost
    I immediately get
    java.lang.ArrayIndexOutOfBoundsException: length=13; index=13
    ! The best part is it doesn't have anything to do with the composable themselves (removing any destination fixes it)
    t
    r
    • 3
    • 6
  • n

    Napa Ram

    08/10/2021, 5:50 AM
    can anyone help me to resolve this issue
    m
    • 2
    • 21
  • n

    Napa Ram

    08/10/2021, 6:53 AM
    HI can anyone help to get code coverage as i am getting below issue with jacoco test report after using latest gradle 7.0.0 and compose
    c
    • 2
    • 1
  • m

    MaxUt

    08/10/2021, 8:17 AM
    Is there a way to load local images stored in /data with Coil ? I've been using Glide so far but it is now deprecated and I'm trying to figure out an alternative.
    c
    • 2
    • 3
  • z

    ziv kesten

    08/10/2021, 8:30 AM
    Hey, I am trying to integrate compose 1.0.1 into an existing project, what versions of Gradle and kotlin should I use?
    m
    c
    • 3
    • 4
  • a

    Adib Faramarzi

    08/10/2021, 9:55 AM
    Is there a way to simulate activity's
    back pressed
    state for compose-navigation?
    popBackStack
    does not finish navigation (and instead just removes the destination) but pressing the back key always works perfectly. This becomes a problem when you have nested navigation as the inner navigation stacks can never pop themselves
    n
    i
    c
    • 4
    • 26
  • p

    Pardeep Sharma

    08/10/2021, 11:35 AM
    Why BottomNavigation not showing the @Composable UI. Compose dependencies i am using: `````` Is there any bug in BottonNavigation compose?
    :thread-please: 3
    ✔️ 1
    c
    • 2
    • 2
  • m

    MaxUt

    08/10/2021, 12:37 PM
    Is there a way to hide an image that couldn't be loaded with Coil ? I've tried using the onExecute function but the states always seems to be EMPTY. Note that I have set a height to my Image composable which is why I want to hide it if it fails.
    v
    c
    • 3
    • 6
Powered by Linen
Title
m

MaxUt

08/10/2021, 12:37 PM
Is there a way to hide an image that couldn't be loaded with Coil ? I've tried using the onExecute function but the states always seems to be EMPTY. Note that I have set a height to my Image composable which is why I want to hide it if it fails.
v

Vadzim Filipovich

08/10/2021, 1:16 PM
You could render an image if state flag is true, so you could create a custom image composable, inside this composable you have state //isError//, and if isError false - display image, if not - display nothing. On coil error callback you could set isError to true
c

Colton Idle

08/10/2021, 3:19 PM
val painter = rememberImagePainter("http")
val state = painter.state
if (state is ImagePainter.State.Loading) {
    
} else {
    Image(
        painter = painter,
        modifier = Modifier.size(48.dp)
    )
}
does this help?
v

Vadzim Filipovich

08/10/2021, 3:43 PM
@Colton Idle notice, that state could be error and it will fall back to else
c

Colton Idle

08/10/2021, 3:49 PM
Use
ImagePainter.State.Error
instead?
v

Vadzim Filipovich

08/10/2021, 3:57 PM
Yep
m

MaxUt

08/10/2021, 3:57 PM
Thank you guys 🙂 I ended up using
@Composable
fun ImageWrapper(painter: ImagePainter, content: @Composable () -> Unit) {
    if (painter.state is ImagePainter.State.Success || painter.state is ImagePainter.State.Empty) {
        content()
    }
}
View count: 3