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)