-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efffb2c
commit 7001dbe
Showing
2 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/infomaniak/swisstransfer/ui/components/SinglePaneScaffold.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Infomaniak SwissTransfer - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.swisstransfer.ui.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import com.infomaniak.swisstransfer.ui.theme.Dimens | ||
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme | ||
import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow | ||
import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark | ||
|
||
@Composable | ||
fun SinglePaneScaffold( | ||
topBar: @Composable () -> Unit = {}, | ||
bottomBar: @Composable () -> Unit = {}, | ||
snackbarHost: @Composable () -> Unit = {}, | ||
content: @Composable (PaddingValues) -> Unit, | ||
) { | ||
Scaffold( | ||
topBar = topBar, | ||
bottomBar = bottomBar, | ||
snackbarHost = snackbarHost, | ||
) { contentPadding -> | ||
Box( | ||
contentAlignment = Alignment.TopCenter, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
Box(Modifier.widthIn(max = Dimens.MaxSinglePaneScreenWidth)) { | ||
content(contentPadding) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@PreviewLightAndDark | ||
@PreviewLargeWindow | ||
@Composable | ||
private fun Preview() { | ||
SwissTransferTheme { | ||
Surface { | ||
SinglePaneScaffold { | ||
Box( | ||
Modifier | ||
.fillMaxSize() | ||
.background(Color.Cyan) | ||
) | ||
} | ||
} | ||
} | ||
} |