Git Product home page Git Product logo

jetpackcomposemvvm's Introduction

JetpackComposeMVVM

Sample Jetpack compose project with MVVM architecture. Project includes Hilt for dependecy injection and Flow for emit the data and collect on UI.

Jetpack Compose Understandings

  • Jetpack Compose provides a native way to navigate through multiple composable components.
  • With NavHost and NavController, you can push or pop you composables.
  • All those fragment transactions, navigations and intents for activities are handle by Navigation.

NavHost

  • Graphs are wrapped in a single NavHost.
  • It has declaration of the Routes.

navController

  • It is initialized at the root and passed to every graph.
  • It is shared among them.
  • Every screen have access to the navController.
  • It provides API to move around the declared routes.
  • Stack can be viewed as a history of the composables

Frequently used methods are

  • rememberNavController()
  • navController.navigate("SecondScreen")
  • navController.popBackStack()
  • navController.popBackStack(inclusive: false)
    • Inclusive parameter tells us if the targeted composable should be removed too

Video of my work

Nrup_Country.List_video.mp4

Features included in this project are

  • Jetpack Compose
  • MVVM architecture [ model-View-View Model]
  • Hilt for DI
  • Scaffold
  • TopAppBar
  • BottomBar [ NavigationBar ]
  • BottomNavItem
  • Navigation compose
  • Retrofit
  • OkHttp logging
  • Gson converter factory
  • Kotlin Coroutine
  • Flow for emit and collect data
  • Coil for Image loading
  • Swipe Refresh in Home and Detail screen
  • Adaptive Icon : Theme based Icon support
  • Shimmer Effect (Theme based)
  • Network Check
  • Retry functionality
  • App Bar
  • Bottom Navigation Bar

This repository show the List of Country Flags and you can select to know it's name

  • Show circular loader until API response come.
  • Coil lib used to load the image
  • Center crop the image
#1 #2 #3 #4

Internet check and Retry feature

Top App Bar and Bottom Navigation

#1 #2 #3

To support theme based icon (Adaptive Icon) Do below configuration changes.

  • compileSdk 33
  • targetSdk 33
  • Remove android:roundIcon="@mipmap/ic_launcher_round" from AndroidManifest.xml
  • in res->drawable folder add one XML file name like adaptive_icon.xml

Add this line

<monochrome android:drawable="@drawable/adaptive_icon"/>

So, your anydpi-v26/launcher.xml looks like

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@color/ic_launcher_background"/>
    <foreground android:drawable="@drawable/ic_launcher_foreground"/>
    <monochrome android:drawable="@drawable/adaptive_icon"/>
</adaptive-icon>

And make Vector drawable of your app icon with below constraints :

  • Make the canvas 108x108 px

  • Make the App Icon 48x48 px

  • Make sure, icon don't have shadow

  • To generate App icon to SVG (png to svg) use https://svg2vector.com/

  • To create adaptive icon, [48px x 48px] make your app icon black and white and make blank space as a transparent.

  • Use Paint.net software for that. Reference: https://www.getpaint.net/download.html

Reference https://developer.android.com/develop/ui/views/launch/icon_design_adaptive

Link to learn compose step by step

https://developer.android.com/courses/android-basics-compose/course

Other useful links

jetpackcomposemvvm's People

Contributors

nrupparikh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.