





















@@ -30,27 +30,13 @@ struct GatewayQuickSetupSheet: View {
3030}
31313232if let candidate = self.bestCandidate {
33-VStack(alignment: .leading, spacing: 6) {
34-Text(verbatim: candidate.name)
35-.font(.headline)
36-Text(verbatim: candidate.debugID)
37-.font(.footnote)
38-.foregroundStyle(.secondary)
39-40-VStack(alignment: .leading, spacing: 2) {
41- // Use verbatim strings so Bonjour-provided values can't be interpreted as
42- // localized format strings (which can crash with Objective-C exceptions).
43-Text(verbatim: "Discovery: \(self.gatewayController.discoveryStatusText)")
44-Text(verbatim: "Status: \(self.appModel.gatewayDisplayStatusText)")
45-Text(verbatim: "Node: \(self.appModel.nodeStatusText)")
46-Text(verbatim: "Operator: \(self.appModel.operatorStatusText)")
47-}
48-.font(.footnote)
49-.foregroundStyle(.secondary)
50-}
51-.padding(12)
52-.background(.thinMaterial)
53-.clipShape(RoundedRectangle(cornerRadius: 14))
33+GatewayQuickSetupCandidatePanel(
34+ name: candidate.name,
35+ debugID: candidate.debugID,
36+ discoveryStatusText: self.gatewayController.discoveryStatusText,
37+ gatewayDisplayStatusText: self.appModel.gatewayDisplayStatusText,
38+ nodeStatusText: self.appModel.nodeStatusText,
39+ operatorStatusText: self.appModel.operatorStatusText)
54405541Button {
5642self.connectError = nil
@@ -169,3 +155,43 @@ struct GatewayQuickSetupSheet: View {
169155self.connectError = err
170156}
171157}
158+159+private struct GatewayQuickSetupCandidatePanel: View {
160+private static let readableMonospaceWidth: CGFloat = 72 * 8
161+162+let name: String
163+let debugID: String
164+let discoveryStatusText: String
165+let gatewayDisplayStatusText: String
166+let nodeStatusText: String
167+let operatorStatusText: String
168+169+var body: some View {
170+VStack(alignment: .leading, spacing: 6) {
171+Text(verbatim: self.name)
172+.font(.system(.headline, design: .monospaced))
173+.foregroundStyle(.primary)
174+Text(verbatim: self.debugID)
175+.font(.system(.footnote, design: .monospaced))
176+.foregroundStyle(.secondary)
177+178+VStack(alignment: .leading, spacing: 2) {
179+ // Use verbatim strings so Bonjour-provided values can't be interpreted as
180+ // localized format strings (which can crash with Objective-C exceptions).
181+Text(verbatim: "Discovery: \(self.discoveryStatusText)")
182+Text(verbatim: "Status: \(self.gatewayDisplayStatusText)")
183+Text(verbatim: "Node: \(self.nodeStatusText)")
184+Text(verbatim: "Operator: \(self.operatorStatusText)")
185+}
186+.font(.system(.footnote, design: .monospaced))
187+.foregroundStyle(.secondary)
188+}
189+.frame(maxWidth: Self.readableMonospaceWidth, alignment: .leading)
190+.padding(.vertical, 14)
191+.padding(.horizontal, 16)
192+.frame(maxWidth: .infinity, alignment: .leading)
193+.textSelection(.enabled)
194+.background(.thinMaterial)
195+.clipShape(RoundedRectangle(cornerRadius: 14))
196+}
197+}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。