// The viewer's one head row, the same for a picture, a film and a document, // and the same as every paper page's: the place in the set at the left, then // the circles at the right — Share, and the X last (walker 604bcce6: the // viewers were black system sheets with the close on the left). The hand of // the record's acts is not here: on a thing-first page it stands at the // BOTTOM right (`ViewerFoot`), where a thumb holding the phone reaches it, and // Details is the first card it raises (owner's feedback on 311). An item with // no record (a chat picture never filed) shows its facts behind a circle in // the head. It is defined here and nowhere else — a kind's page draws its own // tools (a scrub bar, a page strip) below, never a second row of these. import SwiftUI extension EnvironmentValues { @Entry var viewerHeadInk: Color? = nil } struct ViewerChrome: View { let item: ViewerItem? let index: Int let count: Int /// The item's file on this device, once its page has it: what Share hands on. let file: URL? let words: ViewerWords? let onClose: () -> Void let onDetails: (ViewerItem) -> Void @Environment(\.theme) private var theme @Environment(\.viewerHeadInk) private var headInk var body: some View { HStack(alignment: .center, spacing: PaperScreenKnobs.paperScreenHeadingGap) { if let place = words?.position(index, of: count) { Text(place) .font(theme.type.display(theme.scale[.headTitleSize] * ViewerKnobs.placeScale).monospacedDigit()) .foregroundStyle(headInk ?? theme.colors.ink.color) .lineLimit(1) .accessibilityIdentifier("viewer-position") } Spacer(minLength: 0) acts NavCircle(symbol: Glyph.symbol("x") ?? "xmark", label: words?.close ?? "", action: onClose) .accessibilityIdentifier("viewer-close") } .cottonContentMargin() .padding(.top, theme.scale.navRowTop) } /// Share hands the file on (also "Open in…" and "Save to Photos"); an /// item with no record shows its facts. @ViewBuilder private var acts: some View { if let file { ShareLink(item: file) { NavDisc(symbol: "square.and.arrow.up") } .buttonStyle(MotionButtonStyle()) .accessibilityLabel(words?.share ?? "") .accessibilityIdentifier("viewer-share") } if let item, item.record == nil { NavCircle(symbol: "text.below.photo", label: words?.details ?? "") { onDetails(item) } .accessibilityIdentifier("viewer-details") } } } /// The viewer's foot: the hand of the record's acts at the bottom right. The /// record's own page is reached by it (Details, its first card) as well as by /// the swipe up. A kind's bottom strip (the player's controls, a document's /// page strip) stands above it, by `viewerFootHeight`, so nothing is covered. /// The record page's hand mode stands its own (unseen) hand here too, so the /// cards rise from the button the person tapped. struct ViewerFoot: View { let onActs: () -> Void @Environment(\.theme) private var theme var body: some View { HStack(spacing: 0) { Spacer(minLength: 0) TrayStackButton(action: onActs) .accessibilityIdentifier("viewer-acts") } .cottonContentMargin() .padding(.bottom, theme.scale.navRowTop) } } /// What the viewer knows of an item with no record behind it — a picture sent /// in a chat that was never filed: its name, its size and its kind of file, /// as values, never a sentence. struct ViewerFacts: View { let item: ViewerItem @Environment(\.theme) private var theme private var facts: [String] { var lines: [String] = [] if let title = item.title, !title.isEmpty { lines.append(title) } if let width = item.width, let height = item.height, width > 0, height > 0 { lines.append("\(width) × \(height)") } if let type = item.contentType, !type.isEmpty { lines.append(type) } return lines } var body: some View { VStack(alignment: .leading, spacing: ViewerKnobs.chromeGap) { ForEach(facts, id: \.self) { line in Text(line) .font(theme.type.interface(ViewerKnobs.captionSize)) .foregroundStyle(theme.colors.ink.color) } } .frame(maxWidth: .infinity, alignment: .leading) .padding(ViewerKnobs.chromeInset) .accessibilityIdentifier("viewer-facts") } }