From 9de0f930686c39b7a1a832c52bb8757dab9034bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=8B=E7=9B=B4=E6=81=90=E6=83=A7=E7=97=87?= <65274728+NieR4ever@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=20NavigationRail=20=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E4=B9=9F=20WindowDraggable=20(#997)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commonMain/kotlin/ui/main/HomeScene.kt | 115 +++++++++--------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/app/shared/src/commonMain/kotlin/ui/main/HomeScene.kt b/app/shared/src/commonMain/kotlin/ui/main/HomeScene.kt index 504965337b..53dfc9462e 100644 --- a/app/shared/src/commonMain/kotlin/ui/main/HomeScene.kt +++ b/app/shared/src/commonMain/kotlin/ui/main/HomeScene.kt @@ -73,6 +73,7 @@ import me.him188.ani.app.ui.cache.CacheManagementViewModel import me.him188.ani.app.ui.external.placeholder.placeholder import me.him188.ani.app.ui.foundation.LocalPlatform import me.him188.ani.app.ui.foundation.avatar.AvatarImage +import me.him188.ani.app.ui.foundation.interaction.WindowDragArea import me.him188.ani.app.ui.foundation.layout.LocalPlatformWindow import me.him188.ani.app.ui.foundation.layout.isWidthAtLeastMedium import me.him188.ani.app.ui.foundation.layout.setRequestFullScreen @@ -187,66 +188,68 @@ private fun HomeSceneLandscape( }, ) { Row(modifier.background(AniThemeDefaults.navigationContainerColor)) { - // NavigationRail 宽度至少为 80.dp, 没有 horizontal padding - NavigationRail( - Modifier.fillMaxHeight(), - header = { UserAvatarInNavigation() }, - windowInsets = windowInsets.only(WindowInsetsSides.Vertical + WindowInsetsSides.Start) - .add(WindowInsets(top = 16.dp)), // 稍微多一点好看点 - containerColor = AniThemeDefaults.navigationContainerColor, - contentColor = contentColorFor(AniThemeDefaults.navigationContainerColor), - ) { - Column( - Modifier - .padding(bottom = 16.dp) - .fillMaxHeight(), - verticalArrangement = Arrangement.spacedBy(16.dp), + WindowDragArea { + // NavigationRail 宽度至少为 80.dp, 没有 horizontal padding + NavigationRail( + Modifier.fillMaxHeight(), + header = { UserAvatarInNavigation() }, + windowInsets = windowInsets.only(WindowInsetsSides.Vertical + WindowInsetsSides.Start) + .add(WindowInsets(top = 16.dp)), // 稍微多一点好看点 + containerColor = AniThemeDefaults.navigationContainerColor, + contentColor = contentColorFor(AniThemeDefaults.navigationContainerColor), ) { - NavigationRailItem( - pagerState.currentPage == 0, - onClick = { - uiScope.launch { - pagerState.scrollToPage(0) - } - }, - icon = { Icon(Icons.Rounded.TravelExplore, null) }, - label = { Text(text = "找番") }, - ) - NavigationRailItem( - pagerState.currentPage == 1, - onClick = { - uiScope.launch { - pagerState.scrollToPage(1) - } - }, - icon = { Icon(Icons.Rounded.Star, null) }, - label = { Text(text = "追番") }, - ) - NavigationRailItem( - pagerState.currentPage == 2, - onClick = { - uiScope.launch { - pagerState.scrollToPage(2) - } - }, - icon = { Icon(Icons.Rounded.DownloadDone, null) }, - label = { Text(text = "缓存") }, - ) + Column( + Modifier + .padding(bottom = 16.dp) + .fillMaxHeight(), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + NavigationRailItem( + pagerState.currentPage == 0, + onClick = { + uiScope.launch { + pagerState.scrollToPage(0) + } + }, + icon = { Icon(Icons.Rounded.TravelExplore, null) }, + label = { Text(text = "找番") }, + ) + NavigationRailItem( + pagerState.currentPage == 1, + onClick = { + uiScope.launch { + pagerState.scrollToPage(1) + } + }, + icon = { Icon(Icons.Rounded.Star, null) }, + label = { Text(text = "追番") }, + ) + NavigationRailItem( + pagerState.currentPage == 2, + onClick = { + uiScope.launch { + pagerState.scrollToPage(2) + } + }, + icon = { Icon(Icons.Rounded.DownloadDone, null) }, + label = { Text(text = "缓存") }, + ) - UpdateCheckerItem() + UpdateCheckerItem() - Spacer(Modifier.weight(1f)) + Spacer(Modifier.weight(1f)) - NavigationRailItem( - pagerState.currentPage == 3, - onClick = { - uiScope.launch { - pagerState.scrollToPage(3) - } - }, - icon = { Icon(Icons.Rounded.Settings, null) }, - label = { Text(text = "设置") }, - ) + NavigationRailItem( + pagerState.currentPage == 3, + onClick = { + uiScope.launch { + pagerState.scrollToPage(3) + } + }, + icon = { Icon(Icons.Rounded.Settings, null) }, + label = { Text(text = "设置") }, + ) + } } } VerticalDivider()