import BaseKit import RastrilloApple import Foundation import RastrilloSnapshots import SwiftUI import XCTest /// Base's look for the screenshot gate (Task 9): the sky at its still pose, /// the three surfaces over it, the type scale and the marks, in light and /// dark (and on iPhone at AX3). `native/scripts/snapshots.sh` runs it; /// `swift test` alone skips it, because baselines match only the OS that /// drew them. The fonts are registered first, or the baselines would /// record the system face. final class LookSnapshots: XCTestCase { @MainActor func testLook() async throws { try XCTSkipUnless(ProcessInfo.processInfo.environment["RASTRILLO_SNAPSHOTS"] != nil, "Run with native/scripts/snapshots.sh") BaseFonts.register() await assertSnapshots(of: Self.catalog) await assertSnapshots(of: Self.typeCatalog) } static let tint = OficinaPalette.accent(.base) @MainActor static var catalog: SnapshotCatalog { // Nothing here holds text that grows: light and dark at the default // size only (each picture of the sky is a few hundred kilobytes). SnapshotCatalog(app: "base-look", variants: [.init(.light, .standard), .init(.dark, .standard)], settings: SnapshotSettings(tint: tint), screens: [ SnapshotScreen("sky", mac: .fixed(width: 640, height: 400), iphone: .fixed(width: 402, height: 874)) { Sky().skyFrozen() }, SnapshotScreen("surfaces", mac: .fixed(width: 720, height: 420), iphone: .fixed(width: 402, height: 760)) { ZStack { Sky(); SurfacesSample().padding(24) }.skyFrozen() }, SnapshotScreen("marks", mac: .fixed(width: 520, height: 160), iphone: .fixed(width: 402, height: 200)) { ZStack { Sky(); MarksSample().padding(20) }.skyFrozen() }, ]) } /// The type scale, at the accessibility size too. @MainActor static var typeCatalog: SnapshotCatalog { SnapshotCatalog(app: "base-type", settings: SnapshotSettings(tint: tint), screens: [ SnapshotScreen("type", mac: .fixed(width: 640, height: 560), iphone: .width(402, minHeight: 700)) { ZStack { Sky(); TypeSample().padding(20) }.skyFrozen() }, ]) } } /// Fixture words: what each surface carries in the mockups. struct SurfacesSample: View { @Environment(\.colorScheme) private var scheme var body: some View { let p = Palette(scheme) ViewThatFits(in: .horizontal) { HStack(alignment: .top, spacing: 18) { cards(p) } VStack(alignment: .leading, spacing: 18) { cards(p) } } .foregroundStyle(p[.frost]) } @ViewBuilder func cards(_ p: Palette) -> some View { card(title: "Glass", line: "The sidebar and the phone's buttons").glass(cornerRadius: 18) card(title: "Sheet", line: "The conversation, the Settings window").glassSheet(cornerRadius: 18) card(title: "Solid", line: "Menus and the job view").solid(cornerRadius: 16) } func card(title: String, line: String) -> some View { VStack(alignment: .leading, spacing: 6) { Text(verbatim: title).font(BaseFont.heading(17)) Text(verbatim: line).font(BaseFont.body(14)).foregroundStyle(Palette(scheme)[.haze]) } .padding(16) .frame(width: 200, alignment: .leading) } } struct TypeSample: View { @Environment(\.colorScheme) private var scheme var body: some View { let p = Palette(scheme) VStack(alignment: .leading, spacing: 10) { HStack(spacing: 9) { BaseMark(size: 18); Text(verbatim: "Base").font(BaseFont.heading(24)) } Text(verbatim: "Sign in to Base").font(BaseFont.heading(30, .medium, relativeTo: .largeTitle)) Text(verbatim: "Ask Base").font(BaseFont.heading(20, .medium, relativeTo: .title3)) Text(verbatim: "Christmas order form").font(BaseFont.heading(16, .semibold, relativeTo: .headline)) Text(verbatim: "Use your Oficina ID, the same one as Docs, Sheets and Calls.").font(BaseFont.body(17)) Text(verbatim: "On it. You'll see a first look in a couple of minutes, with the menu from your Sheets.").font(BaseFont.body(15)) Text(verbatim: "Bakery website ยท Building a first look").font(BaseFont.body(13.5, .semibold, relativeTo: .subheadline)) Text(verbatim: "Started 5 minutes ago").font(BaseFont.body(13, relativeTo: .footnote)).foregroundStyle(p[.haze]) } .foregroundStyle(p[.frost]) .padding(20) .frame(maxWidth: .infinity, alignment: .leading) .glassSheet(cornerRadius: 18) } } struct MarksSample: View { var body: some View { HStack(spacing: 14) { BaseMark(size: 18) ForEach(JobState.allCases, id: \.self) { StateMark($0) } } .padding(16) .glass(cornerRadius: 999) } }