Die App ist die scharfe Schicht (Bedienkonsole des Laufs) - und sie hat es erzaehlt: Menuepunkt 'Klon statt echtem Client', 'Cash heisst Echtgeld', 'Der Bot oeffnet selbst Cash-Tische und setzt echtes Geld ein.', Abzeichen 'Spielgeld/Echtgeld', '(nur Live)'. Jetzt spricht sie mechanisch: Uebung, Cash, Geld, Chips, Tisch, Laeufer, Klon, Client, Not-Aus. swift build laeuft, swift run Pruefung 132 gruen. Die installierte App zeigt die alten Woerter noch, bis sie neu gebaut und installiert wird.
222 lines
9.7 KiB
Swift
222 lines
9.7 KiB
Swift
import CockpitKern
|
||
import SwiftUI
|
||
|
||
struct EntscheidungenAnsicht: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
@State private var filter = EntscheidungsFilter()
|
||
@State private var offen: String?
|
||
|
||
var body: some View {
|
||
let e = cockpit.ansicht.entscheidungen
|
||
let alle = e?.zeilen ?? []
|
||
let treffer = filter.anwenden(alle)
|
||
VStack(spacing: 0) {
|
||
VStack(spacing: 6) {
|
||
TextField("Suchen: Grund, Karten, Hand, Tisch", text: $filter.suche)
|
||
.textFieldStyle(.roundedBorder)
|
||
HStack(spacing: 6) {
|
||
Auswahl(titel: "Aktion", werte: e?.facetten?.aktion ?? [], wahl: $filter.aktion)
|
||
Auswahl(titel: "Stake", werte: e?.facetten?.stake ?? [], wahl: $filter.stake)
|
||
Auswahl(titel: "Spiel", werte: e?.facetten?.spielart ?? [], wahl: $filter.spielart)
|
||
Menu(filter.ergebnis?.rawValue.capitalized ?? "Ergebnis") {
|
||
Button("alle") { filter.ergebnis = nil }
|
||
ForEach(ErgebnisFilter.allCases, id: \.self) { x in Button(x.rawValue) { filter.ergebnis = x } }
|
||
}
|
||
.fixedSize()
|
||
Spacer(minLength: 0)
|
||
if !filter.istLeer { Button("Zurücksetzen") { filter = EntscheidungsFilter() }.buttonStyle(.link) }
|
||
}
|
||
.controlSize(.small)
|
||
Text(zaehler(e, treffer.count)).font(.caption2).foregroundStyle(.secondary)
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
.padding(12)
|
||
Divider()
|
||
if alle.isEmpty {
|
||
Leer(titel: "Noch keine Entscheidungen", text: e?.leer ?? "Sobald der Kern entscheidet, steht es hier.")
|
||
} else {
|
||
List(treffer) { z in
|
||
EntscheidungsZeileAnsicht(z: z, offen: offen == z.id)
|
||
.contentShape(Rectangle())
|
||
.onTapGesture { withAnimation(.snappy) { offen = offen == z.id ? nil : z.id } }
|
||
}
|
||
.scrollContentBackground(.hidden)
|
||
}
|
||
}
|
||
}
|
||
|
||
private func zaehler(_ e: Entscheidungen?, _ n: Int) -> String {
|
||
let da = e?.zeilen.count ?? 0
|
||
var t = n == da ? "\(da) Entscheidungen" : "\(n) von \(da) passen"
|
||
if let h = e?.hinweis { t += " · " + h }
|
||
return t
|
||
}
|
||
}
|
||
|
||
private struct Auswahl: View {
|
||
var titel: String
|
||
var werte: [String]
|
||
@Binding var wahl: String?
|
||
|
||
var body: some View {
|
||
Menu(wahl ?? titel) {
|
||
Button("alle") { wahl = nil }
|
||
ForEach(werte, id: \.self) { w in Button(w) { wahl = w } }
|
||
}
|
||
.fixedSize()
|
||
.disabled(werte.isEmpty)
|
||
}
|
||
}
|
||
|
||
struct EntscheidungsZeileAnsicht: View {
|
||
var z: EntscheidungsZeile
|
||
var offen: Bool
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 5) {
|
||
HStack(spacing: 6) {
|
||
Text(Zeit.uhr(z.zeit)).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
|
||
Text(z.strasse ?? "").font(.caption).foregroundStyle(.secondary)
|
||
Text(Aktionstext.mitBetrag(z.aktionText ?? z.aktion, z.betragBB))
|
||
.font(.callout.weight(.semibold))
|
||
Spacer(minLength: 0)
|
||
if let x = z.ergebnisBB { Text(Format.vorzeichen(x) + " bb").font(.caption.monospacedDigit()).foregroundStyle(Farben.ergebnis(x)) }
|
||
KlickSymbol(status: z.klick, warum: z.klickWarum)
|
||
}
|
||
HStack(spacing: 6) {
|
||
if !z.karten.isEmpty { Kartenzeile(karten: z.karten, board: z.board) }
|
||
Text(z.klartext ?? z.grund ?? "").font(.caption).foregroundStyle(.secondary).lineLimit(offen ? nil : 2)
|
||
}
|
||
if offen, let m = z.modus {
|
||
// Cash steht schon unter Stake; Turnier und K-Poker brauchen die ganze Lage
|
||
if case .cash = m {} else { ModusLeiste(modus: m) }
|
||
}
|
||
if offen {
|
||
Grid(alignment: .leading, horizontalSpacing: 10, verticalSpacing: 3) {
|
||
zeile("Tisch", z.raum ?? "–")
|
||
zeile("Hand", z.hand ?? "–")
|
||
zeile("Stake", [z.stake, z.spielart].compactMap { $0 }.joined(separator: " · "))
|
||
zeile("Equity", Format.prozent(z.equity))
|
||
zeile("Confidence", Format.zahl(z.confidence))
|
||
zeile("Gedenkzeit", z.gedenkzeitS.map { Format.zahl($0, stellen: 1) + " s" } ?? "–")
|
||
zeile("Ergebnis", z.ergebnisText ?? "–")
|
||
zeile("Klick", [z.klick, z.klickWarum].compactMap { $0 }.filter { !$0.isEmpty }.joined(separator: " - "))
|
||
if let b = z.beleg, !b.isEmpty { zeile("Beleg", b) }
|
||
if let g = z.grund, g != z.klartext { zeile("Grund", g) }
|
||
}
|
||
.font(.caption)
|
||
.textSelection(.enabled)
|
||
.padding(.top, 4)
|
||
}
|
||
}
|
||
.padding(.vertical, 3)
|
||
}
|
||
|
||
private func zeile(_ a: String, _ b: String) -> some View {
|
||
GridRow {
|
||
Text(a).foregroundStyle(.secondary)
|
||
Text(b.isEmpty ? "–" : b)
|
||
}
|
||
}
|
||
}
|
||
|
||
struct GeldAnsicht: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
@State private var art: String?
|
||
|
||
var body: some View {
|
||
let g = cockpit.ansicht.geld
|
||
let arten = Array(Set((g?.zeilen ?? []).compactMap(\.art))).sorted()
|
||
let zeilen = (g?.zeilen ?? []).filter { art == nil || $0.art == art }
|
||
VStack(spacing: 0) {
|
||
HStack {
|
||
Picker("Art", selection: $art) {
|
||
Text("alle").tag(String?.none)
|
||
ForEach(arten, id: \.self) { Text($0).tag(String?.some($0)) }
|
||
}
|
||
.fixedSize()
|
||
Spacer()
|
||
if g?.uebung == true { Abzeichen(text: "ÜBUNG", farbe: .blue) }
|
||
}
|
||
.controlSize(.small)
|
||
.padding(12)
|
||
Divider()
|
||
if zeilen.isEmpty {
|
||
Leer(titel: "Keine Geldbewegungen", text: g?.leer ?? "Buy-in, Nachkauf und Aufstehen erscheinen hier.")
|
||
} else {
|
||
List(zeilen) { z in
|
||
VStack(alignment: .leading, spacing: 3) {
|
||
HStack {
|
||
Text(Zeit.uhr(z.zeit)).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
|
||
Text(z.art ?? "–").font(.callout.weight(.semibold))
|
||
if z.uebung == true { Abzeichen(text: "Übung", farbe: .blue) }
|
||
Spacer()
|
||
if let b = z.betrag { Text(Format.zahl(b)).font(.callout.monospacedDigit()) }
|
||
if let b = z.betragBB { Text("\(Format.zahl(b)) bb").font(.caption).foregroundStyle(.secondary) }
|
||
}
|
||
Text([z.raum, z.grund].compactMap { $0 }.filter { !$0.isEmpty }.joined(separator: " · "))
|
||
.font(.caption).foregroundStyle(.secondary).textSelection(.enabled)
|
||
}
|
||
.opacity(z.uebung == true ? 0.75 : 1)
|
||
}
|
||
.scrollContentBackground(.hidden)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
struct ProtokollAnsicht: View {
|
||
enum Teil: String, CaseIterable { case gedanken = "Gedanken", ereignisse = "Ereignisse", geld = "Geld" }
|
||
@Environment(Cockpit.self) private var cockpit
|
||
@AppStorage("protokoll.teil") private var teil: Teil = .gedanken
|
||
@State private var pause: Ticker?
|
||
|
||
var body: some View {
|
||
let t = pause ?? cockpit.ansicht.ticker
|
||
VStack(spacing: 0) {
|
||
HStack {
|
||
Picker("", selection: $teil) { ForEach(Teil.allCases, id: \.self) { Text($0.rawValue) } }
|
||
.pickerStyle(.segmented).labelsHidden()
|
||
if teil != .geld {
|
||
Toggle(isOn: Binding(get: { pause != nil }, set: { pause = $0 ? cockpit.ansicht.ticker : nil })) {
|
||
Image(systemName: "pause")
|
||
}
|
||
.toggleStyle(.button).help("Anhalten zum Lesen")
|
||
}
|
||
}
|
||
.controlSize(.small)
|
||
.padding(12)
|
||
Divider()
|
||
if teil == .geld {
|
||
GeldAnsicht()
|
||
} else {
|
||
ScrollView {
|
||
LazyVStack(alignment: .leading, spacing: 6) {
|
||
if teil == .gedanken {
|
||
ForEach(Array((t?.gedanken ?? []).enumerated()), id: \.offset) { _, g in
|
||
Text(g).font(.system(.caption, design: .monospaced)).textSelection(.enabled)
|
||
}
|
||
} else {
|
||
ForEach(t?.zeilen ?? []) { z in
|
||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||
Text(Zeit.uhr(z.zeit)).foregroundStyle(.secondary)
|
||
Text(z.art ?? "").foregroundStyle(.tint)
|
||
Text([z.raum, z.text].compactMap { $0 }.joined(separator: " · ")).textSelection(.enabled)
|
||
}
|
||
.font(.system(.caption, design: .monospaced))
|
||
}
|
||
}
|
||
}
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
.padding(12)
|
||
}
|
||
.overlay {
|
||
if (teil == .gedanken ? t?.gedanken.isEmpty : t?.zeilen.isEmpty) ?? true {
|
||
Leer(titel: "Noch nichts", text: t?.leer ?? "Der Strom läuft, sobald der Läufer arbeitet.")
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|