2024-07-15 19:52:29 +08:00
|
|
|
package com.aiosman.riderpro
|
|
|
|
|
|
2024-07-15 20:21:03 +08:00
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
2024-07-15 19:52:29 +08:00
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.ColumnScope
|
2024-07-16 10:48:45 +08:00
|
|
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
2024-07-15 19:52:29 +08:00
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.WindowInsets
|
2024-07-16 10:48:45 +08:00
|
|
|
import androidx.compose.foundation.layout.areNavigationBarsVisible
|
2024-07-15 19:52:29 +08:00
|
|
|
import androidx.compose.foundation.layout.asPaddingValues
|
2024-07-16 10:48:45 +08:00
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
2024-07-15 20:21:03 +08:00
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
2024-07-15 19:52:29 +08:00
|
|
|
import androidx.compose.foundation.layout.height
|
2024-07-16 10:48:45 +08:00
|
|
|
import androidx.compose.foundation.layout.navigationBars
|
2024-07-15 19:52:29 +08:00
|
|
|
import androidx.compose.foundation.layout.systemBars
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
2024-07-16 10:48:45 +08:00
|
|
|
import androidx.compose.ui.unit.dp
|
2024-07-15 19:52:29 +08:00
|
|
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun StatusBarMask(darkIcons: Boolean = true) {
|
|
|
|
|
val paddingValues = WindowInsets.systemBars.asPaddingValues()
|
|
|
|
|
val systemUiController = rememberSystemUiController()
|
|
|
|
|
LaunchedEffect(Unit) {
|
|
|
|
|
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = darkIcons)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Spacer(modifier = Modifier.height(paddingValues.calculateTopPadding()))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun StatusBarMaskLayout(
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
|
darkIcons: Boolean = true,
|
2024-07-15 20:21:03 +08:00
|
|
|
maskBoxBackgroundColor: Color = Color.Transparent,
|
2024-07-15 19:52:29 +08:00
|
|
|
content: @Composable ColumnScope.() -> Unit
|
|
|
|
|
) {
|
|
|
|
|
val paddingValues = WindowInsets.systemBars.asPaddingValues()
|
|
|
|
|
val systemUiController = rememberSystemUiController()
|
2024-07-16 10:48:45 +08:00
|
|
|
val navigationBarPaddings =
|
|
|
|
|
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
|
2024-07-15 19:52:29 +08:00
|
|
|
LaunchedEffect(Unit) {
|
|
|
|
|
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = darkIcons)
|
|
|
|
|
}
|
|
|
|
|
Column(
|
2024-07-16 10:48:45 +08:00
|
|
|
modifier = modifier.fillMaxSize()
|
2024-07-15 19:52:29 +08:00
|
|
|
) {
|
2024-07-15 20:21:03 +08:00
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.height(paddingValues.calculateTopPadding())
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.background(maskBoxBackgroundColor)
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
}
|
2024-07-15 19:52:29 +08:00
|
|
|
content()
|
2024-07-16 16:09:11 +08:00
|
|
|
if (navigationBarPaddings > 24.dp) {
|
|
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.height(navigationBarPaddings).fillMaxWidth().background(Color.White)
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-07-15 19:52:29 +08:00
|
|
|
}
|
|
|
|
|
}
|