Skip to content

Commit

Permalink
feat: AssetDisplayScreen use navigateToDropDown instead of navControl…
Browse files Browse the repository at this point in the history
…ler as parameter
  • Loading branch information
huhx committed Aug 4, 2022
1 parent 3fe27ff commit 9343cd6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +67,7 @@ import kotlinx.coroutines.launch
@Composable
fun AssetDisplayScreen(
viewModel: AssetViewModel,
navController: NavHostController,
navigateToDropDown: (String) -> Unit,
onPicked: (List<AssetInfo>) -> Unit,
onClose: (List<AssetInfo>) -> Unit,
) {
Expand All @@ -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) }
Expand All @@ -100,6 +99,30 @@ fun AssetDisplayScreen(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DisplayTopAppBar(
directory: String,
selectedList: List<AssetInfo>,
navigateUp: (List<AssetInfo>) -> 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,
Expand Down Expand Up @@ -155,30 +178,6 @@ private fun DisplayBottomBar(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DisplayTopAppBar(
directory: String,
selectedList: List<AssetInfo>,
navigateUp: (List<AssetInfo>) -> 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(
Expand Down

0 comments on commit 9343cd6

Please sign in to comment.