|
| 1 | +import SwiftUI |
| 2 | + |
| 3 | +extension SettingsView { |
| 4 | + var aboutContent: some View { |
| 5 | + VStack(spacing: Layout.sectionSpacing) { |
| 6 | + appInfoSection |
| 7 | + updateSection |
| 8 | + linksSection |
| 9 | + } |
| 10 | + .frame(maxWidth: .infinity) |
| 11 | + } |
| 12 | + |
| 13 | + private var appInfoSection: some View { |
| 14 | + VStack(spacing: 12) { |
| 15 | + if let appIcon = NSImage(named: NSImage.applicationIconName) { |
| 16 | + Image(nsImage: appIcon) |
| 17 | + .resizable() |
| 18 | + .frame(width: 80, height: 80) |
| 19 | + } |
| 20 | + |
| 21 | + Text("Reframed") |
| 22 | + .font(.system(size: 20, weight: .semibold)) |
| 23 | + .foregroundStyle(ReframedColors.primaryText) |
| 24 | + |
| 25 | + VStack(spacing: 4) { |
| 26 | + Text("Version \(UpdateChecker.currentVersion)") |
| 27 | + .font(.system(size: 12)) |
| 28 | + .foregroundStyle(ReframedColors.secondaryText) |
| 29 | + |
| 30 | + Text("Screen recording & editing for macOS") |
| 31 | + .font(.system(size: 12)) |
| 32 | + .foregroundStyle(ReframedColors.tertiaryText) |
| 33 | + } |
| 34 | + } |
| 35 | + .frame(maxWidth: .infinity) |
| 36 | + .padding(.top, 8) |
| 37 | + } |
| 38 | + |
| 39 | + private var updateSection: some View { |
| 40 | + VStack(spacing: 12) { |
| 41 | + Button { |
| 42 | + Task { await checkForUpdates() } |
| 43 | + } label: { |
| 44 | + HStack(spacing: 6) { |
| 45 | + if updateCheckInProgress { |
| 46 | + ProgressView() |
| 47 | + .controlSize(.mini) |
| 48 | + } |
| 49 | + Text(updateCheckInProgress ? "Checking..." : "Check for Updates") |
| 50 | + } |
| 51 | + } |
| 52 | + .buttonStyle(SettingsButtonStyle()) |
| 53 | + .disabled(updateCheckInProgress) |
| 54 | + |
| 55 | + if let status = updateStatus { |
| 56 | + updateStatusView(status) |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + @ViewBuilder |
| 62 | + private func updateStatusView(_ status: UpdateStatus) -> some View { |
| 63 | + switch status { |
| 64 | + case .upToDate: |
| 65 | + HStack(spacing: 6) { |
| 66 | + Image(systemName: "checkmark.circle.fill") |
| 67 | + .foregroundStyle(.green) |
| 68 | + .font(.system(size: 13)) |
| 69 | + Text("You're up to date!") |
| 70 | + .font(.system(size: 12)) |
| 71 | + .foregroundStyle(ReframedColors.secondaryText) |
| 72 | + } |
| 73 | + |
| 74 | + case .available(let version, let url): |
| 75 | + VStack(spacing: 8) { |
| 76 | + HStack(spacing: 6) { |
| 77 | + Image(systemName: "arrow.up.circle.fill") |
| 78 | + .foregroundStyle(.blue) |
| 79 | + .font(.system(size: 13)) |
| 80 | + Text("Version \(version) is available") |
| 81 | + .font(.system(size: 12, weight: .medium)) |
| 82 | + .foregroundStyle(ReframedColors.primaryText) |
| 83 | + } |
| 84 | + |
| 85 | + Button("Download Update") { |
| 86 | + if let downloadURL = URL(string: url) { |
| 87 | + NSWorkspace.shared.open(downloadURL) |
| 88 | + } |
| 89 | + } |
| 90 | + .buttonStyle(SettingsButtonStyle()) |
| 91 | + } |
| 92 | + |
| 93 | + case .error(let message): |
| 94 | + HStack(spacing: 6) { |
| 95 | + Image(systemName: "exclamationmark.triangle.fill") |
| 96 | + .foregroundStyle(.orange) |
| 97 | + .font(.system(size: 13)) |
| 98 | + Text(message) |
| 99 | + .font(.system(size: 12)) |
| 100 | + .foregroundStyle(ReframedColors.secondaryText) |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + private var linksSection: some View { |
| 106 | + VStack(spacing: 8) { |
| 107 | + Divider() |
| 108 | + .background(ReframedColors.divider) |
| 109 | + |
| 110 | + HStack(spacing: 16) { |
| 111 | + linkButton("GitHub", icon: "arrow.up.right.square", url: "https://github.com/jkuri/Reframed") |
| 112 | + linkButton("Issues", icon: "ladybug", url: "https://github.com/jkuri/Reframed/issues") |
| 113 | + linkButton("Releases", icon: "shippingbox", url: "https://github.com/jkuri/Reframed/releases") |
| 114 | + } |
| 115 | + .padding(.top, 4) |
| 116 | + |
| 117 | + Text("Jan Kuri") |
| 118 | + .font(.system(size: 11)) |
| 119 | + .foregroundStyle(ReframedColors.tertiaryText) |
| 120 | + .padding(.top, 4) |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + private func linkButton(_ title: String, icon: String, url: String) -> some View { |
| 125 | + Button { |
| 126 | + if let linkURL = URL(string: url) { |
| 127 | + NSWorkspace.shared.open(linkURL) |
| 128 | + } |
| 129 | + } label: { |
| 130 | + HStack(spacing: 4) { |
| 131 | + Image(systemName: icon) |
| 132 | + .font(.system(size: 11)) |
| 133 | + Text(title) |
| 134 | + .font(.system(size: 12)) |
| 135 | + } |
| 136 | + .foregroundStyle(ReframedColors.secondaryText) |
| 137 | + } |
| 138 | + .buttonStyle(.plain) |
| 139 | + .onHover { hovering in |
| 140 | + if hovering { |
| 141 | + NSCursor.pointingHand.push() |
| 142 | + } else { |
| 143 | + NSCursor.pop() |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | +} |
0 commit comments