Kirk  Keeling

Kirk Keeling

1635015720

Navigation Basics - Jetpack Compose

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

#jetpack #kotlin #android

What is GEEK

Buddha Community

Navigation Basics - Jetpack Compose
Autumn  Blick

Autumn Blick

1593253920

Jetpack Compose: Twitter UI

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:

The App

There are three screens in this app

Home Screen

Profile Screen

Compose Screen

App State

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.

Models

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

Jeromy  Lowe

Jeromy Lowe

1598743860

JetPack Compose 🏹 — State Management

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

Kirk  Keeling

Kirk Keeling

1635015720

Navigation Basics - Jetpack Compose

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

#jetpack #kotlin #android

Chaz  Homenick

Chaz Homenick

1597972500

Understanding the Basics of Navigation Component

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:

  • Handling back action correctly by default
  • Default standard animations and transitions while switching between fragments
  • Passing data between fragments (this is also my favorite).

Okay, now let’s discuss how to integrate it into our app.

First, we’ve to add following dependencies in our app-level build.gradlefile:

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:

  1. Navigation Graph(nav_graph.xml): It contains all the navigation-related information like the start destination fragment, paths, etc.
  2. NavHost: A container that displays those destinations defined in nav_grap.xml file.
  3. NavController: It manages the swapping of fragments within a NavHost.

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

Aurelie  Block

Aurelie Block

1598923440

Exploring Jetpack Compose: The Basics

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.

Benefits of Using Compose

  • Jetpack compose eliminates us writing long XML files. The same UI can be created with less amount of declarative code.
  • Jetpack compose automatically handles the change in UI state when the data in the app changes.
  • It is compatible with the existing code in our app. You can easily migrate to compose.
  • It has built in support for material design, animations, dark theme etc.
  • It has direct access to the Android platform APIs.

#android #jetpack-compose #android-app-development #kotlin #androiddev