feat(menubar): 新增保持唤醒开关并统一底部透明按钮样式
This commit is contained in:
@@ -4,6 +4,7 @@ import AppKit
|
||||
struct MenuPanelView: View {
|
||||
let metrics: MetricsStore
|
||||
let preferences: AppearancePreferences
|
||||
let keepAwake: KeepAwakeService
|
||||
@Environment(\.openSettings) private var openSettings
|
||||
|
||||
var body: some View {
|
||||
@@ -195,6 +196,14 @@ struct MenuPanelView: View {
|
||||
.font(.system(size: 9)).foregroundStyle(.tertiary)
|
||||
}
|
||||
Spacer()
|
||||
Button { keepAwake.toggle() } label: {
|
||||
Image(systemName: keepAwake.isEnabled ? "cup.and.saucer.fill" : "cup.and.saucer")
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundStyle(keepAwake.isEnabled ? preferences.tintColor : Color.primary)
|
||||
}
|
||||
.help(keepAwake.didFail ? Text("awake.failed") : (keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable")))
|
||||
.accessibilityLabel(keepAwake.isEnabled ? Text("awake.disable") : Text("awake.enable"))
|
||||
.accessibilityValue(keepAwake.isEnabled ? Text("awake.on") : Text("awake.off"))
|
||||
Button { metrics.togglePause() } label: {
|
||||
Image(systemName: metrics.isPaused ? "play.fill" : "pause.fill").frame(width: 20, height: 20)
|
||||
}
|
||||
@@ -209,8 +218,22 @@ struct MenuPanelView: View {
|
||||
}
|
||||
.help(Text("action.quit")).accessibilityLabel(Text("action.quit"))
|
||||
}
|
||||
.buttonStyle(.glass)
|
||||
.buttonStyle(FooterButtonStyle())
|
||||
.controlSize(.small)
|
||||
.padding(.horizontal, 8).padding(.vertical, 6)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private struct FooterButtonStyle: ButtonStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
configuration.label
|
||||
.padding(.horizontal, 9).padding(.vertical, 6)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 6))
|
||||
.overlay {
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(.primary.opacity(configuration.isPressed ? 0.5 : 0.18), lineWidth: 1)
|
||||
}
|
||||
.opacity(configuration.isPressed ? 0.6 : 1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user