blob: 9ed0bddd703aa5bebb230bfc15d0f418e50d129a (
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
45
46
47
48
49
50
51
52
53
54
55
|
import SwiftUI
import UIKit
struct BuildTaskLogView: View {
let task: BuildTask
let viewModel: BuildDetailViewModel
var body: some View {
Group {
if viewModel.loadingTaskLogs.contains(task.logCacheKey) {
SRHTLoadingStateView(message: "Loading log…")
} else if let logText = viewModel.taskLogs[task.logCacheKey] {
GeometryReader { geometry in
ScrollView([.vertical, .horizontal]) {
Text(logText)
.font(.caption2.monospaced())
.textSelection(.enabled)
.padding()
.frame(
minWidth: geometry.size.width,
minHeight: geometry.size.height,
alignment: .topLeading
)
}
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
ShareLink(item: logText)
}
ToolbarItem(placement: .topBarTrailing) {
Button {
UIPasteboard.general.string = logText
} label: {
Image(systemName: "doc.on.doc")
}
.accessibilityLabel("Copy log to clipboard")
}
}
} else if task.log == nil {
ContentUnavailableView(
"No Log",
systemImage: "doc.text",
description: Text("This task has no log output.")
)
} else {
SRHTLoadingStateView(message: "Loading log…")
}
}
.navigationTitle(task.name)
.navigationBarTitleDisplayMode(.inline)
.task {
await viewModel.loadTaskLog(task: task)
}
}
}
|