Repository Public License
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Arcade9// File : Games/TrafficMayhem/TrafficViews.swift10// Description : Traffic Mayhem — SwiftUI flow: junction and mode select,11// the run screen with HUD, banners and coach marks, and the12// results recap.13// Module : Games14// Repository : https://git.spboucher.ai/orix-arcade15// Created : 2026-11-2116// Last Modified : 2026-11-2117//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author : Simon-Pierre Boucher23// Position : Professor of Finance24// Institution : Université du Québec en Outaouais (UQO)25// Department : Département des sciences administratives26// Organization : SP Boucher27//28// Website : https://spboucher.ai29// Git : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General : info@spboucher.ai36// Professional : contact@spboucher.ai37// Direct : simon@spboucher.ai38// Research : research@spboucher.ai39// Development : dev@spboucher.ai40// Support : support@spboucher.ai41// Security/Admin : admin@spboucher.ai42// Notifications : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification : Public69// Distribution : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License : Proprietary, all rights reserved (see license file)83// License File : LICENSE84// Maintainer : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import SwiftUI9293struct TrafficRunConfig: Equatable, Identifiable {94 let id = UUID()95 var layout: Int96 var mode: TrafficSim.Mode97}9899extension TrafficSim.Mode {100 var title: String { self == .endless ? "Endless" : "Rush 60s" }101 var detail: String {102 self == .endless ? "Survive as traffic builds. Three hearts; new challenges arrive one at a time."103 : "Sixty seconds of heavy traffic. Clear as many as you can."104 }105}106107struct TrafficRootView: View {108 let onExit: () -> Void109 @Environment(ArcadeServices.self) private var services110 @State private var run: TrafficRunConfig?111 @State private var layout = 0112 @State private var mode = TrafficSim.Mode.endless113 @State private var loaded = false114115 var body: some View {116 ZStack {117 if let run {118 TrafficRunView(config: run, services: services,119 onRetry: { self.run = TrafficRunConfig(layout: run.layout, mode: run.mode) },120 onMenu: { withAnimation(.easeInOut(duration: 0.25)) { self.run = nil } },121 onExit: onExit)122 .id(run.id)123 .transition(.opacity)124 } else {125 TrafficMenuView(layout: $layout, mode: $mode, onStart: start, onExit: onExit)126 .transition(.opacity)127 }128 }129 .onAppear {130 guard !loaded else { return }131 loaded = true132 let save = services.save.traffic133 layout = save.isUnlocked(save.lastLayout) ? save.lastLayout : 0134 mode = TrafficSim.Mode(rawValue: save.lastMode) ?? .endless135 // `-ORIXLayout N -ORIXMode endless|rush` starts a run straight away (screenshots, soak and performance runs).136 if LaunchOptions.game == .trafficMayhem, let forced = LaunchOptions.int("Layout") {137 layout = forced.clamped(0, TrafficLayout.all.count - 1)138 mode = LaunchOptions.string("Mode").flatMap(TrafficSim.Mode.init(rawValue:)) ?? .endless139 run = TrafficRunConfig(layout: layout, mode: mode)140 }141 }142 .onChange(of: run) { _, value in143 services.setResumeNote(value.map { "\(TrafficLayout.layout($0.layout).name) · \($0.mode.title)" })144 }145 }146147 private func start() {148 guard services.save.traffic.isUnlocked(layout) else { return }149 services.audio.play(.confirm)150 withAnimation(.easeInOut(duration: 0.25)) { run = TrafficRunConfig(layout: layout, mode: mode) }151 }152}153154// MARK: - Menu155156struct TrafficMenuView: View {157 @Binding var layout: Int158 @Binding var mode: TrafficSim.Mode159 let onStart: () -> Void160 let onExit: () -> Void161 @Environment(ArcadeServices.self) private var services162163 var body: some View {164 let save = services.save.traffic165 ZStack {166 AuroraBackground(theme: .traffic)167 VStack(spacing: 0) {168 HStack(spacing: OrixSpace.sm) {169 OrixIconButton(systemImage: "chevron.left", label: "Back to arcade", action: onExit)170 .accessibilityIdentifier("traffic-back")171 VStack(alignment: .leading, spacing: 1) {172 Text("Traffic Mayhem").font(OrixFont.title).foregroundStyle(OrixColor.textPrimary)173 Text(save.runs == 0 ? "Tap to send. Hold to preview." : "\(save.totalCleared.formatted()) vehicles cleared · \(save.runs) runs")174 .font(OrixFont.caption).foregroundStyle(OrixColor.textSecondary)175 }176 Spacer()177 }178 .padding(.horizontal, OrixSpace.md)179 .padding(.top, OrixSpace.xs)180 .padding(.bottom, OrixSpace.sm)181182 ScrollView {183 VStack(alignment: .leading, spacing: OrixSpace.md) {184 VStack(alignment: .leading, spacing: OrixSpace.xs) {185 SectionHeader(title: "Mode")186 HStack(spacing: 4) {187 ForEach(TrafficSim.Mode.allCases, id: \.self) { option in188 let selected = option == mode189 Button {190 services.feedbackTap()191 withAnimation(OrixMotion.snappy) { mode = option }192 } label: {193 Label(option.title, systemImage: option == .endless ? "infinity" : "timer")194 .font(OrixFont.callout.weight(.heavy))195 .foregroundStyle(selected ? OrixColor.ink : OrixColor.textSecondary)196 .frame(maxWidth: .infinity, minHeight: 46)197 .background(selected ? AnyShapeStyle(GameTheme.traffic.gradient) : AnyShapeStyle(Color.clear), in: Capsule())198 .contentShape(Capsule())199 }200 .buttonStyle(.plain)201 .accessibilityAddTraits(selected ? .isSelected : [])202 .accessibilityIdentifier("traffic-mode-\(option.rawValue)")203 }204 }205 .padding(4)206 .background(Color.white.opacity(0.07), in: Capsule())207 .overlay(Capsule().strokeBorder(OrixColor.stroke, lineWidth: 1))208 Text(mode.detail).font(OrixFont.caption).foregroundStyle(OrixColor.textSecondary)209 .fixedSize(horizontal: false, vertical: true)210 }211212 VStack(alignment: .leading, spacing: OrixSpace.sm) {213 SectionHeader(title: "Junction", trailing: "\(save.unlockedCount) of \(TrafficLayout.all.count) open")214 ForEach(TrafficLayout.all, id: \.id) { item in215 TrafficJunctionCard(layout: item, save: save, mode: mode, selected: item.id == layout) {216 if save.isUnlocked(item.id) {217 services.feedbackTap()218 withAnimation(OrixMotion.snappy) { layout = item.id }219 } else {220 services.haptics.play(.warning)221 services.audio.play(.back)222 }223 }224 }225 }226227 VStack(alignment: .leading, spacing: OrixSpace.xs) {228 SectionHeader(title: "How to play")229 tip("hand.tap.fill", "Tap a waiting vehicle to send it. Once it goes, it does not stop.")230 tip("hand.point.up.left.fill", "Hold to preview its path: green is clear, red means a crash. Slide away to cancel.")231 tip("heart.fill", "Three hearts. A crash or a driver who runs out of patience costs one.")232 tip("flame.fill", "Safe crossings build a streak, up to ×5. Close calls pay a bonus.")233 }234 .glassPanel(tint: GameTheme.traffic.primary)235 }236 .padding(.horizontal, OrixSpace.md)237 .padding(.bottom, OrixSpace.lg)238 }239 .scrollIndicators(.hidden)240241 OrixButton(title: "Start · \(TrafficLayout.layout(layout).name)", systemImage: "play.fill", theme: .traffic, action: onStart)242 .accessibilityIdentifier("traffic-start")243 .padding(.horizontal, OrixSpace.md)244 .padding(.top, OrixSpace.xs)245 .padding(.bottom, OrixSpace.xs)246 }247 }248 }249250 private func tip(_ symbol: String, _ text: String) -> some View {251 HStack(alignment: .top, spacing: OrixSpace.sm) {252 Image(systemName: symbol).font(.system(size: 14, weight: .bold)).foregroundStyle(GameTheme.traffic.primary).frame(width: 22)253 Text(text).font(OrixFont.caption).foregroundStyle(OrixColor.textSecondary).fixedSize(horizontal: false, vertical: true)254 }255 .accessibilityElement(children: .combine)256 }257}258259struct TrafficJunctionCard: View {260 let layout: TrafficLayout261 let save: TrafficSave262 let mode: TrafficSim.Mode263 let selected: Bool264 let action: () -> Void265266 var body: some View {267 let unlocked = save.isUnlocked(layout.id)268 let best = save.best(layout: layout.id, mode: mode)269 Button(action: action) {270 HStack(spacing: OrixSpace.sm) {271 TrafficMiniMap(layout: layout)272 .frame(width: 92, height: 112)273 .clipShape(RoundedRectangle(cornerRadius: OrixRadius.md, style: .continuous))274 .overlay(RoundedRectangle(cornerRadius: OrixRadius.md, style: .continuous).strokeBorder(OrixColor.stroke, lineWidth: 1))275 .saturation(unlocked ? 1 : 0.2)276 .opacity(unlocked ? 1 : 0.55)277 .overlay {278 if !unlocked {279 Image(systemName: "lock.fill").font(.system(size: 22, weight: .bold)).foregroundStyle(OrixColor.textPrimary)280 .padding(12).background(.ultraThinMaterial, in: Circle())281 }282 }283 VStack(alignment: .leading, spacing: 6) {284 Text(layout.name).font(OrixFont.headline).foregroundStyle(OrixColor.textPrimary)285 Text(layout.blurb).font(OrixFont.caption).foregroundStyle(OrixColor.textSecondary)286 .fixedSize(horizontal: false, vertical: true)287 if unlocked {288 HStack(spacing: 6) {289 OrixChip(text: best > 0 ? "BEST \(best.formatted())" : "NO SCORE YET", systemImage: best > 0 ? "trophy.fill" : nil,290 tint: best > 0 ? OrixColor.gold : OrixColor.textSecondary)291 OrixChip(text: "\(layout.controlledLanes.count) LANES", tint: GameTheme.traffic.primary)292 }293 } else {294 let previous = TrafficLayout.layout(layout.id - 1)295 let progress = save.bestCleared(layout: previous.id)296 Text("Clear \(layout.unlockCleared) vehicles in one run at \(previous.name).")297 .font(OrixFont.caption).foregroundStyle(OrixColor.gold).fixedSize(horizontal: false, vertical: true)298 HStack(spacing: OrixSpace.xs) {299 OrixProgressBar(fraction: Double(progress) / Double(layout.unlockCleared), theme: .traffic)300 Text("\(min(progress, layout.unlockCleared))/\(layout.unlockCleared)").font(OrixFont.overline).foregroundStyle(OrixColor.textTertiary)301 }302 }303 }304 Spacer(minLength: 0)305 if selected {306 Image(systemName: "checkmark.circle.fill").font(.system(size: 22)).foregroundStyle(GameTheme.traffic.gradient)307 }308 }309 .padding(OrixSpace.sm)310 .background(OrixColor.surface.opacity(selected ? 0.95 : 0.7), in: RoundedRectangle(cornerRadius: OrixRadius.lg, style: .continuous))311 .overlay(312 RoundedRectangle(cornerRadius: OrixRadius.lg, style: .continuous)313 .strokeBorder(selected ? AnyShapeStyle(GameTheme.traffic.gradient) : AnyShapeStyle(OrixColor.stroke), lineWidth: selected ? 2 : 1)314 )315 }316 .buttonStyle(OrixPressStyle())317 .accessibilityElement(children: .ignore)318 .accessibilityLabel(unlocked ? "\(layout.name). \(layout.blurb) \(best > 0 ? "Best \(best)" : "No score yet")"319 : "\(layout.name), locked. Clear \(layout.unlockCleared) vehicles in one run at \(TrafficLayout.layout(layout.id - 1).name).")320 .accessibilityAddTraits(selected ? [.isButton, .isSelected] : .isButton)321 .accessibilityIdentifier("traffic-layout-\(layout.id)")322 }323}324325/// A small map drawn from the real layout data, so each card shows the junction you will actually play.326struct TrafficMiniMap: View {327 let layout: TrafficLayout328329 var body: some View {330 Canvas { context, size in331 context.fill(Path(CGRect(origin: .zero, size: size)), with: .color(Color(hex: 0x0E1430)))332 let s = min(size.width / 300, size.height / 380)333 func p(_ v: Vec2) -> CGPoint {334 CGPoint(x: size.width / 2 + (v.x - layout.focus.x) * s, y: size.height / 2 - (v.y - layout.focus.y) * s)335 }336 func rect(_ r: TrafficRect) -> CGRect {337 let a = p(Vec2(x: r.minX, y: r.maxY)), b = p(Vec2(x: r.maxX, y: r.minY))338 return CGRect(x: a.x, y: a.y, width: b.x - a.x, height: b.y - a.y)339 }340 // Blocks.341 var rng = SeededRNG(seed: UInt64(layout.id) + 40)342 for ix in -4...4 {343 for iy in -5...5 {344 let block = TrafficRect(minX: Double(ix) * 44 - 19, minY: Double(iy) * 44 - 19 + layout.focus.y, maxX: Double(ix) * 44 + 19, maxY: Double(iy) * 44 + 19 + layout.focus.y)345 let colors: [UInt32] = [0x27336B, 0x35307A, 0x1F4A6B, 0x17423A]346 let color = colors[rng.int(in: 0...3)]347 if layout.roads.contains(where: { $0.expanded(6).intersects(block) }) { continue }348 context.fill(Path(roundedRect: rect(block), cornerRadius: 3), with: .color(Color(hex: color)))349 }350 }351 for road in layout.roads { context.fill(Path(rect(road)), with: .color(Color(hex: 0x1C2242))) }352 for marking in layout.markings where marking.kind == .centerLine || marking.kind == .laneDash {353 var line = Path()354 line.move(to: p(marking.from))355 line.addLine(to: p(marking.to))356 context.stroke(line, with: .color(Color(hex: 0xFFC94D, opacity: 0.6)), style: StrokeStyle(lineWidth: 1, dash: [3, 3]))357 }358 // One car per lane, waiting at its stop line (or cruising, for through traffic).359 for lane in layout.lanes {360 let path = layout.paths[lane.paths[0]]361 let s0 = lane.autonomous ? path.exitS - 150 - Double(lane.id) * 40 : path.stopS - 16362 let heading = path.heading(at: s0)363 var car = context364 let c = p(path.point(at: s0))365 car.translateBy(x: c.x, y: c.y)366 car.rotate(by: .radians(-heading))367 let color = lane.autonomous ? 0xEDEFFF : TrafficArt.palette[lane.id % TrafficArt.palette.count]368 car.fill(Path(roundedRect: CGRect(x: -6, y: -3.4, width: 12, height: 6.8), cornerRadius: 2), with: .color(Color(hex: color)))369 }370 }371 .accessibilityHidden(true)372 }373}374375// MARK: - Run376377struct TrafficRunView: View {378 let config: TrafficRunConfig379 let services: ArcadeServices380 let onRetry: () -> Void381 let onMenu: () -> Void382 let onExit: () -> Void383384 @State private var model = TrafficRunModel()385 @State private var scene: TrafficScene?386 @State private var paused = false387 @State private var outcome: (summary: TrafficRunSummary, isRecord: Bool, unlocked: Int?)?388 @State private var banner: (id: Int, title: String, detail: String)?389 @State private var flashOpacity = 0.0390391 private var layout: TrafficLayout { TrafficLayout.layout(config.layout) }392393 var body: some View {394 GameChrome(theme: .traffic, title: "Traffic Mayhem", isPaused: $paused, canPause: outcome == nil,395 pauseDetail: "\(layout.name) · \(config.mode.title)",396 onRestart: { abandon(); onRetry() },397 onExit: { abandon(); onExit() }) {398 ZStack {399 Color(hex: 0x0B1022).ignoresSafeArea()400 if let scene { GameSceneView(scene: scene, isPaused: paused) }401 Color(hex: OrixColor.Hex.danger).opacity(flashOpacity).ignoresSafeArea().allowsHitTesting(false)402 VStack(spacing: OrixSpace.xs) {403 TrafficHUD(model: model, leftHanded: services.settings.leftHanded)404 if let banner {405 VStack(spacing: 2) {406 Text("NEW · \(banner.title.uppercased())").font(OrixFont.overline).tracking(1.6).foregroundStyle(GameTheme.traffic.primary)407 Text(banner.detail).font(OrixFont.callout).foregroundStyle(OrixColor.textPrimary).multilineTextAlignment(.center)408 }409 .padding(.horizontal, OrixSpace.md)410 .padding(.vertical, OrixSpace.xs)411 .background(Color.black.opacity(0.72), in: RoundedRectangle(cornerRadius: OrixRadius.md, style: .continuous))412 .overlay(RoundedRectangle(cornerRadius: OrixRadius.md, style: .continuous).strokeBorder(GameTheme.traffic.primary.opacity(0.5), lineWidth: 1))413 .transition(.move(edge: .top).combined(with: .opacity))414 .accessibilityElement(children: .combine)415 .accessibilityIdentifier("traffic-banner")416 }417 Spacer()418 if let coach = model.coach, outcome == nil {419 CoachMark(text: coach, systemImage: "hand.tap.fill", theme: .traffic)420 .padding(.bottom, OrixSpace.lg)421 .transition(.opacity)422 .id(coach)423 }424 }425 .padding(.horizontal, OrixSpace.sm)426 .padding(.top, 6)427 .allowsHitTesting(false)428429 if let outcome { results(outcome) }430 }431 }432 .onAppear(perform: makeScene)433 .onChange(of: model.banner?.id) { _, _ in showBanner() }434 .onChange(of: model.flash) { _, _ in435 guard !OrixAppearance.reduceMotion else { return }436 flashOpacity = 0.32437 withAnimation(.easeOut(duration: 0.5)) { flashOpacity = 0 }438 }439 .animation(OrixMotion.decorative(OrixMotion.snappy), value: model.coach)440 }441442 private func makeScene() {443 guard scene == nil else { return }444 let tutorial = !services.save.traffic.tutorialDone && !LaunchOptions.autoplay445 let services = services446 scene = TrafficScene(services: services, layout: layout, mode: config.mode,447 seed: LaunchOptions.seed ?? UInt64.random(in: 1...UInt64.max / 2), tutorial: tutorial, model: model,448 onTutorialDone: { services.store.update { $0.traffic.tutorialDone = true } },449 onFinished: finish)450 }451452 private func showBanner() {453 guard let next = model.banner else { return }454 withAnimation(OrixMotion.decorative(OrixMotion.bouncy)) { banner = next }455 Task {456 try? await Task.sleep(for: .seconds(3))457 if banner?.id == next.id { withAnimation(.easeOut(duration: 0.3)) { banner = nil } }458 }459 }460461 /// Leaving mid-run from the pause menu still counts the time played.462 private func abandon() {463 guard outcome == nil, let scene else { return }464 services.addPlayTime(game: .trafficMayhem, duration: scene.sim.elapsed)465 }466467 private func finish(_ summary: TrafficRunSummary) {468 var recorded: (isRecord: Bool, unlocked: Int?) = (false, nil)469 services.store.update { recorded = $0.traffic.record(layout: summary.layout, mode: summary.mode, score: summary.finalScore, cleared: summary.cleared) }470 let isRecord = recorded.isRecord && summary.cleared > 0471 if summary.mode == .rush, summary.finalScore >= TrafficMayhemGame.rushAchievementScore { services.unlock("traffic.rush") }472 if services.save.traffic.unlockedCount == TrafficLayout.all.count { services.unlock("traffic.all") }473 services.recordSession(game: .trafficMayhem, score: summary.finalScore, duration: summary.duration,474 headline: "\(layout.name) · \(summary.cleared) cleared", isRecord: isRecord)475 withAnimation(OrixMotion.decorative(OrixMotion.snappy)) { outcome = (summary, isRecord, recorded.unlocked) }476 }477478 private func results(_ outcome: (summary: TrafficRunSummary, isRecord: Bool, unlocked: Int?)) -> some View {479 let s = outcome.summary480 let timeUp = s.reason == .timeUp481 var rows = [482 ResultRow(label: "Vehicles cleared", value: "\(s.cleared)", systemImage: "car.fill"),483 ResultRow(label: "Best streak", value: "\(s.bestStreak)", systemImage: "flame.fill"),484 ResultRow(label: "Close calls", value: "\(s.closeCalls)", systemImage: "exclamationmark.triangle.fill"),485 ]486 if s.mode == .endless {487 rows.append(ResultRow(label: "Survived \(Int(s.duration) / 60):\(String(format: "%02d", Int(s.duration) % 60))", value: "+\(s.survivalBonus)", systemImage: "clock.fill"))488 }489 let subtitle: String490 if let unlocked = outcome.unlocked {491 subtitle = "New junction unlocked: \(TrafficLayout.layout(unlocked).name)!"492 } else {493 subtitle = timeUp ? "\(layout.name) · Rush complete" : "\(layout.name) · out of hearts"494 }495 return ResultsCard(theme: .traffic, title: timeUp ? "Time!" : "Gridlock!", subtitle: subtitle, score: s.finalScore,496 isNewRecord: outcome.isRecord, success: timeUp, rows: rows,497 primaryTitle: "Retry", onPrimary: onRetry,498 secondaryTitle: "Junctions", secondaryIcon: "map.fill", onSecondary: onMenu, onExit: onExit)499 }500}501502struct TrafficHUD: View {503 let model: TrafficRunModel504 let leftHanded: Bool505506 var body: some View {507 VStack(alignment: leftHanded ? .trailing : .leading, spacing: 6) {508 HStack(spacing: 6) {509 if leftHanded { Spacer(minLength: 60) }510 HStack(spacing: 4) {511 ForEach(0..<TrafficSim.startHearts, id: \.self) { index in512 Image(systemName: index < model.hearts ? "heart.fill" : "heart")513 .font(.system(size: 14, weight: .black))514 .foregroundStyle(index < model.hearts ? OrixColor.danger : OrixColor.textTertiary)515 }516 }517 .padding(.horizontal, 12)518 .frame(minHeight: 36)519 .background(Color.black.opacity(0.5), in: Capsule())520 .overlay(Capsule().strokeBorder(OrixColor.danger.opacity(0.35), lineWidth: 1))521 .accessibilityElement(children: .ignore)522 .accessibilityLabel("Hearts")523 .accessibilityValue("\(model.hearts) of \(TrafficSim.startHearts)")524 HUDPill(systemImage: "star.fill", text: model.score.formatted(), tint: OrixColor.gold, label: "Score")525 .accessibilityIdentifier("traffic-score")526 if let seconds = model.secondsLeft {527 HUDPill(systemImage: "timer", text: "\(seconds)", tint: seconds <= 10 ? OrixColor.danger : GameTheme.traffic.primary, label: "Seconds left")528 }529 if !leftHanded { Spacer(minLength: 60) }530 }531 HStack(spacing: 6) {532 Text("×\(model.multiplier)").font(OrixFont.hud(15)).foregroundStyle(model.multiplier > 1 ? OrixColor.ink : OrixColor.textPrimary)533 .padding(.horizontal, 8).frame(minHeight: 24)534 .background(model.multiplier > 1 ? AnyShapeStyle(GameTheme.traffic.gradient) : AnyShapeStyle(Color.white.opacity(0.12)), in: Capsule())535 HStack(spacing: 3) {536 ForEach(0..<5, id: \.self) { index in537 Capsule().fill(model.multiplier >= 5 || index < model.streak % 5 ? GameTheme.traffic.primary : Color.white.opacity(0.18))538 .frame(width: 9, height: 5)539 }540 }541 Text("streak \(model.streak)").font(OrixFont.overline).foregroundStyle(OrixColor.textSecondary)542 }543 .padding(.horizontal, 8)544 .frame(minHeight: 30)545 .background(Color.black.opacity(0.5), in: Capsule())546 .accessibilityElement(children: .ignore)547 .accessibilityLabel("Streak \(model.streak), multiplier \(model.multiplier)")548 }549 .frame(maxWidth: .infinity, alignment: leftHanded ? .trailing : .leading)550 .animation(OrixMotion.decorative(OrixMotion.snappy), value: model.multiplier)551 .animation(OrixMotion.decorative(OrixMotion.snappy), value: model.hearts)552 }553}554