Files
pokerfreak/mac/Sources/Cockpit/Tische.swift
T
mmintelandClaude Opus 5.5 383f125769 Mac cockpit: catch up with WinUI (server-built live views, stakes, limits, sammler, statistik)
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>
2026-11-30 09:55:51 +01:00

137 lines
6.1 KiB
Swift

import Foundation
import CockpitKern
import SwiftUI
/// : oben die Tische (Klick holt einen nach vorn), darunter was gerade geschah. Sitzt der Laeufer
/// nirgends, steht dort, was bis zum Spielen fehlt, und wie die letzte Sitzung lief.
/// Die Sitzungsleiste ganz oben (wie WinUI LiveTeil/Rust sitzungsleiste.rs): das Ergebnis gross,
/// darunter neun Kennzahlen im Dreierraster und der Abstand zum Sitzungs-Stop als Balken.
struct SitzungsleisteAnsicht: View {
var s: Sitzungsleiste
var body: some View {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 6) {
Circle().fill(s.laeuft ? Color.green : Color.secondary).frame(width: 7, height: 7)
Text(s.titel).font(.caption.weight(.semibold)).foregroundStyle(.secondary)
Spacer()
if !s.ende.isEmpty {
Text(s.ende).font(s.warn ? .caption2.weight(.semibold) : .caption2)
.foregroundStyle(s.warn ? AnyShapeStyle(Color.orange) : AnyShapeStyle(.tertiary)).lineLimit(2)
}
}
HStack(alignment: .lastTextBaseline, spacing: 8) {
Text(s.geld).font(.system(size: 30, weight: .bold, design: .rounded)).monospacedDigit()
.foregroundStyle(Farben.name(s.ton))
if !s.bb.isEmpty {
Text(s.bb).font(.callout.weight(.semibold)).monospacedDigit().foregroundStyle(Farben.name(s.ton))
}
}
// Wie WinUI: "Hände" steht im Tooltip der Tische-Zelle, nicht als eigene Zelle
let haende = s.zellen.first { $0.titel == "Hände" }
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 6), count: 3), spacing: 6) {
ForEach(Array(s.zellen.filter { $0.titel != "Hände" }.enumerated()), id: \.offset) { _, z in
VStack(alignment: .leading, spacing: 1) {
Text(z.titel).font(.caption2).foregroundStyle(.secondary).lineLimit(1)
Text(z.wert).font(.system(size: 15, weight: .semibold, design: .rounded)).monospacedDigit()
.foregroundStyle(Farben.name(z.ton)).lineLimit(1).minimumScaleFactor(0.7)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(8)
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 10))
.help(z.titel == "Tische" && haende != nil ? "\(z.titel): \(z.wert)\nHände: \(haende!.wert)" : "\(z.titel): \(z.wert)")
}
}
if let anteil = s.stoppAnteil {
VStack(alignment: .leading, spacing: 3) {
ProgressView(value: min(1, max(0, anteil))).tint(Farben.name(s.stoppTon))
Text(s.stoppText).font(.caption2).foregroundStyle(.secondary)
}
} else if !s.stoppText.isEmpty {
Text(s.stoppText).font(.caption2).foregroundStyle(.secondary)
}
}
.padding(12)
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 14))
}
}
struct Abschnitt<Rechts: View>: View {
var titel: String
var hinweis: String?
@ViewBuilder var rechts: Rechts
var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 6) {
Text(titel).font(.caption.weight(.semibold)).foregroundStyle(.secondary)
if let hinweis { Text(hinweis).font(.caption2).foregroundStyle(.tertiary) }
Spacer(minLength: 0)
rechts
}
.padding(.top, 4)
}
}
/// Ein einklappbarer Abschnitt: Kopfzeile mit Symbol und Chevron, Inhalt nur offen. Der Zustand
/// merkt sich je `schluessel` (bleibt über Neustarts). So wird die lange Seite kurz - Nebeninfos
/// liegen hinter einem Klick (Owner 7.11.: Infos hinter Expandables verstecken).
struct EinklappAbschnitt<Inhalt: View>: View {
var titel: String
var symbol: String
var hinweis: String?
var schluessel: String
@ViewBuilder var inhalt: Inhalt
@State private var offen: Bool
init(titel: String, symbol: String, hinweis: String? = nil, schluessel: String,
vorgabe: Bool = true, @ViewBuilder inhalt: () -> Inhalt) {
self.titel = titel; self.symbol = symbol; self.hinweis = hinweis; self.schluessel = schluessel
self.inhalt = inhalt()
_offen = State(initialValue: UserDefaults.standard.object(forKey: schluessel) as? Bool ?? vorgabe)
}
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Button {
offen.toggle()
UserDefaults.standard.set(offen, forKey: schluessel)
} label: {
HStack(alignment: .firstTextBaseline, spacing: 6) {
Image(systemName: symbol).font(.caption2).foregroundStyle(.secondary).frame(width: 14)
Text(titel).font(.caption.weight(.semibold)).foregroundStyle(.secondary)
if let hinweis { Text(hinweis).font(.caption2).foregroundStyle(.tertiary) }
Spacer(minLength: 0)
Image(systemName: offen ? "chevron.down" : "chevron.right")
.font(.caption2).foregroundStyle(.tertiary)
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
if offen { inhalt }
}
.padding(.top, 4)
}
}
struct Foto: View {
var url: URL
var body: some View {
AsyncImage(url: url) { bild in
bild.resizable().scaledToFit().clipShape(RoundedRectangle(cornerRadius: 8))
} placeholder: {
ProgressView().frame(maxWidth: .infinity, minHeight: 80)
}
}
}
/// Die Karte gibt beim Drücken sichtbar nach - man sieht, dass der Klick ankam.
struct KartenDruck: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.scaleEffect(configuration.isPressed ? 0.98 : 1)
.brightness(configuration.isPressed ? 0.06 : 0)
.animation(.snappy(duration: 0.12), value: configuration.isPressed)
}
}