Skip to content

Commit

Permalink
Update the responsive scaffold menu item arrangement behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinto committed Aug 15, 2024
1 parent 881a098 commit 5f76676
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun ResponsiveAppBarScaffold(
TopAppBar(
title = appBarTitle,
actions = {
actions(Arrangement.Start)
actions(Arrangement.Reverse)
},
scrollBehavior = scrollBehavior
)
Expand All @@ -57,7 +57,7 @@ fun ResponsiveAppBarScaffold(
if (sizeClass.widthSizeClass != WindowWidthSizeClass.Expanded) {
BottomAppBar(
actions = {
actions(Arrangement.Reverse)
actions(Arrangement.Start)
},
floatingActionButton = floatingActionButton
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,52 +69,6 @@ fun HomeScaffold(
horizontalArrangement = arrangement,
verticalAlignment = Alignment.CenterVertically,
) {
var isSortVisible by remember { mutableStateOf(false) }
IconButton(onClick = {
isSortVisible = true
}) {
Icon(
painter = painterResource(R.drawable.ic_sort),
contentDescription = null
)
DropdownMenu(
expanded = isSortVisible,
onDismissRequest = {
isSortVisible = false
}
) {
SortSetting.entries.forEach {
DropdownMenuItem(
onClick = {
isSortVisible = false
onActiveSortChange(it)
},
text = {
val resource = remember(it) {
when (it) {
SortSetting.DateAsc -> R.string.home_sort_date_ascending
SortSetting.DateDesc -> R.string.home_sort_date_descending
SortSetting.LabelAsc -> R.string.home_sort_label_ascending
SortSetting.LabelDesc -> R.string.home_sort_label_descending
SortSetting.IssuerAsc -> R.string.home_sort_issuer_ascending
SortSetting.IssuerDesc -> R.string.home_sort_issuer_descending
}
}
Text(stringResource(resource))
},
trailingIcon = {
if (activeSortSetting == it) {
Icon(
painter = painterResource(R.drawable.ic_check),
contentDescription = null
)
}
}
)
}
}
}

var isMoreActionsVisible by remember { mutableStateOf(false) }
IconButton(onClick = {
isMoreActionsVisible = true
Expand Down Expand Up @@ -161,6 +115,53 @@ fun HomeScaffold(
)
}
}

var isSortVisible by remember { mutableStateOf(false) }
IconButton(onClick = {
isSortVisible = true
}) {
Icon(
painter = painterResource(R.drawable.ic_sort),
contentDescription = null
)
DropdownMenu(
expanded = isSortVisible,
onDismissRequest = {
isSortVisible = false
}
) {
SortSetting.entries.forEach {
DropdownMenuItem(
onClick = {
isSortVisible = false
onActiveSortChange(it)
},
text = {
val resource = remember(it) {
when (it) {
SortSetting.DateAsc -> R.string.home_sort_date_ascending
SortSetting.DateDesc -> R.string.home_sort_date_descending
SortSetting.LabelAsc -> R.string.home_sort_label_ascending
SortSetting.LabelDesc -> R.string.home_sort_label_descending
SortSetting.IssuerAsc -> R.string.home_sort_issuer_ascending
SortSetting.IssuerDesc -> R.string.home_sort_issuer_descending
}
}
Text(stringResource(resource))
},
trailingIcon = {
if (activeSortSetting == it) {
Icon(
painter = painterResource(R.drawable.ic_check),
contentDescription = null
)
}
}
)
}
}
}

}
}
}
Expand Down

0 comments on commit 5f76676

Please sign in to comment.