Files
pokerfreak/mac/Sources/Cockpit/Ueberblick.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

74 lines
2.8 KiB
Swift

import Foundation
import CockpitKern
import SwiftUI
// Der Überblick, wenn der Laeufer nirgends sitzt: was bis zum Spielen fehlt, wie die letzte Sitzung
// lief, wo das Geld gegen die Stopps steht und was gerade geschah - als Bilder statt Tabellen.
/// Bricht Marken um, wenn die Zeile voll ist.
struct FlussLayout: Layout {
var abstand: CGFloat
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
let zeilen = anordnen(breite: proposal.width ?? .infinity, subviews)
return CGSize(width: proposal.width ?? zeilen.map(\.breite).max() ?? 0,
height: zeilen.map(\.hoehe).reduce(0, +) + abstand * CGFloat(max(0, zeilen.count - 1)))
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
var y = bounds.minY
for z in anordnen(breite: bounds.width, subviews) {
var x = bounds.minX
for i in z.teile {
let g = subviews[i].sizeThatFits(.unspecified)
subviews[i].place(at: CGPoint(x: x, y: y), proposal: .unspecified)
x += g.width + abstand
}
y += z.hoehe + abstand
}
}
private func anordnen(breite: CGFloat, _ subviews: Subviews) -> [(teile: [Int], breite: CGFloat, hoehe: CGFloat)] {
var zeilen: [(teile: [Int], breite: CGFloat, hoehe: CGFloat)] = []
for (i, s) in subviews.enumerated() {
let g = s.sizeThatFits(.unspecified)
if let letzte = zeilen.last, letzte.breite + abstand + g.width <= breite {
zeilen[zeilen.count - 1].teile.append(i)
zeilen[zeilen.count - 1].breite += abstand + g.width
zeilen[zeilen.count - 1].hoehe = max(letzte.hoehe, g.height)
} else {
zeilen.append(([i], g.width, g.height))
}
}
return zeilen
}
}
/// Eine kleine Spielkarte für Listen.
struct MiniKarte: View {
var code: String
var body: some View {
let k = Karte(code)
VStack(spacing: -2) {
Text(k?.rang ?? "?").font(.system(size: 10, weight: .bold, design: .rounded))
Text(k?.farbe.symbol ?? "").font(.system(size: 8))
}
.foregroundStyle(k?.farbe.rot == true ? Color.red : Color.black)
.frame(width: 16, height: 22)
.background(Color.white.opacity(0.92), in: RoundedRectangle(cornerRadius: 3))
}
}
/// "Heute 10:09", "Gestern 01:36", sonst Datum und Uhrzeit.
enum Tag {
static func relativ(_ t: Double) -> String {
let d = t.datum
let kal = Calendar.current
let uhr = Zeit.kurz(t)
if kal.isDateInToday(d) { return "Heute \(uhr)" }
if kal.isDateInYesterday(d) { return "Gestern \(uhr)" }
return d.formatted(.dateTime.day().month(.abbreviated)) + " \(uhr)"
}
}