If you are working on a mobile app, chances are you need some form of navigation. Getting navigation right isn’t easy with many challenges at hand: back stack handling, lifecycles, state saving and restoration and deep linking are just some of them. In this post, we’ll explore the Navigation component’s support for Jetpack Compose and take a look under the hood!
Before getting started, we’ll add a dependency on
navigation-compose, the Navigation component’s artifact for Compose support.
Let’s jump into the code!
First, we create and memoize a
NavController using the
rememberNavController returns a
Recently, some clients asked us about our opinion on a newly released framework. To get a better idea of it, we ran an internal hack day — here’s how!
Stay tuned for the second part about our experiences with running Jetpack Compose hack day!
Basically, a hack day is a one-day event where you can work on whatever. This is awesome for exploring a new technology or just doing something different once in a while! There are no rules except for that what you’re doing should probably be kinda related to your work, but it doesn’t have to be!
If you haven’t, I recommend reading my other post about LiveData in Repositories.
We recently joined a new project with heavy LiveData usage, everywhere. The search for main thread blockages led us down a rabbit hole of removing a significant portion of our LiveData usages. Here’s how we migrated our Repositories from LiveData.
We were faced with a tough challenge: We had to migrate as quickly and smoothly as possible — there was no time for huge interruptions.
Having all our repositories and lots of helper classes use LiveData, this left us with two options:
We recently joined a new project with heavy
LiveData usage, everywhere. The search for main thread blockages led us down a rabbit hole of removing a significant portion of our
We started off with Repositories, ViewModels and Fragments. The repositories would connect to data sources and expose
LiveData. The ViewModels would then expose the
LiveData to the UI Layer.
Now — there are some issues with this, like the actually unneeded abstraction — but we won’t look at that here. Here’s what a typical Repository would look like:
This post was written for Compose 0.1.0.
Jetpack Compose is Google’s new Android UI Toolkit, currently in development. If you already want to have a look, you can play around with it and learn some exciting new things!
One area where Compose shines is previews. By annotating Composables with
@Preview , you can preview the Composables inside Android Studio.
This is very useful when working with e.g. Design Systems, or you just want to explore different variants of your UI components. But often, your Composables will take parameters, like our
In these cases, you can’t use the…
In our codebase, we use a lot of custom views for reusability — but most of the time, a custom view was overkill. Here’s how we used View Binding to replace some of our custom views.
If you are not familiar with View Binding yet, here is a great post by Sean McQuillan about it. In short: View Binding is a better alternative over Kotlin Synthetics, findViewById and good old Butterknife. It allows you to access the views in a layout in a type-safe and null-safe way.
For each XML layout, View Binding generates a binding object. For a layout…
MotionLayout Alpha 5 introduces touch regions for triggering transitions. This article explores the how and why.
Defining an OnSwipe or OnClick event which triggers the transition is fairly straightforward with just a few attributes being needed:
touchAnchorId: The touch anchor to be used for tracking touches
touchAnchorSide: The side on the touch anchor for touches to be tracked from
dragDirection: The direction to be swiped in
Before Alpha 5, MotionLayout tracked touches on the whole MotionLayout and then used the provided
touchAnchorId to calculate the progress of the transition, based on…
A piece of rather popular advice heard in software development is “favour composition over inheritance”. I won’t go into the details of why as there is an excellent chapter in “Effective Java” about it, as well as this nice article by Eric Lin.
This article explores how class delegation can be useful and how it works under the hood.
In our case, we had a custom view which should expose an interface looking like this:
Now it was time to create the
Of course, we don’t want to start putting logic into our view just for…
Just shy of the holidays, the ConstraintLayout team released a new alpha version of MotionLayout, introducing KeyTriggers (and more). If you haven’t used MotionLayout before, I recommend taking a look at Nicolas Roard series about it. But let’s get started!
Before MotionLayout, to achieve the
FloatingActionButton effect from the above video you most likely used a
CoordinatorLayout with a
MotionLayout makes doing this possible in an easier way requiring less code using
KeyTrigger — so let’s shoot!
KeyTrigger allows you to have MotionLayout call a method on the specified target at a…
I recently gave a talk on Kotlin/JS, what it is and how you can use it at Kotlin User Group Munich.
You can find the recording online: https://twitter.com/KTUGMunich/status/1009489884430491648
As well as the slides: https://speakerdeck.com/jossiwolf/js-kug-munich
If you have any questions, please let me know!