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>
71 lines
3.4 KiB
Swift
71 lines
3.4 KiB
Swift
import Foundation
|
|
import CockpitKern
|
|
import SwiftUI
|
|
|
|
/// Übung | Cash als Kapsel - Cash nur nach Rückfrage, dann wird das ganze Cockpit rot.
|
|
struct ModusSchalter: View {
|
|
@Environment(Cockpit.self) private var cockpit
|
|
|
|
var body: some View {
|
|
let zuschauen = cockpit.zuschauen
|
|
let cash = cockpit.wahl.cash && !zuschauen
|
|
let trainer = cockpit.reiter == .trainer
|
|
let gesperrt = cockpit.laeuft == true || cockpit.verbindung != .verbunden
|
|
HStack(spacing: 0) {
|
|
// Auf der Trainer-Seite fuehren die drei zurueck zum Spielen (und waehlen, wenn erlaubt, den Modus)
|
|
teil("Zuschauer", an: zuschauen && !trainer, farbe: .teal, aus: gesperrt) { waehlen { cockpit.zuschauenWaehlen() } }
|
|
teil("Übung", an: !cash && !zuschauen && !trainer, farbe: .blue, aus: gesperrt) { waehlen { cockpit.modusWaehlen(cash: false) } }
|
|
teil("Echtgeld", an: cash && !trainer, farbe: .red, aus: gesperrt) { waehlen { cockpit.modusWaehlen(cash: true) } }
|
|
// Trainer (Owner 24.11.: "nach oben"): oeffnet nur seine Seite, schaltet am Laeufer nichts um
|
|
teil("Trainer", an: trainer, farbe: .indigo, aus: false) { cockpit.reiter = .trainer }
|
|
}
|
|
.padding(3)
|
|
.background(.white.opacity(0.07), in: Capsule())
|
|
.animation(.snappy, value: cash)
|
|
.animation(.snappy, value: zuschauen)
|
|
.help(cockpit.laeuft == true ? "Erst aufhören, dann den Modus wechseln"
|
|
: "Zuschauer: liest nur, klickt nie · Übung: Claim Chips · Echtgeld: Geld · Trainer: selbst üben an der Bühne")
|
|
}
|
|
|
|
private func waehlen(_ tun: () -> Void) {
|
|
let warTrainer = cockpit.reiter == .trainer
|
|
cockpit.reiter = .cash
|
|
if !warTrainer || (cockpit.laeuft != true && cockpit.verbindung == .verbunden) { tun() }
|
|
}
|
|
|
|
private func teil(_ titel: String, an: Bool, farbe: Color, aus: Bool, _ tun: @escaping () -> Void) -> some View {
|
|
Button(action: tun) {
|
|
Text(titel).font(.callout.weight(.semibold)).lineLimit(1).minimumScaleFactor(0.8)
|
|
.frame(maxWidth: .infinity).padding(.vertical, 6)
|
|
.foregroundStyle(an ? .white : .secondary)
|
|
.background(an ? farbe.gradient : Color.clear.gradient, in: Capsule())
|
|
.contentShape(Capsule())
|
|
}
|
|
.buttonStyle(.plain)
|
|
.disabled(aus && cockpit.reiter != .trainer)
|
|
}
|
|
}
|
|
|
|
/// Cash einschalten nur bewusst: wer tippt, liest einmal, was das heisst.
|
|
struct LiveFrage: View {
|
|
@Environment(Cockpit.self) private var cockpit
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Label("Echtgeld heißt echtes Geld", systemImage: "exclamationmark.triangle.fill")
|
|
.font(.callout.weight(.semibold)).foregroundStyle(.red)
|
|
Text("Der Läufer öffnet selbst Tische und setzt Geld.")
|
|
.font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
|
HStack {
|
|
Button("Abbrechen") { cockpit.cashFragen = false }
|
|
Spacer()
|
|
Button("Echtgeld einschalten") { cockpit.cashBestaetigen() }
|
|
.buttonStyle(.borderedProminent).tint(.red)
|
|
}
|
|
.controlSize(.small)
|
|
}
|
|
.padding(10)
|
|
.background(.red.opacity(0.12), in: RoundedRectangle(cornerRadius: 12))
|
|
}
|
|
}
|