fix(menubar): 修复清理构建状态项并增加液态外观选择
This commit is contained in:
@@ -22,11 +22,9 @@ struct kymoApp: App {
|
||||
@State private var language = LanguagePreferences()
|
||||
|
||||
var body: some Scene {
|
||||
MenuBarExtra {
|
||||
MenuBarExtra(MenuBarLabel.title(for: metrics.snapshot), image: "BrandMark") {
|
||||
MenuPanelView(metrics: metrics, preferences: appearance, keepAwake: keepAwake, settingsPresentation: settingsPresentation)
|
||||
.environment(\.locale, language.locale)
|
||||
} label: {
|
||||
MenuBarLabel(snapshot: metrics.snapshot)
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 586 B |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path d="M512 85.333333c235.648 0 426.666667 191.018667 426.666667 426.666667s-191.018667 426.666667-426.666667 426.666667S85.333333 747.648 85.333333 512 276.352 85.333333 512 85.333333z m196.096 230.570667a25.429333 25.429333 0 0 0-32.554667-2.858667c-123.306667 86.528-192.853333 137.813333-208.810666 153.685334a64 64 0 0 0 90.538666 90.538666c9.344-9.386667 60.501333-78.976 153.514667-208.938666a25.173333 25.173333 0 0 0-2.688-32.426667zM746.666667 469.333333a42.666667 42.666667 0 1 0 0 85.333334 42.666667 42.666667 0 0 0 0-85.333334z m-469.333334 0a42.666667 42.666667 0 1 0 0 85.333334 42.666667 42.666667 0 0 0 0-85.333334z m98.901334-153.429333a42.666667 42.666667 0 1 0-60.330667 60.330667 42.666667 42.666667 0 0 0 60.330667-60.330667zM512 234.666667a42.666667 42.666667 0 1 0 0 85.333333 42.666667 42.666667 0 0 0 0-85.333333z" fill="#2c2c2c"/></svg>
|
||||
|
Before Width: | Height: | Size: 931 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
+13
-3
@@ -1,8 +1,19 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"filename": "BrandMark.svg",
|
||||
"idiom": "universal"
|
||||
"filename": "BrandMark.png",
|
||||
"idiom": "universal",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"filename": "BrandMark@2x.png",
|
||||
"idiom": "universal",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "BrandMark@3x.png",
|
||||
"idiom": "universal",
|
||||
"scale": "3x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
@@ -10,7 +21,6 @@
|
||||
"version": 1
|
||||
},
|
||||
"properties": {
|
||||
"preserves-vector-representation": true,
|
||||
"template-rendering-intent": "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,5 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MenuBarLabel: View {
|
||||
let snapshot: MetricsSnapshot
|
||||
|
||||
var body: some View {
|
||||
// Use one native image/title label: the previous multi-view HStack showed
|
||||
// only its first image and percentage in the user-verified menu bar.
|
||||
Label {
|
||||
Text(verbatim: title)
|
||||
.monospacedDigit()
|
||||
} icon: {
|
||||
Image("BrandMark")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 18, height: 18)
|
||||
}
|
||||
.labelStyle(.titleAndIcon)
|
||||
}
|
||||
|
||||
private var title: String {
|
||||
enum MenuBarLabel {
|
||||
static func title(for snapshot: MetricsSnapshot) -> String {
|
||||
var items = ["CPU \(MetricFormat.percent(snapshot.cpu?.usage))"]
|
||||
if let gpu = snapshot.gpuUsage {
|
||||
items.append("GPU \(MetricFormat.percent(gpu))")
|
||||
|
||||
@@ -53,14 +53,7 @@ struct AppearanceSettingsView: View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent("appearance.title") {
|
||||
Picker("appearance.title", selection: $preferences.appearance) {
|
||||
Text("appearance.system").tag(AppAppearance.system)
|
||||
Text("appearance.light").tag(AppAppearance.light)
|
||||
Text("appearance.dark").tag(AppAppearance.dark)
|
||||
}
|
||||
.labelsHidden()
|
||||
.pickerStyle(.segmented)
|
||||
.fixedSize()
|
||||
LiquidAppearancePicker(selection: $preferences.appearance)
|
||||
}
|
||||
LabeledContent("accent.title") {
|
||||
Picker("accent.title", selection: $preferences.accent) {
|
||||
@@ -148,6 +141,71 @@ struct AppearanceSettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct LiquidAppearancePicker: View {
|
||||
@Binding var selection: AppAppearance
|
||||
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
||||
@Namespace private var selectionNamespace
|
||||
|
||||
var body: some View {
|
||||
GlassEffectContainer(spacing: 10) {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(AppAppearance.allCases) { appearance in
|
||||
Button {
|
||||
if reduceMotion {
|
||||
selection = appearance
|
||||
} else {
|
||||
withAnimation(.smooth(duration: 0.24)) {
|
||||
selection = appearance
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Label(appearance.title, systemImage: appearance.symbol)
|
||||
.labelStyle(.titleAndIcon)
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
.foregroundStyle(selection == appearance ? .primary : .secondary)
|
||||
.padding(.horizontal, 11)
|
||||
.frame(minWidth: 108, minHeight: 34)
|
||||
.contentShape(.capsule)
|
||||
.background {
|
||||
if selection == appearance {
|
||||
Capsule()
|
||||
.fill(.clear)
|
||||
.glassEffect(.regular.interactive(), in: .capsule)
|
||||
.glassEffectID("appearance-selection", in: selectionNamespace)
|
||||
.glassEffectTransition(.matchedGeometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityAddTraits(selection == appearance ? .isSelected : [])
|
||||
}
|
||||
}
|
||||
.padding(4)
|
||||
.glassEffect(.regular, in: .capsule)
|
||||
}
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(Text("appearance.title"))
|
||||
}
|
||||
}
|
||||
|
||||
private extension AppAppearance {
|
||||
var title: LocalizedStringKey {
|
||||
switch self {
|
||||
case .system: "appearance.system"
|
||||
case .light: "appearance.light"
|
||||
case .dark: "appearance.dark"
|
||||
}
|
||||
}
|
||||
|
||||
var symbol: String {
|
||||
switch self {
|
||||
case .system: "circle.lefthalf.filled"
|
||||
case .light: "sun.max.fill"
|
||||
case .dark: "moon.fill"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum SettingsPage: String, CaseIterable, Identifiable {
|
||||
case appearance, language, about
|
||||
var id: String { rawValue }
|
||||
|
||||
Reference in New Issue
Block a user