Skip to content

Commit

Permalink
修复首页在 macos 小屏的 window insets
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Nov 10, 2024
1 parent 8b4b3a7 commit aa89da5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 9 additions & 1 deletion app/shared/src/commonMain/kotlin/ui/main/MainScene.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
Expand Down Expand Up @@ -60,6 +61,7 @@ import me.him188.ani.app.ui.foundation.LocalPlatform
import me.him188.ani.app.ui.foundation.animation.SharedTransitionKeys
import me.him188.ani.app.ui.foundation.ifThen
import me.him188.ani.app.ui.foundation.layout.LocalPlatformWindow
import me.him188.ani.app.ui.foundation.layout.desktopTitleBar
import me.him188.ani.app.ui.foundation.layout.desktopTitleBarPadding
import me.him188.ani.app.ui.foundation.layout.isAtLeastMedium
import me.him188.ani.app.ui.foundation.layout.setRequestFullScreen
Expand Down Expand Up @@ -152,7 +154,13 @@ private fun MainSceneContent(
fadeIn(snap()) togetherWith fadeOut(snap())
},
) { page ->
TabContent(layoutType = navigationLayoutType) {
TabContent(
layoutType = navigationLayoutType,
Modifier.ifThen(navigationLayoutType != NavigationSuiteType.NavigationBar) {
// macos 标题栏只会在 NavigationRail 的区域内, TabContent 区域无需这些 padding.
consumeWindowInsets(WindowInsets.desktopTitleBar())
},
) {
when (page) {
MainScenePage.Exploration -> {
ExplorationPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ object AniWindowInsets {
* 如果 TopAppBar 不会接触窗口左上角, 就使用这个.
*/
@Composable
inline fun forTopAppBarWithoutDesktopTitle() = (WindowInsets.systemBars.union(WindowInsets.displayCutout))
.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) // 要加上 displayCutout 因为刘海可能会挡住横屏状态下的状态栏返回键
inline fun forTopAppBarWithoutDesktopTitle() = forTopAppBar()// 要加上 displayCutout 因为刘海可能会挡住横屏状态下的状态栏返回键

/**
* 包含 macOS 标题栏
Expand Down

0 comments on commit aa89da5

Please sign in to comment.