-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from hrach/results
Add `results` module
- Loading branch information
Showing
12 changed files
with
282 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 30 additions & 2 deletions
32
demo/src/main/kotlin/dev/hrach/navigation/demo/screens/Home.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,53 @@ | ||
package dev.hrach.navigation.demo.screens | ||
|
||
import android.annotation.SuppressLint | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.material3.OutlinedButton | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.navigation.NavController | ||
import dev.hrach.navigation.demo.Destinations | ||
import dev.hrach.navigation.results.NavigationResultEffect | ||
|
||
@SuppressLint("UnrememberedGetBackStackEntry") | ||
@Composable | ||
internal fun Home( | ||
navController: NavController, | ||
) { | ||
var bottomSheetResult by rememberSaveable { mutableIntStateOf(-1) } | ||
NavigationResultEffect<Destinations.BottomSheet.Result>( | ||
backStackEntry = remember(navController) { navController.getBackStackEntry<Destinations.Home>() }, | ||
navController = navController, | ||
) { result -> | ||
bottomSheetResult = result.id | ||
} | ||
Home( | ||
navigate = navController::navigate, | ||
bottomSheetResult = bottomSheetResult, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun Home( | ||
navigate: (Any) -> Unit, | ||
bottomSheetResult: Int, | ||
) { | ||
Column { | ||
Text("Home") | ||
|
||
OutlinedButton(onClick = { navController.navigate(Destinations.Modal1) }) { | ||
OutlinedButton(onClick = { navigate(Destinations.Modal1) }) { | ||
Text("Modal 1") | ||
} | ||
|
||
OutlinedButton(onClick = { navController.navigate(Destinations.BottomSheet) }) { | ||
OutlinedButton(onClick = { navigate(Destinations.BottomSheet) }) { | ||
Text("BottomSheet") | ||
} | ||
|
||
Text("BottomSheetResult: $bottomSheetResult") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("org.jetbrains.kotlin.plugin.compose") | ||
id("org.jetbrains.kotlinx.binary-compatibility-validator") | ||
id("com.vanniktech.maven.publish") | ||
id("com.gradleup.nmcp") | ||
id("org.jmailen.kotlinter") | ||
} | ||
|
||
version = property("VERSION_NAME") as String | ||
|
||
android { | ||
namespace = "dev.hrach.navigation.results" | ||
|
||
compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
||
defaultConfig { | ||
minSdk = libs.versions.minSdk.get().toInt() | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
buildConfig = false | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
freeCompilerArgs = freeCompilerArgs.toMutableList().apply { | ||
add("-Xexplicit-api=strict") | ||
}.toList() | ||
} | ||
|
||
lint { | ||
disable.add("GradleDependency") | ||
abortOnError = true | ||
warningsAsErrors = true | ||
} | ||
} | ||
|
||
nmcp { | ||
publishAllPublications {} | ||
} | ||
|
||
kotlinter { | ||
reporters = arrayOf("json") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.navigation.compose) | ||
implementation(libs.kotlin.serialization.json) | ||
implementation(libs.androidx.lifecycle.runtime) | ||
testImplementation(libs.junit) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_ARTIFACT_ID=results | ||
POM_NAME=Navigation Results sharing | ||
POM_DESCRIPTION=Results sharing between screens API for Jetpack Navigation Compose | ||
POM_PACKAGING=aar |
Oops, something went wrong.