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

    Se7eN

    10/30/2020, 10:23 AM
    I'm getting this error while passing a parcelable as argument in navigation:
    java.lang.UnsupportedOperationException: Parcelables don't support default values.
            at androidx.navigation.NavType$ParcelableType.parseValue(NavType.java:679)
            at androidx.navigation.NavType.parseAndPut(NavType.java:96)
            at androidx.navigation.NavDeepLink.parseArgument(NavDeepLink.java:306)
            at androidx.navigation.NavDeepLink.getMatchingArguments(NavDeepLink.java:260)
            at androidx.navigation.NavDestination.matchDeepLink(NavDestination.java:474)
            at androidx.navigation.NavGraph.matchDeepLink(NavGraph.java:79)
            at androidx.navigation.NavController.navigate(NavController.java:1025)
            at androidx.navigation.NavController.navigate(NavController.java:1008)
            at androidx.navigation.NavController.navigate(NavController.java:994)
            at androidx.navigation.compose.NavHostControllerKt.navigate(NavHostController.kt:100)
    This is my code:
    composable(Routing.Root.Main.route) {
        Routing.Root.Main.Content(
            onChatClick = { user ->
                navController.navigate("${Routing.Root.Conversation.route}/${user}")
            }
        )
    }
    
    composable(
        "${Routing.Root.Conversation.route}/{user}",
        arguments = listOf(navArgument("user") { type = NavType.ParcelableType(User::class.java) })
    ) { backStackEntry ->
        backStackEntry.arguments?.getParcelable<User>("user")?.let { user ->
            Routing.Root.Conversation.Content(user = user)
        }
    }
    And this is the User class:
    @Parcelize
    data class User(
        val name: Name,
        val picture: Picture
    ) : Parcelable
    
    @Parcelize
    data class Name(
        val first: String,
        val last: String,
        val title: String
    ) : Parcelable
    
    @Parcelize
    data class Picture(
        val large: String,
        val medium: String,
        val thumbnail: String
    ) : Parcelable
    I know @Ian Lake suggested using IDs but I don't wanna bother with that right now for a sample app. How can I fix this?
    a
    m
    +4
    • 7
    • 20
  • k

    Kshitij Patil

    10/30/2020, 12:24 PM
    Anyone working on Neuomorphic design system using Jetpack Compose?
    👀 4
    p
    r
    • 3
    • 5
  • p

    Philip Blandford

    10/30/2020, 12:49 PM
    In a constraintLayout, how can I guarantee that one element will be underneath the others? Up until alpha05 I was wrapping them in Surfaces and setting the elevation, which didn't feel ideal but it worked. Now in alpha06 that doesn't work any more and they just appear in an order that varies with refreshes.
    s
    a
    • 3
    • 8
  • g

    Grzegorz Baczek

    10/30/2020, 1:47 PM
    Hey, I'm currently playing a little with LazyRowFor and I was wondering if there is any possibility to scroll the list programatically, not with the finger swipe. I actually can't find any clear answer for that so I decided to ask it here.
    c
    a
    h
    • 4
    • 6
  • c

    cb

    10/30/2020, 4:29 PM
    📐 We've just merged in a new library into Accompanist for WindowInsets support. Please try out the snapshot if you're interested, and let us know how it goes. https://github.com/chrisbanes/accompanist/tree/main/insets
    👍 24
    🙏🏽 1
    • 1
    • 1
  • p

    pavi2410

    10/30/2020, 6:10 PM
    Do anybody know how to make dynamic gradient list like this? I tried to use ScrollableColumn with its scrollState, but I am super confused how to vary the gradient on scroll
    Compressed_20201030_205055.mp4
    ➕ 3
    c
    a
    +2
    • 5
    • 6
  • p

    Prashant Priyadarshi

    10/30/2020, 6:39 PM
    onImeActionPerformed is not getting invoked on submit button click in soft keyboard. This code was working earlier. Have there been any changes ? As of now I am on alpha06
    TextField(
    value = text.value,
    onValueChange = { s ->
    text.value = s
    },
    keyboardType = KeyboardType.Text,
    imeAction = ImeAction.Send,
    onImeActionPerformed = { action: ImeAction, keyboard: SoftwareKeyboardController?
    ->
    // close keyboard when submit button is clicked
    if(action == ImeAction.Send)
    keyboard?.hideSoftwareKeyboard()
    },
    )
    s
    • 2
    • 4
  • l

    loloof64

    10/30/2020, 7:34 PM
    Hi everyone 😃 Is there a way to change the tint of a VectorAsset : I've also been looking at https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorAsset.html. But it seems like impossible 😢
    j
    l
    a
    • 4
    • 9
  • l

    loloof64

    10/30/2020, 7:44 PM
    Oups sorry : I've just read from the documentation that vectorResource() is to be avoided, and than I'd better load asynchronously. So I've got to change my code and try to figure out how to adapt my code. Can someone recommand me a simple guideline (or point me to an existing one) in order to load an image asynchronously ? I've read some ideas around Picasso, but I still find them a bit hard to use.
    • 1
    • 1
  • o

    Oussama Haff.

    10/30/2020, 8:47 PM
    Hello 👋 Can you please confirm if the following assertion is true ? Given : a tree of composables
    + Parent     // retrieves state from ViewModel, declares fun action on VM
    |
    |---+ Child A          // passes state without using it, passes action as fun
        |
        |---+ Child A-1        // uses state 
        |
        |---+ Child A-2 
        |
        |---+ Child A-3       // invoke the action fun
    When : invoking the passed action by clicking on Child A-3 Then :
    + Parent         // will NOT recompose 
    |
    |---+ Child A          // will recompose (because A-1 recompose) 
        |
        |---+ Child A-1         // will recompose 
        |
        |---+ Child A-2         // will NOT recompose
        |
        |---+ Child A-3         // will NOT recompose
    s
    k
    • 3
    • 5
  • z

    ziv kesten

    10/30/2020, 9:27 PM
    Is there a way to add transition animations to the new navigation library for compose?
    i
    c
    +4
    • 7
    • 38
  • u

    3bdoelnaggar

    10/31/2020, 12:05 AM
    I want to draw 5 circle with text in them and animate them, until now I managed to animate just circles with draw circle the goal at the end to learn animate any "view" https://twitter.com/3bdoelnaggar/status/1318322080434343936 how can I achieve that thanks
    d
    • 2
    • 5
  • v

    Vsevolod Ganin

    10/31/2020, 12:38 AM
    Is there a way to make a material exposed dropdown menu? I already know composables
    DropdownMenu
    and
    DropdownMenuItem
    but I can’t figure what to put in
    toggle
    to make it look like from design doc. It seems that there should be either
    TextField
    or
    OutlineTextField
    but these are very unfriendly when I try to mute their text editing capabilities
    d
    • 2
    • 5
  • n

    Nat Strangerweather

    10/31/2020, 9:41 AM
    Hello! Since updating to alpha_06, I have the following errors and I can't find any solution in the release notes. I see that "backgroundColor" was replaced with "colors" for the Button, but I don't know how to implement this. Does anyone know what I need to use in the three snippets? Cheers!
    s
    a
    • 3
    • 3
  • s

    Se7eN

    10/31/2020, 10:55 AM
    How do you guys handle nullable states. Doesn't stuff like
    Text(user?.name ?: "")
    make the code ugly?
    g
    g
    j
    • 4
    • 18
  • g

    Grigorii Yurkov

    10/31/2020, 11:50 AM
    Can someone explain me
    navigation-compose
    advantages over simple
    when (screen) {...}
    ?
    @Composable
    private fun AppContent(
        navigationViewModel: NavigationViewModel,
        postsRepository: PostsRepository,
        interestsRepository: InterestsRepository
    ) {
        Crossfade(navigationViewModel.currentScreen) { screen ->
            Surface(color = MaterialTheme.colors.background) {
                when (screen) {
                    is Screen.Home -> HomeScreen(
                        navigateTo = navigationViewModel::navigateTo,
                        postsRepository = postsRepository
                    )
                    is Screen.Interests -> InterestsScreen(
                        navigateTo = navigationViewModel::navigateTo,
                        interestsRepository = interestsRepository
                    )
                    is Screen.Article -> ArticleScreen(
                        postId = screen.postId,
                        postsRepository = postsRepository,
                        onBack = { navigationViewModel.onBack() }
                    )
                }
            }
        }
    }
    (code from JetNews)
    a
    i
    • 3
    • 2
  • g

    grandstaish

    10/31/2020, 12:55 PM
    Is there a way to make a non-interactive
    Checkbox
    (but also not appear disabled)? Context: I have a
    ListItem
    with a trailing
    Checkbox
    where clicking the list item toggles the checked state. I’m currently sharing the
    interactionState
    between the checkbox and list item so that they ripple together. Sharing interactions like this is cool, but I’d prefer having no ripple at all on the checkbox
    a
    l
    l
    • 4
    • 11
  • s

    Se7eN

    10/31/2020, 1:21 PM
    I'm getting different instances of a view model in different screens of the same
    NavHost
    . Is this intended? How can I scope the view models to the
    NavHost
    or activity?
    NavHost(navController = navController, startDestination = "screen1") {
        composable("screen1") { Screen1() }
        composable("screen2") { Screen2() }
    }
    
    @Composable fun Screen1() {
        val viewModel: MainViewModel = viewModel()
    }
    
    @Composable fun Screen2() {
        val viewModel: MainViewModel = viewModel()
    }
    i
    g
    a
    • 4
    • 7
  • n

    Najib Ghadri

    10/31/2020, 1:59 PM
    Hello dear community! I have a question regarding Compose, Firestore and Flutter. I don't mind opinionated answers, even though I know you don't like them, however I have been planning on my app for quite some time and I need help in taking the best decision. (I have read previous questions here regarding this, but I thought I need to ask.) I will be starting building an e-commerce-like app myself, and I plan a release for not earlier than next year March/April. I've been following the progress in Flutter for a year now and I leaned back to go back to native Android for the first release. I also knew about jetpack and compose, and saw that it's not production ready yet. I like the development efficiency of both Jetpack compose and Flutter, but both are not production ready compose being less. However I feel like Compose could be supported more fundamentally in the long run, since it is the native platform. Another thing is, I have been looking around how to use Firestore with Compose, but couldn't find anything, is this integration possible currently? Considering that I will use Firebase services, the current state of compose, my release date (and if you have any familiarity with Flutter) what is your opinionated suggestion, which platform should I/ I shouldn't start building on? Android Kotlin native, Jetpack compose, Flutter? Thank you.
    g
    a
    • 3
    • 7
  • j

    jaqxues

    10/31/2020, 2:34 PM
    There is no Navigation Icon for the toolbar I can just use, is there?
    g
    • 2
    • 3
  • s

    Se7eN

    10/31/2020, 3:33 PM
    Is there something like
    onBackPressed
    listener? I want to override onBackPressed to make sure I don't navigate back in certain cases
    g
    a
    • 3
    • 6
  • f

    FunkyMuse

    10/31/2020, 4:00 PM
    Hello to everyone, is there bottom sheet implementation in compose?
    v
    • 2
    • 2
  • h

    Halil Ozercan

    10/31/2020, 5:08 PM
    What should I do if I want to create a custom modifier which will be stateful (
    composed
    ) and that state depends on the size of the composable that it is attached to. For example, initial state is going to have 50 random objects if size is smaller than a threshold, 100 objects if it is larger.
    a
    • 2
    • 4
  • n

    Nat Strangerweather

    10/31/2020, 5:41 PM
    Hi there, could you please help me with this code? Basically, I have three buttons and I want to be able to select them individually but also to have several of them selected at the same time if needed. So far, all I managed to do is that when I select one all the others are selected too. I know I need to loop through them for it to work, but I don't understand how to do it:
    @Composable
    fun CirclesLayout() {
        val selectedState = remember { mutableStateOf(false) }
        ScrollableRow {
            for (circle in listOf()) {
                Circles(
                    color = if (!selectedState.value) Color(0xffA5D6A7) else Color(0xff4CAF50),
                    gradientColor = Color(0xff4CAF50),
                    text = "Alarms",
                    selected = selectedState.value,
                    onSelected = { selectedState.value = !selectedState.value }),
                Circles(
                    color = if (!selectedState.value) Color(0xffB39DDB) else Color(0xff673AB7),
                    gradientColor = Color(0xff673AB7),
                    text = "Media Sounds",
                    selected = selectedState.value,
                    onSelected = { selectedState.value = !selectedState.value }),
                Circles(
                    color = if (!selectedState.value) Color(0xffFFAB91) else Color(0xffFF5722),
                    gradientColor = Color(0xffFF5722),
                    text = "Touch Sounds",
                    selected = selectedState.value,
                    onSelected = { selectedState.value = !selectedState.value })
            }
        }
    }
    Any ideas? Thanks!
    s
    • 2
    • 3
  • s

    Se7eN

    10/31/2020, 6:03 PM
    val navController = rememberNavController()
    val visible by remember { mutableStateOf(false) }
    Scaffold(
        ...
    ) {
        NavHost(navController, "screen1") {
            composable("screen1") { ... }
            composable("screen2") { ... }
        }
    }
    
    AnimatedVisibility(visible) {
        Box(modifier = Modifier.fillMaxSize()) { ... }
    }
    When I'm on screen2 and the
    AnimatedVisiblity
    becomes visible, it automatically navigates to screen1. This feels like a bug 🤔
    i
    • 2
    • 5
  • j

    jaqxues

    10/31/2020, 6:34 PM
    A couple of questions about the Drawer Can I make it smaller like a standard Drawer on Android? The Compose one is just huge. Are there `DrawerButton`s or something other to create them (same goes for the drawer headers, with an app name and a logo maybe). Are there any plans to write those so I know what to invest time in?
    a
    • 2
    • 4
  • r

    Robert Menke

    10/31/2020, 7:03 PM
    Is there a good example project for navigation-compose? Migrating my compose app over to alpha01 and just want to see how the entry point is done.
    i
    j
    • 3
    • 12
  • r

    romainguy

    10/31/2020, 7:59 PM
    The shape tag is a gradient drawable, not a vector drawable resource
    r
    • 2
    • 1
  • h

    Halil Ozercan

    10/31/2020, 9:28 PM
    Inspired by this animation that I stumbled upon in /r/internetisbeautiful, developed a quick prototype in compose. Quick demo video:

    https://youtu.be/iCe5f7L9vBg▾

    Repo: https://github.com/halilozercan/compose-dotsandlines
    🌟 14
    s
    g
    • 3
    • 3
  • f

    FunkyMuse

    10/31/2020, 10:54 PM
    Is there onResume & onPause equivalent method in a composable function?
    a
    • 2
    • 3
Powered by Linen
Title
f

FunkyMuse

10/31/2020, 10:54 PM
Is there onResume & onPause equivalent method in a composable function?
a

Adam Powell

10/31/2020, 11:46 PM
strictly speaking you can use
LifecycleObserver
,
LifecycleOwnerAmbient
and
DisposableEffect
together to get exactly that, but there might be a better fit for what you're doing. What's the use case?
f

FunkyMuse

11/01/2020, 9:48 AM
On resume i check for permission if it's given and update the button's layout
a

Adam Powell

11/01/2020, 2:20 PM
The above should work fine then. We might provide some canned version of it in the stock libraries later but its implementation would be exactly the above
👍 1
View count: 1