https://kotlinlang.org logo
Docs
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

    Bruno_

    11/05/2019, 7:15 PM
    is there any way to to load a file other than
    startActivityForResult
    ? technically I could make everything that I need global, but it would cause spaghetti code
    b
    m
    +2
    • 5
    • 13
  • n

    nglauber

    11/06/2019, 1:01 AM
    Any suggestion for async image loading? In other words: do we have Glide/Fresco/Picasso for Compose? 🙂
    a
    l
    +2
    • 5
    • 25
  • k

    Karthick

    11/06/2019, 4:17 AM
    What is effect in compose
    l
    • 2
    • 3
  • a

    amar_1995

    11/06/2019, 6:39 AM
    I am new in android development. Can anybody explain with effect the impact of column vs flexcolumn, row vs flexRow, flexible vs inflexible. I am not able to understand when to use what.
    l
    a
    • 3
    • 4
  • a

    andrew

    11/07/2019, 12:21 AM
    Flutter web has very shitty performance last I saw. I hope they can clean it up
    a
    • 2
    • 1
  • j

    joeykaan

    11/07/2019, 7:24 AM
    Perhaps I've missed it somewhere but how would I go about getting involved in the development of Compose? Is it (easily) possible for someone from outside? 🙂
    k
    l
    a
    • 4
    • 7
  • a

    amar_1995

    11/07/2019, 7:37 AM
    I am trying to use floatingActionButton and try to add icon which is in a vector.xml. But there is only image and or shape and nothing for vectorImage. Is there any way to do that.
    Column(modifier = ExpandedHeight, crossAxisAlignment = CrossAxisAlignment.End, mainAxisAlignment = MainAxisAlignment.End ) {
            Column(modifier = Spacing(16.dp)) {
                val icon = +imageResource(R.drawable.add)
                FloatingActionButton(icon = icon, color = Color.Red, elevation = 8.dp)
            }
        }
    Also tried using +vectorResource(R.drawable.add) as Image
    k
    n
    • 3
    • 5
  • j

    Jakub Valigura

    11/07/2019, 9:47 AM
    I am trying to show a Compose Dialog on Button click in a Fragment which uses XML resource as a View. When I call openDialog(…) I get the following exception java.lang.IllegalStateException: Composition requires an active composition context. Is it even possible to mix XML and Compsoe together or was it not implemented yet? Thanks! 🙂
    l
    r
    • 3
    • 5
  • a

    amar_1995

    11/07/2019, 10:32 AM
    I made a composable function which accept
    context
    as input parameter while calling from
    setContent
    . How to use the same function calling from
    @Preview
    function
    class MainActivity : AppCompatActivity() {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContent {
               MainScreen(applicationContext)
            }
        }
    }
    
    @Composable
    fun MainScreen(context: Context) { ...}
    
    @Preview
    @Composable
    fun testPreview() {
        MainScreen( needToGetContextHere )
    }
    As in preview function we cannot pass any parameter. Is there any other approach to preview this ?? I think of one solution is to make
    context
    global. Is there any other better approach ??
    a
    a
    • 3
    • 4
  • a

    Antanas A.

    11/08/2019, 2:09 PM
    Hi everybody, I have a philosophical question on how would you design your system if it would be large enterprise data entry system (suppose legacy desktop application) with many dialogs, forms, listgrids, etc. which must support keyboard only navigation (without using mouse) - keyboard shortcuts, proper keyboard focus (navigating thru components on screen). I know that Compose currently is suitable for Android, but looking into far future lets suppose that it supports now browsers and desktops. As I understood Compose is just a View layer, kind of MVI architecture, model passes information into "Composable function" and you get visual GUI which return back intents/events/etc. How keyboard focus and navigation should be implemented? Does Compose emits some kind of "focused element" event? Or even how to render GUI component with specific Input field focused? If Compose is just "state renderer" so everything must be embedded into parameters (disabled/enabled field, focused/notfocused field). How about dialogs? How dialogs should be encoded? And how to handle navigation if there is some two or more non modal dialogs on screen. Going further it seems that these questions not directly relates to Compose, but should be separate library framework which handles and implements all GUI logic and then uses Compose to render it. Do these kind of libraries already exists? Maybe some of current GUI frameworks can be used, but looks like everything is tightly integrated with its own GUI rendering engine and cannot be used separately. I know that this all Compose stuff is state of art and no best practices currently exists, but what are your thoughts of how this could be implemented in "Compose" way?
    l
    k
    +2
    • 5
    • 38
  • c

    codeslubber

    11/08/2019, 3:41 PM
    The SwiftUI Tutorial has a section where they wrap their paging component and then use it from SwiftUI, each ‘view’ in the sequence is then declarative and the coordinator logic is bolted on. I want to do the equivalent in Compose. Is there a way to integrate Compose code with just standard View components? and/or an example of doing this? It would seem that the whole idea of a framework entitled Compose would be to demonstrate the creation of components that are made up of other components (like a ViewPager2).
    l
    l
    • 3
    • 38
  • z

    zak.taccardi

    11/09/2019, 9:20 PM
    Has the possibility of concurrent mode been discussed? React has started implementing it, and it looks interesting https://reactjs.org/docs/concurrent-mode-intro.html
    c
    j
    • 3
    • 5
  • a

    Ahmed Elhanafy

    11/09/2019, 11:06 PM
    Hello folks, Is there a way to load images from the network?
    m
    • 2
    • 1
  • m

    Muh Rahmatullah

    11/10/2019, 6:37 AM
    Hi all, I am new to jetpack-compose, I have a simple question about the framework, what is the differences between
    compose
    ,
    anko
    &
    litho
    ? thanks!
    b
    p
    • 3
    • 4
  • e

    eneim

    11/11/2019, 4:17 AM
    Hi, Would like to ask if Video playback is available in Compose yet?
    g
    • 2
    • 1
  • a

    amar_1995

    11/11/2019, 6:53 AM
    I am trying to view a list of item. From mainActivity class, I am passing arrayList of item to composable function. But while running the app, I am getting this error
    java.lang.RuntimeException: Unable to start activity ComponentInfo{<http://package.name/package.name.MainActivity|package.name/package.name.MainActivity>}: java.lang.IllegalStateException: Composition requires an active composition context
    l
    • 2
    • 13
  • a

    amar_1995

    11/11/2019, 10:41 AM
    I am using Android Canary 4 for android development using compose. I want to know is there any issue with compose or canary editor as it cannot able show preview window even after cleaning and rebuilding an app. I also noticed that even after adding file inside
    resources
    folder, editor shows error that file doesn't exists.
    l
    c
    +2
    • 5
    • 17
  • c

    Carlos Muñoz

    11/11/2019, 10:55 AM
    Hello everyone! Seeking for some validation / feedback on the following idea that becomes possible thanks to Compose (took some ideas from the official sample): - Single activity, single viewmodel that just receives actions from screen components: https://github.com/carlosmuvi/notes-compose/blob/master/app/src/main/java/com/carlosmuvi/notes/RootViewModel.kt - View model just contains Action handlers, passed down to the screen @Composable: https://github.com/carlosmuvi/notes-compose/blob/master/app/src/main/java/com/carlosmuvi/notes/home/HomeActionHandler.kt - Action + currentState = new State. Handled in reducers: https://github.com/carlosmuvi/notes-compose/blob/master/app/src/main/java/com/carlosmuvi/notes/home/HomeReducer.kt - A parent state to handle the current screen: https://github.com/carlosmuvi/notes-compose/blob/master/app/src/main/java/com/carlosmuvi/notes/AppState.kt - One state object per screen, allowing feature modularization: https://github.com/carlosmuvi/notes-compose/blob/master/app/src/main/java/com/carlosmuvi/notes/home/HomeScreen.kt Some open questions: - Where to notify when a "screen is created" to trigger initialization? - Is it the ViewModel really necessary here, since the state objects could keep the state themselves? - In general, do you see this navigation pattern scalable?
    r
    • 2
    • 4
  • b

    Bruno_

    11/11/2019, 2:17 PM
    any way to get a View instance in compose? I'd like to do this https://developer.android.com/training/snackbar/showing
    k
    l
    • 3
    • 2
  • z

    Zach Klippenstein (he/him) [MOD]

    11/11/2019, 8:28 PM
    Is there anyway to write to/read from the saved instance state from a Compose function - like some kind of ambient or something that provides hooks for that?
    👍 1
    r
    a
    • 3
    • 6
  • a

    amar_1995

    11/12/2019, 9:26 AM
    I want to add two action icon with label and navigationIcon on
    topAppBar
    I wrote this sample code
    TopAppBar(
                    title = { Text(text = "Sample App") },
                    navigationIcon = {
                        SimpleImageButton(R.drawable.hamburger) {
                            openDrawer()
                        }
                    },
                    actionData = listOf(+imageResource(R.drawable.search),+imageResource(R.drawable.img_translate))
    
                ) {
                    AppBarIcon(icon = it, onClick = { Toast.makeText(context, "Clicked ", Toast.LENGTH_SHORT).show()})
                }
    I do have list of two action item, now how to decide which action icon is clicked ? Is there is any way to check image type inside
    if-else
    or
    when
    statement.
    z
    • 2
    • 3
  • n

    Ngenge Senior

    11/12/2019, 10:48 AM
    Just wondering how I can add a ScrollView to this composable function since in landscape mode, all the views are not visible
    @Composable
    fun MaterialCard() {
    
        val image = +imageResource(R.drawable.photographer)
        Card(shape = RoundedCornerShape(size = 8.dp)) {
        Column(modifier = Spacing(16.dp)) {
            SimpleImage(image = image)
            Text("A day in Shark Fin Cove",style = (+themeTextStyle { h6 }).withOpacity(.6f))
            Text("Davenport, California",style = (+themeTextStyle { body2 }).withOpacity(.87f))
            Text("December, 2018",style = (+themeTextStyle { body2 }).withOpacity(0.6f))
            
            Row() {
                Button(text = "Got it",style = ContainedButtonStyle(rippleColor = Color.Green))
                Button(text = "Cancel",style = TextButtonStyle())
                
            }
            
            
        }
        }
    }
    l
    a
    • 3
    • 6
  • a

    amar_1995

    11/13/2019, 9:27 AM
    Can we use
    setContentView
    which is responsible to load xml layout and
    setContent
    in single activity class ?
    l
    m
    a
    • 4
    • 17
  • a

    amar_1995

    11/13/2019, 12:41 PM
    I am using simple
    TextField
    to get userInput. But I am not able to write anything in
    TextFeild
    @Composable
    fun EditTextView(text: String) {
        val textState = +state{ text }
        Padding(left = 8.dp, top = 8.dp, right = 8.dp) {
            Surface(
                color = Color.Gray,
                shape = RoundedCornerShape(8.dp)
            ) {
                Padding(padding = 5.dp) {
                    TextField(value = textState.value,
                        onValueChange = { textState.value = it })
                }
                
            }
        }
    }
    b
    a
    m
    • 4
    • 18
  • u

    ursus

    11/14/2019, 3:37 AM
    Has someone talked about how animations will work? Is it going to be TransitionManager automatic type of stuff?
    l
    m
    z
    • 4
    • 7
  • b

    Balakrishna Sangem

    11/14/2019, 3:35 PM
    Has someone tried nested
    VerticalScroller
    , Is it a lot laggy.
    b
    • 2
    • 4
  • a

    amar_1995

    11/15/2019, 7:04 AM
    There is
    setViewContent
    which accept composable function as input parameter similar to
    setContent
    . So I want know what is a diference between
    setViewContent
    and
    setContent
    and its use-cases. And my second question is that
    setContent
    and
    setViewContent
    both return
    CompositionContext?
    . So what is the usage of CompositionContext ?
    l
    • 2
    • 1
  • k

    kioba

    11/15/2019, 1:43 PM
    @Leland Richardson [G] you can’t just drop bombs like these and move on 😄! What changes are in the queue? Are they in the repository already? https://twitter.com/intelligibabble/status/1195081633172320256?s=20
    🎉 26
    l
    a
    +2
    • 5
    • 14
  • s

    Steve

    11/15/2019, 6:21 PM
    Is Compose something that we can contribute to as well?
    k
    • 2
    • 1
  • s

    spierce7

    11/15/2019, 7:11 PM
    Flutter maintains 3 trees - Widgets, Elements, and Render Objects. The user only sees Widgets though unless they are going lower-level. I’m curious if compose maintains several trees as well. Does it?
    l
    a
    • 3
    • 3
Powered by Linen
Title
s

spierce7

11/15/2019, 7:11 PM
Flutter maintains 3 trees - Widgets, Elements, and Render Objects. The user only sees Widgets though unless they are going lower-level. I’m curious if compose maintains several trees as well. Does it?
l

Leland Richardson [G]

11/15/2019, 7:28 PM
At the moment, no. Compose UI forms a single tree of ComponentNodes. That said, we have explored this type of architecture a bit but decided not to go down this route, though may revisit at a later date.
a

Adam Powell

11/15/2019, 9:36 PM
if you're looking for a (very) rough equivalence mapping, the call graph in compose serves the purpose of flutter's widget tree, the slot table serves the purpose of the element tree, and the ComponentNode tree serves the purpose of the renderobject tree.
👍 1
❤️ 1
👌 2
so different constructs accomplishing similar tasks
View count: 3