// The reader's chrome, shown and hidden together by a tap in the middle of// the page (`reader-paper.png`): at the top the running head, the book's// title in spaced small capitals over a hairline; at the foot the page// number, centred, and under it the bar under the seek line — back, the// chapter's title (a tap opens the contents), how far through, and at the// right the hand. The seek line is the book's page edge (`ReaderSeekLine`):// chapter ticks, a ribbon where the reader is, a drag to anywhere; after a// jump the core's Back slip stands over it until it retires. Every word is live type in the face's inks; the// chrome lies on the face's own ground, so it reads as part of the page.//// While a tier stands at the hub the bar steps aside for it; the running// head and the page number stay, as in `hand-faces.png`.#if os(iOS)importCottonPaperimportCottonValuesimportSwiftUIenumReaderChromeKnobs {staticlet headSize: CGFloat = 12staticlet headTracking: CGFloat = 2.4staticlet headRise: CGFloat = 14staticlet side: CGFloat = 24staticlet pageSize: CGFloat = 15staticlet barSize: CGFloat = 14staticlet bar: CGFloat = 44staticlet handBox: CGFloat = 44staticlet hand: CGFloat = 22}structReaderChrome: View {let reading: BookReadinglet close: () -> Voidvar body: someView {let face = reading.face VStack(spacing: 0) {if reading.chromeShown { head(face) .transition(.opacity) }Spacer(minLength: 0)if reading.chromeShown { foot(face) .transition(.opacity) } } .accessibilityElement(children: .contain) .accessibilityIdentifier("reader-chrome") }privatefunc head(_ face: ReaderFace) -> someView { VStack(spacing: ReaderChromeKnobs.headRise * 0.6) {Text(reading.title) .font(CottonFonts.caslon(ReaderChromeKnobs.headSize)) .textCase(.uppercase) .tracking(ReaderChromeKnobs.headTracking) .foregroundStyle(face.secondary) .lineLimit(1) .truncationMode(.tail) .accessibilityIdentifier("reader-running-head")Rectangle().fill(face.hairline).frame(height: 1) } .padding(.horizontal, ReaderChromeKnobs.side) .padding(.top, ReaderChromeKnobs.headRise * 0.5) .background(face.ground.ignoresSafeArea(edges: .top)) }privatefunc foot(_ face: ReaderFace) -> someView { VStack(spacing: 6) {// Back, over the page's last lines and clear of its number, until it retires.if !reading.tiers.closes, let back = reading.backSlip, reading.seekSlip == nil {Button { reading.seekBack() } label: { ReaderSlip(words: back.words, face: face) } .buttonStyle(.plain) .padding(.horizontal, ReaderSeekKnobs.slipGutter) .transition(.opacity) .accessibilityIdentifier("reader-seek-back") }iflet page = reading.pageWords {Text(page) .font(CottonFonts.caslon(ReaderChromeKnobs.pageSize).monospacedDigit()) .foregroundStyle(face.ink) .accessibilityLabel(ShellLines.line("cards", "reader.page", ["page": page])) .accessibilityIdentifier("reader-page-number") }if !reading.tiers.closes { VStack(spacing: 0) {iflet seek = reading.seek {ReaderSeekLine(face: face, ticks: seek.ticks.map(\.at), at: reading.seekAt, slip: reading.seekSlip, value: seek.words.here, label: seek.words.line, drag: { reading.seeking($0) }, release: { reading.seekReleased($0, width: $1) }, step: { reading.seekStep($0) }) } else {Rectangle().fill(face.hairline).frame(height: 1) .padding(.horizontal, ReaderChromeKnobs.side) } bar(face) } .background(face.ground.ignoresSafeArea(edges: .bottom)) .transition(.opacity) } } }privatefunc bar(_ face: ReaderFace) -> someView { HStack(spacing: 12) {ReaderBackButton(ink: face.ink, close: close)Button { reading.openContents() } label: {Text(reading.chapter ?? "") .font(CottonFonts.caslon(ReaderChromeKnobs.barSize)) .foregroundStyle(face.ink) .lineLimit(1) .truncationMode(.tail) .frame(minHeight: ReaderChromeKnobs.bar) .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityIdentifier("reader-chapter")Spacer(minLength: 8)iflet words = reading.progressWords {Text(words) .font(CottonFonts.caslon(ReaderChromeKnobs.barSize).monospacedDigit()) .foregroundStyle(face.ink) .accessibilityIdentifier("reader-progress") }Button { reading.openHand() } label: {FaceHandMark().stroke(lineWidth: 1.3) .foregroundStyle(face.ink) .frame(width: ReaderChromeKnobs.hand, height: ReaderChromeKnobs.hand) .frame(width: ReaderChromeKnobs.handBox, height: ReaderChromeKnobs.handBox) .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityLabel(ShellLines.line("cards", "reader.hand")) .accessibilityIdentifier("reader-hand") } .frame(height: ReaderChromeKnobs.bar) .padding(.leading, ReaderChromeKnobs.side - 14) .padding(.trailing, ReaderChromeKnobs.side - 12) .accessibilityElement(children: .contain) .accessibilityLabel(ShellLines.line("cards", "reader.bar")) }}/// The bar's back chevron, in the face's ink.structReaderBackButton: View {let ink: SwiftUI.Colorlet close: () -> Voidvar body: someView {Button(action: close) {Image(systemName: "chevron.left") .font(CottonFonts.symbol(17, weight: .regular)) .foregroundStyle(ink) .frame(width: 44, height: 44) .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityLabel(ShellLines.line("cards", "reader.back")) .accessibilityIdentifier("reader-back") }}#endif