Skip to content

Instantly share code, notes, and snippets.

View Debdutta-Panda's full-sized avatar

Debdutta Panda Debdutta-Panda

View GitHub Profile
@Debdutta-Panda
Debdutta-Panda / module_level_build.gradle
Created June 2, 2022 16:26
Dependency for Android Jetpack Compose Navigation
implementation "androidx.navigation:navigation-compose:2.4.2"
@Debdutta-Panda
Debdutta-Panda / project_level_build_gradle
Last active June 2, 2022 16:41
Android Jetpack Compose Version Upgrade
buildscript {
ext {
compose_version = '1.1.1'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
@Debdutta-Panda
Debdutta-Panda / MainActivity.kt
Created June 2, 2022 17:09
Basic Navigation
package com.debduttapanda.powernavigation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.*
import androidx.compose.runtime.Composable
@Debdutta-Panda
Debdutta-Panda / nagigateUp.kt
Created June 2, 2022 17:43
Use navigateUp to go back
@Composable
fun PageB(navController: NavHostController) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
){
Text(
"Page B",
color = Color(0xfff44336),
@Debdutta-Panda
Debdutta-Panda / DelayedAutomaticNavigation.kt
Created June 2, 2022 17:54
Delayed Automatic Navigation
@Composable
fun PageA(navController: NavHostController) {
LaunchedEffect(key1 = Unit){
delay(4000)
navController.navigate("page_b")
}
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
@Debdutta-Panda
Debdutta-Panda / NavigationArgument.kt
Created June 2, 2022 18:51
Pass arguments in jetpack compose navigation
package com.debduttapanda.powernavigation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
@Debdutta-Panda
Debdutta-Panda / OptionalArgument.kt
Created June 2, 2022 19:17
Optional arguments in jetpack compose navigation
package com.debduttapanda.powernavigation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.KeyboardOptions
@Debdutta-Panda
Debdutta-Panda / NavigateForResult.kt
Created June 3, 2022 03:52
Navigate for result
package com.debduttapanda.powernavigation
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
@Debdutta-Panda
Debdutta-Panda / MainActivity.kt
Created June 3, 2022 15:58
Jetpack Compose Navigation with MVVM
package com.debduttapanda.powernavigation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
@Debdutta-Panda
Debdutta-Panda / MainActivity.kt
Created June 3, 2022 19:05
Improved Navigation with MVVM with jetpack compose
package com.debduttapanda.powernavigation
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text