Jetpack Compose - MotionLayout with scrollableView - android-jetpack-compose

I have a Compose MotionLayout with :
a title at the middle of the screen first
a bellow content which can be a LazyColumn or a Column with verticalScroll()
When I dragUp the content, the title must go to the top of the screen (it works) and the content must remain bellow (it works too).
I use NestedScrollConnection to detect when there is a DragUp on my List and apply it to my swipeableState (swipeableState.performDrag(...)).
The problem is that my LazyColumn/scrollable column scrolls inside itself during the MotionLayout top animation.
I do not remember in XML I had this issue.
How to handle it?

Related

How can I selectively disable android:windowSoftInputMode="adjustResize" from manifest file?

Initially I want to show a composable immediately on top of the Android default keyboard, what slides in if needed on my different screens. Similar like in this example, but I do not want to set WindowCompat.setDecorFitsSystemWindows(window, false), which would be required for this solution.
Therefore, I've set in the manifestv for that Activity:
android:windowSoftInputMode="adjustResize"
And aligned stuff I want to display immediately on top of the keyboard to Alignment.Bottom.
For the very same activity, I also have a use case, where the keyboard slides in, but I do not want to align it on top of the keyboard. it shall remain on the the same position as it was without keyboard.
Can I selectively tell a composable to ignore android:windowSoftInputMode="adjustResize", which was already set for the whole Activity?

Jetpack Compose - Change default Visible % in ModalBottomSheetLayout

I have a ModalBottomSheetLayout with a list of items in my Compose view, which can be showed by some UI interaction.
By default, when bottomSheetState.show() is called, the visible ratio for the BottomSheet is 50%. However, this is not ideal from a UX perspective as the user will have to physically pull up the bottom sheet to see all the contents in the list.
Extremely frustrating is the fact that bottomSheetState.show() does not take in any parameters, and that the 50% value seems to be hard coded in. According to the declaration in androix.compose.material:
suspend fun show() {
val targetValue =
if (isHalfExpandedEnabled) HalfExpanded
else Expanded
animateTo(targetValue = targetValue)
}
I would like to instead show a custom value, say 75%, when the bottom sheet is showed, but so far I haven't found a way to do so. Is there a workaround to this?
I am not sure if you can make it 75% visible but you can show it expanded
bottomSheetState.animateTo(ModalBottomSheetValue.Expanded)

Jetpack Compose BottomSheetScaffold: Smooth closing

I'm using Jetpack Compose with the BottomSheetScaffold. To be able to show and hide the bottom sheet from both within and outside the composable, I used a showBottomSheet: MutableState<Boolean> variable. The peek height within the composable is then determined like this:
val baseBottomSheetPeekHeight by remember { mutableStateOf(60.dp) }
val bottomSheetPeekHeight = if (showBottomSheet.value) baseBottomSheetPeekHeight else 0.dp
Later, in the BottomSheetScaffold, I use the variable like this:
BottomSheetScaffold(
...
sheetPeekHeight = bottomSheetPeekHeight,
...
)
(Full reproducer project here: https://github.com/dbrgn/compose-repro)
This generally works as intended, I can set showBottomSheet.value to false to hide the bottom sheet. However, the hiding looks janky, because not all sub-composables are hidden at the same time.
It's a bit hard to see in the animation above due to the GIF conversion, but when closing the bottom sheet peek pane, the other content (below it) is visible for a short moment, before the bottom sheet disappears.
Is there a way to avoid this janky hiding behavior? Or even better, is there a way to smoothly animate the hiding of the pane?
In my case for Smooth closing BottomSheetScaffold I used to: scaffoldState.bottomSheetState.animateTo(Collapsed, tween(duration))
-- (when duration is any Int you want).
The same for Expanding:
scaffoldState.bottomSheetState.animateTo(Expanded, tween(duration))
If you look at the source code of collapse() or expand() function, you will see there just calling animateTo(Expanded) and animateTo(Collapsed). You can customize animateTo() as you wish.
See animateTo() documentation.

Modal Bottom Sheet in Jetpack Compose for Activity

I have bottom navigation bar. So my composable functions do not take up the full screen size.
When I use ModalBottomSheetLayout, it opens in the composable fun, not in the activity, like when i was using it before when using BottomSheetDialogFragment.
I don't want to write my ModalBottomSheetLayout on the upper level, I think that this is not the right approach.
And i don't want to use the old BottomSheetDialogFragment, since compose is everywhere in a project.

Alignment of the TabBarControls in a TabSet

we're using smartGWT for our web application. An the main page is a tabset that shows different tabs. What I want to do is do a button to the tab set with the setTabBarControls method which then is alligned to the left instead to the right. So it would somewhat look like the current Firefox version.
Is there a possibility to change the allignment of the TabBarControls? I couldn't find any.
If you want to create something like the Firefox corner button, just use TabSet.addChild(). That will place the button at the upper left, and you can use setLeft/setTop to move it elsewhere. If you want the control to appear to the left of the tabs, set a layoutStartMargin on the TabBar to leave space for it.

Resources