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

    Isaac Udy

    12/11/2019, 11:27 PM
    I'm working on a routing/navigation library for Jetpack compose (with a particular focus on being capable of supporting multiple modules). I'd like to hear about people's navigation requirements (beyond forward/back/modal presentation), such as a screen presenting another screen within itself, master/detail screens for tablets or larger devices. I would also like to hear suggestions on the API for the library - I've posted a small example of how I think it might work in the thread below.
    m
    • 2
    • 8
  • b

    Bino

    12/12/2019, 10:50 AM
    Is there already any way of custom fonts eg. ttf or otf inside compose? I only found
    fontStyle
    and
    fontFamily
    but can I set a specific font for a fontFamily..?
    s
    • 2
    • 3
  • l

    Luca Nicoletti

    12/13/2019, 10:43 AM
    @Composable fun onDispose(callback: () -> Unit)
    will this accept a
    @Composable
    which actually returns a value now? Something like:
    @Composable fun disposeEverything() : Boolean
    ?
    l
    • 2
    • 2
  • r

    Roar Gronmo

    12/13/2019, 11:08 AM
    I have a hard time understanding
    Column
    ,
    Row
    ,
    modifier=
    and
    Gravity
    Do anyone have reasonable (sane) explanation on how I can achieve following tricky thing (see picture). Here's the code where this layout is built, I want the "5 Center End me!" to be centered vertically (up-down) (as shown), but I can't find any reasonable way to do it in dev03, this was achievable in dev02...
    @Composable
    fun CardGravityTest()
    {
        Card(
                modifier = Spacing(all = 4.dp),
                color = Color.LightGray,
                shape = RoundedCornerShape(
                        5.dp
                )
        ){
            Column {
                Row {
                    Surface(color = Color.Red,
                            modifier = Spacing(all = 4.dp)) {
                        Text(text = "1 XX")
                    }
                    Column(modifier = Flexible(1f) wraps Expanded wraps Spacing(4.dp)){
                        Surface(color = Color.Green){
                            Text(text="2 Flexible wraps Expanded(1f) wraps Spacing(4.dp) x x xx xxx xxxx x xx xxx x xxx")
                        }
                        Surface(color = Color.Magenta){
                            Text(text = "3 Second line xxxxx xxx xx xxxxx xxxx")
                        }
                    }
                    Column() {
                        Surface(color = Color.DarkGray) {
                            Text(text = "4 Column: OK High on top!")
                        }
    
                        Surface(color = Color.Yellow,
                                modifier = Gravity.End){
                            Text(text = "5 Center End me!",
                                    modifier = Gravity.End)
                        }
                    }
                }
    
                Divider()
    
                Row (modifier = Spacing(top = 4.dp)){
                    Column (modifier = Flexible(1f) wraps Expanded){
                        Surface(color = Color.Blue, modifier = Gravity.Start) {
                            Text(text = "6 Row spacing top, Column Flexible(1f) wraps Expanded, Surface gravity start")
                        }
                    }
                    Column(modifier = Flexible(1f) wraps Expanded){
                        Surface(color = Color.Cyan, modifier = Gravity.End) {
                            Text(text = "7 Column Flexible wraps Expanded, Surface gravity end, " +
                                    "paragraphstyle TextAlign.end ", paragraphStyle = ParagraphStyle(textAlign = TextAlign.End))
                        }
                    }
                }
    
                Row {
                    Surface(modifier = Spacing(all = 4.dp), color = Color.White) {
                        Text(text = "8 on Row")
                    }
                    Surface(modifier = Spacing(all = 4.dp), color = Color.Green)
                    {
                        Text(text = "9 on Row")
                    }
                    Column(modifier = Gravity.Center wraps Flexible(1f)){
                        Surface(color = Color.Red) {
                            Text(text = "10 col center flex, line 1")
                        }
                        Surface(color = Color.DarkGray)
                        {
                            Text(text = "11 line 2 xxxxxx")
                        }
                    }
                    Column(modifier = Gravity.Center wraps Expanded) {
                        Surface(color = Color.Magenta, modifier = Gravity.End) {
                            Text(text = "12 col cnt mod end")
                        }
                    }
                }
    
    
            }
        }
    }
    m
    • 2
    • 10
  • z

    Zach Klippenstein (he/him) [MOD]

    12/13/2019, 6:35 PM
    I’m trying to figure out how to use legacy android `View`s from composable functions, using the WebComponent sample here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:ui/ui-android-view/src/main/java/androidx/ui/androidview/WebComponent.kt The integration looks very simple (just call the view as a function), but I can’t do this in my own project and it looks like the sample requires the
    ui-android-view-non-ir
    artifact, which is not published to Maven. Is it actually possible to do this integration with the artifacts that are currently published?
    c
    • 2
    • 2
  • l

    Leland Richardson [G]

    12/13/2019, 6:38 PM
    it’s possible without it, but that artifact does add a lot of “adapters” that would make your life a lot easier
    z
    • 2
    • 14
  • b

    Bryan Lee

    12/13/2019, 6:48 PM
    Maybe a silly question - Is there still a use for Live Data, Data Binding & View Models if using Compose? From my understanding, Compose takes care of observing data with @Model, persisting state across config changes, and there's no more layout for databinding.
    p
    s
    +2
    • 5
    • 5
  • s

    Slackbot

    12/13/2019, 10:00 PM
    This message was deleted.
    r
    b
    j
    • 4
    • 8
  • i

    itnoles

    12/14/2019, 2:56 AM
    Did you rename crossAxisAlignment?
    r
    r
    n
    • 4
    • 3
  • i

    Isaac Udy

    12/14/2019, 5:23 AM
    Is there a way to make a layout stable for state/memo calls, while changing a parent composable? Example:
    @Composable fun Foo(x: Int){
        val bar: @Composable() (@Composable() ()->Unit) -> Unit = if(x == 1) ::BooFar else ::FooBar 
        bar {
           val stable = +memo { UUID.randomUUID().toString() }
           Text(text = stable)
        }
    }
    • 1
    • 1
  • r

    Roar Gronmo

    12/14/2019, 1:38 PM
    In XML it is possible to align neighbouring
    TextView
    on baseline (text baseline
    app:layout_constraintBaseline_toBaselineOf
    ), is/will this be possible in @Compose ?
    :yes: 1
    a
    • 2
    • 1
  • j

    Jon

    12/14/2019, 3:13 PM
    Hi everyone, I did a search but no luck - has anyone integrated a standard MapView with Compose? It seems like it should be easy but I’m just not certain what steps to take. Thanks for any tips/links!
    a
    z
    • 3
    • 4
  • y

    Yang

    12/15/2019, 5:04 AM
    Not sure if it's related to the compiler plugin but is there a known issue with the IR compiler where a Java SAM within a suspend function fails to compile? Java interface:
    public interface JavaInterface {
        // this only happens when the method returns void
        void test();
    }
    class MainActivity : AppCompatActivity() {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            GlobalScope.launch {
                test()
            }
        }
    }
    
    suspend fun test() {
        withContext(Dispatchers.Default) {
            // sam conversion won't compile
            val listener1 = JavaInterface {
                println("")
            }
    
            // this works
            val listener2 = object : JavaInterface {
                override fun test() {
                    println("")
                }
            }
        }
    }
    i
    l
    • 3
    • 4
  • m

    msink

    12/15/2019, 12:08 PM
    Did anyone tried to compile
    compose-runtime
    by Kotlin/Native? I did quick and dirty port, and it more or less works
    🤞 2
    👀 5
    👍 3
    a
    c
    • 3
    • 4
  • b

    Bryan Lee

    12/16/2019, 6:04 PM
    Anyone see what I'm doing incorrectly? I get the following error here
    val icon = +imageResource(R.drawable.ic_my_location_white_24dp)
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference Something to note: Using setViewContent instead of setContent since I'm using a custom map view
    class MainActivity : AppCompatActivity() {
        val mapContext = MapContext()
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setViewContent {
                AppTheme {
                    MapStack(mapContext = mapContext)
                }
            }
        }
    }
    
    @Composable
    fun MapStack(webMap: WebMap = WebMap(), mapContext: MapContext) {
        Stack {
            MapComponent(mapContext = mapContext, map = webMap.map)
    
            aligned(Alignment.BottomRight){
                val icon = +imageResource(R.drawable.ic_my_location_white_24dp)
                FloatingActionButton(
                            icon = icon,
                            modifier = Spacing(left = 8.dp, top = 8.dp, right = 20.dp, bottom = 48.dp)
                    )
            }
        }
    }
    t
    • 2
    • 2
  • z

    Zsolt

    12/16/2019, 6:24 PM
    Is my understanding right that back press handling / back stack functionality is not supported, but is on the roadmap at some point? I'm playing around with something related to this and would be curious what's the official standpoint on this. Thanks!
    w
    • 2
    • 2
  • r

    Roar Gronmo

    12/16/2019, 6:38 PM
    When reading Flutter tutorial I see some resemblence to @Compose, is this because of Material pattern which both use or some other type of cooperation...?
    i
    a
    +2
    • 5
    • 6
  • t

    Timo Drick

    12/17/2019, 1:16 AM
    When i write following class:
    @Model
    Test(var test: String)
    the Compose framework will observe it and recompose the UI when it changes. Can i also observe this class in my custom code outside of a @Composable function?
    👍 1
    a
    a
    • 3
    • 3
  • b

    Bryan Lee

    12/17/2019, 7:33 PM
    Can someone explain to me what this does?
    private fun WebView.setRef(ref: (WebView) -> Unit) {
        ref(this)
    }
    Taken from ui/ui-android-view/src/main/java/androidx/ui/androidview/WebComponent.kt
    l
    z
    l
    • 4
    • 7
  • z

    Zsolt

    12/17/2019, 8:56 PM
    Just noticed that changing a var in a @Model annotated class constructor doesn't trigger recomposition, only if the var is declared in the class body.
    l
    • 2
    • 8
  • b

    Bryan Lee

    12/17/2019, 11:08 PM
    Can I use
    val context = +ambient(ContextAmbient)
    from a composable nested within setViewContent{ }? Currently seem to be getting an NPE because of this. Is there an alternative way of getting context? EDIT: Currently I'm doing this from my activity to get context to a listener into my composable function.
    val context: Context = this
    setViewContent {
            MapApp(context = context)
    }
    l
    • 2
    • 7
  • b

    Bryan Lee

    12/18/2019, 6:28 PM
    Is it possible yet to navigate from a view nested in setViewContent{ } to a view made of Composables? I'm trying to use ComposeView{ }, but I get the error "Composition requires an active composition context"
    • 1
    • 1
  • l

    Leland Richardson [G]

    12/19/2019, 11:12 PM
    how are you going between screens? what are you using for navigation?
    b
    a
    a
    • 4
    • 9
  • c

    codeslubber

    12/19/2019, 11:22 PM
    (the solution in the architecture patterns was not bad: a viewmodel that is retrievable per Activity.. )
    h
    a
    • 3
    • 5
  • m

    Mark Haehnel

    12/20/2019, 9:28 AM
    Has someone figured out a way of back button navigation for compose?
    m
    • 2
    • 1
  • d

    Drew Hamilton

    12/20/2019, 4:29 PM
    I’m struggling to make a “quote indent” component where a bar on the left expands to the full height of X lines of text.
    Like Slack’s.
    This is what I was expecting to work:
    Row {
        ColoredRect(
            color = (+MaterialTheme.colors()).onSurface.copy(alpha = 0.12f),
            width = 4.dp
        )
        Space(Width(8.dp))
        Text(toDo.text)
    }
    But what happens is that the
    ColoredRect
    expands infinitely in height, pushing any elements below the row out of sight. I’m using it as the
    text
    element in an
    AlertDialog
    . What am I doing wrong?
    a
    • 2
    • 4
  • b

    Bryan Lee

    12/20/2019, 10:36 PM
    Trying to pop up an Alert Dialog and getting this error. Anyone come across this? "java.lang.IllegalArgumentException: Constraints should be satisfiable, but minHeight(0.ipx) > maxHeight(-75.ipx)"
    • 1
    • 2
  • r

    Roar Gronmo

    12/21/2019, 7:22 AM
    I see that composable official tutorial still is using dev02, should it be like that ? https://developer.android.com/jetpack/compose/setup
    k
    c
    a
    • 4
    • 7
  • z

    Zsolt

    12/22/2019, 2:41 PM
    Hi, I've been playing around with back navigation + screen history, and managed to create a working solution. Published article with link to GitHub project inside: https://twitter.com/ZsoltKocsi/status/1208753898330247168
    🎉 2
    m
    • 2
    • 1
  • d

    dimsuz

    12/22/2019, 6:28 PM
    Great. Currently I get lost a bit regarding this parts of an API, because currently modifiers seem to do same things as some Composable library widgets do. But I totally get it, experimentation phase and all that :)
    a
    • 2
    • 1
Powered by Linen
Title
d

dimsuz

12/22/2019, 6:28 PM
Great. Currently I get lost a bit regarding this parts of an API, because currently modifiers seem to do same things as some Composable library widgets do. But I totally get it, experimentation phase and all that :)
a

Adam Powell

12/22/2019, 6:40 PM
Yep, we're working out both what the available widget set should be as well as the API layering of conveniences vs. the lower level sources of truth for how things are put together
👍 1
View count: 1