mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-28 17:23:47 +00:00
refactor(ui): clean up StatusCardView layout and remove unused invalid server count message
This commit is contained in:
@@ -55,7 +55,7 @@ struct ShadowsocksXNG2App: App {
|
||||
} label: {
|
||||
StatusMenuLabel(control: proxyControl)
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
// .menuBarExtraStyle(.window)
|
||||
|
||||
// 主 workspace 窗口(ADR 0016/0017):SwiftUI `Window` scene。启动呈现由
|
||||
// defaultLaunchBehavior 决定:静默启动关闭(默认)时 presented 启动即呈现
|
||||
|
||||
@@ -27,16 +27,6 @@ struct ProxyStatusMenu: View {
|
||||
|
||||
Divider()
|
||||
StatusCardView(control: control)
|
||||
|
||||
if control.snapshot.skippedInvalidServerCount > 0 {
|
||||
Text("已跳过 \(control.snapshot.skippedInvalidServerCount) 个无效服务器")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.orange)
|
||||
.help("激活时跳过了存在已知本地阻塞问题的服务器")
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.bottom, 12)
|
||||
}
|
||||
|
||||
Divider()
|
||||
Button("退出 ShadowsocksX-NG2(代理仍在后台运行)") {
|
||||
NSApp.terminate(nil)
|
||||
|
||||
@@ -1,70 +1,36 @@
|
||||
import SwiftUI
|
||||
|
||||
/// 菜单栏面板代理状态卡(issue #60):只做 tone→语义色映射与排版,行结构、
|
||||
/// 回退文案与色调政策全部来自 StatusCardModel(与状态菜单同用一份文本映射,
|
||||
/// issue #47 的整体 snapshot 口径)。
|
||||
/// 菜单栏面板代理状态卡
|
||||
struct StatusCardView: View {
|
||||
@ObservedObject var control: ProxyControlWorkflow
|
||||
|
||||
var body: some View {
|
||||
let card = StatusCardModel.card(from: control.snapshot)
|
||||
return VStack(alignment: .leading, spacing: 7) {
|
||||
row(card.runtimeRow)
|
||||
if let detail = card.runtimeDetail {
|
||||
detailLine(detail)
|
||||
}
|
||||
row(card.systemProxyRow)
|
||||
if let detail = card.systemProxyDetail {
|
||||
detailLine(detail)
|
||||
}
|
||||
|
||||
Text(card.target.text)
|
||||
.font(.footnote.weight(.medium))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
.help(card.target.help)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel("活动目标:\(card.target.text)")
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("模式:")
|
||||
.foregroundStyle(.secondary)
|
||||
Text(card.modeText)
|
||||
}
|
||||
.font(.caption)
|
||||
.accessibilityElement(children: .combine)
|
||||
row(card.runtimeRow)
|
||||
if let detail = card.runtimeDetail {
|
||||
detailLine(detail)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(12)
|
||||
.background(.background.secondary, in: RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.strokeBorder(.quaternary)
|
||||
)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.top, 8)
|
||||
.padding(.bottom, 12)
|
||||
row(card.systemProxyRow)
|
||||
if let detail = card.systemProxyDetail {
|
||||
detailLine(detail)
|
||||
}
|
||||
|
||||
Text(card.target.text)
|
||||
.truncationMode(.middle)
|
||||
.help(card.target.help)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel("活动目标:\(card.target.text)")
|
||||
|
||||
Text("模式:\(card.modeText)").accessibilityElement(children: .combine)
|
||||
}
|
||||
|
||||
private func row(_ row: StatusCardModel.Row) -> some View {
|
||||
HStack(spacing: 4) {
|
||||
Text("\(row.label):")
|
||||
.foregroundStyle(.secondary)
|
||||
Text(row.text)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundStyle(color(row.tone))
|
||||
}
|
||||
.font(.footnote)
|
||||
.lineLimit(1)
|
||||
.accessibilityElement(children: .combine)
|
||||
Text("\(row.label):\(row.text)").accessibilityElement(children: .combine)
|
||||
}
|
||||
|
||||
private func detailLine(_ detail: StatusCardModel.DetailLine) -> some View {
|
||||
Text(detail.text)
|
||||
.font(.caption)
|
||||
.foregroundStyle(color(detail.tone))
|
||||
.lineLimit(2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.help(detail.text)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user