Skip to content

Commit

Permalink
Rename top app bar TopAppBarMenu into TopAppBarButton
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Aug 21, 2024
1 parent 9b2bb97 commit 91eaf97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewTablet

@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun SwissTransferTobAppBar(@StringRes titleRes: Int, navigationMenu: TopAppBarMenu? = null, vararg actionMenus: TopAppBarMenu) {
fun SwissTransferTobAppBar(
@StringRes titleRes: Int,
navigationMenu: TopAppBarButton? = null,
vararg actionMenus: TopAppBarButton
) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = SwissTransferTheme.materialColors.tertiary,
Expand All @@ -52,24 +56,24 @@ fun SwissTransferTobAppBar(@StringRes titleRes: Int, navigationMenu: TopAppBarMe
}

@Composable
private fun MenuButton(navigationMenu: TopAppBarMenu) {
private fun MenuButton(navigationMenu: TopAppBarButton) {
IconButton(onClick = navigationMenu.onClick) {
Icon(imageVector = navigationMenu.icon, contentDescription = stringResource(navigationMenu.contentDescription))
}
}

@Immutable
data class TopAppBarMenu(
data class TopAppBarButton(
val icon: ImageVector,
@StringRes val contentDescription: Int,
val onClick: () -> Unit,
) {
companion object {
val backButton: (onClick: () -> Unit) -> TopAppBarMenu = {
TopAppBarMenu(AppIcons.ArrowLeft, R.string.contentDescriptionButtonBack, it)
val backButton: (onClick: () -> Unit) -> TopAppBarButton = {
TopAppBarButton(AppIcons.ArrowLeft, R.string.contentDescriptionButtonBack, it)
}
val closeButton: (onClick: () -> Unit) -> TopAppBarMenu = {
TopAppBarMenu(AppIcons.Cross, R.string.contentDescriptionButtonClose, it)
val closeButton: (onClick: () -> Unit) -> TopAppBarButton = {
TopAppBarButton(AppIcons.Cross, R.string.contentDescriptionButtonClose, it)
}
}
}
Expand All @@ -80,10 +84,10 @@ data class TopAppBarMenu(
private fun SwissTransferTobAppBarPreview() {
SwissTransferTheme {
SwissTransferTobAppBar(
R.string.appName,
TopAppBarMenu.backButton {},
TopAppBarMenu(AppIcons.Add, R.string.appName) {},
TopAppBarMenu.closeButton {}
titleRes = R.string.appName,
navigationMenu = TopAppBarButton.backButton {},
TopAppBarButton(AppIcons.Add, R.string.appName) {},
TopAppBarButton.closeButton {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun ImportFilesScreen() {
SwissTransferTobAppBar(
titleRes = R.string.importFilesScreenTitle,
navigationMenu = null,
TopAppBarMenu.closeButton { /*TODO*/ }
TopAppBarButton.closeButton { /*TODO*/ }
)
},
topButton = { modifier ->
Expand Down

0 comments on commit 91eaf97

Please sign in to comment.