Skip to content

Commit

Permalink
[feat] TopAppBar 공간 확보를 위해 상단 패딩 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns777 committed Mar 31, 2024
1 parent 2bd710a commit b24fc23
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowInsetsCompat
import com.unifest.android.core.designsystem.ComponentPreview
import com.unifest.android.core.designsystem.R
import com.unifest.android.core.designsystem.theme.Title0
Expand All @@ -36,6 +39,10 @@ fun UnifestTopAppBar(
contentColor: Color = Color.Black,
onNavigationClick: () -> Unit = {},
) {
val view = LocalView.current
val insets = with(LocalDensity.current) {
WindowInsetsCompat.toWindowInsetsCompat(view.rootWindowInsets, view).getInsets(WindowInsetsCompat.Type.statusBars()).top.toDp()
}
CompositionLocalProvider(LocalContentColor provides contentColor) {
val icon: @Composable (Modifier, imageVector: ImageVector) -> Unit =
{ modifier, imageVector ->
Expand All @@ -53,6 +60,7 @@ fun UnifestTopAppBar(
modifier = Modifier
.fillMaxWidth()
.background(containerColor)
.padding(top = insets)
.then(modifier),
) {
if (navigationType == TopAppBarNavigationType.Back) {
Expand Down

0 comments on commit b24fc23

Please sign in to comment.