Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this blog, we are going to learn about gestures in Jetpack Compose. Jetpack compose is a modern toolkit for building native UI. Compose provides a variety of APIs to help you detect gestures that are generated from user interaction. Swipe to dismiss is a single composable function to delete the item from the list and many other functionalities to perform an action like archive the product, move to cart and add to wishlist, etc.
Swipe to dismiss composable function direct offered by the material theme in android.
First of all, we make a UI on which we have to apply gestures. I have created a card view that has some admin details like names and messages. this card is a swipeable view that we can swipe to right or left.
This is the single Composble function to use swipe any view and perform an action in Compose.
State-> state in this composable is performing a vital role. we write our logic inside lambda for the confirmStateChange parameter of the rememberDismissState method.
Modifier-> An ordered, immutable collection of modifier elements that decorate or add behavior to Compose UI elements. For example, backgrounds, padding and click event listeners decorate or add behavior to rows, text, or buttons.
modifier elements
DissmissContent-> That is the place used for the content UI to be visible in the dismiss function.
Background-> That’s the surface is used to background a particular item. Generally, you might add color, icon, text, etc on to indicate to item swipe.
In this code, we make an admin card swipeable to right or left. when cards swipe on the right side they are move-in archive, and the cards swipe on the left side are deleted.
DismissDirection used to card move on different sides. according to directions, we change the color of the card.
In this preview, you have seen the card move to the right side and the background color is green, which also indicates a text message move to archive.at the same preview on the move item on the left side but the background color changes to red and also indicates a message move to bin/delete.
In this blog, we have learned about the Gesture in jetpack compose. we have learned how to implementation of the Swipe to Dismiss Ui create and perform the action in Android.
For more information regarding the compose gesture in the android visit the link.
Thanks for reading this blog. You can also check other blogs from here.
Always be ready for learning 🙂
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.