diff options
| author | Christian Cleberg <[email protected]> | 2026-04-13 09:57:23 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-13 09:57:23 -0500 |
| commit | 0e461a382257979037e8927e5f6b468635b0a7fe (patch) | |
| tree | 0aa3a19f6f8f966b0e90f4874ed54359a7898107 /Hutch/Extensions | |
| parent | ee9f2904aa319231b7047fca3cb069f0c07019cd (diff) | |
| download | hutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.gz hutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.bz2 hutch-0e461a382257979037e8927e5f6b468635b0a7fe.zip | |
feat: add power user actions
Implements: https://todo.sr.ht/~ccleberg/hutch/52
Implements: https://todo.sr.ht/~ccleberg/hutch/53
Implements: https://todo.sr.ht/~ccleberg/hutch/54
Diffstat (limited to 'Hutch/Extensions')
| -rw-r--r-- | Hutch/Extensions/PowerUserActions.swift | 40 | ||||
| -rw-r--r-- | Hutch/Extensions/SRHTWebURL.swift | 14 |
2 files changed, 54 insertions, 0 deletions
diff --git a/Hutch/Extensions/PowerUserActions.swift b/Hutch/Extensions/PowerUserActions.swift new file mode 100644 index 0000000..97e4d52 --- /dev/null +++ b/Hutch/Extensions/PowerUserActions.swift @@ -0,0 +1,40 @@ +import SwiftUI + +struct DebugTextBlock: View { + let title: String + let content: String + + var body: some View { + VStack(alignment: .leading, spacing: 8) { + Text(title) + .font(.caption.weight(.semibold)) + .foregroundStyle(.secondary) + .textCase(.uppercase) + + Text(content) + .font(.caption.monospaced()) + .foregroundStyle(.primary) + .textSelection(.enabled) + .frame(maxWidth: .infinity, alignment: .leading) + .padding(12) + .background(Color(.secondarySystemBackground), in: RoundedRectangle(cornerRadius: 12)) + } + } +} + +struct CopyConfirmationBadge: View { + let message: String + + var body: some View { + HStack(spacing: 6) { + Image(systemName: "checkmark.circle.fill") + .font(.caption) + Text(message) + .font(.caption.weight(.medium)) + } + .foregroundStyle(.white) + .padding(.horizontal, 12) + .padding(.vertical, 8) + .background(.green.gradient, in: Capsule()) + } +} diff --git a/Hutch/Extensions/SRHTWebURL.swift b/Hutch/Extensions/SRHTWebURL.swift index cd8e8be..bfed48b 100644 --- a/Hutch/Extensions/SRHTWebURL.swift +++ b/Hutch/Extensions/SRHTWebURL.swift @@ -12,6 +12,16 @@ enum SRHTWebURL { ) } + static func httpsCloneURL(_ repositorySummary: RepositorySummary) -> String? { + repository(repositorySummary)?.absoluteString + } + + static func sshCloneURL(_ repositorySummary: RepositorySummary) -> String { + let host = "\(repositorySummary.service.rawValue).sr.ht" + let user = repositorySummary.service == .hg ? "hg" : "git" + return "\(user)@\(host):\(repositorySummary.owner.canonicalName)/\(repositorySummary.name)" + } + static func commit(repository: RepositorySummary, commitId: String) -> URL? { userScopedURL( host: "\(repository.service.rawValue).sr.ht", @@ -63,6 +73,10 @@ enum SRHTWebURL { ) } + static func tracker(_ trackerSummary: TrackerSummary) -> URL? { + tracker(ownerUsername: trackerSummary.owner.canonicalName.srhtUsername, trackerName: trackerSummary.name) + } + static func projectSource(_ source: Project.SourceRepo) -> URL? { userScopedURL( host: "\(source.repoType.service.rawValue).sr.ht", |
