Implementing the UI on Android
Before we start, I'd like to emphasize that I had conflicting thoughts when I was writing this chapter (as a matter of fact, the whole example project). I wanted to polish the UI as much as possible, try out the new Android 12 splash screen API, make it edge-to-edge, and so on. But at the same time, I didn't want to introduce things without explicitly talking about them in this book as well, and to do that felt out of scope.
So, consider this as me finding an excuse for why the UI looks so barebone.
Now, let's throw some Jetpack Compose code together and see how consuming the shared code can be presented on an Android UI:
- Let's create a
MainScreen
that will contain our small number of composable components. We'll start by creating theMainScreen
composable:@Composable fun MainScreen(viewModel: MainViewModel) { val state by viewModel.state.collectAsState() val breeds...