Dekroo
06/30/2025, 8:08 PM@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
content: @Composable() () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> darkScheme
else -> lightScheme
}
MaterialTheme(
colorScheme = colorScheme,
typography = AppTypography,
content = content
)
}
---------------
Text(
text = qrCode,
modifier = modifier,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface
)
Jonathan
06/30/2025, 9:25 PMComposables
inside of a custom Layout {}
?
I would like to animate the relative positions of child Composable
in my custom Scaffold Composable based the offset of an AnchoredDragState
. Essentially, I would like to slide my nav bar “out of the way” when a sibling Composable
is dragged.
I’ve got a POF working using a Box
the Modifier.offset { ... }
on my child Composables
and hardcoded sizes. I would like to be able to wrap this logic up in a custom Layout
and not have to rely on individual offset modifiers and hardcoded sizes. Previously, I tried building this by accessing the offset of a AnchoredDraggableState but dragging became erratic.
If anyone has any experience with this, any advice would be appreciated.Dovydas
07/01/2025, 6:56 AMBox
Background (modifier applied to this)
Content
When I set the background to be a shared element, it renders in the overlay and above the content during the transition. So I also set renderInSharedTransitionScopeOverlay
for the content, but now it loses it's navigation transitions. Therefore after that I also add animateEnterExit
on the content with the same transition. But that modifier has no context about the difference between pop and push transitions, so I lose my seperate pop transitions. And from there I don't know how to proceed further, my full code is in the thread.Tim Karagosian
07/01/2025, 12:43 PMRaymond
07/01/2025, 4:09 PMRaymond
07/01/2025, 4:09 PMmattinger
07/01/2025, 4:28 PMDevices.TABLET
is an error, as it's an older form of specifying the device configuration. AS fixes it by inlining the configuration:
@Preview(device = "spec:width=1280dp,height=800dp,dpi=240")
I can then add things like orientation=portrait
. This is all well and good, but i'd rather use the built in pixel_tablet
spec and have it rotated to portrait mode. However, i can't figure out if there's a way to do that and then apply landscape mode. The documentation on using these new definitions seems a bit scarce where i'm looking (and the autocomplete only shows pixel_5
in the new type of spec)
https://developer.android.com/develop/ui/compose/tooling/previews
Anyone have suggestions as to how to do this without a fully custom device specification, and/or any other documentation i might have missed?Colton Idle
07/02/2025, 12:56 AMMichal Klusák
07/02/2025, 7:29 AMandroid:windowSoftInputMode="adjustResize"
Activity xml:
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<FrameLayout
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Versions:
compose = 1.7.5Jirka Hutárek
07/02/2025, 1:51 PMimport android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Button
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
internal class SampleActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val coroutineScope = rememberCoroutineScope()
var sheetVisible by remember { mutableStateOf(false) }
var dialogVisible by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.fillMaxSize()
) {
Button(
onClick = {
coroutineScope.launch {
sheetVisible = true
delay(500)
dialogVisible = true
}
}
) {
Text("Sheet -> Dialog")
}
Button(
onClick = {
coroutineScope.launch {
dialogVisible = true
delay(500)
sheetVisible = true
}
}
) {
Text("Dialog -> Sheet")
}
}
if (sheetVisible) {
ModalBottomSheet(
onDismissRequest = { sheetVisible = false },
) {
Box(
modifier = Modifier
.background(Color.Yellow)
.fillMaxWidth()
.height(320.dp)
)
}
}
if (dialogVisible) {
Dialog(
onDismissRequest = { dialogVisible = false },
) {
Box(
modifier = Modifier
.background(Color.Cyan)
.size(320.dp, 400.dp)
)
}
}
}
}
}
No matter if I set z-indices on various things, put the modals in boxes, etc., the thing that gets invoked last is the thing that's drawn on top. Is there a way to say have the dialog always on top, no matter if the bottom sheet appears before or after it (except for putting the dialog inside the bottom sheet but that is not my use case)? 🙏אליהו הדס
07/03/2025, 7:31 AMZoltan Demant
07/03/2025, 7:37 AMCheckable(x) { .. }
and that works great.
When I instead have if(x) Checkable(true) { .. } else Checkable(false) { .. }
then the Switch composable differs between the two and jumps between the states instead of animating.
I think I know why - the context in which the switch is rendered differs, both checked & the lambda differs - but how can I fix that?
data class Checkable(
val checked: Boolean,
val enabled: Boolean = true,
val onCheckedChanged: (Boolean) -> Unit,
) : SettingsAction {
override val onClick = {
onCheckedChanged(!checked)
}
@Composable
override fun RowScope.Render() {
Switch(
checked = checked,
enabled = enabled,
onCheckedChanged = onCheckedChanged,
)
}
}
Tower Guidev2
07/03/2025, 8:57 AMandroidx.compose.ui.platform.ComposeView
and androidx.fragment.app.FragmentContainerView
niether of these approaches work
How do i show a compose fragment from within an xml layout?Robert Levonyan
07/03/2025, 10:04 AMdataarg
classes will be available?Pablo
07/03/2025, 2:54 PMval uiState by vm.uiState.collectAsStateWithLifecycle()
and inside that screen I have a composable which iterates one list of elements contained on that uistate:
ListPane(items = uiState.itemsMap,
I want a recomposition if the user changes the order of the map (I have a button for that), but it's a map, and unfortunately if you change the map order, JVM will consider the same instance of the previous unordered map, so recomposition is not dispatched.
But I noticed that if I have a different variable in the uistate, for example, a count which is increased each time the map is ordered... then, suddenly the screen starts recomposing. How it's possible? if I am not reading that count value anywhere, is just stored in the uistate, but is not used or accesed.Ahmed Elkhodery
07/03/2025, 5:52 PM:wasmBrowserDevelopmentRun
to develop on the wasmJS target i'm getting this error:
e: java.lang.IllegalStateException: IC internal error: can not find library org.jetbrains.androidx.graphics:graphics-shapes
i tried to bump compose version to 1.9.0-alpha02
but still didn't solve i'm on kotlin 2.1.21
Pranathi
07/04/2025, 6:36 AMGuyaume Tremblay
07/04/2025, 1:02 PMrememberSaveableWebViewState
from Accompanist but without success. Also, tried using MovableContentOf but had a weird issue where it was trying to compose the webview at both place and crash (doesn't remember well, should probably try again)
My final workaround was to place it in a box next to the navhost and flipping the alpha...
Do you have something better ?Badran
07/04/2025, 1:17 PMReprator
07/04/2025, 6:47 PMdata class LambdaUnStableSample1ContextWrapper(val context: Context) //Unstable due to usage of context
@Composable
private fun LambdaUnStableSample1Outer(
onClick: () -> Unit
) {
println("RecompositionLambdaSampleList LambdaUnStableSample 3: Outer")
Column(
modifier = Modifier
.border(2.dp, getRandomColor())
.padding(10.dp)
) {
Button(onClick = onClick) {
Text(text = "Click")
}
}
}
@Composable
private fun LambdaUnStableSample1() {
var counter by remember {
mutableIntStateOf(0)
}
val contextWrapper = LambdaUnStableSample1ContextWrapper(LocalContext.current)
println("RecompositionLambdaSampleList LambdaUnStableSample 1: root")
Column {
println("RecompositionLambdaSampleList LambdaUnStableSample 2: Column")
LambdaUnStableSample1Outer {
println("RecompositionLambdaSampleList LambdaUnStableSample 4: Outer")
counter++
contextWrapper.context
}
}
}
the output is:
RecompositionLambdaSampleList LambdaUnStableSample 4: Outer
But the output should be or i am expecting is as follows:
RecompositionLambdaSampleList LambdaUnStableSample 4: Outer
RecompositionLambdaSampleList LambdaUnStableSample 1: root
RecompositionLambdaSampleList LambdaUnStableSample 2: Column
RecompositionLambdaSampleList LambdaUnStableSample 3: Outer
As the lambda is unstable due to usage of contextWrapper.context in lambda body,
So can anyone help me to understand, why it is not printing the all, that i am expecting
Or please provide me with a simple example were the composable recompose due to unstable lambda, without any viewmodelIdris Ocasio
07/04/2025, 10:28 PMDave Leeds
07/06/2025, 7:17 PM@Serializable
@JvmInline
value class Id(val value: String)
... as part of a route class like this ...
@Serializable
data class Document(val id: Id)
Then I get an error when trying to navigate with it.
DocumentListScreen(onDocumentClicked = { id -> nav.navigate(Document(id)) })
Here's what the error looks like:
Route Document could not find any NavType for argument id of type Id - typeMap received was {}
I've worked around this by unwrapping the value.
DocumentListScreen(onDocumentClicked = { id -> nav.navigate(Document(id.value)) })
And then reinstantiating the Id
value class on the other side. But I'm wondering whether I'm doing things right. Is there a more appropriate way to make this work? I'd love to keep using value classes for things like this if possible.谢朋刚
07/07/2025, 9:28 AM@Composable Modifier
, composed
factory, and Modifier Node
?
I still don’t quite understand the distinctions among these three, and even feel that their final effects are the same.Jordi Saumell
07/07/2025, 12:14 PM.toggleable(isSelected, Role.switch, onValueChange)
.
The problem is the reading order: it first reads "on/off", then the label text, then "switch", and finally the click action.
I don't see how to change the order: my understanding is that it should read as label - state - "switch" - action.
I have tried many things, even setting it manually (which I don't like, as I want to use the standard state description instead of providing a custom one), and it keeps reading the state first:
Modifier.clearAndSetSemantics {
contentDescription = text
this.role = Role.Switch
this.onClick = onValueChange
stateDescription = if (selected) {
"On"
} else {
"Off"
}
}
mattinger
07/07/2025, 2:46 PM谢朋刚
07/08/2025, 2:25 AM@Composable fun Modifier.floatAction(): Modifier = this.align(Alignment.BottomEnd)
Does it need to be changed to:
@Composable fun BoxScope.floatAction(): Modifier = Modifier.align(Alignment.BottomEnd) // this is wrong
Or use Kotlin's context parameters feature.Sangeet
07/08/2025, 6:28 AMcollectAsStateWithLifecycle
on consumer side and stateIn
in producer side to restrict view getting updates
https://medium.com/androiddevelopers/consuming-flows-safely-in-jetpack-compose-cde014d0d5a3
https://medium.com/androiddevelopers/things-to-know-about-flows-sharein-and-statein-operators-20e6ccb2bc74
.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000L),
null
)
Also there was some suggestion to use it to fetch initial data for a screen rather than using init
or LaunchedEffect(Unit)
as it have its own issue.
One problem which I found was the data will be re-fetched if screen is kept in background for more than 5s which is kind of making bad UX if we don't hold data in repo layer.
Are there any better approach for fetching initial data from compose screens ?Slackbot
07/08/2025, 10:50 AMTower Guidev2
07/08/2025, 2:39 PM2.2.0
and compose bom 2025.06.01
my application has developed an issue where single items within a LazyColumn are not being recomposed e.g. when selected
or selection is toggled, basically any list item that is affected by any user interaction now does not recompose to reflect the user interaction.
when i downgrade kotlin to 2.1.10
the issue does not exist.
why is this?Tapan Desai
07/08/2025, 4:08 PMNavigation3
library right now.
I have come across a scenario where we need to scope a ViewModel
to the previous screen
Current we are using compose-destinations which is built on top of Jetpack Navigation library
We scope a ViewModel
to the previous destination like this. Can this is be achieved in Navigation3
?
@Composable
@Destination(style = DestinationStyleBottomSheet::class)
fun ColumnScope.SalesStaffBottomSheet(
navigator: DestinationsNavigator,
navBackStackEntry: NavBackStackEntry,
navController: NavController,
result: ResultBackNavigator<SalesStaffDetails>,
) {
val backStack = remember(navBackStackEntry) {
navController.getBackStackEntry(AnalyticsMobileDestination.route)
}
val viewModel = hiltViewModel<AnalyticsViewModel>(backStack)
val uiState by viewModel.analyticsUiState.collectAsStateWithLifecycle()
SalesStaffDialogBottomSheet(
uiState = uiState,
onSalesStaffClick = { result.navigateBack(it) },
onCloseClick = { navigator.popBackStack() }
)
}