All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.eygraber.vice.nav.material3.ViceMaterial3NavGraphBuilder.kt Maven / Gradle / Ivy

There is a newer version: 0.9.7
Show newest version
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 = emptyList(),
  deepLinks: List = 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  NavGraphBuilder.viceBottomSheet(
  typeMap: Map> = emptyMap(),
  deepLinks: List = emptyList(),
  modalBottomSheetProperties: ModalBottomSheetProperties = ModalBottomSheetDefaults.properties,
  skipPartiallyExpanded: Boolean = false,
  crossinline destinationFactory: (TypedNavBackStackEntry) -> ViceDestination<*, *, *, *>,
) {
  bottomSheet(
    typeMap = typeMap,
    deepLinks = deepLinks,
    modalBottomSheetProperties = modalBottomSheetProperties,
    skipPartiallyExpanded = skipPartiallyExpanded,
  ) {
    remember(it.id) { destinationFactory(TypedNavBackStackEntry(it.toRoute(), it)) }.Vice()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy