Exploring Canvas in Jetpack Compose — Crafting Graphics, Animations, and Game Experiences | by Nirbhay Pherwani | Sep, 2023
The Canvas composable isn’t limited to graphics; it’s also used in creating interactive and immersive game experiences directly within your app. Let’s look at a simple game concept — a bouncing ball. Bouncing Ball Game @Composablefun BouncingBallGame() {val position = remember { mutableStateOf(Offset(300f, 0f)) }val…
Getting Better with Kotlin — Exploring Advanced Features and Effective Coding Strategies | by Nirbhay Pherwani | Aug, 2023
1. Inline Classes — Compact Abstractions Example — Inline classes allow us to create lightweight wrappers around primitive types without runtime overhead. Inline Class Example Explanation — In this example, we define an inline class Meter that wraps a Double value. The toCentimeter function showcases…
Why Build a Pattern Library in Jetpack Compose? — Elevating User Experiences in Large-Scale Applications | by Nirbhay Pherwani | Aug, 2023
A pattern library acts as a resource for UI design and development. It comprises reusable UI components and custom styles that ensure a cohesive user experience. Pattern libraries offer several key benefits — Sourced from Dribbble 1. Consistency Across User Experience Regardless of the app’s…
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 =…
Kotlin’s Supercharged Flow API — Combining and Merging Flows for Reactive Programming | by Nirbhay Pherwani | Aug, 2023
.combine is a function provided by Kotlin’s Flow API. It allows us to combine two or more flows into a single flow, emitting values whenever any of the source flows emit a new value. This is useful for scenarios where you want to react to…
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 =…
Seamless Navigation Between Pager and Standalone Composables in Jet Pack Compose | by Nirbhay Pherwani | Jul, 2023
Passport Composable Pager, in the context of Android development, refers to a user interface component that allows users to swipe or scroll through a set of pages or items in a horizontal or vertical manner. It is a common design pattern used to display a…