Skip to content

Commit

Permalink
chore: Move the TopAppBar to the MainScreen to temporary fix an anima…
Browse files Browse the repository at this point in the history
…tion issue
  • Loading branch information
tevincent committed Dec 4, 2024
1 parent 61bda97 commit 2b6ed3c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun SwissTransferTopAppBar(
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun SwissTransferTopAppBar(
title: String,
title: String = "",
navigationMenu: TopAppBarButton? = null,
vararg actionMenus: TopAppBarButton,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ fun MainNavHost(
withFileSize = false,
withSpaceLeft = false,
withFileDelete = false,
onCloseClicked = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import androidx.compose.runtime.remember
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.infomaniak.swisstransfer.ui.components.BrandTopAppBar
import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar
import com.infomaniak.swisstransfer.ui.components.TopAppBarButton
import com.infomaniak.swisstransfer.ui.navigation.MainNavigation
import com.infomaniak.swisstransfer.ui.navigation.NavigationDestination.Companion.toDestination
import com.infomaniak.swisstransfer.ui.screen.main.components.MainScaffold
Expand All @@ -43,7 +45,17 @@ fun MainScreen() {
MainScaffold(
navController = navController,
currentDestination = currentDestination,
largeWindowTopAppBar = { BrandTopAppBar() },
largeWindowTopAppBar = {
// This is temporary to fix an issue with the animation when displaying the FilesDetailsScreen
if (currentDestination is MainNavigation.FilesDetailsDestination) {
SwissTransferTopAppBar(
navigationMenu = TopAppBarButton.backButton { navController.popBackStack() },
actionMenus = arrayOf(TopAppBarButton.closeButton { }),
)
} else {
BrandTopAppBar()
}
},
content = { MainNavHost(navController, currentDestination) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ fun MainScaffold(
content: @Composable () -> Unit = {},
) {
val navType by rememberNavType(currentDestination)
val topAppBar = if (navType != NavigationSuiteType.None) largeWindowTopAppBar else {
{}
}

MainScaffold(
navType = navType,
currentDestination = currentDestination,
navigateToSelectedItem = navController::navigateToSelectedItem,
largeWindowTopAppBar = topAppBar,
largeWindowTopAppBar = largeWindowTopAppBar,
content = content
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
withFileSize = true,
withSpaceLeft = true,
withFileDelete = true,
onCloseClicked = {},
navigateBack = { navController.popBackStack() },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fun FilesDetailsScreen(
withFileSize: Boolean,
withSpaceLeft: Boolean,
withFileDelete: Boolean,
onCloseClicked: (() -> Unit),
navigateBack: (() -> Unit),
) {
// If we don't have a folderUuid, it means we have to load files from importedFiles in ImportFilesViewModel
Expand All @@ -60,8 +59,6 @@ fun FilesDetailsScreen(
withFileSize = withFileSize,
withSpaceLeft = withSpaceLeft,
onFileRemoved = getOnFileRemoveCallback(importFilesViewModel, withFileDelete),
onCloseClicked = onCloseClicked,
navigateBack = navigateBack,
)
}
}
Expand All @@ -77,21 +74,13 @@ private fun getOnFileRemoveCallback(

@Composable
private fun FilesDetailsScreen(
title: String = "",
files: List<FileUi>,
navigateToDetails: (String) -> Unit,
withFileSize: Boolean,
withSpaceLeft: Boolean,
onFileRemoved: ((uuid: String) -> Unit)? = null,
onCloseClicked: (() -> Unit),
navigateBack: (() -> Unit),
) {
Column {
SwissTransferTopAppBar(
title = title,
navigationMenu = TopAppBarButton.backButton { navigateBack() },
TopAppBarButton.closeButton { onCloseClicked() },
)

FilesSize(files, withFileSize = withFileSize, withSpaceLeft)
FileItemList(
Expand All @@ -116,14 +105,11 @@ private fun FilesDetailsScreenPreview(@PreviewParameter(FileUiListPreviewParamet
SwissTransferTheme {
Surface {
FilesDetailsScreen(
title = "Title",
files = files,
navigateToDetails = { _ -> },
withFileSize = true,
withSpaceLeft = true,
onCloseClicked = {},
onFileRemoved = {},
navigateBack = {},
)
}
}
Expand Down

0 comments on commit 2b6ed3c

Please sign in to comment.