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

    aryk

    03/04/2020, 12:37 PM
    Is it possible to convert a Bitmap into an Image?
    m
    • 2
    • 1
  • k

    Kazemihabib1996

    03/04/2020, 5:58 PM
    I'm playing with Clip and Draw components can someone explain me why this doesn't produce a rounded shape rectangle?
    Container(width = 400.dp, height = 400.dp) {
    Clip(shape = RoundedCornerShape(20.dp)) {
    Draw { canvas, parentsize ->
    val outer = Rect(10f, 10f, 100f, 100f)
    canvas.drawRect(outer, paint)
    }
    }
    }
    z
    • 2
    • 6
  • t

    tcracknell

    03/04/2020, 6:14 PM
    Hello! The latest Jetpack Compose minor release, dev06, has just dropped and you can get it now on Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/releases/compose and https://developer.android.com/jetpack/androidx/releases/ui. Please note that the majority of the documentation including codelabs, tutorials, and samples will only be updated for major releases so you may notice some discrepancies if you’re using the latest version of Compose. Feedback is always welcome; please log issues at https://issuetracker.google.com/issues/new?component=612128!
    :kotlin: 6
    🎉 22
    k
    l
    j
    • 4
    • 9
  • k

    Kevin Hester

    03/04/2020, 7:01 PM
    Hi ya'll any guess when the Compose support for better lifecycle awareness will drop? I'd eagerly use it (though currently onCommit and misc onStop glue is working fine.
    l
    • 2
    • 25
  • a

    aryk

    03/04/2020, 9:18 PM
    What's the point of the
    indent
    parameter? Can't we just add a left offset with padding?
    @Composable 
    fun Divider(
        modifier: Modifier = Modifier.None, 
        color: Color = MaterialTheme.colors().surface, 
        height: Dp = 1.dp, 
        indent: Dp = 0.dp
    ): Unit
    l
    • 2
    • 1
  • g

    gumil

    03/04/2020, 10:42 PM
    I'm getting NoSuchMethodError setContent on
    0.1.0-dev06
    Is this a known error? I also get
    e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    when adding Text Style
    l
    m
    • 3
    • 15
  • h

    henrikhorbovyi

    03/05/2020, 3:01 PM
    Hey folks, is there some ideia of how it will be the integration between Compose and Motion layout? I've been playing with both and I was wondering that.
    k
    n
    c
    • 4
    • 7
  • i

    Ian Warwick

    03/05/2020, 4:39 PM
    Hey composers, what is the alternative to
    DrawShape
    now?
    z
    s
    +3
    • 6
    • 14
  • i

    Ian Warwick

    03/05/2020, 5:13 PM
    What is this voodoo magic (luckily it was just a hacky function I am not using)
    s
    l
    • 3
    • 9
  • g

    gumil

    03/05/2020, 7:50 PM
    TextButton and OutlinedButton's children aren't updated by
    @Model
    classes. I suspect that the
    noinline
    might have affected this. It works okay using a plain button
    l
    • 2
    • 8
  • t

    Thaw De Zin

    03/06/2020, 6:35 AM
    Is it normal that AdapterList is overlap with Button? And, when I try to click Button more than 20 times, VerticalScroller is fine. But, in AdapterList, my app is stopped with java.lang.IndexOutOfBoundsException: Index: 8, Size: 8. And whatever the numbers are, it just says Index: 8, Size: 8. Plese someone correct my code. Thank you.
    LayoutTestingActivity.kt
    v
    l
    r
    • 4
    • 11
  • i

    Ian Warwick

    03/06/2020, 9:53 AM
    AS now complains about method name convention with @Composable (did not do this before)
    s
    • 2
    • 3
  • i

    Ian Warwick

    03/06/2020, 10:12 AM
    https://medium.com/@fluxtah/jetpack-compose-migrating-from-dev05-to-dev06-3b81d1ea234c?sk=fab1a46d42be83f064c1828c8fb7a51b
    👍 20
    👏 3
    l
    l
    • 3
    • 3
  • a

    aryk

    03/06/2020, 9:47 PM
    How can I draw an image now that DrawImage is gone?
    v
    k
    l
    • 4
    • 6
  • v

    Vinay Gaba

    03/07/2020, 6:45 AM
    Seeing some weirdness when using
    ImagePainter
    to display an image. Code in thread..
    k
    • 2
    • 4
  • i

    itnoles

    03/07/2020, 6:56 AM
    Material Icons Extended going to be sucks for file size.
    l
    • 2
    • 3
  • k

    Klaas Kabini

    03/07/2020, 7:32 AM
    Is this a bug or not. The Box does not produce a circular shape if you do this
    Box(modifier = modifier + ImagePainter(image = image).toModifier(),
                shape = CircleShape,
                border = Border(borderWidth, borderColor))
    v
    • 2
    • 9
  • m

    molikto

    03/07/2020, 9:46 AM
    I am getting a compiler backend exception when compile my code
    kotlin.UninitializedPropertyAccessException was thrown at: org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase.getParent
    . Excepton in thread. Any idea how to fix it ?
    l
    • 2
    • 3
  • a

    aryk

    03/07/2020, 1:04 PM
    Can I pass a class annotated with
    @Model
    into a Composable without having it recompose when something changes?
    a
    • 2
    • 1
  • a

    Andrew Kuryan

    03/07/2020, 1:19 PM
    Hey guys, do we currently have any way to display video with jetpack compose?
    z
    j
    • 3
    • 3
  • k

    Klaas Kabini

    03/08/2020, 8:56 AM
    Can you rotate counter-clockwise using the Canvas provided by compose? With legacy view system a negative rotation angle meant rotating counter-clockwise. I am trying to do the same with compose but no success.
    b
    r
    a
    • 4
    • 5
  • c

    caelum19

    03/08/2020, 8:24 PM
    Hey guys, I'm getting a NoSuchMethodException on any @Preview I attempt to use after upgrading to dev06.
    composeOptions {
            kotlinCompilerExtensionVersion = "0.1.0-dev06"
            kotlinCompilerVersion "1.3.61-dev-withExperimentalGoogleExtensions-20200129"
        }
        buildFeatures {
    //        viewBinding = true
           compose true
        }
    Anyone else experienced this?
    a
    g
    • 3
    • 5
  • g

    gpaligot

    03/09/2020, 5:11 PM
    Hello! Someone know how I can scroll at the end of an AdapterList (or a VerticalScroller if it isn't possible with an AdapterList)?
    r
    • 2
    • 1
  • u

    ursus

    03/10/2020, 3:21 AM
    I wanted to ask folks bit of a OT but related to paradigm shift compose will bring, i.e. immutable models. I like this, but ergonomics are very poor imo, given a nested model like this
    data class State(
        val items: List<Item> = emptyList(),
        ...
    )
    
    sealed class Item
    data class HeaderItem(val titleRes: Int) : Item()
    sealed class ServiceItem : Item() { ..
    data class SimpleItem(..) : ServiceItem
    data class FormItem(val textItems: List<TextItem> = emptyList()) : ServiceItem
    -- lets say now I need to change text item inside a form item with mutable models code is pretty neat in kotlin
    state.items
        .firstOrNull { it is FormItem && item.service.id == serviceId }
        ?.let { it as FormItem }
        ?.textItems
        ?.firstOrNull { it.id == textItemId }
        ?.apply {
            value = text
            validity = FormItem.TextItem.Validity.PENDING
        }
    with immutable obviously you need to create copies
    setState {
        copy(
            items = items.map { item ->
                if (item is FormItem && item.service.id == serviceId) {
                    item.copy(
                        textItems = item.textItems.map {
                            if (it.id == textItemId) {
                                it.copy(value = text, validity = FormItem.TextItem.Validity.PENDING)
                            } else {
                                it
                            }
                        })
                } else {
                    item
                }
            }
        )
    }
    e
    c
    j
    • 4
    • 3
  • u

    ursus

    03/10/2020, 3:22 AM
    tbh thats some BS code -- all the nested copying, or returning identity in map. I must be missing something. So I was wondering, is kotlin missing some sugar for this, or are immutable models at UI level irrelevant if we can enforce only main thread can touch them? Or maybe I think I've read redux/react people denormalize their states?
    ➕ 1
    a
    c
    • 3
    • 24
  • j

    jolo

    03/10/2020, 1:30 PM
    Beta-build does not have Compose support, please download 4.1 Canary 2 instead 🙂
    ➕ 1
    k
    s
    +2
    • 5
    • 5
  • g

    Guy Bieber

    03/10/2020, 1:41 PM
    Jetpack Compose Question: I am trying to get a android.ui.material.button to look pressed. How is that done in compose?
    a
    l
    +2
    • 5
    • 13
  • g

    Guy Bieber

    03/10/2020, 1:41 PM
    Jetpack Compose Question: Is there an easy place to find the modifiers for various widgets?
    a
    • 2
    • 6
  • k

    kyleg

    03/10/2020, 4:17 PM
    I see recommendations for using Compose and things like Room in the same project by isolating Compose to another module. I’m in Android Studio. I create a new module. Is this uspposed to be library module or what? I created Android App module but now can’t get my one module’s Activities to be able to
    import mycomposemodule.testactivity
    . How do I accomplish this? I’m trying to add Compose functionality to an existing application that uses Room and other stuff.
    dev06
    , by the way.
    s
    • 2
    • 1
  • a

    amar_1995

    03/10/2020, 8:08 PM
    How to achieve pull-to-refresh a list view in compose ?
    👍 3
    m
    v
    r
    • 4
    • 9
Powered by Linen
Title
a

amar_1995

03/10/2020, 8:08 PM
How to achieve pull-to-refresh a list view in compose ?
👍 3
m

matvei

03/11/2020, 9:43 PM
Not sure it's possible right now, as AdapterList doesn't expose scroll state. You can certainly achieve this with with Vectical/HorizontalScroller, try it 🙂
v

vipulasri

03/12/2020, 5:14 AM
@matvei but I would like to know how to use it? I mean use it directly in xml? just because
swipe-to-refresh
doesn't support dsl as of now.
m

matvei

03/12/2020, 10:38 AM
Oh sorry, I wan't talking about using existent SwipeToReshesh, I was talking about making your own 🙂
v

vipulasri

03/12/2020, 10:40 AM
Ohh Okay. Got it thanks.
m

matvei

03/12/2020, 10:46 AM
With compose it should be very simple to make a workable version
@Composable
    fun SwipeToRefreshLayout(
        resheshingState: Boolean,
        onRefresh: () -> Unit,
        swipeIcon: @Composable() () -> Unit,
        content: @Composable() () -> Unit
    ) {
        val size = with(DensityAmbient.current) { 100.dp.toPx().value }
        //min is below - to hide
        val min = -size
        val max = size * 2
        StateDraggable(
            state = resheshingState,
            onStateChange = { if (it) onRefresh() },
            anchorsToState = listOf(min to false, max to true),
            animationBuilder = TweenBuilder(),
            dragDirection = DragDirection.Vertical,
            minValue = min,
            maxValue = max
        ) { value ->
            val dpOffset = with(DensityAmbient.current) {
                (value.value * 0.5).px.toDp()
            }
            Stack {
                content()
                Box(LayoutGravity.TopCenter + LayoutOffset(0.dp, dpOffset)) {
                    swipeIcon()
                }
            }
        }
    }
}
👍 2
I made one few month ago just for fun, should still work. You need to copy-paste StateDraggable for now though, as it's not public
v

vipulasri

03/12/2020, 10:47 AM
Thanks @matvei 🤩. Will definitely look into this.
r

Ryan Mentley

03/13/2020, 8:22 AM
It miiiiiiiight work with AdapterList, assuming the nested drag stuff works as intended. I haven't tried it though, currently have more basic things to add support for 😅
View count: 1