-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpatch_mac.diff
More file actions
38 lines (35 loc) · 1.46 KB
/
Copy pathpatch_mac.diff
File metadata and controls
38 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- mac/Sources/PixShell/UI/ConnectOverlay.swift
+++ mac/Sources/PixShell/UI/ConnectOverlay.swift
@@ -13,6 +13,8 @@
private let stepLabel = NSTextField(labelWithString: "")
private let bar = IndeterminateBar()
private var stepTimer: Timer?
private var stepIndex = 0
+ private let cancelBtn = NSButton(title: "取消", target: nil, action: nil)
+ var onCancel: (() -> Void)?
/// 分步文案(对齐真实 SSH 流程的观感;不是真进度,只表达"在动")
private static let steps = ["正在建立 TCP 连接…", "SSH 握手…", "身份认证…", "打开会话…"]
@@ -35,10 +37,14 @@
stepLabel.font = Theme.ui(12); stepLabel.textColor = Theme.muted
stepLabel.alignment = .center
- let stack = NSStackView(views: [pulse, titleLabel, stepLabel, bar])
+ cancelBtn.target = self
+ cancelBtn.action = #selector(cancelClicked)
+ cancelBtn.bezelStyle = .rounded
+
+ let stack = NSStackView(views: [pulse, titleLabel, stepLabel, bar, cancelBtn])
stack.orientation = .vertical
stack.alignment = .centerX
stack.spacing = 12
stack.translatesAutoresizingMaskIntoConstraints = false
card.addSubview(stack)
@@ -52,6 +58,11 @@
])
}
+ @objc private func cancelClicked() {
+ onCancel?()
+ }
+
/// 开始:贴满 host 视图并播放动画。
func show(in host: NSView, title: String) {
stepTimer?.invalidate()