From 29d248dc1ddfaa66b1a9bde982b3e507293cf7da Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 22 Aug 2026 14:33:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=B9=E7=AA=97/=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=8D=A1=E5=8A=A8=E4=BD=9C=E6=8C=89=E9=92=AE=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=B8=BA=E7=BA=B8=E9=9D=A2=E8=AF=AD=E8=A8=80,=E8=B5=84?= =?UTF-8?q?=E6=96=99=E5=BA=93=E5=AE=89=E6=94=BE=E5=8D=A1=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=BB=E8=9A=80=E8=B4=A8=E6=84=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Theme 新增 WeiBeiDialogButtonStyle:主按钮实心朱砂+米白文字 (与发送按钮同一实心语言),次按钮刻蚀底座+发丝框+悬停贴地投影; 28pt 高、controlRadius 圆角,禁用态各自弱化 - 资料库安放通知卡:卡片换 WeiBeiEtchedBackdrop+双层投影, 路径行包进刻蚀井,文字芯片按钮换成上述按钮对并按 macOS 惯例把主动作放右侧 - 课程记录保存弹层、设置迁移确认的 .borderedProminent/ 系统按钮同步换新样式,全应用不再有系统默认按钮混入纸面语言 --- Sources/WeiBei/Support/Theme.swift | 73 +++++++++++++++++++ Sources/WeiBei/Views/CourseRecordsView.swift | 3 +- .../Views/EmptyWorkspaceLauncherView.swift | 39 +++++++--- .../WeiBei/Views/Settings/SettingsView.swift | 3 +- 4 files changed, 104 insertions(+), 14 deletions(-) diff --git a/Sources/WeiBei/Support/Theme.swift b/Sources/WeiBei/Support/Theme.swift index b44cfb98c..0e7a1852e 100644 --- a/Sources/WeiBei/Support/Theme.swift +++ b/Sources/WeiBei/Support/Theme.swift @@ -1669,6 +1669,79 @@ struct WeiBeiTextActionButtonStyle: ButtonStyle { } } +/// Dialog / sheet action buttons in the paper language: the solid-cinnabar +/// primary (same filled treatment as the send action) and the etched +/// secondary, so sheets stop mixing system `.bordered` chrome in. +struct WeiBeiDialogButtonStyle: ButtonStyle { + enum Prominence { + case primary + case secondary + } + + @Environment(\.isEnabled) private var isEnabled + @Environment(\.colorScheme) private var colorScheme + var prominence: Prominence = .secondary + @State private var hovering = false + + func makeBody(configuration: Configuration) -> some View { + let shape = RoundedRectangle(cornerRadius: WeiBeiMetric.controlRadius, style: .continuous) + return configuration.label + .weiBeiText(12, weight: prominence == .primary ? .semibold : .medium) + .foregroundStyle(foreground) + .padding(.horizontal, 14) + .frame(height: 28) + .background { background(isPressed: configuration.isPressed, shape: shape) } + .clipShape(shape) + .scaleEffect(configuration.isPressed ? 0.97 : 1) + .animation(WeiBeiMotion.press, value: configuration.isPressed) + .animation(WeiBeiMotion.hover, value: hovering) + .onHover { hovering = isEnabled && $0 } + .onChange(of: isEnabled) { _, enabled in + if !enabled { hovering = false } + } + } + + private var foreground: Color { + guard isEnabled else { + return prominence == .primary + ? WeiBeiTheme.onCinnabar.opacity(0.66) + : WeiBeiTheme.tertiaryInk.opacity(0.60) + } + if prominence == .primary { return WeiBeiTheme.onCinnabar } + return hovering ? WeiBeiTheme.ink : WeiBeiTheme.secondaryInk + } + + @ViewBuilder + private func background(isPressed: Bool, shape: RoundedRectangle) -> some View { + if !isEnabled { + if prominence == .primary { + shape.fill(WeiBeiTheme.cinnabar.opacity(0.38)) + } else { + WeiBeiEtchedBackdrop( + shape: shape, + fill: WeiBeiTheme.paperInset.opacity(0.16), + stroke: WeiBeiTheme.hairline.opacity(0.28) + ) + } + } else if prominence == .primary { + if isPressed { + shape.fill(WeiBeiTheme.cinnabar.opacity(colorScheme == .dark ? 0.78 : 0.86)) + } else if hovering { + shape.fill(WeiBeiTheme.cinnabar.opacity(colorScheme == .dark ? 0.86 : 0.92)) + } else { + shape.fill(WeiBeiTheme.cinnabar) + } + } else { + WeiBeiEtchedBackdrop( + shape: shape, + fill: WeiBeiTheme.paperInset.opacity(isPressed ? 0.40 : hovering ? 0.34 : 0.22), + stroke: WeiBeiTheme.hairline.opacity(hovering || isPressed ? 0.55 : 0.40), + showsContactShadow: hovering && !isPressed + ) + } + } +} + extension View { func weibeiPanel() -> some View { self diff --git a/Sources/WeiBei/Views/CourseRecordsView.swift b/Sources/WeiBei/Views/CourseRecordsView.swift index 53291d976..febce16fd 100644 --- a/Sources/WeiBei/Views/CourseRecordsView.swift +++ b/Sources/WeiBei/Views/CourseRecordsView.swift @@ -434,12 +434,13 @@ private struct LearningMemoryEditSheet: View { Button(store.ui("取消", "Cancel")) { dismiss() } + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .secondary)) Button(store.ui("保存修改", "Save")) { if store.updateLearningMemory(memory.id, in: scope, kind: kind, text: text) { dismiss() } } - .buttonStyle(.borderedProminent) + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .primary)) .disabled( text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || text.trimmingCharacters(in: .whitespacesAndNewlines).count > 500 diff --git a/Sources/WeiBei/Views/EmptyWorkspaceLauncherView.swift b/Sources/WeiBei/Views/EmptyWorkspaceLauncherView.swift index 48dad2409..d942cdf60 100644 --- a/Sources/WeiBei/Views/EmptyWorkspaceLauncherView.swift +++ b/Sources/WeiBei/Views/EmptyWorkspaceLauncherView.swift @@ -644,6 +644,17 @@ private struct LibraryPlacementNoticeCard: View { .lineLimit(1) .truncationMode(.middle) } + .padding(.horizontal, 12) + .padding(.vertical, 7) + .frame(maxWidth: .infinity) + .background { + WeiBeiEtchedBackdrop( + shape: RoundedRectangle(cornerRadius: 7, style: .continuous), + fill: WeiBeiTheme.paperInset.opacity(0.32), + stroke: WeiBeiTheme.hairline.opacity(0.45) + ) + } + .clipShape(RoundedRectangle(cornerRadius: 7, style: .continuous)) if let relocationErrorText { Text(relocationErrorText) @@ -657,28 +668,32 @@ private struct LibraryPlacementNoticeCard: View { ProgressView() .progressViewStyle(.linear) } else { - HStack(spacing: 14) { - Button(store.ui("就用这里", "Use This Folder")) { - confirmed = true - } - .buttonStyle(WeiBeiTextActionButtonStyle(active: true)) - + HStack(spacing: 10) { Button(store.ui("换个位置…", "Choose Another Location…")) { relocateLibrary() } - .buttonStyle(WeiBeiTextActionButtonStyle()) + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .secondary)) + + Button(store.ui("就用这里", "Use This Folder")) { + confirmed = true + } + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .primary)) } } } .padding(.horizontal, 16) .padding(.vertical, 13) .frame(maxWidth: 470) - .background(WeiBeiTheme.paperRaised.opacity(0.55)) - .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) - .overlay { - RoundedRectangle(cornerRadius: 8, style: .continuous) - .stroke(WeiBeiTheme.hairline.opacity(0.5), lineWidth: 1) + .background { + WeiBeiEtchedBackdrop( + shape: RoundedRectangle(cornerRadius: 8, style: .continuous), + fill: WeiBeiTheme.paperRaised.opacity(0.55), + stroke: WeiBeiTheme.hairline.opacity(0.5) + ) } + .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) + .shadow(color: WeiBeiTheme.ink.opacity(0.06), radius: 2, y: 1) + .shadow(color: WeiBeiTheme.ink.opacity(0.05), radius: 10, y: 3) .padding(.top, 10) .accessibilityElement(children: .contain) .accessibilityIdentifier("library-placement-notice") diff --git a/Sources/WeiBei/Views/Settings/SettingsView.swift b/Sources/WeiBei/Views/Settings/SettingsView.swift index 41b13a13a..098ce5bb7 100644 --- a/Sources/WeiBei/Views/Settings/SettingsView.swift +++ b/Sources/WeiBei/Views/Settings/SettingsView.swift @@ -397,10 +397,11 @@ struct SettingsView: View { Button(store.ui("开始迁移", "Start Migration")) { confirmMigration(to: destination) } - .buttonStyle(.borderedProminent) + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .primary)) Button(store.ui("取消", "Cancel")) { pendingMigrationDestination = nil } + .buttonStyle(WeiBeiDialogButtonStyle(prominence: .secondary)) } } .padding(.horizontal, 14)