Tag: Jetpack

Unleashing Creativity with Custom Modifiers in Android Jetpack Compose | by Nirbhay Pherwani | Aug, 2023

Example 1 — Gradient Background Modifier Create a custom modifier that applies a gradient background to a composable. This can be used to provide a consistent visual theme across your app’s components. Gradient Background Custom Modifier fun Modifier.gradientBackground(colors: List<Color>): Modifier = composed {drawWithContent {drawRect(brush =…

Seamless Play of D&D — Implementing Drag and Drop Across Multiple Screens in Your Android App with Jetpack Compose | by Nirbhay Pherwani | Aug, 2023

The LongPressDraggable composable function is the foundation of our seamless D&D experience. It allows us to wrap any content (ex. horizontal pager) with dragging behavior, making it draggable upon a long-press gesture. Code @Composablefun LongPressDraggable(modifier: Modifier = Modifier,content: @Composable BoxScope.() -> Unit) {val state =…