WinUI is ahead; the Swift app now draws what sicht/ precomputes instead of computing its own views: - Spielen page: live tables from sitzen.live (raster, kacheln, bereit, search, close question), "Gerade eben" from entscheidungen.feed, money from geld.anzeige - Stakes priority with tables per stake (spielplan.stufen/stufen_tische); micro_only is gone - Loss limits (deckel_einstellen), sammler in Zuschauer mode (main button becomes Sammeln starten/stoppen), "Nur offene Tische spielen", queue - Statistik: full auswertung (key figures, EV/SD curve, bb/100 by ..., history, best times, play/opponent picture, tournaments) - Small items: Spickzettel, streamer toggle, sendung_lesen, daily limits editor Intentional deviations: "highest first" compares instead of 1e15 + bb (WinUI cannot separate NL2 and NL5 there), a single table shows its tile, narrow segment pickers fall back to menus. Plan: plans/2026-11-30_swift-winui-abgleich.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
4.6 KiB
Swift
100 lines
4.6 KiB
Swift
import Foundation
|
||
import CockpitKern
|
||
import SwiftUI
|
||
|
||
/// Zuschauer (WinUI `ZuschauerTeil`): die Tische stehen in derselben Tischuebersicht wie beim Spielen; hier nur
|
||
/// der eigene Zug (sitzt der Bediener selbst) und der Abgleich gegen den Kern. Der Lauf liest nur und klickt nie.
|
||
struct ZuschauerAnsicht: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
|
||
var body: some View {
|
||
let z = cockpit.ansicht.zuschauer
|
||
let zuege = (z?.tische ?? []).compactMap(\.zug)
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
ForEach(Array(zuege.enumerated()), id: \.offset) { ZuschauerZugKarte(a: $0.element) }
|
||
if let z, !z.abgleich.isEmpty {
|
||
Abschnitt(titel: "Abgleich", hinweis: "du gegen den Kern, nur Chips") { EmptyView() }
|
||
ForEach(z.abgleich) { AbgleichZeile(a: $0) }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private struct ZuschauerZugKarte: View {
|
||
var a: ZuschauerZug
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 7) {
|
||
HStack(spacing: 6) {
|
||
HStack(spacing: 4) { ForEach(Array(a.karten.enumerated()), id: \.offset) { KarteAnsicht(code: $0.element, gross: true) } }
|
||
Spacer(minLength: 0)
|
||
if let s = a.strasse { Text(s).font(.caption2).foregroundStyle(.tertiary) }
|
||
}
|
||
if let e = a.empfehlung {
|
||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||
Text(Aktionstext.mitBetrag(e.aktion, e.betragBB)).font(.callout.weight(.semibold))
|
||
if let q = a.equity { Text("Equity \(Format.prozent(q))").font(.caption).foregroundStyle(.secondary) }
|
||
Spacer(minLength: 0)
|
||
}
|
||
if let t = e.klartext ?? e.grund, !t.isEmpty {
|
||
Text(t).font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
}
|
||
if let h = a.hinweis { Text(h).font(.caption).foregroundStyle(.secondary) }
|
||
Text(kenngroessen).font(.caption2.monospacedDigit()).foregroundStyle(.tertiary)
|
||
if !a.linien.isEmpty {
|
||
Divider()
|
||
Text("EV je Linie").font(.caption2.weight(.semibold)).foregroundStyle(.secondary)
|
||
ForEach(a.linien) { l in
|
||
HStack {
|
||
Text(Aktionstext.mitBetrag(l.aktion, l.betragBB)).font(.caption)
|
||
Spacer(minLength: 0)
|
||
Text(l.evBB.map { String(format: "%+.2f bb", $0) } ?? "–").font(.caption.monospacedDigit())
|
||
}
|
||
}
|
||
}
|
||
if !a.reads.isEmpty {
|
||
Divider()
|
||
Text("Reads").font(.caption2.weight(.semibold)).foregroundStyle(.secondary)
|
||
ForEach(a.reads) { r in
|
||
Text("Sitz \(r.sitz): \(r.einschaetzung.stilText) · \(r.einschaetzung.satz)")
|
||
.font(.caption).fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
}
|
||
}
|
||
.padding(10)
|
||
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 16, style: .continuous))
|
||
}
|
||
|
||
private var kenngroessen: String {
|
||
var teile: [String] = []
|
||
if let t = a.topfBB { teile.append(String(format: "Topf %.1f bb", t)) }
|
||
if let z = a.zuZahlenBB { teile.append(String(format: "zu zahlen %.1f bb", z)) }
|
||
if let s = a.stackBB { teile.append(String(format: "Stack %.1f bb", s)) }
|
||
if let t = a.taktS { teile.append("Takt \(Int(t)) s") }
|
||
return teile.joined(separator: " · ")
|
||
}
|
||
}
|
||
|
||
private struct AbgleichZeile: View {
|
||
var a: ZuschauerAbgleich
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 3) {
|
||
HStack {
|
||
Text(a.hand ?? "Hand").font(.caption.weight(.semibold)).lineLimit(1)
|
||
Spacer(minLength: 0)
|
||
Text(a.abweichungen == 0 ? "wie der Kern" : a.kostenBB.map { String(format: "kostet %.2f bb", $0) } ?? "")
|
||
.font(.caption.monospacedDigit()).foregroundStyle(a.abweichungen == 0 ? .green : .orange)
|
||
}
|
||
ForEach(a.zuege) { z in
|
||
Text("\(z.strasse ?? ""): du \(z.bediener ?? "?"), Kern \(z.kern ?? "?")" + (z.warum.map { " - \($0)" } ?? ""))
|
||
.font(.caption2).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
if a.unbewertet > 0 { Text("\(a.unbewertet) Züge unbewertet").font(.caption2).foregroundStyle(.tertiary) }
|
||
}
|
||
.padding(8)
|
||
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 10))
|
||
}
|
||
}
|