61 lines
2.2 KiB
Swift
61 lines
2.2 KiB
Swift
import SwiftUI
|
|
import SFSafeSymbols
|
|
|
|
struct PageContentResultsView: View {
|
|
|
|
@Environment(\.language)
|
|
private var language
|
|
|
|
@ObservedObject
|
|
var results: PageGenerationResults
|
|
|
|
#warning("Rework to only show a single popup with all files, and indicate missing ones")
|
|
private var totalFileCount: Int {
|
|
results.usedFiles.count + results.missingFiles.count + results.missingLinkedFiles.count
|
|
}
|
|
|
|
var body: some View {
|
|
HStack {
|
|
TextWithPopup(
|
|
symbol: .photoOnRectangleAngled,
|
|
text: "\(totalFileCount) images and files",
|
|
items: results.usedFiles.sorted().map { $0.id })
|
|
.foregroundStyle(.secondary)
|
|
|
|
TextWithPopup(
|
|
symbol: .docBadgePlus,
|
|
text: "\(results.linkedPages.count + results.missingLinkedPages.count) page links",
|
|
items: results.linkedPages.sorted().map { $0.localized(in: language).title })
|
|
.foregroundStyle(.secondary)
|
|
|
|
TextWithPopup(
|
|
symbol: .globe,
|
|
text: "\(results.externalLinks.count) external links",
|
|
items: results.externalLinks.sorted())
|
|
.foregroundStyle(.secondary)
|
|
|
|
if !results.missingLinkedPages.isEmpty {
|
|
TextWithPopup(
|
|
symbol: .exclamationmarkTriangleFill,
|
|
text: "\(results.missingLinkedPages.count) missing pages",
|
|
items: results.missingLinkedPages.keys.sorted())
|
|
.foregroundStyle(.red)
|
|
}
|
|
if !results.missingFiles.isEmpty {
|
|
TextWithPopup(
|
|
symbol: .exclamationmarkTriangleFill,
|
|
text: "\(results.missingFiles.count) missing files",
|
|
items: results.missingFiles.keys.sorted())
|
|
.foregroundStyle(.red)
|
|
}
|
|
if !results.invalidCommands.isEmpty {
|
|
TextWithPopup(
|
|
symbol: .exclamationmarkTriangleFill,
|
|
text: "\(results.invalidCommands.count) invalid commands",
|
|
items: results.invalidCommands.map { $0.markdown }.sorted())
|
|
.foregroundStyle(.red)
|
|
}
|
|
}
|
|
}
|
|
}
|