Skip to content

Commit 0347b9a

Browse files
committed
refactor(app): extract PermissionRow to its own file
Reduces SettingsView.swift below 600-line SwiftLint limit.
1 parent 3911eab commit 0347b9a

File tree

2 files changed

+64
-65
lines changed

2 files changed

+64
-65
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import SwiftUI
2+
3+
/// A row showing permission status with a colored icon, info popover, and click-to-open Settings.
4+
struct PermissionRow: View {
5+
let label: String
6+
let detail: String
7+
var granted: Bool
8+
var warning: Bool = false
9+
var optional: Bool = false
10+
var help: String = ""
11+
var settingsURL: String = ""
12+
@State private var showingHelp = false
13+
14+
private var icon: String {
15+
if granted { return "checkmark.circle.fill" }
16+
if warning || optional { return "exclamationmark.triangle.fill" }
17+
return "xmark.circle.fill"
18+
}
19+
20+
private var iconColor: Color {
21+
if granted { return .green }
22+
if warning || optional { return .orange }
23+
return .red
24+
}
25+
26+
var body: some View {
27+
// swiftlint:disable:next closure_body_length
28+
HStack {
29+
Image(systemName: icon)
30+
.foregroundStyle(iconColor)
31+
VStack(alignment: .leading, spacing: 2) {
32+
Text(label)
33+
Text(detail)
34+
.font(.caption)
35+
.foregroundStyle(.secondary)
36+
}
37+
Spacer()
38+
if !help.isEmpty {
39+
Button {
40+
showingHelp.toggle()
41+
} label: {
42+
Image(systemName: "questionmark.circle")
43+
.foregroundStyle(.secondary)
44+
}
45+
.buttonStyle(.borderless)
46+
.popover(isPresented: $showingHelp) {
47+
VStack(alignment: .leading, spacing: 8) {
48+
Text(help)
49+
.font(.callout)
50+
if !settingsURL.isEmpty {
51+
Button("Open System Settings") {
52+
if let url = URL(string: settingsURL) {
53+
NSWorkspace.shared.open(url)
54+
}
55+
showingHelp = false
56+
}
57+
}
58+
}
59+
.padding()
60+
}
61+
}
62+
}
63+
}
64+
}

app/MeetingTranscriber/Sources/SettingsView.swift

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -535,68 +535,3 @@ struct SettingsView: View {
535535
audioDevices = session.devices.map { (id: $0.uniqueID, name: $0.localizedName) }
536536
}
537537
}
538-
539-
/// A row showing permission status with a colored icon, tooltip, and click-to-open Settings.
540-
/// A row showing permission status with a colored icon, info popover, and click-to-open Settings.
541-
struct PermissionRow: View {
542-
let label: String
543-
let detail: String
544-
var granted: Bool
545-
var warning: Bool = false
546-
var optional: Bool = false
547-
var help: String = ""
548-
var settingsURL: String = ""
549-
550-
@State private var showingHelp = false
551-
552-
private var icon: String {
553-
if granted { return "checkmark.circle.fill" }
554-
if warning || optional { return "exclamationmark.triangle.fill" }
555-
return "xmark.circle.fill"
556-
}
557-
558-
private var iconColor: Color {
559-
if granted { return .green }
560-
if warning || optional { return .orange }
561-
return .red
562-
}
563-
564-
var body: some View {
565-
// swiftlint:disable:next closure_body_length
566-
HStack {
567-
Image(systemName: icon)
568-
.foregroundStyle(iconColor)
569-
VStack(alignment: .leading, spacing: 2) {
570-
Text(label)
571-
Text(detail)
572-
.font(.caption)
573-
.foregroundStyle(.secondary)
574-
}
575-
Spacer()
576-
if !help.isEmpty {
577-
Button {
578-
showingHelp.toggle()
579-
} label: {
580-
Image(systemName: "questionmark.circle")
581-
.foregroundStyle(.secondary)
582-
}
583-
.buttonStyle(.borderless)
584-
.popover(isPresented: $showingHelp) {
585-
VStack(alignment: .leading, spacing: 8) {
586-
Text(help)
587-
.font(.callout)
588-
if !settingsURL.isEmpty {
589-
Button("Open System Settings") {
590-
if let url = URL(string: settingsURL) {
591-
NSWorkspace.shared.open(url)
592-
}
593-
showingHelp = false
594-
}
595-
}
596-
}
597-
.padding()
598-
}
599-
}
600-
}
601-
}
602-
}

0 commit comments

Comments
 (0)