1635015720
With this video I'm starting a new tutorial series about Navigation in Jetpack Compose. This first video in this tutorial series will be an introduction video where you will learn some basics, about nav controller, nav host, how to declare destinations in your navigation graph, how to set the default start destinations, how to navigate between different composable screens, how to pop off a back stack when navigating etc. Watch the whole video to learn more about it! :)
⌚Timestamps
0:00 - Introduction
1:46 - Create Screen Composables
4:04 - Screen Holder Class
5:42 - Add Nav Host Controller
6:16 - Add Nav Host
7:36 - Nav Graph and Destinations
9:05 - Navigate to Detail Screen
10:36 - Navigate Back
11:38 - popBackStack()
12:06 - Navigate Back Explicitly & Pop Back stack
13:46 - Conclusion
1593253920
He used Flutter (which is an amazing tool btw for building cross platform apps) — with just one day of work, 1500 lines of code. That’s beyond impressive (specially the fact that Flutter can be hosted on CodePen as well).
So with similar constraints, I wanted to try out Jetpack Compose. I followed the CodePen example (as closely as I could) and this is the result:
Complete source code:
There are three screens in this app
Home Screen
Profile Screen
Compose Screen
Before we get to the screens — take a look at app state model, which will be used for navigation and theming. I also added some helpers for navigating to individual screens & for checking theme.
There are two models — both data classes. The Tweet model is annotated with _@Model _as we update this model from our composed functions to update view state. User stays the same, hence it’s not annotated.
#kotlin #android #jetpack-compose #android-app-development #jetpack
1598743860
State Management in Android is a complex concept and to know the reason you have to first understand the architectural design of Android and to learn why it’s the key requirement to manage state. The Marcelo Benites article Managing State in Android defines the best description of the state:
The state is an object that is connected/subscribed to one or more widgets, contains data, and eager to update the widgets from that data. If there’s any change happens in data, it notifies all widgets to whom it’s connected. The values of the state are changed at runtime.
#jetpack-compose #jetpack #state #android #kotlin
1635015720
With this video I'm starting a new tutorial series about Navigation in Jetpack Compose. This first video in this tutorial series will be an introduction video where you will learn some basics, about nav controller, nav host, how to declare destinations in your navigation graph, how to set the default start destinations, how to navigate between different composable screens, how to pop off a back stack when navigating etc. Watch the whole video to learn more about it! :)
⌚Timestamps
0:00 - Introduction
1:46 - Create Screen Composables
4:04 - Screen Holder Class
5:42 - Add Nav Host Controller
6:16 - Add Nav Host
7:36 - Nav Graph and Destinations
9:05 - Navigate to Detail Screen
10:36 - Navigate Back
11:38 - popBackStack()
12:06 - Navigate Back Explicitly & Pop Back stack
13:46 - Conclusion
1597972500
We all have used fragments in our app and wrote fragment transactions many times according to our needs. So, the navigation component is another way to handle transactions but it provides few other benefits too.
Some of them are:
Okay, now let’s discuss how to integrate it into our app.
First, we’ve to add following dependencies in our app-level build.gradle
file:
def nav_version = "2.3.0"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
The recommended way to navigate between destinations is to use the Safe Args Gradle plugin. This plugin generates simple object and builder classes that enable type-safe navigation and argument passing between destinations. To add Safe Args to our project, include the following classpath in our top-level build.gradle
file:
buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.3.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
Also, add this line to our app or module’s build.gradle
file:
apply plugin: "androidx.navigation.safeargs"
There are three main components that we need to understand:
If you want to avoid implementing it from scratch, Android Studio can help you to start. Just select the navigation template while creating a project or adding a new activity.
#navigation-component #androiddev #android #jetpack-compose #android-app-development
1598923440
Jetpack Compose, the next big change in Android is now in the alpha stage, so this might be the perfect time to start exploring the library and find out how it will help us writing better user interfaces with ease.
Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. — Official Docs.
#android #jetpack-compose #android-app-development #kotlin #androiddev