mcpiroman
11/06/2021, 8:40 PMFlow
.
Yet, official jetpack compose codelab does use it quite extensively (although switches out of it at the end).
If the first line is true, I think this guide should not suggest it at all, maybe just mention it as a possibility.
Even if `LiveData`is as OK as the former options it introduces unnecessary complexity and decision-branches.Android75
11/07/2021, 4:06 AMAmrJyniat
11/07/2021, 9:55 AMIcons.Unspecified
like Color.Unspecified
so if I passed it nothing will show as Icon?Rafiul Islam
11/07/2021, 2:12 PMval activity = LocalContext.current as Activity
But I never found the answer.thelumiereguy
11/07/2021, 4:19 PMAlexander Suraphel
11/07/2021, 4:36 PMinline operator fun <T> State<T>.getValue
defined as inline
?Lilly
11/07/2021, 11:01 PMSnapshotStateMap<String, Any>
. Is it possible to perform a recompose based on the change of a specific key?Pedram Keyani
11/08/2021, 12:24 AMrsktash
11/08/2021, 2:59 AMelse {
Box(Modifier.height(Dp.Hairline))
}
it won't crash.w_bianrytree
11/08/2021, 3:27 AMTim Scheuermann
11/08/2021, 4:32 AMZoltan Demant
11/08/2021, 7:58 AM1.1.0-beta02
? I cant exactly pinpoint what is causing it, but jank seems to build up over time as you use the app when targeting this release (it sounds like a leak, but Ive tested for that thoroughly).Zoltan Demant
11/08/2021, 11:42 AMflow.collectAsState
inside a composable, if the flow I pass in changes, the last value from the old flow seems to be collected again before the new flow kicks off. 🧵👀Rick Regan
11/08/2021, 3:24 PM@Composable
fun Dimensions() {
BoxWithConstraints {
val orientation = if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT) "P" else "L"
println("$orientation: w = $maxWidth, h = $maxHeight")
}
}
I started in portrait orientation and then rotated the device left 8 times (with android:screenOrientation="fullUser"
to allow it to render upside down). There were three unexpected things about the output:
(1) Duplicate messages for a given rotation
(2) Change in orientation is not in sync with the change in dimensions
(3) Incorrect intermediate dimensions
(1) I suppose is just Compose working as advertised (duplicate recompositions), but (2) and (3) I don't understand.
(See 🧵for details.)Joseph Hawkes-Cates
11/08/2021, 7:17 PMkrzysztof
11/08/2021, 9:19 PMSkc
11/08/2021, 11:22 PMFilip Wiesner
11/09/2021, 10:41 AMArpit Shukla
11/09/2021, 11:11 AMC1
which collects an event Flow from a view model. C1
calls another composable C2
passing some data and lambdas. C2
contains a Scaffold.
Now when my ViewModel sends an event of showing a snackbar (after doing some validation when user clicked a button), I want to pass that event to C2
. How can I do this?Mehdi Haghgoo
11/09/2021, 12:53 PMLocalInfo.current.bottomBarItems
as part of my CompositionLocal or should it be BottomBarItems?Arpit Shukla
11/09/2021, 12:58 PMFlow
from one composable to another? (The flow is created and its value is modified outside composition)Mehdi Haghgoo
11/09/2021, 12:59 PMiamthevoid
11/09/2021, 1:38 PMModalBottomSheetLayout
on user action. I have a component in app, that called ActionSheet
and wrap ModalBottomSheetLayout
. It pass ModalBottomSheetState
from outside by composable function params, other params for ModalBottomSheetLayout
assigns under the hood [thread].
Also there is MutableStateFlow
[somewhere in app, doesnt matter], that typed with ActionSheetCommand
type. When user do the action then concrete implementation of ActionSheetCommand
emits through the `MutableStateFlow`[thread]. ActionSheetWrapper
[thread] - another wrapper around ActionSheet
, collect these emits and show `ActionSheet`(ModalBottomSheetLayout
) using state, that initialized in ActionSheetWrapper
.
Somewhy ModalBottomSheetLayout
opens only on first emit. All next emits even not printed inside emit
function of collector. Why can it be? Looks like emit
function in collector somehow deadlock queue and next emits just not pass through MutableStateFlow
.tylerwilson
11/09/2021, 2:23 PMMehdi Haghgoo
11/09/2021, 2:58 PMMehdi Haghgoo
11/09/2021, 3:10 PMArjun Achatz
11/09/2021, 5:19 PMalorma
11/09/2021, 5:55 PMtestTag
as identifiers for composables, as those use String. And as we have it harcoded all around the composables (like Modifier.testTag("RowItem")
) and then use "RowItem"
on tests... with possible issue when renaming one or other...
I've played a bit with it and came up for possible solution on not duplicating the strings...
Would these make sense on compose?Roberto Leinardi
11/09/2021, 8:14 PMScaffoldState
across the entire application (e.g. via singleton in Hilt)?
I have the feeling that would be really bad but I can't think of another way to solve this issue: https://stackoverflow.com/questions/69902988/how-to-show-snackbars-from-composables-or-viewmodels-on-a-multi-module-single-aSteffen Funke
11/09/2021, 9:19 PMBottomSheetDialogFragment
(can’t change that to Compose unfortunately), which contains a LazyColumn
.
I am kind of stuck figuring out, why the scrolling does not work as expected, e.g. why the BottomSheetDialogFragment
intercepts the LazyColumn
scrolling.
Is there any flag / setting / modifier for LazyColumn
regarding nested scrolling, that I am missing?
Expected behaviour would be that I can drag the Sheet down as soon as I have scrolled up completely, but not before. Cannot convert it to a Column
though, since the items need to be lazy loaded.
👉 Video attached in 🧵.
Any ideas welcomed. Thank you!Steffen Funke
11/09/2021, 9:19 PMBottomSheetDialogFragment
(can’t change that to Compose unfortunately), which contains a LazyColumn
.
I am kind of stuck figuring out, why the scrolling does not work as expected, e.g. why the BottomSheetDialogFragment
intercepts the LazyColumn
scrolling.
Is there any flag / setting / modifier for LazyColumn
regarding nested scrolling, that I am missing?
Expected behaviour would be that I can drag the Sheet down as soon as I have scrolled up completely, but not before. Cannot convert it to a Column
though, since the items need to be lazy loaded.
👉 Video attached in 🧵.
Any ideas welcomed. Thank you!Will Shelor
11/10/2021, 3:33 AMclass ComposeBottomSheetDialogFragment(
val sheetContent: @Composable ColumnScope.() -> Unit
) : DialogFragment() {
private var onDismissListener: (() -> Unit)? = null
@OptIn(ExperimentalMaterialApi::class)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View {
super.onCreateView(inflater, container, savedInstanceState)
setStyle(STYLE_NO_FRAME, R.style.FullScreenDialog)
dialog?.let {
val width = ViewGroup.LayoutParams.MATCH_PARENT
val height = ViewGroup.LayoutParams.MATCH_PARENT
it.window?.setLayout(width, height)
it.window?.setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.transparent)))
}
return inflater.inflate(R.layout.fragment_checkout_landing_screen, container, false).apply {
this.findViewById<ComposeView>(R.id.compose_view).apply {
setContent {
// your content
}
}
}
}
override fun getTheme() = R.style.FullScreenDialog
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
onDismissListener?.invoke()
}
fun setOnDismissListener(function: () -> Unit) {
this.onDismissListener = function
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FullScreenDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:padding">0dp</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
</resources>
Steffen Funke
11/10/2021, 5:18 AMisCancelable
in the BottomSheetDialogFragment…. But swipe to dismiss is nice and I would like it to keep, if I can.It was one of my first experiences with Compose.Yeah feels like learning something new everyday again 😆
Will Shelor
11/10/2021, 5:20 AMSteffen Funke
11/10/2021, 5:22 AMLazyColumn
denies scrolling… But I feel I might have to dig deeper there, “halfway there”:
val lazyListState = rememberLazyListState()
val disallow = RequestDisallowInterceptTouchEvent()
LazyColumn(
modifier = Modifier
.pointerInteropFilter(requestDisallowInterceptTouchEvent = disallow, onTouchEvent = {
when(it.action) {
MotionEvent.ACTION_DOWN -> {
disallow(true)
return@pointerInteropFilter true
}
MotionEvent.ACTION_UP -> {
disallow(false)
return@pointerInteropFilter false
}
}
true
})
.fillMaxWidth(),
state = lazyListState
) {
.... items content
We made a custom bottom sheet for just this reason. We copied the base idea of the accompanist bottom sheet scaffold and made our own with some custom behavior.So it keeps being swipe to dismissable? Mind to share some insights in how you tackled the nested scrolling part in the custom behavior? Probably would make a good stackoverlfow answer as well 😄
Will Shelor
11/10/2021, 5:26 AMSteffen Funke
11/10/2021, 5:36 AMThere is a method on View called isNestedScrollingEnabled(), and Compose always returns false,Mind if I ask where you found that call, and that compose returns false? Maybe subclassing
ComposeView
(like with those old ViewPager hacks to allow nested scrolling) would be worth looking into 🤔.RequestDisallowInterceptTouchEvent
could be a lead, but no luck for now. I feel I’ll have to read myself back in touch event internals.Will Shelor
11/10/2021, 7:02 AM