Tag: Pherwani

What can Advanced / Lesser Known Modifiers do for your UI? — A Comprehensive Exploration in Jetpack Compose | by Nirbhay Pherwani | Dec, 2023

.drawWithCache in action Overview Modifier.drawWithCache is a specialized modifier in Jetpack Compose that enhances performance for complex drawing operations. This modifier is particularly useful when you have custom drawing logic that involves calculations or operations that don’t change often. It allows you to cache certain…

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…

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 =…