-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NavGraph builders for material3 bottom sheet (#198)
- Loading branch information
Showing
8 changed files
with
234 additions
and
35 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
plugins { | ||
id("com.eygraber.conventions-kotlin-multiplatform") | ||
id("com.eygraber.conventions-android-library") | ||
id("com.eygraber.conventions-compose-jetbrains") | ||
id("com.eygraber.conventions-detekt") | ||
id("com.eygraber.conventions-publish-maven-central") | ||
} | ||
|
||
android { | ||
namespace = "com.eygraber.vice.nav.material3" | ||
} | ||
|
||
kotlin { | ||
defaultKmpTargets( | ||
project = project, | ||
) | ||
|
||
sourceSets { | ||
commonMain.dependencies { | ||
api(projects.viceNav) | ||
|
||
api(libs.compose.navigation) | ||
api(libs.compose.navigationMaterial3) | ||
|
||
implementation(compose.material3) | ||
implementation(compose.runtime) | ||
} | ||
} | ||
} |
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,3 @@ | ||
POM_ARTIFACT_ID=vice-nav-material3 | ||
POM_NAME=VICE Nav for compose material3 navigation | ||
POM_DESCRIPTION=A VICE integration with Compose Navigation and material3 ModalBottomSheet |
55 changes: 55 additions & 0 deletions
55
...al3/src/commonMain/kotlin/com/eygraber/vice/nav/material3/ViceMaterial3NavGraphBuilder.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.eygraber.vice.nav.material3 | ||
|
||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.ModalBottomSheetDefaults | ||
import androidx.compose.material3.ModalBottomSheetProperties | ||
import androidx.compose.runtime.remember | ||
import androidx.navigation.NamedNavArgument | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavDeepLink | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavType | ||
import androidx.navigation.toRoute | ||
import com.eygraber.compose.material3.navigation.bottomSheet | ||
import com.eygraber.vice.nav.TypedNavBackStackEntry | ||
import com.eygraber.vice.nav.ViceDestination | ||
import kotlin.jvm.JvmSuppressWildcards | ||
import kotlin.reflect.KType | ||
|
||
@ExperimentalMaterial3Api | ||
public fun NavGraphBuilder.viceBottomSheet( | ||
route: String, | ||
arguments: List<NamedNavArgument> = emptyList(), | ||
deepLinks: List<NavDeepLink> = emptyList(), | ||
modalBottomSheetProperties: ModalBottomSheetProperties = ModalBottomSheetDefaults.properties, | ||
skipPartiallyExpanded: Boolean = false, | ||
destinationFactory: (NavBackStackEntry) -> ViceDestination<*, *, *, *>, | ||
) { | ||
bottomSheet( | ||
route = route, | ||
arguments = arguments, | ||
deepLinks = deepLinks, | ||
modalBottomSheetProperties = modalBottomSheetProperties, | ||
skipPartiallyExpanded = skipPartiallyExpanded, | ||
) { | ||
remember(it.id) { destinationFactory(it) }.Vice() | ||
} | ||
} | ||
|
||
@ExperimentalMaterial3Api | ||
public inline fun <reified T : Any> NavGraphBuilder.viceBottomSheet( | ||
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(), | ||
deepLinks: List<NavDeepLink> = emptyList(), | ||
modalBottomSheetProperties: ModalBottomSheetProperties = ModalBottomSheetDefaults.properties, | ||
skipPartiallyExpanded: Boolean = false, | ||
crossinline destinationFactory: (TypedNavBackStackEntry<T>) -> ViceDestination<*, *, *, *>, | ||
) { | ||
bottomSheet<T>( | ||
typeMap = typeMap, | ||
deepLinks = deepLinks, | ||
modalBottomSheetProperties = modalBottomSheetProperties, | ||
skipPartiallyExpanded = skipPartiallyExpanded, | ||
) { | ||
remember(it.id) { destinationFactory(TypedNavBackStackEntry(it.toRoute<T>(), it)) }.Vice() | ||
} | ||
} |
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