diff --git a/compose_image_picker/src/main/java/com/huhx/picker/data/AssetRoute.kt b/compose_image_picker/src/main/java/com/huhx/picker/data/AssetRoute.kt index e5c27f6..11886bc 100644 --- a/compose_image_picker/src/main/java/com/huhx/picker/data/AssetRoute.kt +++ b/compose_image_picker/src/main/java/com/huhx/picker/data/AssetRoute.kt @@ -27,7 +27,7 @@ fun AssetPickerRoute( composable("asset_display") { AssetDisplayScreen( viewModel = viewModel, - navController = navController, + navigateToDropDown = { navController.navigate("asset_selector?directory=$it") }, onPicked = onPicked, onClose = onClose, ) diff --git a/compose_image_picker/src/main/java/com/huhx/picker/view/AssetDisplayScreen.kt b/compose_image_picker/src/main/java/com/huhx/picker/view/AssetDisplayScreen.kt index 10455f5..5324d7c 100644 --- a/compose_image_picker/src/main/java/com/huhx/picker/view/AssetDisplayScreen.kt +++ b/compose_image_picker/src/main/java/com/huhx/picker/view/AssetDisplayScreen.kt @@ -50,7 +50,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController import coil.compose.AsyncImage import coil.decode.VideoFrameDecoder import coil.request.ImageRequest @@ -68,7 +67,7 @@ import kotlinx.coroutines.launch @Composable fun AssetDisplayScreen( viewModel: AssetViewModel, - navController: NavHostController, + navigateToDropDown: (String) -> Unit, onPicked: (List) -> Unit, onClose: (List) -> Unit, ) { @@ -79,7 +78,7 @@ fun AssetDisplayScreen( directory = directory, selectedList = viewModel.selectedList, navigateUp = onClose, - navigateToDropDown = { navController.navigate("asset_selector?directory=$directory") } + navigateToDropDown = navigateToDropDown ) }, bottomBar = { DisplayBottomBar(viewModel, onPicked) } @@ -100,6 +99,30 @@ fun AssetDisplayScreen( } } +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun DisplayTopAppBar( + directory: String, + selectedList: List, + navigateUp: (List) -> Unit, + navigateToDropDown: (String) -> Unit, +) { + CenterAlignedTopAppBar( + modifier = Modifier.statusBarsPadding(), + navigationIcon = { + IconButton(onClick = { navigateUp(selectedList) }) { + Icon(Icons.Filled.Close, contentDescription = "") + } + }, + title = { + Row(modifier = Modifier.clickable { navigateToDropDown(directory) }) { + Text(directory, fontSize = 18.sp) + Icon(Icons.Default.KeyboardArrowDown, contentDescription = "") + } + }, + ) +} + @Composable private fun DisplayBottomBar( viewModel: AssetViewModel, @@ -155,30 +178,6 @@ private fun DisplayBottomBar( } } -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun DisplayTopAppBar( - directory: String, - selectedList: List, - navigateUp: (List) -> Unit, - navigateToDropDown: () -> Unit, -) { - CenterAlignedTopAppBar( - modifier = Modifier.statusBarsPadding(), - navigationIcon = { - IconButton(onClick = { navigateUp(selectedList) }) { - Icon(Icons.Filled.Close, contentDescription = "") - } - }, - title = { - Row(modifier = Modifier.clickable { navigateToDropDown() }) { - Text(directory, fontSize = 18.sp) - Icon(Icons.Default.KeyboardArrowDown, contentDescription = "") - } - }, - ) -} - @OptIn(ExperimentalPagerApi::class) @Composable private fun AssetTab(