Rak
01/19/2022, 4:20 PMDialogFragment
?Brian Donovan
01/19/2022, 4:25 PMTolriq
01/19/2022, 5:34 PMColton Idle
01/19/2022, 6:03 PMremember {}
a when statement?
I'm trying something like this
remember{
when (someValue) {
optionA -> {
doSomething()
but I get an error of "remember calls must not return Unit"rsktash
01/19/2022, 6:22 PMHuan
01/19/2022, 6:41 PMSealed class
, when
and flow
with LazyColumn
🧵brabo-hi
01/19/2022, 7:47 PMNavHost
?Simon Stahl
01/19/2022, 8:01 PMManojna Chintapalli
01/19/2022, 8:07 PMdrawerContent
in the Scaffold
of BottomSheetScaffold
and the bottomsheet is always displayed at the bottom partially(acc. to the designs). My issue is that when I open Side Nav drawer the bottomsheet is covering some contents of the Nav drawer at the bottom. I am able to collapse the bottomsheet all the way to the bottom when Side Nav is opened by using DisposableEffect
but is there any other way to achieve this without the brute force method?
if (drawerScaffoldState.drawerState.currentValue != DrawerValue.Closed) {
DisposableEffect(Unit) {
onDispose {
// do soemthing
}
}
}
elye
01/19/2022, 8:16 PMThis function has a reified type parameter and thus can only be inlined at compilation time, not called directly
@Composable
fun Launcher() {
val context = LocalContext.current
LazyColumn(modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally) {
item {
context.StartActivityButton<LaunchedEffectActivity>()
}
}
}
@Composable
private inline fun <reified T : Activity>Context.StartActivityButton() {
Button(onClick = {
startActivity(Intent(this, T::class.java))
}) {
Text(T::class.toString())
}
}
More info here https://stackoverflow.com/q/70768211/3286489natario1
01/19/2022, 8:34 PMclickable(enabled=false, onClick=...)
? This used to work.elye
01/19/2022, 8:48 PMderiveStateOf
not able to work together with snapshotFlow
in aiding recomposition? Separate them out seems working, but not together. The code example in https://stackoverflow.com/q/70771821/3286489Colton Idle
01/19/2022, 10:03 PMbottomSheet(route = Screen.DebugBottomSheet.route) {
DebugBottomSheet(previousScreenVM = hiltViewModel(remember { navController.previousBackStackEntry!! }))
}
my bottomsheet
@Composable
fun DebugBottomSheet(
viewModel: DebugBottomSheetViewModel = hiltViewModel(),
previousScreenVM: ViewModel,
) {}
Error: java.lang.RuntimeException: Cannot create an instance of class androidx.lifecycle.ViewModel
Altynbek Nurtaza
01/19/2022, 10:06 PMjustinbis
01/19/2022, 11:37 PMbrabo-hi
01/20/2022, 2:01 AMnavController.popBackStack()
and navController.navigateUp()
Moritz Post
01/20/2022, 11:52 AMCanvas
composable in my compose desktop app. I have found that the Canvas.onDraw
method is called multiple times although the size of the canvas has not canged. This leads to jank since the drawing is quite intensive. Next to the canvas i have a couple of items that are clickable() so they show hoover feedback for the mouse cursor. Even just hoovering over these unrelated items triggers a redraw of the canvas. Is there a way to circumvent this redrawing?Asif
01/20/2022, 12:07 PMGerardo Ernesto Rodriguez Navar
01/20/2022, 2:38 PMViktor Petrovski
01/20/2022, 2:57 PMBrian Donovan
01/20/2022, 3:10 PMZoltan Demant
01/20/2022, 4:42 PMTopaz Centuallas
01/20/2022, 5:59 PMInk
01/20/2022, 7:25 PMLaura Kelly
01/20/2022, 9:48 PMBox(
modifier = modifier
.triStateCheckbox(…)
.requiredSize(…)
.border(…)
.background(…)
.semantics {
error("Error invalid input")
}
) {
MyIcon(
contentDescription = null,
modifier = Modifier.clearAndSetSemantics {}
)
}
I set some breakpoints and SemanticsPropertyReceiver.error
is being set correctly, but setContentInvalid
in AndroidComposeViewAccessibilityDelegateCompat
is not.
I tried removing the inner icon since it’s altering its semantics but that doesn’t seem to change anything.
I’m trying to figure out if I am doing something wrong in using .semantics
or if there might be bug here.tad
01/20/2022, 11:35 PMChris Fillmore
01/21/2022, 12:01 AMStateFlow<Boolean>
? Even if there are many such components in a list? (dozens? hundreds?)Colton Idle
01/21/2022, 4:50 AMSideEffect{}
is triggered on a successful composition. Let's say all I'm doing is incrementing a variable in that block. What if I wanted to increment on every composition (successful and "failed"). Is there any sideEffect type block for that? Or would I just put that in my composable without any sideeffect-esque {} and that basically counts as failed + successful compositions?Colton Idle
01/21/2022, 7:23 AMclass ScreenViewState {
val list = mutableStateListOf<Item>()
and my Item
class ConcreteType(override val type: String = "") : Item {
var something by mutableStateOf("beep")
then in my VM I call
(myItem as ConcreteType).something = "boop"
My composable always beeps, but never boops.MRSasko
01/21/2022, 7:45 AMMRSasko
01/21/2022, 7:45 AMrattleshirt
01/21/2022, 8:07 AMval state by rememberSaveable(key = "mapState") {
mutableStateOf(Bundle())
}
and pass it to onCreate:
Lifecycle.Event.ON_CREATE -> mapView.onCreate(state)
otherwise you are always creating a new bundle and losing its stateColton Idle
01/21/2022, 8:07 AMMRSasko
01/21/2022, 8:24 AM@Composable
fun rememberMapViewWithLifecycle(): MapView {
val context = LocalContext.current
val mapView = remember {
MapView(context).apply {
id = R.id.map
}
}
// Makes MapView follow the lifecycle of this composable
val bundle = Bundle()
val lifecycleObserver = rememberMapLifecycleObserver(mapView, bundle)
val lifecycle = LocalLifecycleOwner.current.lifecycle
DisposableEffect(lifecycle) {
lifecycle.addObserver(lifecycleObserver)
onDispose {
lifecycle.removeObserver(lifecycleObserver)
}
}
return mapView
}
@Composable
private fun rememberMapLifecycleObserver(mapView: MapView, bundle: Bundle): LifecycleEventObserver =
remember(mapView) {
LifecycleEventObserver { _, event ->
when (event) {
Lifecycle.Event.ON_CREATE -> mapView.onCreate(bundle)
Lifecycle.Event.ON_START -> mapView.onStart()
Lifecycle.Event.ON_RESUME -> mapView.onResume()
Lifecycle.Event.ON_PAUSE -> mapView.onPause()
Lifecycle.Event.ON_STOP -> mapView.onStop()
Lifecycle.Event.ON_DESTROY -> mapView.onDestroy()
else -> throw IllegalStateException()
}
}
}