Difference between Jetpack Compose ModalDrawer and Scaffold Drawer? - android

What exactly is the difference between a ModalDrawer() and Scaffold(DrawerContent)? I seem to recall reading somewhere that the ModalDrawer() incorporates the navigation component. I also think I read that you can't use a ModalDrawer with Scaffold, or that they don't work well together.
When do you want to use one over the other?

Related

Jetpack compose rememberSwipeableState is internal

i want to create a swipable component using jetpack compose and as the document Gestures | JetpackCompose I should use rememberSwipeableState.
but when I want to use it I face this error:
Cannot access 'rememberSwipeableState': it is internal in 'androidx.compose.material3'
what should I do?
This issue is already being tracked here, issue in Material3 Compose. Alternatively as per their recommendation
For the time being, we recommend forking Swipeable if you need it in
M3!
you can use Material2 Compose Swipeable and fork it.

Keyboard navigation in Jetpack Compose

Android usually supports navigation with the tab and enter key as described here.
However, when using Jetpack compose this option seems unavailable. Is this true and if yes I wonder what would be the simplest method to navigate a Jetpack Compose Kotlin App using my keyboard?
maybe use the custom navigation as described here ?
or better implement a whole new navigation method as described here?
Thank you for any help

Can you set up NavController with TopAppBar in Jetpack Compose?

I know with Navigation Component, you can easily set up your toolbar to work with it (https://developer.android.com/guide/navigation/navigation-ui#create_a_toolbar).
You call setupWithNavController and it all magically happens. Then, you get a back arrow whenever you aren't at the start destination.
I am currently working with Jetpack Compose and I'm still new to it. I'm trying to see if navigation component is able to do something similar with the TopAppBar in a Scaffold.
Is there an easy way to set up the nav component with the TopAppBar, or do my navigation icons (back arrows) need to be done manually (call navController.popBackStack as the onClick for these icons)?
In compose, as of compose 1.0.1, at least, you must manually implement it. For a complete understanding, check out this codelab. People are trying to make coding as easy as possible. If it could be automatically done, what you're asking for, it would have been the recommended way in the official codelab, but it isn't. You can file a feature request though.

Shared element transition in Jetpack compose

I wanted to animate my image logo from Screen A to Screen B. In XML based layouts it was possible using windowContentTransitions & transitionName. So I wanted to ask is something similar available in Jetpack Compose?
I have already seen this https://github.com/mobnetic/compose-shared-element
But, Is there something in-built functionality similar to the XML?
Not supported yet by compose. See this conversation on kotlin-lang: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616517641495500?thread_ts=1616516302.494300&cid=CJLTWPH7S

Android Architecture navigation Component with Bottom Navigation?

Now I am wondering which is the most proper way of implementation when want to combine BottomNavigation with the new Android Architecture Navigation Component?
For now found two approaches:
Single Navigation Graph which maintains all BottomNavigation items and which is shown here from Google Codelabs: https://codelabs.developers.google.com/codelabs/android-navigation/#1
Multiple Navigation Graphs where every BottomNavigation item has its own navigation graph which maintains only its behavior and backstack which i shown here: https://proandroiddev.com/mastering-the-bottom-navigation-with-the-new-navigation-architecture-component-cd6a71b266ae
My opinion is that the second one is more clear and understandable, but maybe you have another opinion.
Having separate backstacks or not is a decision based on user experience but if you do want multiple backstacks for bottomnavigation then follow the link for correct approach by androidx developers.
https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSample
I think it depends with the number of nested fragments you will have per each navigation item. The fewer the fragments then i would use the first approach and the more the fragments then i would use the latter approach

Categories

Resources