// The settings grammar — the grouped cards Home itself is built from.//// A card sits on the RECESSED ground (`groundMuted`) at the settings rail// (16pt), which is the one deliberate exception to the 29pt content margin.//// THE DIVIDER DIVIDES THE WORDS: it starts at the label's left edge, past the// icon column, and stops at the card's inner padding. A full-bleed rule would// cut the icons off from their own labels.importSwiftUIpublicstructSettingsCard<Content: View>: View {privatelet label: String?privatelet isPadded: Boolprivatelet content: Content @Environment(\.theme) privatevar themepublicinit(label: String? = nil, padded: Bool = false, @ViewBuilder content: () -> Content) {self.label = labelself.isPadded = paddedself.content = content() }publicvar body: someView { VStack(alignment: .leading, spacing: 8) {iflet label {// Flush with the card's left edge — no extra indent.Text(label).cottonType(.sectionLabel) } VStack(spacing: 0) { content } .padding(isPadded ? ChromeKnobs.chromeSettingsMargin : 0) .frame(maxWidth: .infinity, alignment: .leading) .background(CottonColors.groundElevated) .clipShape(RoundedRectangle(cornerRadius: SettingsCardKnobs.chromeCardRadius, style: .continuous)) } }}/// The icon column's width — the glyph plus its gap, so every label in a card/// shares one left edge whether its row has an icon or not.privatelet iconSlot: CGFloat = 36publicstructSettingsRow: View {privatelet symbol: String?privatelet label: Stringprivatelet subtitle: String?privatelet value: String?/// The value's ink. Secondary — a figure — unless the caller says/// otherwise; Home's Account row sets the owner's name in tertiary.privatelet valueInk: TextInkprivatelet showsChevron: Boolprivatelet isDestructive: Boolprivatelet isDisabled: Boolprivatelet isLast: Boolprivatelet identifier: String?privatelet action: (() -> Void)? @Environment(\.theme) privatevar themepublicinit( symbol: String? = nil, label: String, subtitle: String? = nil, value: String? = nil, valueInk: TextInk = .secondary, chevron: Bool = false, destructive: Bool = false, disabled: Bool = false, isLast: Bool = false, identifier: String? = nil, action: (() -> Void)? = nil ) {self.symbol = symbolself.label = labelself.subtitle = subtitleself.value = valueself.valueInk = valueInkself.showsChevron = chevronself.isDestructive = destructiveself.isDisabled = disabledself.isLast = isLastself.identifier = identifierself.action = action }publicvar body: someView { VStack(spacing: 0) {// The row's own name is GIVEN rather than applied from outside, so// the VALUE can carry `<id>-value`. Applied only when there is one:// setting an empty identifier would fight with a caller that still// names the row from outside, and every existing caller does.iflet identifier { button.accessibilityIdentifier(identifier) } else { button }if !isLast {Rectangle() .fill(CottonColors.hairline) .frame(height: ComposerCardKnobs.chromeHairline) .padding(.leading, ChromeKnobs.chromeSettingsMargin + (symbol == nil ? 0 : iconSlot)) .padding(.trailing, ChromeKnobs.chromeSettingsMargin) } } }privatevar button: someView {// `TravellingPress`, not a bare `Button`: a row is the full width of// the card, so a finger dragged ACROSS one never leaves its bounds and// a plain button released as a tap and opened the row. The rule and// why it takes nothing from the scroller are in `Chrome/Pressable.swift`.TravellingPress(style: OpacityButtonStyle(), action: action) { content }// Inert, and NOT a button, without a handler. .disabled(action == nil || isDisabled) .accessibilityLabel(value.map { "\(label), \($0)" } ?? label) }privatevar content: someView { HStack(spacing: 0) {iflet symbol {Image(systemName: symbol) .font(.system(size: 20))// The icon wears the ACCENT — the one interactive colour —// or the error tone. Never a per-row hue. .foregroundStyle(isDestructive ? CottonColors.statusError : CottonColors.accent) .frame(width: iconSlot, alignment: .leading) } VStack(alignment: .leading, spacing: 0) {Text(label) .cottonType(.rowTitle, ink: isDestructive ? .error : .ink, weight: .regular) .lineLimit(1)iflet subtitle {Text(subtitle).cottonType(.caption).lineLimit(1) } }Spacer(minLength: 8)iflet value {Text(value) .cottonType(.rowTitle, ink: valueInk, weight: .regular) .lineLimit(1)// `<id>-value`, so a test can read what a row STATES rather// than only that the row is there — the assertion// `settings-database-connected-ais-value` makes. .accessibilityIdentifier(identifier.map { "\($0)-value" } ?? "") }if showsChevron {Image(systemName: "chevron.right") .font(.system(size: 18)) .foregroundStyle(CottonColors.inkTertiary) .padding(.leading, 6) } } .padding(.horizontal, ChromeKnobs.chromeSettingsMargin) .padding(.vertical, 10) .frame(minHeight: 52) .opacity(isDisabled ? DisabledOpacity.control : 1) .contentShape(Rectangle()) }}/// The sizes, counts and timings SettingsCard draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumSettingsCardKnobs {staticlet chromeCardRadius: CGFloat = 24}/// The side margin every settings-style screen and row keeps: Swift's own,/// beside its first reader — a theme sets only its tokens.enumChromeKnobs {staticlet chromeSettingsMargin: CGFloat = 16}