summaryrefslogtreecommitdiff
path: root/Hutch/Views/Repositories/CommitRowView.swift
blob: 362ab4de5b832048b55d7ece5748d855f284418b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import SwiftUI
import UIKit

struct CommitRowView: View {
    let commit: CommitSummary

    var body: some View {
        VStack(alignment: .leading, spacing: 4) {
            Text(commit.title)
                .font(.subheadline)
                .lineLimit(1)

            HStack(spacing: 8) {
                Text(commit.shortId)
                    .font(.caption.monospaced())
                    .foregroundStyle(.secondary)

                Text(commit.author.name)
                    .font(.caption)
                    .foregroundStyle(.secondary)

                Spacer()

                Text(commit.author.time.relativeDescription)
                    .font(.caption)
                    .foregroundStyle(.tertiary)
            }
        }
        .padding(.vertical, 2)
        .contextMenu {
            Button {
                UIPasteboard.general.string = commit.id
            } label: {
                Label("Copy Full SHA", systemImage: "doc.on.doc")
            }

            Button {
                UIPasteboard.general.string = commit.shortId
            } label: {
                Label("Copy Short SHA", systemImage: "doc.on.doc.fill")
            }
        }
    }
}