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

    Peter Enyedi

    09/23/2022, 10:15 AM
    Hello everyone! I have a navigation related question. My app has a NavDrawer with two screens. All the screens has a TopAppBar. When I'm on there screens, I can use the Drawer and can see the "hamburger menu" on the top left corner. From the first screen, I can navigate to a Details screen, which has the same TopAppBar except the "hamburger menu", instead there is a back arrow. My question is, how can I implement the navigation between the Drawer screens and to the Detials screen?
    • 1
    • 1
  • i

    iroyo

    09/23/2022, 10:21 AM
    Hello people! I have a wrapper around BasicTextField that “autofocus” with a LaunchedEffect. The value of the “input” is held by a VM which could initialize it with “something” received by savedState. (Imagine I open a Search Screen with a already-written text). The problem is the cursor does not position itself at the end of the string.. I’ve tried looking if this could be caused be the launchedEffect being triggered before the initial text is set.. but it doesn’t seem to be the problem.
    @HiltViewModel
    class SearchVM @Inject constructor(
        savedStateHandle: SavedStateHandle
    ) : ViewModel() {
    
        var query by mutableStateOf(savedStateHandle["query"] ?: "")
            private set
    }
    the wrapper of BaseTextField is very simple it only has:
    if (autofocus) {
        LaunchedEffect(Unit) {
            focusRequester.requestFocus()
        }
    }
    z
    • 2
    • 1
  • a

    Asad Mukhtar

    09/23/2022, 11:36 AM
    Hi, Why on MutableLiveData value change Compose didn`t compose the UI?
    a
    c
    • 3
    • 7
  • o

    oday

    09/23/2022, 11:51 AM
    what is the equivalent to this when using composeTestRule?
    onView(
                allOf(
                    withText("Amsterdam"),
                    withId(R.id.name),
                    hasSibling(allOf(withText("The Netherlands"), withId(R.id.country)))
                )
            ).check(matches(isDisplayed()))
    I am trying:
    composeTestRule.onAllNodes(
        withText("Amsterdam"),
        withId(R.id.name),
        hasSibling()
    ).assertAll(isDisplayed())
    but yea it needs a SemanticMatcher, not a Matcher
    • 1
    • 1
  • a

    Aaron Waller

    09/23/2022, 12:38 PM
    Is there a way to put a gradient on the statusbar? Changing color is possible with the accompanist library, but there I can only define one color:
    systemUiController.setSystemBarsColor(
        color = Color.Transparent
    )
    How can I put a gradient?
    s
    a
    c
    • 4
    • 5
  • k

    K Merle

    09/23/2022, 3:31 PM
    Is it possible to remove Vertical padding from OutlinedTextField?
    c
    c
    l
    • 4
    • 6
  • z

    Zach

    09/23/2022, 7:18 PM
    What is the most straight forward way to dismiss the soft keyboard in a compose test?
    • 1
    • 2
  • s

    ste

    09/24/2022, 7:37 AM
    I'm experimenting `ViewModel`s, and I'm creating one by providing a
    key
    (so it does get recreated when the key changes), but it actually gets recreated everytime, even if the key is the same.
    @Composable
    fun OnlineSearchTab(
        textFieldValue: TextFieldValue,
        viewModel: OnlineSearchTabViewModel = viewModel(key = textFieldValue.text)
    )
    What am I missing?
  • s

    Sunil Kumar

    09/24/2022, 2:49 PM
    Hi everyone, did anyone noticed that twitter and google play store app for android has lagging in scrolling(scrolling stucks in between) on their home pages and both of them are using jetpack compose now. So can we say that still jetpack compose is not that performant as android with xml and its not ready for performance intensive production apps?
    j
    s
    +2
    • 5
    • 8
  • b

    Bharath Kandula

    09/24/2022, 4:51 PM
    Hi guys, I want to implement the screen-like screen recording in jetpack compose. Below scrolling only applies to the lazy column lists only.
    Column(
            modifier = Modifier
                .fillMaxWidth()
                .fillMaxHeight()
                .background(BackgroundPrimary)
        ) {
            CustomAppBar() {
                navController.popBackStack()
            }
            Divider(thickness = 1.dp, color = BorderPrimary)
            Spacer(modifier = Modifier.height(Spacing20))
            Column(
                modifier = Modifier.wrapContentHeight().fillMaxWidth()
               
            ) {
                Row(
                    modifier = Modifier
                        .padding(horizontal = 40.dp, vertical = 20.sp)
                        .fillMaxWidth(),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Spacer(modifier = Modifier.width(30.dp))
                    Column {
                        Text(
                            text = viewModel.getSelectedContact().name ?: "",
                            modifier = Modifier.padding(vertical = 2.dp),
                            color = ContentPrimary
                        )
                        Text(
                            text = "${viewModel.getSelectedOperator().name} ${viewModel.getSelectedCircle().name}",
                            color = ContentSecondary
                        )
                        Text(
                            text = viewModel.getSelectedContact().mobileNumber ?: "",
                            color = ContentSecondary
                        )
                    }
                    Spacer(modifier = Modifier.weight(1f))
                    Text(
                        text = "Change",
                        color = ContentBrand,
                        modifier = Modifier.clickable(onClick = {
                            navController.navigate(BillPayNavigationScreens.ConfirmCircleOperator.route)
                        })
                    )
                    Spacer(modifier = Modifier.width(30.dp))
                }
                PreSearchViewForPlanScreen()
             
                val pagerState = rememberPagerState()
    
              
    
                Tabs(tabs = tabs, pagerState = pagerState)
                PlansContentScreen(tabs = tabs, pagerState = pagerState, viewModel,navController)
            }
        }
    
    @Composable
    fun PlansContentScreen(plans: List<PlanInfoData>, navController: NavHostController) {
        LazyColumn(modifier = Modifier.padding(vertical = 10.dp, horizontal = 40.dp).fillMaxHeight()) {
            items(items = plans) { plan ->
                UI(plan, navController)
                Spacer(modifier = Modifier.height(30.dp))
            }
        }
    }
    Can anyone suggest the scrolling approach? The search is sticky and lazy column scroll. Thanks, advance.
    c
    • 2
    • 1
  • b

    Bharath Kandula

    09/24/2022, 4:51 PM
    https://kotlinlang.slack.com/files/U02D9J4M9QD/F043UFLF1QC/record_2022-09-24-18-31-22.mkv.mp4
  • a

    Asad Mukhtar

    09/24/2022, 9:14 PM
    Hi, everyone how you guys handle the preview functions, like I have a function in which I pass the user model to set the values in composable views, and Preview didn`t able to show preview if any parameter without default value added in the function definition, so you guys assign the default UserModel or not?
    j
    • 2
    • 2
  • s

    Starr

    09/24/2022, 9:17 PM
    Is it possible to use Compose in multiplatform
    commonMain
    for all platforms (desktop, web, android)?
    r
    j
    +2
    • 5
    • 9
  • s

    Slackbot

    09/25/2022, 2:52 AM
    This message was deleted.
  • a

    Alexander

    09/25/2022, 11:24 AM
    Hello everyone, I want to warn everyone who wants to use NativeAdView in Compose, now there is a problem with the fact that onAdImpression only fires once on the first ad, and on the rest of the screens the ad is rendered but not taken into account. A little later, we found a workaround for ads to be counted, but later there were problems with the fact that clicks were no longer counted in admob and even cancelled. Therefore, consider this if you are given a similar task.
    r
    n
    • 3
    • 11
  • j

    Ji Sungbin

    09/25/2022, 4:46 PM
    Hi, I’m trying to test the size of Composable. I set the Assertions and
    Modifier.size
    to the same size, but the assertion fails. Am I using the aasertion api wrong?
    @Test
    fun size_is_500_x_500() {
        val size = 500.dp
        testRule.setContent {
            Box(
                modifier = Modifier.size(
                    size = size,
                ),
            )
        }
        testRule
            .onRoot()
            .assertWidthIsEqualTo(
                expectedWidth = size,
            )
            .assertHeightIsEqualTo(
                expectedHeight = size,
            )
    }
    java.lang.AssertionError: Actual width is 392.72726.dp, expected 500.0.dp (tolerance: 0.5.dp)
    z
    • 2
    • 2
  • n

    Napa Ram

    09/26/2022, 8:09 AM
    Hi, i have lazy column inside ModelBottomSheetLayout, and now i am trying to add SwipeRefresh to get latest list of data. Problem: whenever i try to refresh bottom sheet getting close. Any Reference for ModelBottomSheetLayout with SwipeRefresh. Thanks I have added code snippets in the Thread for SwipeRefresh inside BottomSheet. Please Review It.
    j
    c
    +2
    • 5
    • 8
  • h

    Hasan Nagizade

    09/26/2022, 8:15 AM
    java.lang.IllegalArgumentException: Cannot skip the enclosing group while in an empty region what could be the reason of this? I literally have no idea where to look
    a
    • 2
    • 3
  • k

    KotlinLeaner

    09/26/2022, 12:35 PM
    Does anyone know how to ask rational permission in using
    rememberLauncherForActivityResult
    in jetpack compose? I am trying for so long but unable to understand through
    accompanist
    library..
  • l

    Lilly

    09/26/2022, 6:13 PM
    I have noticed that the material design
    banner
    component was never popular in compose. In material design 3 it isn't listed anymore. What would be a replacement for banners, e.g. to notify about bluetooth or wifi being disabled?
    c
    g
    • 3
    • 3
  • m

    MR3Y

    09/26/2022, 8:55 PM
    I think you may take a look at this: https://danielrampelt.com/blog/jetpack-compose-custom-schedule-layout-part-1/
    z
    k
    • 3
    • 2
  • m

    mattinger

    09/26/2022, 11:49 PM
    Does anyone know if Android Studio is going to make the default gradle language be kotlin at any point? It bothers me when i create a compose project (which has to be kotlin anyway, for the most part) that the gradle files are in groovy. Also the fact that it doesn't create a toml file for your dependencies bothers me too. It seems like these should be best practices and AS should get the users moving in that direction.
    g
    k
    +4
    • 7
    • 22
  • z

    Zoltan Demant

    09/27/2022, 4:37 AM
    Ive noticed that
    AnimatedContent
    skips the transition sometimes, despite targetState having changed. Why could that be? Potential bug? Code in 🧵
    o
    d
    • 3
    • 28
  • a

    AmrJyniat

    09/27/2022, 9:58 AM
    Is there a way to update a property item(data class) inside a
    mutableStateListOf
    without creating a new list then assign it to the original
    mutableStateListOf
    ?
    z
    z
    • 3
    • 3
  • k

    KotlinLeaner

    09/27/2022, 11:58 AM
    Hi guys, anyone know why my this function is not doing recomposition after button click.
    z
    a
    • 3
    • 6
  • y

    Young Rock

    09/27/2022, 12:11 PM
    Hey guys, does anyone know how to handle nested swipeable?
    j
    s
    • 3
    • 5
  • e

    elye

    09/27/2022, 1:24 PM
    Hi, Anyone know what's the use of
    ViewRootForInspector
    , and how one can use it?
  • f

    farmerbb

    09/27/2022, 8:44 PM
    Does anyone know how I can get (or calculate) the duration of a
    spring()
    animation? Specifically, one that uses
    Spring.StiffnessMedium
    ?
    s
    a
    • 3
    • 2
  • t

    Travis Griggs

    09/27/2022, 8:53 PM
    Buddy whose helping me port an app to compose claims there's no DateTime Picker for Compose. I looked briefly and did not prove him wrong. And on web searches only found people hacking the pre-compose one in. I looked in Accompanist and didn't see anything. Is it still the case that there is no "integrated" DatedPicker for Compose?
    d
    s
    +2
    • 5
    • 5
  • c

    Chris Fillmore

    09/27/2022, 9:41 PM
    Can I scale something down (using
    graphicsLayer
    or otherwise) and also have it scale down the amount of space it occupies?
    s
    • 2
    • 9
Powered by Linen
Title
c

Chris Fillmore

09/27/2022, 9:41 PM
Can I scale something down (using
graphicsLayer
or otherwise) and also have it scale down the amount of space it occupies?
To be clear I mean, currently I see that adjacent items in the layout still think that its full dimensions, not its scaled down dimensions
s

Stylianos Gakis

09/27/2022, 11:21 PM
Maybe some sort of fillMaxSize while also using the fraction parameter? https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).fillMaxHeight(kotlin.Float) ? Maybe something with weights if you're in a scope where you can do that
And yeah the graphicsLayer scale only affects drawing, not layout.
c

Chris Fillmore

09/27/2022, 11:35 PM
Thanks for responding. I played around a bit more and I think I can get something workable by wrapping it in a Box like:
val width = ...
val height = ...
val scale = ...

Box(
  Modifier
    .size(width = width * scale, height = height * scale)
    .wrapContentSize(unbounded = true)
) {
  Surface(
    Modifier
      .size(width, height)
      .scale(scale)
  ) { ... }
}
s

Stylianos Gakis

09/28/2022, 12:03 AM
Interestingly approach. I do wonder if there's a better alternative, but this looks interesting yeah. Is the unbounded true for the case where scale is <1.0? In which case it'll still draw outside of the size bounds right?
c

Chris Fillmore

09/28/2022, 12:05 AM
Yes it still draws outside, but because the scale e.g.
0.5f
is applied, there’s nothing there
so it looks natural
s

Stylianos Gakis

09/28/2022, 7:35 AM
But it's still possible that if there's something next to the outer box touching it, the two things will draw on each other no?
c

Chris Fillmore

09/28/2022, 2:31 PM
Currently I’m only dealing with scale < 1.0f. It’s possible the behaviour at scale > 1.0f is undesirable, I haven’t tested. Also it’s possible that each use case will need to manage e.g. padding and such, in case the boundaries look bad. I don’t know what will happen here. So far in my use case it looks good, but I can’t say for sure it applies to all use cases generally. If you want to check it out, I extracted a utility:
@Composable
fun ScaledLayout(
  scale: Float,
  width: Dp,
  height: Dp,
  content: @Composable () -> Unit,
) {
  Box(
    modifier = Modifier
      .size(width = width * scale, height = height * scale)
      .wrapContentSize(unbounded = true),
    contentAlignment = Alignment.Center,
  ) {
    content()
  }
}
The
content
still needs to apply the same size and scale on its own, to achieve the right effect. The “ScaledLayout” just provides it a layout container that will fit the provided
scale
.
View count: 8