-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add General / Permissions / About panes to redesigned Settings #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
FuJacob
wants to merge
3
commits into
feat/settings-redesign-scaffold
from
feat/settings-redesign-general-perms-about
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import SwiftUI | ||
|
|
||
| /// File overview: | ||
| /// Shared chrome for every settings detail pane. Pulls the form styling, scroll wrapping, and | ||
| /// optional top-of-pane callout into one place so individual panes stay focused on their rows | ||
| /// rather than repeating layout boilerplate. | ||
| /// | ||
| /// Why a callout slot: | ||
| /// The legacy settings window puts a single attention banner at the top of the form. The redesign | ||
| /// surfaces attention per pane: when a pane is in a degraded state (missing permission, runtime | ||
| /// unavailable) we render an inline callout above the form so the actionable surface lives next to | ||
| /// the controls that fix it. | ||
| struct SettingsPaneScaffold<Content: View>: View { | ||
| let callout: SettingsPaneCallout? | ||
| @ViewBuilder let content: () -> Content | ||
|
|
||
| init( | ||
| callout: SettingsPaneCallout? = nil, | ||
| @ViewBuilder content: @escaping () -> Content | ||
| ) { | ||
| self.callout = callout | ||
| self.content = content | ||
| } | ||
|
|
||
| var body: some View { | ||
| ScrollView { | ||
| VStack(spacing: 0) { | ||
| if let callout { | ||
| SettingsCalloutView(callout: callout) | ||
| .padding(.horizontal, 20) | ||
| .padding(.top, 16) | ||
| } | ||
| Form { | ||
| content() | ||
| } | ||
| .formStyle(.grouped) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| struct SettingsPaneCallout: Equatable { | ||
| enum Tone { | ||
| case warning | ||
| case info | ||
| } | ||
|
|
||
| let tone: Tone | ||
| let message: String | ||
| } | ||
|
|
||
| private struct SettingsCalloutView: View { | ||
| let callout: SettingsPaneCallout | ||
|
|
||
| var body: some View { | ||
| HStack(alignment: .top, spacing: 10) { | ||
| Image(systemName: iconName) | ||
| .foregroundStyle(tint) | ||
| .imageScale(.medium) | ||
|
|
||
| Text(callout.message) | ||
| .font(.callout) | ||
| .fixedSize(horizontal: false, vertical: true) | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| } | ||
| .padding(12) | ||
| .background( | ||
| RoundedRectangle(cornerRadius: 8, style: .continuous) | ||
| .fill(tint.opacity(0.12)) | ||
| ) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 8, style: .continuous) | ||
| .stroke(tint.opacity(0.4), lineWidth: 1) | ||
| ) | ||
| } | ||
|
|
||
| private var iconName: String { | ||
| switch callout.tone { | ||
| case .warning: return "exclamationmark.triangle.fill" | ||
| case .info: return "info.circle.fill" | ||
| } | ||
| } | ||
|
|
||
| private var tint: Color { | ||
| switch callout.tone { | ||
| case .warning: return .orange | ||
| case .info: return .accentColor | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| /// File overview: | ||
| /// "About" detail pane of the redesigned Settings window. Consolidates what used to live across | ||
| /// three legacy sections (header, support CTA, uninstall) plus a new Acknowledgements modal that | ||
| /// lists the third-party packages Cotabby ships with. | ||
| struct AboutPaneView: View { | ||
| let appUpdateManager: AppUpdateManager | ||
|
|
||
| @State private var isShowingAcknowledgements = false | ||
|
|
||
| var body: some View { | ||
| SettingsPaneScaffold { | ||
| Section { aboutHeader } | ||
| Section("Support") { supportRow } | ||
| Section("Links") { linksRow } | ||
| Section("Uninstall") { uninstallText } | ||
| } | ||
| .sheet(isPresented: $isShowingAcknowledgements) { | ||
| AcknowledgementsView { isShowingAcknowledgements = false } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var aboutHeader: some View { | ||
| HStack(spacing: 12) { | ||
| Image("CotabbyLogo") | ||
| .resizable() | ||
| .scaledToFit() | ||
| .frame(width: 40, height: 40) | ||
| .clipShape(RoundedRectangle(cornerRadius: 9, style: .continuous)) | ||
|
|
||
| VStack(alignment: .leading, spacing: 2) { | ||
| Text("Cotabby") | ||
| .font(.system(size: 16, weight: .semibold, design: .rounded)) | ||
|
|
||
| Text("Local macOS AI Autocomplete") | ||
| .font(.system(size: 12, design: .rounded)) | ||
| .foregroundStyle(.secondary) | ||
|
|
||
| Text(appVersionText) | ||
| .font(.system(size: 11, design: .rounded)) | ||
| .foregroundStyle(.secondary) | ||
| } | ||
|
|
||
| Spacer(minLength: 12) | ||
|
|
||
| Button("Check for Updates") { | ||
| appUpdateManager.checkForUpdates() | ||
| } | ||
| } | ||
| .padding(.vertical, 4) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var supportRow: some View { | ||
| LabeledContent { | ||
| if let supportURL = URL(string: "https://ko-fi.com/cotabby") { | ||
| Link(destination: supportURL) { | ||
| Label("Support", systemImage: "heart.fill") | ||
| } | ||
| .buttonStyle(.borderedProminent) | ||
| .tint(.blue) | ||
| } | ||
| } label: { | ||
| Text( | ||
| "Cotabby is free and open source, maintained by two university students in our free time. " | ||
| + "If it's useful to you, please consider supporting development." | ||
| ) | ||
| .foregroundStyle(.secondary) | ||
| .fixedSize(horizontal: false, vertical: true) | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var linksRow: some View { | ||
| VStack(alignment: .leading, spacing: 8) { | ||
| if let repoURL = URL(string: "https://github.com/FuJacob/Cotabby") { | ||
| Link(destination: repoURL) { | ||
| Label("GitHub Repository", systemImage: "chevron.left.forwardslash.chevron.right") | ||
| } | ||
| } | ||
| if let wikiURL = URL(string: "https://github.com/FuJacob/Cotabby/wiki") { | ||
| Link(destination: wikiURL) { | ||
| Label("Wiki & Contributor Guide", systemImage: "book") | ||
| } | ||
| } | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| Button { | ||
| isShowingAcknowledgements = true | ||
| } label: { | ||
| Label("Acknowledgements", systemImage: "doc.text") | ||
| } | ||
| .buttonStyle(.link) | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var uninstallText: some View { | ||
| Text( | ||
| "Drag Cotabby.app from Applications to the Trash. " | ||
| + "To remove leftover data, also delete ~/Library/Application Support/Cotabby. " | ||
| + "Privacy permissions can only be revoked in System Settings → Privacy & Security." | ||
| ) | ||
| .font(.caption) | ||
| .foregroundStyle(.secondary) | ||
| } | ||
|
|
||
| /// The app bundle is the canonical source for human-facing version text. | ||
| private var appVersionText: String { | ||
| let shortVersion = | ||
| Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String | ||
| let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String | ||
|
|
||
| switch (shortVersion, buildNumber) { | ||
| case (let shortVersion?, let buildNumber?) where shortVersion != buildNumber: | ||
| return "Version \(shortVersion) (\(buildNumber))" | ||
| case (let shortVersion?, _): | ||
| return "Version \(shortVersion)" | ||
| case (_, let buildNumber?): | ||
| return "Build \(buildNumber)" | ||
| default: | ||
| return "Unknown version" | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.