1 /* <lambda>null2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.accompanist.navigation.material 18 19 import android.annotation.SuppressLint 20 import androidx.compose.foundation.layout.ColumnScope 21 import androidx.compose.runtime.Composable 22 import androidx.navigation.NamedNavArgument 23 import androidx.navigation.NavBackStackEntry 24 import androidx.navigation.NavDeepLink 25 import androidx.navigation.NavGraphBuilder 26 import androidx.navigation.get 27 28 /** 29 * Add the [content] [Composable] as bottom sheet content to the [NavGraphBuilder] 30 * 31 * @param route route for the destination 32 * @param arguments list of arguments to associate with destination 33 * @param deepLinks list of deep links to associate with the destinations 34 * @param content the sheet content at the given destination 35 */ 36 @SuppressLint("NewApi") // b/187418647 37 @ExperimentalMaterialNavigationApi 38 public fun NavGraphBuilder.bottomSheet( 39 route: String, 40 arguments: List<NamedNavArgument> = emptyList(), 41 deepLinks: List<NavDeepLink> = emptyList(), 42 content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit 43 ) { 44 addDestination( 45 BottomSheetNavigator.Destination( 46 provider[BottomSheetNavigator::class], 47 content 48 ).apply { 49 this.route = route 50 arguments.forEach { (argumentName, argument) -> 51 addArgument(argumentName, argument) 52 } 53 deepLinks.forEach { deepLink -> 54 addDeepLink(deepLink) 55 } 56 } 57 ) 58 } 59