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

    bohregard

    06/23/2020, 1:43 AM
    So I’m playing around with WebViews and I can’t seem to get the view to load changes. It appears frozen
    Box(
            modifier = Modifier.fillMaxWidth() + Modifier.fillMaxHeight()
        ) {
            AndroidView(view = webView(ContextAmbient.current, "<https://google.com>"))
        }
    
    fun webView(context: Context, url: String) = WebView(context).apply {
        loadUrl(url)
        settings.apply {
            javaScriptEnabled = true
            domStorageEnabled = true
        }
    
        webViewClient = client
    }
    Any ideas why it would be frozen?
    z
    m
    +2
    • 5
    • 18
  • u

    ursus

    06/23/2020, 4:26 AM
    Uhm, I think you guys will be forced to do something about widgets now as well 😄
    ❤️ 1
    a
    r
    +2
    • 5
    • 6
  • c

    Carminelaface

    06/23/2020, 9:26 AM
    Hi guys, I have one question, I just saw this in the androidx.ui.material package
    /**
     * Contains the default values used by [Button]
     */
    object Button {
        
        /**
         * The default inner padding used by [Button]
         */
        val DefaultInnerPadding = ...
    
        /**
         * The default disabled background color used by Contained [Button]s
         */
        @Composable
        val defaultDisabledBackgroundColor
            
        /**
         * The default disabled content color used by all types of [Button]s
         */
        @Composable
        val defaultDisabledContentColor
    }
    This is not only for the button but for many other views. I think a better naming for the object would be
    ButtonDefalutValues
    or
    ButtonDefaluts
    and remove the
    default
    suffix from all the properties.
    j
    • 2
    • 1
  • a

    aipok

    06/23/2020, 10:50 AM
    Is there any concept in mind of how the composable should be decoupled or how big should/could be views/pages/screens with nested composable elements? Another question is, what is the best way to pass or get an instance of the ViewModel inside compose element?
    j
    • 2
    • 4
  • r

    Roi Peretz

    06/23/2020, 11:39 AM
    Hi, I need an advice. I am developing a project with native mobile apps. Right now I am working with Kotlin for android (Coroutines, Flow, Clean Arch, MVI), and SwiftUI (Combine, Clean Arch, MVI). I am thinking to move to Jetpack Compose in the android app because it is very similar to the declerative UI in SwiftUI. You recommend to go for it? Or to wait when the Jetpack Compose will be ready for production?
    t
    a
    +2
    • 5
    • 8
  • r

    Roman Abaev

    06/23/2020, 12:10 PM
    Hello, is there any example with jetpack compose BottomAppBar? I can't manage my elements in it properly
    g
    • 2
    • 2
  • m

    Mantas Varnagiris

    06/23/2020, 12:26 PM
    I can use
    rawDragGestureFilter
    to move stuff around with one finger. Is there a modifier that allows to register multi finger touch? There is
    scaleGestureFilter
    for scale, but I can't find a way to do rotation with 2 fingers. What am I missing?
    ➕ 1
    • 1
    • 1
  • a

    aipok

    06/23/2020, 2:47 PM
    How to disable
    Text
    value from being selected on long press? I have a
    Text
    element inside
    Button
    and while I long click on button, its text is being selected. Could not find how can I disable it.
    s
    • 2
    • 3
  • g

    Guy Bieber

    06/23/2020, 11:02 PM
    It seems like if there was not a user interaction (i.e. updating initial state from the server instead of a user action) the values don’t update. I use the same model for different controls and some work / some don’t.
    l
    g
    • 3
    • 9
  • h

    Hyun

    06/24/2020, 5:00 AM
    Hi, I need an advice. I would like to call suspend function on
    TextButton.onClick
    . as
    onClick
    is not Composable. I can’t use
    launchInComposition
    so, I tried the below. but I’m not sure if this is proper approach or not. I searched on this channel but. it was difficult to find the discussion.
    scope = remember { CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate) }
    onDispose { scope.cancel() }
    
    TextButton(onClick={ scope.launch { doSuspendFunction() }})
    what is the best approach on this case?
    l
    z
    • 3
    • 5
  • o

    Octave Decaux

    06/24/2020, 9:04 AM
    I'm trying to implement a modified WithConstraint. Linter says NodeLayout call doesn't take any argument, code compiles just fine, but it is not executed. I guess there is an internal NodeLayout Composable function which refers to the NodeLayout class, but I cannot find it. What is the proper way to use NodeLayout in my own code ?
    a
    z
    • 3
    • 11
  • j

    Julius Marozas

    06/24/2020, 9:16 AM
    Hi, I would like to anchor a floating action button to the edge of a bottom sheet. In xml I would use
    app:layout_anchor
    with
    app:layout_anchorGravity
    . Is this currently possible in Compose?
    m
    • 2
    • 1
  • s

    samueldple

    06/24/2020, 12:21 PM
    When using a scaffold with a conditional FAB, I find I have to cast to compile:
    floatingActionButton = if (condition) { 
        @Composable {
            FloatingActionButton(onClick = {backStack.push(Routing.EditDrink(null))}) {
                Icon(Icons.Default.Add)
            }
        } as @Composable() () -> Unit
    } else null
    Or I get an "Expected type was Nothing?" error, but when casting the cast shows as a useless cast. Am I doing something stupid?
    😅 2
    d
    m
    • 3
    • 7
  • m

    mbonnin

    06/24/2020, 1:49 PM
    Is there something similar to Barriers in ConstraintLayout ?
    s
    v
    • 3
    • 3
  • v

    Vinay Gaba

    06/24/2020, 5:29 PM
    Excited to try some of the new API’s that were just released!
    a
    • 2
    • 3
  • r

    romainguy

    06/24/2020, 5:39 PM
    I’ve just updated my demo for dev14, using the new ConstraintLayout DSL
    👍 15
    v
    l
    g
    • 4
    • 6
  • s

    samueldple

    06/24/2020, 7:53 PM
    I find that following the movement of
    Toggleable
    into a modifier, the bounds on the ripple applied are incorrect. I have the below code, but the ripple now extends to fill the full square bounds rather than the shape's bounds. How should this be rectified?
    Surface(
            shape = RoundedCornerShape(8.dp),
            modifier = Modifier.toggleable(
                value = selected,
                onValueChange = { ... }
            )
    ) {
        ...
    }
    Do I need to do my own
    RippleIndication
    for this effect?
    r
    • 2
    • 4
  • v

    vanpra

    06/24/2020, 11:26 PM
    Is there any way to have a negative margin with constraint layout. I've tried using offset but this doesn't seem to move/resize other components which it is linked to
    m
    • 2
    • 1
  • g

    Guy Bieber

    06/24/2020, 11:33 PM
    I am trying to use pixelcopy to capture the screen in a compose application, however, it asks for a view (which is kind of hidden in compose). What is the relationship between compose and views? How do I get the view currently being rendered by compose?
    fun getScreenShotFromView(view: View, activity: Activity, callback: (Bitmap) -> Unit) {
        activity.window?.let { window ->
            val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
            val locationOfViewInWindow = IntArray(2)
            view.getLocationInWindow(locationOfViewInWindow)
            try {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    PixelCopy.request(
                        window,
                        Rect(
                            locationOfViewInWindow[0],
                            locationOfViewInWindow[1],
                            locationOfViewInWindow[0] + view.width,
                            locationOfViewInWindow[1] + view.height
                        ), bitmap, { copyResult ->
                            if (copyResult == PixelCopy.SUCCESS) {
                                callback(bitmap) }
                            else {
    
                            }
                            // possible to handle other result codes ...
                        },
                        Handler()
                    )
                }
            } catch (e: IllegalArgumentException) {
                // PixelCopy may throw IllegalArgumentException, make sure to handle it
                e.printStackTrace()
            }
        }
    }
    l
    r
    +4
    • 7
    • 17
  • k

    kagomez

    06/25/2020, 2:46 AM
    Hey guys if anyone speaks Spanish I’m going to give a small introduction into Compose this Friday at Android Dev Perú so if you want to check over if you’re starting go ahead and join
    👍 8
    • 1
    • 1
  • m

    Mikael Alfredsson

    06/25/2020, 9:47 AM
    I’ve must have missed something about how the UI updates are handled. Before (when the magic of @Model existed) I could change the data model outside a @compose scope (data pushed via FCM) and it automatically updated the UI. Without that magic, I should according to the migration guide, I should use
    by state
    or
    mutableStateOf
    together with
    remember
    , both of them reassign the datamodel to a wrapped variable inside the @Compose scope and i’m not sure how to mutate the data class and force a refresh.
    m
    g
    +2
    • 5
    • 16
  • b

    bmo

    06/25/2020, 11:23 AM
    Hello everyone, I made a very simple app using compose and it crashes with the error :
    java.lang.IllegalArgumentException: Key 640122159 was already registered. Please call unregister before registering again
    The code can be found here https://github.com/bmonjoie/ComposeTipsCalculator I have seriously no idea what I'm doing wrong so if someone could give me any pointers, that would be really appreciated
    a
    • 2
    • 5
  • t

    Timo Drick

    06/25/2020, 12:04 PM
    I cannot find the constructor for
    androidx.ui.core.LayoutNode(modifier = currentComposer.materialize(modifier), measureBlocks = measureBlocks) { childrend() }
    Which is used in many base composable components. I would like to use especially the way LayzyItems using it to be able to add and remove Nodes during measurement runs. Why is it hidden from the Public API? Or maybe i just missed something?
    s
    a
    • 3
    • 10
  • a

    andylamax

    06/25/2020, 12:40 PM
    https://twitter.com/intelligibabble/status/1273339533891788800 This tweet referes to using compose in any tree. Does this mean it can be applicable to kotlin/jvm for desktop? or even used in kotlin/js?
    s
    t
    +2
    • 5
    • 17
  • l

    louiscad

    06/25/2020, 1:07 PM
    Hello, people from Flutter made an extensive document about state restoration and their plans (since it's not supported natively yet). When it comes to Jetpack Compose, I've not seen much about facilities to ease state saving (yet), so I'm wondering if that document could help shape the APIs that we can use to support state restoration easily. Here it is: https://flutter.dev/go/state-restoration-design
    👍 2
    z
    a
    a
    • 4
    • 26
  • a

    aipok

    06/25/2020, 2:31 PM
    I need to make an animation for
    Image
    using an array of
    DrawableResIds
    . Let say to switch an image every second. Does anyone know how to achieve this using Compose animation API or transition? Or might there is some other way to do it?
    z
    m
    • 3
    • 4
  • v

    Vince Rickey

    06/25/2020, 4:00 PM
    Hi. My coworker @Jordan Carlyon and I are Android developers at the Wall Street Journal. We’re working on a joint initiative with our iOS and backend teams to create a Component Library that uses Jetpack Compose backed by JSON models. We successfully completed a concept thanks to the documentation and samples, but I haven’t found much information on the roadmap in terms of moving to alpha or beta. A level of parity with SwiftUI is important. Right now we’re debating whether or not it’s worth using Jetpack Compose in a small corner of our app or just building a standalone library and waiting to integrate until Jetpack Compose is more mature knowing that it could be a while. Any advice or general feedback would be helpful. Thanks!
    b
    r
    v
    • 4
    • 6
  • h

    Hyun

    06/25/2020, 5:08 PM
    Hi, I need an advice again. the code below hide ui if shown == false
    if (shown) {
        Column {
            Text("Success")
        }
    }
    but, I would like to use the way below similar to data binding.(
    android:visiblity="@{model.shown}"
    ) as it reduce indent depth, so, seems easy to read UI code. and feel better to separate ui and logic.
    Column(Modifier.visible(shown)) {
        Text("Success")
    }
    I tried to customize Modifier. but, it looks difficult. is there any possible solution? or is it not recommended approach?
    t
    l
    s
    • 4
    • 20
  • m

    manueldidonna

    06/25/2020, 7:20 PM
    ListItem
    icon is wrapped in a
    Box
    with
    ContentGravity.TopStart
    . I think that a Center Alignment would be more appropriate
    a
    a
    m
    • 4
    • 5
  • a

    amar_1995

    06/26/2020, 11:52 AM
    Is there any solution to integrate pagination library with compose
    AdapterList
    ?
    ➕ 1
    👍 1
    a
    • 2
    • 1
Powered by Linen
Title
a

amar_1995

06/26/2020, 11:52 AM
Is there any solution to integrate pagination library with compose
AdapterList
?
➕ 1
👍 1
a

Andrey Kulikov

06/26/2020, 1:23 PM
not yet, but we are planning it
👍 6
View count: 2