Nick Navarro

1607483626

Navigation Component with Jetpack Compose

In this video show you how to use Navigation Component with Jetpack Compose. It is very simple to use Navigation Component with Jetpack Compose. In fact, it’s exactly the same. I recommend a single activity architecture with a fragment for each screen in your app. Each fragment should have it’s own viewmodel. That kind of an architecture is perfect for Jetpack Compose and navigation component.

Code: https://bit.ly/39Q7AJb

Subscribe : https://www.youtube.com/channel/UCoNZZLhPuuRteu02rh7bzsw

#jetpack #web-development

What is GEEK

Buddha Community

Navigation Component with Jetpack Compose
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

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

Nick Navarro

1607483626

Navigation Component with Jetpack Compose

In this video show you how to use Navigation Component with Jetpack Compose. It is very simple to use Navigation Component with Jetpack Compose. In fact, it’s exactly the same. I recommend a single activity architecture with a fragment for each screen in your app. Each fragment should have it’s own viewmodel. That kind of an architecture is perfect for Jetpack Compose and navigation component.

Code: https://bit.ly/39Q7AJb

Subscribe : https://www.youtube.com/channel/UCoNZZLhPuuRteu02rh7bzsw

#jetpack #web-development

Walker  Welch

Walker Welch

1614672180

Jetpack Compose: Scrollable Components

In this article, you’ll learn how to create scrollable lists in JetPack Compose. Compose recently moved from the dev to alpha stage, so we’ll be discussing a different implementation than in my previous JetPack Compose articles about lists. Stick to the end to learn about new Compose components.

Introduction

In our usual Android UI design, aka XML layouts, we have widgets like RecyclerView to effectively display large data sets. I would agree that RecyclerView has solved many pain points, but the problem is having so much boilerplate code.

We need to override a bunch of functions —onCreateViewHolderonBindViewHoldergetItemCount, etc. In those functions, we need to write the same template of code all the time. In addition to if you need any extra features, we need to implement them by ourselves. I agree it’s for the best performance, but it’s too much to do.

This is where I think JetPack Compose shines. Building declarative UI keeps the developers’ context to the same programming language (Kotlin) and reduces the boilerplate code.

Scrollable Compose Components

So today’s topic is scrollable components in JetPack Compose. Compose provides a couple of ways to show vertical or horizontal lists.

Note: Jetpack Compose is an actively developing framework. Each day, hundreds of brilliant minds from Google work on it. The code we’re using in this article may change with the updates.

#jetpack-compose #kotlin #mobile #android