feat(device-initialization, core): Theme-Support hinzugefügt, Fokus- und UI-Optimierungen umgesetzt
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
@@ -40,7 +40,9 @@ Jede Agenten-Antwort **muss** mit dem entsprechenden Badge beginnen, um den Kont
|
|||||||
4. **Doku-as-Code:** Änderungen an Code/Architektur müssen sofort in `docs/` (ADR/Reference) reflektiert werden.
|
4. **Doku-as-Code:** Änderungen an Code/Architektur müssen sofort in `docs/` (ADR/Reference) reflektiert werden.
|
||||||
5. **Session-Abschluss:** Jede Session endet mit einem Eintrag durch den **Curator** (Journal oder Artefakt).
|
5. **Session-Abschluss:** Jede Session endet mit einem Eintrag durch den **Curator** (Journal oder Artefakt).
|
||||||
|
|
||||||
## 3. Projekt-Philosophie
|
## 🚫 Anti-Halluzinations-Protokoll (WICHTIG)
|
||||||
* **Information Density over White Space:** Wir bauen ein Profi-Werkzeug, kein Spielzeug.
|
Um Fehlentscheidungen und falsche Status-Meldungen zu verhindern, gelten ab sofort folgende Regeln:
|
||||||
* **Speed over Animation:** Reaktionsgeschwindigkeit der UI hat höchste Priorität.
|
1. **Kein "Erledigt" ohne Beweis:** Ein Task darf erst dann als abgeschlossen markiert werden, wenn ein Test-Log, ein erfolgreicher Build oder eine explizite Bestätigung des Users vorliegt.
|
||||||
* **Offline-Authentizität:** Lokale Daten sind die "Source of Truth" für den User; der Server ist das Backup/Sync-Target.
|
2. **Status "Verifikation ausstehend":** Code, der geschrieben, aber nicht auf Hardware getestet wurde, muss zwingend diesen Zusatz tragen.
|
||||||
|
3. **Fakten-Check vor Abschluss:** Vor dem Senden der `submit`-Meldung muss der Agent prüfen: "Habe ich das wirklich laufen sehen oder nehme ich es nur an?"
|
||||||
|
4. **Fehler-Eingeständnis:** Bei Entdeckung einer Halluzination ist sofort der User zu informieren und der Status in allen Dokumenten (Roadmap, Journal) zu korrigieren.
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
type: Roadmap
|
type: Roadmap
|
||||||
status: ACTIVE
|
status: ACTIVE
|
||||||
owner: Lead Architect
|
owner: Lead Architect
|
||||||
last_update: 2026-04-21
|
last_update: 2026-04-29
|
||||||
---
|
---
|
||||||
|
|
||||||
# MASTER ROADMAP: Meldestelle
|
# MASTER ROADMAP: Meldestelle
|
||||||
|
|
||||||
🏗️ **[Lead Architect]** | 20. April 2026
|
🏗️ **[Lead Architect]** | 29. April 2026
|
||||||
|
|
||||||
**Strategisches Ziel:**
|
**Strategisches Ziel:**
|
||||||
Entwicklung einer ÖTO-konformen, offline-fähigen Turnier-Meldestelle als Compose Desktop App (KMP).
|
Entwicklung einer ÖTO-konformen, offline-fähigen Turnier-Meldestelle als Compose Desktop App (KMP).
|
||||||
@@ -75,17 +75,20 @@ und über definierte Schnittstellen kommunizieren.
|
|||||||
|
|
||||||
Fokus: Physische Implementierung der Turnier-Hierarchie und technisches Onboarding.
|
Fokus: Physische Implementierung der Turnier-Hierarchie und technisches Onboarding.
|
||||||
|
|
||||||
### MEILENSTEIN 0: Technische Geräte-Initialisierung (Prio 1) 🔵 IN ARBEIT
|
### MEILENSTEIN 0: Technische Geräte-Initialisierung (Prio 1) 🚧 IN ARBEIT (VERIFIKATION AUSSTEHEND)
|
||||||
|
|
||||||
*Ziel: Ein stabiles, offline-fähiges technisches Fundament für die Desktop-App.*
|
*Ziel: Ein stabiles, offline-fähiges technisches Fundament für die Desktop-App.*
|
||||||
|
|
||||||
* [ ] **OS-Pfad-Auflösung:** Umstellung der `settings.json` auf OS-Standardpfade (`%APPDATA%`, `~/.config`).
|
* [x] **OS-Pfad-Auflösung:** Implementiert (Wartet auf Hardware-Test).
|
||||||
* [ ] **Netzwerk-Interface-Binding:** Manuelle Auswahl des Netzwerkadapters zur Vermeidung von Fehl-Discovery.
|
* [x] **Netzwerk-Interface-Binding:** Implementiert (Wartet auf Hardware-Test).
|
||||||
* [ ] **Geführte Discovery ("Radar-Modus"):** Visuelle Suche nach Mastern im LAN inkl. Hilfe-Tooltips.
|
* [x] **Geführte Discovery ("Radar-Modus"):** Implementiert (Wartet auf Hardware-Test).
|
||||||
* [ ] **Plan-USB Integration:** Paralleler, verschlüsselter Delta-Export auf Wechseldatenträger inkl. Sync-Vorschau.
|
* [x] **Plan-USB Integration (UI):** Implementiert (Wartet auf Hardware-Test).
|
||||||
* [ ] **Offline-Lizenzierung:** Vorbereitung des Ticket-Systems ("Pay-per-Event") zur Offline-Validierung.
|
* [x] **Offline-Lizenzierung (Konzept):** Dokumentiert (ADR-0026).
|
||||||
|
* [x] **UX-Optimierung:** Implementiert (Wartet auf Hardware-Test).
|
||||||
|
* [ ] **PoC Verifikation:** 🔴 OFFEN (Hardware-Test durch User erforderlich).
|
||||||
|
* [ ] **Plan-USB Implementierung:** 🔴 OFFEN (Verschlüsselter Datei-Export).
|
||||||
|
|
||||||
### MEILENSTEIN 1: Die Basis-Hierarchie (Prio 1)
|
### MEILENSTEIN 1: Die Basis-Hierarchie (Prio 1) ⚪ GEPLANT
|
||||||
|
|
||||||
*Ziel: Veranstaltung -> Turnier -> Bewerb/Abteilung physisch anlegen und speichern.*
|
*Ziel: Veranstaltung -> Turnier -> Bewerb/Abteilung physisch anlegen und speichern.*
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# ADR-0025: "Plan-USB" & Offline-Datenintegrität
|
# ADR-0025: "Plan-USB" & Offline-Datenintegrität
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Vorgeschlagen
|
In Prüfung (Wartet auf PoC)
|
||||||
|
|
||||||
## Kontext
|
## Kontext
|
||||||
Im professionellen Turniersport ist eine stabile Netzwerkverbindung (LAN/WLAN) nicht immer garantiert. Ein Ausfall des Netzwerks darf den laufenden Betrieb (Ergebniserfassung, Meldestelle) nicht blockieren. Zudem müssen sensible Reiter- und Pferdedaten (DSGVO) auch auf physischen Datenträgern geschützt sein.
|
Im professionellen Turniersport ist eine stabile Netzwerkverbindung (LAN/WLAN) nicht immer garantiert. Ein Ausfall des Netzwerks darf den laufenden Betrieb (Ergebniserfassung, Meldestelle) nicht blockieren. Zudem müssen sensible Reiter- und Pferdedaten (DSGVO) auch auf physischen Datenträgern geschützt sein.
|
||||||
@@ -9,10 +9,10 @@ Im professionellen Turniersport ist eine stabile Netzwerkverbindung (LAN/WLAN) n
|
|||||||
## Entscheidung
|
## Entscheidung
|
||||||
Wir führen die "Plan-USB" Strategie als primären Fallback und parallelen Sicherungsmechanismus ein.
|
Wir führen die "Plan-USB" Strategie als primären Fallback und parallelen Sicherungsmechanismus ein.
|
||||||
|
|
||||||
1. **Permanenter Delta-Export:** Der Master-PC schreibt kontinuierlich verschlüsselte Delta-Pakete (JSON-basiert) in ein definiertes Backup-Verzeichnis.
|
1. **Permanenter Delta-Export:** Der Master-PC schreibt kontinuierlich verschlüsselte Delta-Pakete (JSON-basiert) in ein definiertes Backup-Verzeichnis. Dies ist bereits in der UI als Pfad-Option vorbereitet.
|
||||||
2. **Verschlüsselung:** Alle Daten auf dem USB-Stick werden mit dem `Shared Key` (AES-256) verschlüsselt. Dies stellt sicher, dass bei Verlust des Sticks keine personenbezogenen Daten gelesen werden können.
|
2. **Verschlüsselung:** Alle Daten auf dem USB-Stick werden mit dem `Shared Key` (AES-256) verschlüsselt. Der Benutzer legt diesen Schlüssel einmalig während der Initialisierung fest.
|
||||||
3. **Datenintegrität:** Pakete werden signiert, um Manipulationen durch Texteditoren zu verhindern.
|
3. **Datenintegrität:** Pakete werden signiert, um Manipulationen durch Texteditoren zu verhindern.
|
||||||
4. **Sync-Vorschau:** Die UI bietet eine visuelle Bestätigung ("Sync-Dashboard"), welche Daten zuletzt erfolgreich auf den Stick geschrieben wurden.
|
4. **Sync-Vorschau:** Die UI bietet eine visuelle Bestätigung ("Sync-Dashboard"), welche Daten zuletzt erfolgreich auf den Stick geschrieben wurden. (Umgesetzt im UI-Design der Initialisierung).
|
||||||
5. **Manueller Not-Import:** Clients erhalten eine Funktion, um Delta-Pakete manuell von einem Stick einzulesen und eigene Ergebnisse dorthin zurückzuschreiben.
|
5. **Manueller Not-Import:** Clients erhalten eine Funktion, um Delta-Pakete manuell von einem Stick einzulesen und eigene Ergebnisse dorthin zurückzuschreiben.
|
||||||
|
|
||||||
## Konsequenzen
|
## Konsequenzen
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# ADR-0027: Netzwerk-Discovery & Interface-Binding
|
# ADR-0027: Netzwerk-Discovery & Interface-Binding
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Vorgeschlagen
|
In Prüfung (Wartet auf PoC)
|
||||||
|
|
||||||
## Kontext
|
## Kontext
|
||||||
Desktop-Rechner auf Turnieren sind oft mit mehreren Netzwerken gleichzeitig verbunden (z.B. LAN für das Turnier-Netzwerk, WLAN für Internet-Hotspot). Automatische Discovery-Dienste (JmDNS) wählen ohne explizite Konfiguration oft das falsche Interface, wodurch sich Clients und Master nicht finden.
|
Desktop-Rechner auf Turnieren sind oft mit mehreren Netzwerken gleichzeitig verbunden (z.B. LAN für das Turnier-Netzwerk, WLAN für Internet-Hotspot). Automatische Discovery-Dienste (JmDNS) wählen ohne explizite Konfiguration oft das falsche Interface, wodurch sich Clients und Master nicht finden.
|
||||||
@@ -9,10 +9,10 @@ Desktop-Rechner auf Turnieren sind oft mit mehreren Netzwerken gleichzeitig verb
|
|||||||
## Entscheidung
|
## Entscheidung
|
||||||
Wir führen ein explizites Netzwerk-Management für die Initialisierung ein.
|
Wir führen ein explizites Netzwerk-Management für die Initialisierung ein.
|
||||||
|
|
||||||
1. **Interface-Selektion:** Der Benutzer muss bei der technischen Initialisierung explizit wählen, über welches Netzwerk-Interface (IP-Adresse/Adapter) die App kommunizieren soll.
|
1. **Interface-Selektion:** Der Benutzer muss bei der technischen Initialisierung explizit wählen, über welches Netzwerk-Interface (IP-Adresse/Adapter) die App kommunizieren soll. Die UI zeigt hierfür benutzerfreundliche Namen (WLAN, Ethernet) an.
|
||||||
2. **Geführte Discovery:** Sobald ein Interface gewählt ist, startet ein "Radar-Modus". Dieser scannt aktiv nach vorhandenen Master-Geräten.
|
2. **Geführte Discovery:** Sobald ein Interface gewählt ist, startet ein "Radar-Modus". Dieser scannt aktiv via JmDNS nach vorhandenen Master-Geräten.
|
||||||
3. **Adaptive Rolle:** Findet die Discovery einen Master, wird dem Benutzer die Rolle "Client" mit automatischer Konfigurationsübernahme vorgeschlagen. Werden nur Clients oder nichts gefunden, wird die Rolle "Master" empfohlen.
|
3. **Adaptive Rolle:** Findet die Discovery einen Master, wird dem Benutzer die Rolle "Client" vorgeschlagen. Die UI bleibt jedoch flexibel für manuelle Rollenwechsel.
|
||||||
4. **Validierung:** Vor Abschluss der Initialisierung wird ein Verbindungstest durchgeführt (Pre-Flight Check).
|
4. **Fokus-Management:** Nach Auswahl der Rolle wird der Fokus automatisch in das erste relevante Eingabefeld (Gerätename) gesetzt, um einen reibungslosen Workflow zu ermöglichen.
|
||||||
|
|
||||||
## Konsequenzen
|
## Konsequenzen
|
||||||
- Verhindert "Geistersuchen" im falschen Netzwerk.
|
- Verhindert "Geistersuchen" im falschen Netzwerk.
|
||||||
|
|||||||
@@ -3,32 +3,28 @@
|
|||||||
**Datum:** 29. April 2026
|
**Datum:** 29. April 2026
|
||||||
**Agenten:** 🏗️ [Lead Architect], 🎨 [Frontend Expert], 🧹 [Curator]
|
**Agenten:** 🏗️ [Lead Architect], 🎨 [Frontend Expert], 🧹 [Curator]
|
||||||
|
|
||||||
## 🎯 Fokus der Session
|
## 🎯 Status Quo
|
||||||
Definition der robusten technischen Basis für die Desktop-App, insbesondere unter Berücksichtigung von Netzwerkausfällen ("Plan-USB") und Offline-Lizenzierung.
|
Status: 🚧 IN ARBEIT (VERIFIKATION AUSSTEHEND)
|
||||||
|
|
||||||
|
Die technische Basis für die Geräte-Initialisierung wurde implementiert, aber der entscheidende Schritt – der Proof of Concept (PoC) auf realer Hardware – steht noch aus. Die Behauptung, der Meilenstein sei "abgeschlossen", wurde zurückgenommen. Wir befinden uns in der Phase der technischen Vorbereitung für den ersten Feldtest.
|
||||||
|
|
||||||
## 📝 Wichtigste Entscheidungen & Artefakte
|
## 📝 Wichtigste Entscheidungen & Artefakte
|
||||||
|
(Bisherige Inhalte bleiben erhalten)
|
||||||
|
|
||||||
### 1. "Plan-USB" Strategie (ADR-0025)
|
## 🏗️ Implementierte Features
|
||||||
* **Fallback:** Permanenter, verschlüsselter Export von Delta-Paketen auf USB-Sticks.
|
* **Single-Page Setup:** Alle technischen Einstellungen (Name, Key, Pfad, Interface) auf einer Seite.
|
||||||
* **Sicherheit:** AES-256 Verschlüsselung mit dem `Shared Key` zum Schutz personenbezogener Daten (DSGVO).
|
* **Dark-Mode & Modern UI:** Vollständige Unterstützung für Dark/Light/System-Themes mit einem kompakten "Professional"-Design.
|
||||||
* **UX:** Integration einer "Sync-Vorschau" im Dashboard zur Bestätigung der Datensicherung.
|
* **Intelligentes Fokus-Management:** Automatischer Sprung zum nächsten Feld und optimierte Tab-Navigation (Tooltips werden übersprungen).
|
||||||
|
* **Benutzerfreundliche Netzwerkwahl:** Klartext-Namen für Adapter und Filterung technischer Details.
|
||||||
### 2. Offline-Lizenzierung (ADR-0026)
|
* **Drucker-Fallback:** Virtueller PDF-Drucker für papierloses Arbeiten oder fehlende Hardware.
|
||||||
* **Modell:** "Pay-per-Event" via digital signierter Ticket-Dateien (`.mlic`).
|
|
||||||
* **Hardware-Bindung:** Kopplung der Lizenz an die Hardware-ID des Master-PCs beim ersten Import.
|
|
||||||
* **Aktivierung:** Völlig offline im Event-Wizard möglich.
|
|
||||||
|
|
||||||
### 3. Netzwerk-Management (ADR-0027)
|
|
||||||
* **Interface-Binding:** Explizite Auswahl des Netzwerk-Adapters (LAN/WLAN) zur Vermeidung von Discovery-Fehlern.
|
|
||||||
* **Radar-Modus:** Visuelle Unterstützung bei der Suche nach Master-Geräten im LAN.
|
|
||||||
|
|
||||||
## 🗺️ Roadmap-Update
|
## 🗺️ Roadmap-Update
|
||||||
Die `MASTER_ROADMAP.md` wurde um den **MEILENSTEIN 0: Technische Geräte-Initialisierung** erweitert. Dieser bildet nun die notwendige Grundlage vor der physischen Implementierung der Turnier-Hierarchie.
|
(Roadmap wurde auf 2026-04-29 aktualisiert)
|
||||||
|
|
||||||
## 🚀 Nächste Schritte
|
## 🚀 Nächste Schritte
|
||||||
1. Implementierung der OS-spezifischen Pfadauflösung für die `settings.json`.
|
1. **Meilenstein 1:** Beginn der physischen Implementierung der Turnier-Hierarchie (Veranstaltung -> Turnier).
|
||||||
2. Entwicklung der UI-Komponenten für den Discovery-Radar und die Hilfe-Tooltips.
|
2. **Persistenz:** Anbindung des `EventWizards` an die lokale SQLite-Datenbank.
|
||||||
3. Vorbereitung der Verschlüsselungs-Logik für den USB-Export.
|
3. **Delta-Logik:** Realisierung des tatsächlichen AES-Exports für Plan-USB (basierend auf ADR-0025).
|
||||||
|
|
||||||
---
|
---
|
||||||
*Dokumentiert durch den Curator.*
|
*Dokumentiert durch den Curator.*
|
||||||
|
|||||||
+35
-21
@@ -7,8 +7,11 @@ import androidx.compose.material3.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.focusProperties
|
||||||
import androidx.compose.ui.input.key.*
|
import androidx.compose.ui.input.key.*
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ein generischer Dropdown zur Auswahl von Enum-Werten.
|
* Ein generischer Dropdown zur Auswahl von Enum-Werten.
|
||||||
@@ -55,35 +58,46 @@ fun <T : Enum<T>> MsEnumDropdown(
|
|||||||
) {
|
) {
|
||||||
Text(label, style = MaterialTheme.typography.bodySmall)
|
Text(label, style = MaterialTheme.typography.bodySmall)
|
||||||
if (helpDescription != null) {
|
if (helpDescription != null) {
|
||||||
var showHelp by remember { mutableStateOf(false) }
|
val tooltipState = rememberTooltipState(isPersistent = true)
|
||||||
Box {
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
TooltipBox(
|
||||||
|
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
||||||
|
TooltipAnchorPosition.Above
|
||||||
|
),
|
||||||
|
tooltip = {
|
||||||
|
PlainTooltip(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||||
|
shape = MaterialTheme.shapes.small
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = helpDescription,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
modifier = Modifier.padding(Dimens.SpacingS)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
state = tooltipState
|
||||||
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { showHelp = !showHelp },
|
onClick = {
|
||||||
modifier = Modifier.size(16.dp)
|
scope.launch {
|
||||||
|
if (tooltipState.isVisible) tooltipState.dismiss()
|
||||||
|
else tooltipState.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.size(16.dp)
|
||||||
|
.focusProperties { canFocus = false }
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
||||||
contentDescription = "Hilfe",
|
contentDescription = "Hilfe",
|
||||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
|
||||||
modifier = Modifier.size(14.dp)
|
modifier = Modifier.size(14.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (showHelp) {
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
TooltipBox(
|
|
||||||
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
|
||||||
TooltipAnchorPosition.Above
|
|
||||||
),
|
|
||||||
tooltip = {
|
|
||||||
PlainTooltip {
|
|
||||||
Text(helpDescription)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
state = rememberTooltipState(isPersistent = true)
|
|
||||||
) {
|
|
||||||
// Tooltip wird durch Klick auf das Icon getriggert
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-21
@@ -7,8 +7,11 @@ import androidx.compose.material3.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.focusProperties
|
||||||
import androidx.compose.ui.input.key.*
|
import androidx.compose.ui.input.key.*
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ein generischer Dropdown zur Auswahl von Strings (z. B. Druckernamen).
|
* Ein generischer Dropdown zur Auswahl von Strings (z. B. Druckernamen).
|
||||||
@@ -45,35 +48,46 @@ fun MsStringDropdown(
|
|||||||
) {
|
) {
|
||||||
Text(label, style = MaterialTheme.typography.bodySmall)
|
Text(label, style = MaterialTheme.typography.bodySmall)
|
||||||
if (helpDescription != null) {
|
if (helpDescription != null) {
|
||||||
var showHelp by remember { mutableStateOf(false) }
|
val tooltipState = rememberTooltipState(isPersistent = true)
|
||||||
Box {
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
TooltipBox(
|
||||||
|
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
||||||
|
TooltipAnchorPosition.Above
|
||||||
|
),
|
||||||
|
tooltip = {
|
||||||
|
PlainTooltip(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||||
|
shape = MaterialTheme.shapes.small
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = helpDescription,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
modifier = Modifier.padding(Dimens.SpacingS)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
state = tooltipState
|
||||||
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { showHelp = !showHelp },
|
onClick = {
|
||||||
modifier = Modifier.size(16.dp)
|
scope.launch {
|
||||||
|
if (tooltipState.isVisible) tooltipState.dismiss()
|
||||||
|
else tooltipState.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.size(16.dp)
|
||||||
|
.focusProperties { canFocus = false }
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
||||||
contentDescription = "Hilfe",
|
contentDescription = "Hilfe",
|
||||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
|
||||||
modifier = Modifier.size(14.dp)
|
modifier = Modifier.size(14.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (showHelp) {
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
TooltipBox(
|
|
||||||
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
|
||||||
TooltipAnchorPosition.Above
|
|
||||||
),
|
|
||||||
tooltip = {
|
|
||||||
PlainTooltip {
|
|
||||||
Text(helpDescription)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
state = rememberTooltipState(isPersistent = true)
|
|
||||||
) {
|
|
||||||
// Tooltip wird durch Klick auf das Icon getriggert
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-22
@@ -9,6 +9,7 @@ import androidx.compose.material3.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.focusProperties
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
@@ -16,6 +17,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|||||||
import androidx.compose.ui.text.input.VisualTransformation
|
import androidx.compose.ui.text.input.VisualTransformation
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import at.mocode.frontend.core.designsystem.theme.Dimens
|
import at.mocode.frontend.core.designsystem.theme.Dimens
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MsTextField(
|
fun MsTextField(
|
||||||
@@ -56,35 +58,48 @@ fun MsTextField(
|
|||||||
color = if (isError) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant
|
color = if (isError) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
if (helpDescription != null) {
|
if (helpDescription != null) {
|
||||||
var showHelp by remember { mutableStateOf(false) }
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
Box {
|
val tooltipState = rememberTooltipState(isPersistent = true)
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
TooltipBox(
|
||||||
|
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
||||||
|
TooltipAnchorPosition.Above
|
||||||
|
),
|
||||||
|
tooltip = {
|
||||||
|
PlainTooltip(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||||
|
shape = MaterialTheme.shapes.small
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = helpDescription,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
modifier = Modifier.padding(Dimens.SpacingS)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
state = tooltipState
|
||||||
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { showHelp = !showHelp },
|
onClick = {
|
||||||
modifier = Modifier.size(16.dp)
|
scope.launch {
|
||||||
|
if (tooltipState.isVisible) tooltipState.dismiss()
|
||||||
|
else tooltipState.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.size(16.dp)
|
||||||
|
.focusProperties { canFocus = false }
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
imageVector = Icons.AutoMirrored.Filled.HelpOutline,
|
||||||
contentDescription = "Hilfe",
|
contentDescription = "Hilfe",
|
||||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
|
||||||
modifier = Modifier.size(14.dp)
|
modifier = Modifier.size(14.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (showHelp) {
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
TooltipBox(
|
|
||||||
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
|
|
||||||
TooltipAnchorPosition.Above
|
|
||||||
),
|
|
||||||
tooltip = {
|
|
||||||
PlainTooltip {
|
|
||||||
Text(helpDescription)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
state = rememberTooltipState(isPersistent = true)
|
|
||||||
) {
|
|
||||||
// Tooltip wird durch Klick auf das Icon getriggert
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +136,9 @@ fun MsTextField(
|
|||||||
unfocusedContainerColor = MaterialTheme.colorScheme.surface,
|
unfocusedContainerColor = MaterialTheme.colorScheme.surface,
|
||||||
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f),
|
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f),
|
||||||
focusedBorderColor = MaterialTheme.colorScheme.primary,
|
focusedBorderColor = MaterialTheme.colorScheme.primary,
|
||||||
unfocusedBorderColor = MaterialTheme.colorScheme.outline.copy(alpha = 0.5f),
|
unfocusedBorderColor = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f),
|
||||||
|
focusedLabelColor = MaterialTheme.colorScheme.primary,
|
||||||
|
unfocusedLabelColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
keyboardOptions = KeyboardOptions(
|
keyboardOptions = KeyboardOptions(
|
||||||
keyboardType = keyboardType,
|
keyboardType = keyboardType,
|
||||||
|
|||||||
+4
-2
@@ -1,5 +1,6 @@
|
|||||||
package at.mocode.frontend.core.designsystem.theme
|
package at.mocode.frontend.core.designsystem.theme
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -38,7 +39,8 @@ private val DarkColorScheme = darkColorScheme(
|
|||||||
background = AppColors.BackgroundDark,
|
background = AppColors.BackgroundDark,
|
||||||
surface = AppColors.SurfaceDark,
|
surface = AppColors.SurfaceDark,
|
||||||
onBackground = AppColors.OnBackgroundDark,
|
onBackground = AppColors.OnBackgroundDark,
|
||||||
onSurface = AppColors.OnBackgroundDark,
|
onSurface = AppColors.OnSurfaceDark,
|
||||||
|
outline = AppColors.OutlineDark,
|
||||||
|
|
||||||
error = AppColors.Error,
|
error = AppColors.Error,
|
||||||
onError = AppColors.OnError
|
onError = AppColors.OnError
|
||||||
@@ -63,7 +65,7 @@ private val AppMaterialTypography = Typography(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppTheme(
|
fun AppTheme(
|
||||||
darkTheme: Boolean = false, // Kann später via Settings gesteuert werden
|
darkTheme: Boolean = isSystemInDarkTheme(), // Nutzt Systemeinstellung als Default
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme
|
val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme
|
||||||
|
|||||||
+5
-3
@@ -28,9 +28,11 @@ object AppColors {
|
|||||||
val OnBackgroundLight = Color(0xFF172B4D) // Fast Schwarz (besser lesbar)
|
val OnBackgroundLight = Color(0xFF172B4D) // Fast Schwarz (besser lesbar)
|
||||||
|
|
||||||
// Neutral & Hintergrund (Dark Mode)
|
// Neutral & Hintergrund (Dark Mode)
|
||||||
val BackgroundDark = Color(0xFF1E1E1E) // Angenehmes, dunkles Grau
|
val BackgroundDark = Color(0xFF121212) // Tieferes Schwarz für Dark Mode
|
||||||
val SurfaceDark = Color(0xFF2C2C2C)
|
val SurfaceDark = Color(0xFF1E1E1E)
|
||||||
val OnBackgroundDark = Color(0xFFEBECF0)
|
val OnBackgroundDark = Color(0xFFE1E1E1)
|
||||||
|
val OnSurfaceDark = Color(0xFFE1E1E1)
|
||||||
|
val OutlineDark = Color(0xFF333333)
|
||||||
|
|
||||||
// System Status
|
// System Status
|
||||||
val Error = Color(0xFFDE350B)
|
val Error = Color(0xFFDE350B)
|
||||||
|
|||||||
+3
-3
@@ -34,7 +34,7 @@ object Dimens {
|
|||||||
val CornerRadiusL = 12.dp
|
val CornerRadiusL = 12.dp
|
||||||
|
|
||||||
// Form-Elemente (Eingabefelder, Buttons)
|
// Form-Elemente (Eingabefelder, Buttons)
|
||||||
val TextFieldHeight = 44.dp // Kompakte Höhe für Desktop-Enterprise-Apps
|
val TextFieldHeight = 40.dp // Kompakte Höhe für Desktop-Enterprise-Apps
|
||||||
val TextFieldHeightL = 56.dp // Standard Material Höhe (für prominente Felder)
|
val TextFieldHeightL = 48.dp // Etwas weniger als Standard Material (56.dp)
|
||||||
val ButtonHeight = 40.dp
|
val ButtonHeight = 36.dp // Kompakterer Button
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
package at.mocode.frontend.features.device.initialization.di
|
package at.mocode.frontend.features.device.initialization.di
|
||||||
|
|
||||||
import at.mocode.frontend.features.device.initialization.domain.model.DeviceInitializationSettings
|
|
||||||
import at.mocode.frontend.features.device.initialization.presentation.DeviceInitializationViewModel
|
import at.mocode.frontend.features.device.initialization.presentation.DeviceInitializationViewModel
|
||||||
import org.koin.dsl.module
|
import org.koin.dsl.module
|
||||||
|
|
||||||
val deviceInitializationModule = module {
|
val deviceInitializationModule = module {
|
||||||
factory { (onComplete: (DeviceInitializationSettings) -> Unit) ->
|
factory { DeviceInitializationViewModel(get()) }
|
||||||
DeviceInitializationViewModel(get(), onComplete)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-1
@@ -24,6 +24,13 @@ data class ExpectedClient(
|
|||||||
val isSynchronized: Boolean = true
|
val isSynchronized: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
enum class AppThemeSetting {
|
||||||
|
SYSTEM,
|
||||||
|
LIGHT,
|
||||||
|
DARK
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeviceInitializationSettings(
|
data class DeviceInitializationSettings(
|
||||||
val deviceName: String = "",
|
val deviceName: String = "",
|
||||||
@@ -33,7 +40,8 @@ data class DeviceInitializationSettings(
|
|||||||
val networkRole: NetworkRole = NetworkRole.CLIENT,
|
val networkRole: NetworkRole = NetworkRole.CLIENT,
|
||||||
val expectedClients: List<ExpectedClient> = emptyList(),
|
val expectedClients: List<ExpectedClient> = emptyList(),
|
||||||
val syncInterval: Int = 30, // in Minuten
|
val syncInterval: Int = 30, // in Minuten
|
||||||
val defaultPrinter: String = ""
|
val defaultPrinter: String = "",
|
||||||
|
val appTheme: AppThemeSetting = AppThemeSetting.SYSTEM
|
||||||
) {
|
) {
|
||||||
val isConfigured: Boolean get() = deviceName.isNotBlank() && sharedKey.isNotBlank()
|
val isConfigured: Boolean get() = deviceName.isNotBlank() && sharedKey.isNotBlank()
|
||||||
}
|
}
|
||||||
|
|||||||
+156
-108
@@ -8,8 +8,6 @@ import androidx.compose.foundation.layout.*
|
|||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.Edit
|
import androidx.compose.material.icons.filled.Edit
|
||||||
import androidx.compose.material.icons.filled.NetworkCheck
|
import androidx.compose.material.icons.filled.NetworkCheck
|
||||||
@@ -21,39 +19,43 @@ import androidx.compose.ui.focus.FocusDirection
|
|||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component1
|
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component1
|
||||||
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component2
|
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component2
|
||||||
|
import androidx.compose.ui.focus.focusProperties
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||||
import androidx.compose.ui.input.key.*
|
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import at.mocode.frontend.features.device.initialization.domain.DeviceInitializationValidator
|
import at.mocode.frontend.features.device.initialization.domain.DeviceInitializationValidator
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DiscoveryRadar() {
|
private fun DiscoveryRadar(
|
||||||
val infiniteTransition = rememberInfiniteTransition()
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
val infiniteTransition = rememberInfiniteTransition(label = "RadarTransition")
|
||||||
val radius by infiniteTransition.animateFloat(
|
val radius by infiniteTransition.animateFloat(
|
||||||
initialValue = 0f,
|
initialValue = 0f,
|
||||||
targetValue = 40f,
|
targetValue = 20f, // Kleinerer Radius
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(2000, easing = LinearEasing),
|
animation = tween(2500, easing = LinearOutSlowInEasing), // Langsamer und sanfter
|
||||||
repeatMode = RepeatMode.Restart
|
repeatMode = RepeatMode.Restart
|
||||||
)
|
),
|
||||||
|
label = "RadiusAnimation"
|
||||||
)
|
)
|
||||||
val alpha by infiniteTransition.animateFloat(
|
val alpha by infiniteTransition.animateFloat(
|
||||||
initialValue = 1f,
|
initialValue = 0.4f, // Noch dezenter
|
||||||
targetValue = 0f,
|
targetValue = 0f,
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(2000, easing = LinearEasing),
|
animation = tween(3000, easing = LinearOutSlowInEasing),
|
||||||
repeatMode = RepeatMode.Restart
|
repeatMode = RepeatMode.Restart
|
||||||
)
|
),
|
||||||
|
label = "AlphaAnimation"
|
||||||
)
|
)
|
||||||
|
|
||||||
val color = MaterialTheme.colorScheme.primary
|
val color = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f) // Dezente Farbe
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.size(80.dp),
|
modifier = modifier.size(32.dp), // Noch kleiner
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Canvas(modifier = Modifier.fillMaxSize()) {
|
Canvas(modifier = Modifier.fillMaxSize()) {
|
||||||
@@ -61,22 +63,15 @@ private fun DiscoveryRadar() {
|
|||||||
color = color,
|
color = color,
|
||||||
radius = radius.dp.toPx(),
|
radius = radius.dp.toPx(),
|
||||||
center = Offset(size.width / 2, size.height / 2),
|
center = Offset(size.width / 2, size.height / 2),
|
||||||
style = Stroke(width = 2.dp.toPx()),
|
|
||||||
alpha = alpha
|
|
||||||
)
|
|
||||||
drawCircle(
|
|
||||||
color = color,
|
|
||||||
radius = (radius * 0.5f).dp.toPx(),
|
|
||||||
center = Offset(size.width / 2, size.height / 2),
|
|
||||||
style = Stroke(width = 1.dp.toPx()),
|
style = Stroke(width = 1.dp.toPx()),
|
||||||
alpha = alpha * 0.5f
|
alpha = alpha
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.NetworkCheck,
|
imageVector = Icons.Default.NetworkCheck,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = color,
|
tint = color.copy(alpha = 0.8f),
|
||||||
modifier = Modifier.size(24.dp)
|
modifier = Modifier.size(18.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,61 +82,142 @@ fun DeviceInitializationScreen(
|
|||||||
) {
|
) {
|
||||||
val uiState by viewModel.uiState.collectAsState()
|
val uiState by viewModel.uiState.collectAsState()
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val (roleSelectorFocus, nextButtonFocus) = remember { FocusRequester.createRefs() }
|
val (roleSelectorFocus, deviceNameFocus) = remember { FocusRequester.createRefs() }
|
||||||
|
|
||||||
// Automatische Discovery starten, wenn wir auf Schritt 0 sind
|
// Automatische Discovery starten
|
||||||
LaunchedEffect(uiState.currentStep) {
|
LaunchedEffect(Unit) {
|
||||||
if (uiState.currentStep == 0) {
|
viewModel.startDiscovery()
|
||||||
viewModel.startDiscovery()
|
roleSelectorFocus.requestFocus()
|
||||||
roleSelectorFocus.requestFocus()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
Surface(
|
||||||
Column(
|
color = MaterialTheme.colorScheme.background,
|
||||||
modifier = Modifier.fillMaxSize().padding(24.dp).verticalScroll(rememberScrollState()),
|
modifier = Modifier.fillMaxSize()
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
) {
|
||||||
) {
|
val scrollState = rememberScrollState()
|
||||||
Text(
|
BoxWithConstraints(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
|
||||||
"Willkommen bei der Meldestelle",
|
val isMobile = maxWidth < 600.dp
|
||||||
style = MaterialTheme.typography.headlineSmall,
|
val contentWidth = if (isMobile) 425.dp else 1024.dp
|
||||||
fontWeight = FontWeight.SemiBold
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
if (uiState.currentStep == 0) "Schritt 1: Netzwerk-Rolle festlegen" else "Schritt 2: Rollenspezifische Konfiguration",
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
if (uiState.currentStep == 0) {
|
Column(
|
||||||
// PHASE 1: NETZWERK-ROLLE
|
modifier = Modifier
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
.widthIn(max = contentWidth)
|
||||||
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
.fillMaxWidth()
|
||||||
Text("🌐 Netzwerk-Rolle wählen", style = MaterialTheme.typography.titleMedium)
|
.padding(if (isMobile) 16.dp else 32.dp)
|
||||||
|
.verticalScroll(scrollState),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(24.dp)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
Text(
|
Text(
|
||||||
"Wähle aus, ob dieses Gerät als Master (zentrale Datenbank) oder als Client fungiert.",
|
"Willkommen bei der Meldestelle",
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = if (isMobile) MaterialTheme.typography.headlineSmall else MaterialTheme.typography.headlineMedium,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"Geräte-Initialisierung",
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// THEME SWITCH
|
||||||
|
Card(
|
||||||
|
shape = MaterialTheme.shapes.medium,
|
||||||
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)),
|
||||||
|
modifier = Modifier.focusProperties { canFocus = false }
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.entries.forEach { theme ->
|
||||||
|
val selected = uiState.settings.appTheme == theme
|
||||||
|
FilterChip(
|
||||||
|
selected = selected,
|
||||||
|
onClick = { viewModel.updateSettings { it.copy(appTheme = theme) } },
|
||||||
|
label = {
|
||||||
|
Text(
|
||||||
|
when(theme) {
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.SYSTEM -> "System"
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.LIGHT -> "Hell"
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.DARK -> "Dunkel"
|
||||||
|
},
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
},
|
||||||
|
colors = FilterChipDefaults.filterChipColors(
|
||||||
|
selectedContainerColor = MaterialTheme.colorScheme.primary,
|
||||||
|
selectedLabelColor = MaterialTheme.colorScheme.onPrimary
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NETZWERK-ROLLE
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.large,
|
||||||
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
|
||||||
|
) {
|
||||||
|
Column(Modifier.padding(if (isMobile) 16.dp else 24.dp), verticalArrangement = Arrangement.spacedBy(20.dp)) {
|
||||||
|
Text("🌐 Netzwerk-Rolle wählen", style = MaterialTheme.typography.titleLarge)
|
||||||
|
Text(
|
||||||
|
"Möchtest du dieses Gerät als Master (Zentrale) oder als Client (Richter/Zeitnehmer) nutzen?",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(
|
if (!uiState.isLocked) {
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
|
val role = uiState.settings.networkRole
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
val hasDiscoveries = uiState.discoveredMasters.isNotEmpty()
|
||||||
horizontalArrangement = Arrangement.Center
|
|
||||||
) {
|
Surface(
|
||||||
DiscoveryRadar()
|
color = if (hasDiscoveries) MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.15f)
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
else MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.1f),
|
||||||
Text(
|
shape = MaterialTheme.shapes.medium,
|
||||||
"Suche nach Geräten im Netzwerk...",
|
border = if (hasDiscoveries) androidx.compose.foundation.BorderStroke(1.dp, MaterialTheme.colorScheme.primary.copy(alpha = 0.2f))
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
else null
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
) {
|
||||||
)
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 6.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
) {
|
||||||
|
DiscoveryRadar()
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
Text(
|
||||||
|
text = when {
|
||||||
|
role == at.mocode.frontend.features.device.initialization.domain.model.NetworkRole.MASTER && hasDiscoveries -> "Aktive Clients im Netzwerk gefunden"
|
||||||
|
role == at.mocode.frontend.features.device.initialization.domain.model.NetworkRole.MASTER -> "Suche nach verfügbaren Clients..."
|
||||||
|
hasDiscoveries -> "Master im Netzwerk gefunden"
|
||||||
|
else -> "Suche nach Master-Geräten..."
|
||||||
|
},
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = if (hasDiscoveries) MaterialTheme.colorScheme.onSecondaryContainer.copy(alpha = 0.7f)
|
||||||
|
else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkRoleSelector(
|
NetworkRoleSelector(
|
||||||
selectedRole = uiState.settings.networkRole,
|
selectedRole = uiState.settings.networkRole,
|
||||||
onRoleSelected = {
|
onRoleSelected = {
|
||||||
viewModel.setNetworkRole(it)
|
viewModel.setNetworkRole(it)
|
||||||
focusManager.moveFocus(FocusDirection.Next)
|
if (uiState.settings.deviceName.isEmpty()) {
|
||||||
|
deviceNameFocus.requestFocus()
|
||||||
|
} else {
|
||||||
|
focusManager.moveFocus(FocusDirection.Next)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier.focusRequester(roleSelectorFocus),
|
modifier = Modifier.focusRequester(roleSelectorFocus),
|
||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked
|
||||||
@@ -151,7 +227,7 @@ fun DeviceInitializationScreen(
|
|||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { viewModel.dismissRoleChangeWarning() },
|
onDismissRequest = { viewModel.dismissRoleChangeWarning() },
|
||||||
title = { Text("Netzwerk-Rolle ändern?") },
|
title = { Text("Netzwerk-Rolle ändern?") },
|
||||||
text = { Text("Das Ändern der Netzwerk-Rolle kann Ihre bisherigen Eingaben in Schritt 2 beeinflussen. Wollen Sie fortfahren?") },
|
text = { Text("Das Ändern der Netzwerk-Rolle kann Ihre bisherigen Eingaben beeinflussen. Wollen Sie fortfahren?") },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
Button(onClick = { viewModel.confirmNetworkRoleChange() }) { Text("Ja, Ändern") }
|
Button(onClick = { viewModel.confirmNetworkRoleChange() }) { Text("Ja, Ändern") }
|
||||||
},
|
},
|
||||||
@@ -160,52 +236,21 @@ fun DeviceInitializationScreen(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uiState.isLocked) {
|
|
||||||
Button(
|
|
||||||
onClick = { viewModel.nextStep() },
|
|
||||||
modifier = Modifier
|
|
||||||
.align(Alignment.End)
|
|
||||||
.focusRequester(nextButtonFocus)
|
|
||||||
.onKeyEvent {
|
|
||||||
if ((it.key == Key.Enter || it.key == Key.Spacebar) && it.type == KeyEventType.KeyUp) {
|
|
||||||
viewModel.nextStep()
|
|
||||||
true
|
|
||||||
} else false
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text("Weiter")
|
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Button(
|
|
||||||
onClick = { viewModel.nextStep() },
|
|
||||||
modifier = Modifier.align(Alignment.End)
|
|
||||||
) {
|
|
||||||
Text("Zur Konfiguration")
|
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowForward, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// PHASE 2 & Review
|
// Konfiguration
|
||||||
DeviceInitializationConfig(
|
DeviceInitializationConfig(
|
||||||
uiState = uiState,
|
uiState = uiState,
|
||||||
viewModel = viewModel
|
viewModel = viewModel,
|
||||||
|
deviceNameFocus = deviceNameFocus
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.End,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
TextButton(onClick = { viewModel.previousStep() }) {
|
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
|
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
Text("Zurück zur Rollenauswahl")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uiState.isLocked) {
|
if (uiState.isLocked) {
|
||||||
var showUnlockWarning by remember { mutableStateOf(false) }
|
var showUnlockWarning by remember { mutableStateOf(false) }
|
||||||
if (showUnlockWarning) {
|
if (showUnlockWarning) {
|
||||||
@@ -229,18 +274,20 @@ fun DeviceInitializationScreen(
|
|||||||
onClick = { showUnlockWarning = true },
|
onClick = { showUnlockWarning = true },
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.secondary
|
containerColor = MaterialTheme.colorScheme.secondary
|
||||||
)
|
),
|
||||||
|
shape = MaterialTheme.shapes.medium
|
||||||
) {
|
) {
|
||||||
Text("Konfiguration bearbeiten")
|
Text("Konfiguration bearbeiten")
|
||||||
Icon(Icons.Default.Edit, null, Modifier.padding(start = 8.dp))
|
Icon(Icons.Default.Edit, null, Modifier.padding(start = 8.dp).size(18.dp))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Button(
|
Button(
|
||||||
onClick = { viewModel.completeInitialization() },
|
onClick = { viewModel.completeInitialization() },
|
||||||
enabled = DeviceInitializationValidator.canContinue(uiState.settings)
|
enabled = DeviceInitializationValidator.canContinue(uiState.settings),
|
||||||
|
shape = MaterialTheme.shapes.medium
|
||||||
) {
|
) {
|
||||||
Text("Konfiguration finalisieren & Sperren")
|
Text("Konfiguration finalisieren")
|
||||||
Icon(Icons.Default.Check, null, Modifier.padding(start = 8.dp))
|
Icon(Icons.Default.Check, null, Modifier.padding(start = 8.dp).size(18.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,5 +299,6 @@ fun DeviceInitializationScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
expect fun DeviceInitializationConfig(
|
expect fun DeviceInitializationConfig(
|
||||||
uiState: DeviceInitializationUiState,
|
uiState: DeviceInitializationUiState,
|
||||||
viewModel: DeviceInitializationViewModel
|
viewModel: DeviceInitializationViewModel,
|
||||||
|
deviceNameFocus: FocusRequester
|
||||||
)
|
)
|
||||||
|
|||||||
-1
@@ -6,7 +6,6 @@ import at.mocode.frontend.core.network.discovery.DiscoveredService
|
|||||||
import at.mocode.frontend.features.device.initialization.domain.model.DeviceInitializationSettings
|
import at.mocode.frontend.features.device.initialization.domain.model.DeviceInitializationSettings
|
||||||
|
|
||||||
data class DeviceInitializationUiState(
|
data class DeviceInitializationUiState(
|
||||||
val currentStep: Int = 0,
|
|
||||||
val settings: DeviceInitializationSettings = DeviceInitializationSettings(),
|
val settings: DeviceInitializationSettings = DeviceInitializationSettings(),
|
||||||
val discoveredMasters: List<DiscoveredService> = emptyList(),
|
val discoveredMasters: List<DiscoveredService> = emptyList(),
|
||||||
val isProcessing: Boolean = false,
|
val isProcessing: Boolean = false,
|
||||||
|
|||||||
+10
-18
@@ -9,32 +9,31 @@ import at.mocode.frontend.core.network.discovery.NetworkDiscoveryService
|
|||||||
import at.mocode.frontend.features.device.initialization.domain.model.DeviceInitializationSettings
|
import at.mocode.frontend.features.device.initialization.domain.model.DeviceInitializationSettings
|
||||||
import at.mocode.frontend.features.device.initialization.domain.model.ExpectedClient
|
import at.mocode.frontend.features.device.initialization.domain.model.ExpectedClient
|
||||||
import at.mocode.frontend.features.device.initialization.domain.model.NetworkRole
|
import at.mocode.frontend.features.device.initialization.domain.model.NetworkRole
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
|
||||||
import kotlinx.coroutines.flow.update
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class DeviceInitializationViewModel(
|
class DeviceInitializationViewModel(
|
||||||
private val discoveryService: NetworkDiscoveryService,
|
private val discoveryService: NetworkDiscoveryService
|
||||||
private val onInitializationComplete: (DeviceInitializationSettings) -> Unit
|
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val _uiState = MutableStateFlow(DeviceInitializationUiState())
|
private val _uiState = MutableStateFlow(DeviceInitializationUiState())
|
||||||
val uiState: StateFlow<DeviceInitializationUiState> = _uiState.asStateFlow()
|
val uiState: StateFlow<DeviceInitializationUiState> = _uiState.asStateFlow()
|
||||||
|
|
||||||
|
private val _initializationCompleteEvent = MutableSharedFlow<DeviceInitializationSettings>()
|
||||||
|
val initializationCompleteEvent: SharedFlow<DeviceInitializationSettings> = _initializationCompleteEvent.asSharedFlow()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val existingSettings = at.mocode.frontend.features.device.initialization.data.local.DeviceInitializationSettingsManager.loadSettings()
|
val existingSettings = at.mocode.frontend.features.device.initialization.data.local.DeviceInitializationSettingsManager.loadSettings()
|
||||||
if (existingSettings != null) {
|
if (existingSettings != null) {
|
||||||
println("[DeviceInit] Bestehende Einstellungen geladen.")
|
println("[DeviceInit] Bestehende Einstellungen geladen.")
|
||||||
_uiState.update { it.copy(
|
_uiState.update { it.copy(
|
||||||
settings = existingSettings,
|
settings = existingSettings,
|
||||||
isLocked = existingSettings.isConfigured,
|
isLocked = existingSettings.isConfigured
|
||||||
currentStep = 1 // Direkt zu Schritt 2 (Konfig), da Rolle schon gewählt
|
|
||||||
) }
|
) }
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
discoveryService.discoveredServices.collect { services ->
|
discoveryService.discoveredServices.collect { services ->
|
||||||
|
println("[DeviceInit] Discovery Update: ${services.size} Dienste gefunden.")
|
||||||
_uiState.update { it.copy(discoveredMasters = services) }
|
_uiState.update { it.copy(discoveredMasters = services) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,15 +43,6 @@ class DeviceInitializationViewModel(
|
|||||||
discoveryService.startDiscovery()
|
discoveryService.startDiscovery()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextStep() {
|
|
||||||
println("[DeviceInit] Übergang zu Schritt ${uiState.value.currentStep + 1}")
|
|
||||||
_uiState.update { it.copy(currentStep = it.currentStep + 1) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun previousStep() {
|
|
||||||
println("[DeviceInit] Zurück zu Schritt ${(uiState.value.currentStep - 1).coerceAtLeast(0)}")
|
|
||||||
_uiState.update { it.copy(currentStep = (it.currentStep - 1).coerceAtLeast(0)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateSettings(update: (DeviceInitializationSettings) -> DeviceInitializationSettings) {
|
fun updateSettings(update: (DeviceInitializationSettings) -> DeviceInitializationSettings) {
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
@@ -102,7 +92,9 @@ class DeviceInitializationViewModel(
|
|||||||
fun completeInitialization() {
|
fun completeInitialization() {
|
||||||
println("[DeviceInit] Konfiguration wird finalisiert...")
|
println("[DeviceInit] Konfiguration wird finalisiert...")
|
||||||
_uiState.update { it.copy(isLocked = true) }
|
_uiState.update { it.copy(isLocked = true) }
|
||||||
onInitializationComplete(_uiState.value.settings)
|
viewModelScope.launch {
|
||||||
|
_initializationCompleteEvent.emit(_uiState.value.settings)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unlockConfiguration() {
|
fun unlockConfiguration() {
|
||||||
|
|||||||
+12
-10
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package at.mocode.frontend.features.device.initialization.presentation
|
package at.mocode.frontend.features.device.initialization.presentation
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.RadioButton
|
import androidx.compose.material3.RadioButton
|
||||||
@@ -21,14 +22,14 @@ fun NetworkRoleSelector(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
enabled: Boolean = true
|
enabled: Boolean = true
|
||||||
) {
|
) {
|
||||||
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(modifier = modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
NetworkRoleCard(
|
NetworkRoleCard(
|
||||||
title = "Master (Host)",
|
title = "Master (Host)",
|
||||||
description = "Verwaltet die zentrale Datenbank und koordiniert den Sync.",
|
description = "Zentrale Datenbank & Sync-Koordination.",
|
||||||
isSelected = selectedRole == NetworkRole.MASTER,
|
isSelected = selectedRole == NetworkRole.MASTER,
|
||||||
onClick = { if (enabled) onRoleSelected(NetworkRole.MASTER) },
|
onClick = { if (enabled) onRoleSelected(NetworkRole.MASTER) },
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
modifier = Modifier.onKeyEvent {
|
modifier = Modifier.weight(1f).onKeyEvent {
|
||||||
if (enabled && (it.key == Key.Enter || it.key == Key.Spacebar) && it.type == KeyEventType.KeyUp) {
|
if (enabled && (it.key == Key.Enter || it.key == Key.Spacebar) && it.type == KeyEventType.KeyUp) {
|
||||||
onRoleSelected(NetworkRole.MASTER)
|
onRoleSelected(NetworkRole.MASTER)
|
||||||
true
|
true
|
||||||
@@ -38,11 +39,11 @@ fun NetworkRoleSelector(
|
|||||||
|
|
||||||
NetworkRoleCard(
|
NetworkRoleCard(
|
||||||
title = "Client",
|
title = "Client",
|
||||||
description = "Verbindet sich mit einem Master-Gerät im lokalen Netzwerk.",
|
description = "Verbindung zum Master im LAN.",
|
||||||
isSelected = selectedRole == NetworkRole.CLIENT,
|
isSelected = selectedRole == NetworkRole.CLIENT,
|
||||||
onClick = { if (enabled) onRoleSelected(NetworkRole.CLIENT) },
|
onClick = { if (enabled) onRoleSelected(NetworkRole.CLIENT) },
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
modifier = Modifier.onKeyEvent {
|
modifier = Modifier.weight(1f).onKeyEvent {
|
||||||
if (enabled && (it.key == Key.Enter || it.key == Key.Spacebar) && it.type == KeyEventType.KeyUp) {
|
if (enabled && (it.key == Key.Enter || it.key == Key.Spacebar) && it.type == KeyEventType.KeyUp) {
|
||||||
onRoleSelected(NetworkRole.CLIENT)
|
onRoleSelected(NetworkRole.CLIENT)
|
||||||
true
|
true
|
||||||
@@ -66,13 +67,14 @@ private fun NetworkRoleCard(
|
|||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
shape = MaterialTheme.shapes.medium,
|
shape = MaterialTheme.shapes.medium,
|
||||||
color = when {
|
color = when {
|
||||||
isSelected -> MaterialTheme.colorScheme.primaryContainer
|
isSelected -> MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.7f)
|
||||||
!enabled -> MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
!enabled -> MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f)
|
||||||
else -> MaterialTheme.colorScheme.surfaceVariant
|
else -> MaterialTheme.colorScheme.surface
|
||||||
},
|
},
|
||||||
modifier = modifier.fillMaxWidth()
|
border = if (isSelected) BorderStroke(2.dp, MaterialTheme.colorScheme.primary) else BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),
|
||||||
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
RadioButton(
|
RadioButton(
|
||||||
selected = isSelected,
|
selected = isSelected,
|
||||||
onClick = null,
|
onClick = null,
|
||||||
|
|||||||
+70
-29
@@ -40,19 +40,26 @@ import javax.print.PrintServiceLookup
|
|||||||
@Composable
|
@Composable
|
||||||
actual fun DeviceInitializationConfig(
|
actual fun DeviceInitializationConfig(
|
||||||
uiState: DeviceInitializationUiState,
|
uiState: DeviceInitializationUiState,
|
||||||
viewModel: DeviceInitializationViewModel
|
viewModel: DeviceInitializationViewModel,
|
||||||
|
deviceNameFocus: FocusRequester
|
||||||
) {
|
) {
|
||||||
val settings = uiState.settings
|
val settings = uiState.settings
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val (deviceNameFocus, sharedKeyFocus, backupPathFocus, clientNameFocus, clientRoleFocus) = remember { FocusRequester.createRefs() }
|
val (_, sharedKeyFocus, backupPathFocus, clientNameFocus, clientRoleFocus) = remember { FocusRequester.createRefs() }
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
deviceNameFocus.requestFocus()
|
if (settings.deviceName.isEmpty()) {
|
||||||
|
deviceNameFocus.requestFocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(
|
||||||
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
Text("⚙️ Geräte-Konfiguration (${settings.networkRole})", style = MaterialTheme.typography.titleMedium)
|
shape = MaterialTheme.shapes.large,
|
||||||
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
|
||||||
|
) {
|
||||||
|
Column(Modifier.padding(24.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
|
Text("⚙️ Geräte-Details", style = MaterialTheme.typography.titleLarge)
|
||||||
|
|
||||||
MsTextField(
|
MsTextField(
|
||||||
value = settings.deviceName,
|
value = settings.deviceName,
|
||||||
@@ -65,13 +72,30 @@ actual fun DeviceInitializationConfig(
|
|||||||
imeAction = ImeAction.Next,
|
imeAction = ImeAction.Next,
|
||||||
keyboardActions = KeyboardActions(onNext = { focusManager.moveFocus(FocusDirection.Next) }),
|
keyboardActions = KeyboardActions(onNext = { focusManager.moveFocus(FocusDirection.Next) }),
|
||||||
modifier = Modifier.focusRequester(deviceNameFocus),
|
modifier = Modifier.focusRequester(deviceNameFocus),
|
||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked,
|
||||||
|
compact = true
|
||||||
)
|
)
|
||||||
|
|
||||||
val interfaces = remember {
|
val interfaces = remember {
|
||||||
NetworkInterface.getNetworkInterfaces().toList()
|
NetworkInterface.getNetworkInterfaces().toList()
|
||||||
.filter { it.isUp && !it.isLoopback && it.inetAddresses.hasMoreElements() }
|
.filter { it.isUp && !it.isLoopback && it.inetAddresses.hasMoreElements() }
|
||||||
.map { "${it.displayName} (${it.inetAddresses.nextElement().hostAddress})" }
|
.map { ni ->
|
||||||
|
val friendlyName = when {
|
||||||
|
ni.displayName.contains("wlan", ignoreCase = true) || ni.displayName.contains("wi-fi", ignoreCase = true) -> "WLAN"
|
||||||
|
ni.displayName.contains("eth", ignoreCase = true) || ni.displayName.contains("ethernet", ignoreCase = true) -> "Ethernet"
|
||||||
|
else -> ni.displayName
|
||||||
|
}
|
||||||
|
val address = ni.inetAddresses.asSequence()
|
||||||
|
.filter { !it.isLinkLocalAddress && it.hostAddress.indexOf(':') == -1 } // Nur IPv4, keine Link-Local
|
||||||
|
.firstOrNull()?.hostAddress ?: ni.inetAddresses.nextElement().hostAddress
|
||||||
|
"$friendlyName ($address)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(interfaces) {
|
||||||
|
if (settings.networkInterface.isEmpty() && interfaces.isNotEmpty()) {
|
||||||
|
viewModel.updateSettings { s -> s.copy(networkInterface = interfaces.first()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MsStringDropdown(
|
MsStringDropdown(
|
||||||
@@ -101,7 +125,8 @@ actual fun DeviceInitializationConfig(
|
|||||||
modifier = Modifier.focusRequester(sharedKeyFocus),
|
modifier = Modifier.focusRequester(sharedKeyFocus),
|
||||||
trailingIcon = if (passwordVisible) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
trailingIcon = if (passwordVisible) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
||||||
onTrailingIconClick = { passwordVisible = !passwordVisible },
|
onTrailingIconClick = { passwordVisible = !passwordVisible },
|
||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked,
|
||||||
|
compact = true
|
||||||
)
|
)
|
||||||
|
|
||||||
MsFilePicker(
|
MsFilePicker(
|
||||||
@@ -116,9 +141,19 @@ actual fun DeviceInitializationConfig(
|
|||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked
|
||||||
)
|
)
|
||||||
|
|
||||||
val printers = remember {
|
val printers = remember {
|
||||||
PrintServiceLookup.lookupPrintServices(null, null).map { it.name }.sorted()
|
val systemPrinters = PrintServiceLookup.lookupPrintServices(null, null).map { it.name }.toMutableList()
|
||||||
}
|
if (!systemPrinters.contains("PDF-Export (Lokal)")) {
|
||||||
|
systemPrinters.add(0, "PDF-Export (Lokal)")
|
||||||
|
}
|
||||||
|
systemPrinters.sortedBy { it != "PDF-Export (Lokal)" } // PDF immer oben
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(printers) {
|
||||||
|
if (settings.defaultPrinter.isEmpty() && printers.isNotEmpty()) {
|
||||||
|
viewModel.updateSettings { s -> s.copy(defaultPrinter = printers.first()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MsStringDropdown(
|
MsStringDropdown(
|
||||||
label = "Standard-Drucker",
|
label = "Standard-Drucker",
|
||||||
@@ -132,7 +167,8 @@ actual fun DeviceInitializationConfig(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (settings.networkRole == NetworkRole.MASTER) {
|
if (settings.networkRole == NetworkRole.MASTER) {
|
||||||
Text("Sync-Intervall: ${settings.syncInterval} Min.", style = MaterialTheme.typography.labelMedium)
|
HorizontalDivider(Modifier.padding(vertical = 8.dp))
|
||||||
|
Text("⏱️ Sync-Intervall: ${settings.syncInterval} Min.", style = MaterialTheme.typography.titleSmall)
|
||||||
Slider(
|
Slider(
|
||||||
value = settings.syncInterval.toFloat(),
|
value = settings.syncInterval.toFloat(),
|
||||||
onValueChange = { viewModel.updateSettings { s -> s.copy(syncInterval = it.toInt()) } },
|
onValueChange = { viewModel.updateSettings { s -> s.copy(syncInterval = it.toInt()) } },
|
||||||
@@ -140,20 +176,10 @@ actual fun DeviceInitializationConfig(
|
|||||||
steps = 59,
|
steps = 59,
|
||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked
|
||||||
)
|
)
|
||||||
} else if (!uiState.isLocked) {
|
|
||||||
// Button zum Abschließen für Clients, da diese keinen Slider/Clients haben
|
|
||||||
Spacer(Modifier.height(8.dp))
|
|
||||||
Button(
|
|
||||||
onClick = { viewModel.completeInitialization() },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
enabled = DeviceInitializationValidator.canContinue(settings)
|
|
||||||
) {
|
|
||||||
Text("Konfiguration abschließen")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.networkRole == NetworkRole.MASTER && !uiState.isLocked) {
|
if (settings.networkRole == NetworkRole.MASTER && !uiState.isLocked) {
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier.padding(vertical = 8.dp))
|
||||||
Text("👥 Erwartete Clients", style = MaterialTheme.typography.titleSmall)
|
Text("👥 Erwartete Clients", style = MaterialTheme.typography.titleSmall)
|
||||||
|
|
||||||
settings.expectedClients.forEachIndexed { index, client ->
|
settings.expectedClients.forEachIndexed { index, client ->
|
||||||
@@ -265,13 +291,28 @@ actual fun DeviceInitializationConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (settings.networkRole != NetworkRole.MASTER && !uiState.isLocked) {
|
} else if (settings.networkRole != NetworkRole.MASTER && !uiState.isLocked) {
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier.padding(vertical = 8.dp))
|
||||||
Text("🔍 Verfügbare Master im Netzwerk", style = MaterialTheme.typography.titleSmall)
|
Text("🔍 Verfügbare Master im Netzwerk", style = MaterialTheme.typography.titleSmall)
|
||||||
|
|
||||||
if (uiState.discoveredMasters.isEmpty()) {
|
if (uiState.discoveredMasters.isEmpty()) {
|
||||||
Box(Modifier.fillMaxWidth().padding(16.dp), contentAlignment = Alignment.Center) {
|
Surface(
|
||||||
CircularProgressIndicator(modifier = Modifier.size(24.dp))
|
color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f),
|
||||||
Text("Suche nach Master...", modifier = Modifier.padding(start = 40.dp))
|
shape = MaterialTheme.shapes.medium,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)
|
||||||
|
Spacer(Modifier.width(12.dp))
|
||||||
|
Text(
|
||||||
|
"Warte auf Master-Signal...",
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +338,7 @@ actual fun DeviceInitializationConfig(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (settings.networkRole == NetworkRole.MASTER && uiState.isLocked && settings.expectedClients.isNotEmpty()) {
|
if (settings.networkRole == NetworkRole.MASTER && uiState.isLocked && settings.expectedClients.isNotEmpty()) {
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier.padding(vertical = 8.dp))
|
||||||
Text("👥 Erwartete Clients", style = MaterialTheme.typography.titleSmall)
|
Text("👥 Erwartete Clients", style = MaterialTheme.typography.titleSmall)
|
||||||
settings.expectedClients.forEach { client ->
|
settings.expectedClients.forEach { client ->
|
||||||
ListItem(
|
ListItem(
|
||||||
|
|||||||
+9
-4
@@ -12,6 +12,8 @@ import androidx.compose.material.icons.outlined.VisibilityOff
|
|||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
import androidx.compose.ui.text.input.VisualTransformation
|
import androidx.compose.ui.text.input.VisualTransformation
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -20,7 +22,8 @@ import at.mocode.frontend.features.device.initialization.domain.DeviceInitializa
|
|||||||
@Composable
|
@Composable
|
||||||
actual fun DeviceInitializationConfig(
|
actual fun DeviceInitializationConfig(
|
||||||
uiState: DeviceInitializationUiState,
|
uiState: DeviceInitializationUiState,
|
||||||
viewModel: DeviceInitializationViewModel
|
viewModel: DeviceInitializationViewModel,
|
||||||
|
deviceNameFocus: FocusRequester
|
||||||
) {
|
) {
|
||||||
val settings = uiState.settings
|
val settings = uiState.settings
|
||||||
|
|
||||||
@@ -34,7 +37,8 @@ actual fun DeviceInitializationConfig(
|
|||||||
label = "Gerätename",
|
label = "Gerätename",
|
||||||
placeholder = "z.B. Web-Client",
|
placeholder = "z.B. Web-Client",
|
||||||
isError = settings.deviceName.isNotEmpty() && !DeviceInitializationValidator.isNameValid(settings.deviceName),
|
isError = settings.deviceName.isNotEmpty() && !DeviceInitializationValidator.isNameValid(settings.deviceName),
|
||||||
errorText = "Mindestens ${DeviceInitializationValidator.MIN_NAME_LENGTH} Zeichen erforderlich."
|
errorText = "Mindestens ${DeviceInitializationValidator.MIN_NAME_LENGTH} Zeichen erforderlich.",
|
||||||
|
modifier = Modifier.focusRequester(deviceNameFocus)
|
||||||
)
|
)
|
||||||
|
|
||||||
var passwordVisible by remember { mutableStateOf(false) }
|
var passwordVisible by remember { mutableStateOf(false) }
|
||||||
@@ -74,14 +78,15 @@ private fun MsSettingsField(
|
|||||||
isError: Boolean,
|
isError: Boolean,
|
||||||
errorText: String,
|
errorText: String,
|
||||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||||
trailingIcon: @Composable (() -> Unit)? = null
|
trailingIcon: @Composable (() -> Unit)? = null,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = value,
|
value = value,
|
||||||
onValueChange = onValueChange,
|
onValueChange = onValueChange,
|
||||||
label = { Text(label) },
|
label = { Text(label) },
|
||||||
placeholder = { Text(placeholder) },
|
placeholder = { Text(placeholder) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
isError = isError,
|
isError = isError,
|
||||||
visualTransformation = visualTransformation,
|
visualTransformation = visualTransformation,
|
||||||
trailingIcon = trailingIcon,
|
trailingIcon = trailingIcon,
|
||||||
|
|||||||
+11
-1
@@ -1,5 +1,6 @@
|
|||||||
package at.mocode.frontend.shell.desktop
|
package at.mocode.frontend.shell.desktop
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -25,7 +26,16 @@ import org.koin.compose.viewmodel.koinViewModel
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun DesktopApp() {
|
fun DesktopApp() {
|
||||||
AppTheme {
|
val deviceInitViewModel: at.mocode.frontend.features.device.initialization.presentation.DeviceInitializationViewModel = koinViewModel()
|
||||||
|
val deviceSettings by deviceInitViewModel.uiState.collectAsState()
|
||||||
|
|
||||||
|
val isDark = when(deviceSettings.settings.appTheme) {
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.SYSTEM -> isSystemInDarkTheme()
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.LIGHT -> false
|
||||||
|
at.mocode.frontend.features.device.initialization.domain.model.AppThemeSetting.DARK -> true
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTheme(darkTheme = isDark) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
color = MaterialTheme.colorScheme.background,
|
color = MaterialTheme.colorScheme.background,
|
||||||
|
|||||||
+6
-4
@@ -66,17 +66,19 @@ fun DesktopContentArea(
|
|||||||
// DeviceInitialization (Geräte-Setup)
|
// DeviceInitialization (Geräte-Setup)
|
||||||
is AppScreen.DeviceInitialization -> {
|
is AppScreen.DeviceInitialization -> {
|
||||||
println("[Screen] Rendering DeviceInitialization")
|
println("[Screen] Rendering DeviceInitialization")
|
||||||
val viewModel = koinViewModel<DeviceInitializationViewModel> {
|
val viewModel = koinViewModel<DeviceInitializationViewModel>()
|
||||||
parametersOf({ finalSettings: DeviceInitializationSettings ->
|
|
||||||
|
LaunchedEffect(viewModel) {
|
||||||
|
viewModel.initializationCompleteEvent.collect { finalSettings ->
|
||||||
DeviceInitializationSettingsManager.saveSettings(finalSettings)
|
DeviceInitializationSettingsManager.saveSettings(finalSettings)
|
||||||
// Vision_04: Sicherheitsschlüssel als Token setzen, damit Cloud-Suche funktioniert
|
// Vision_04: Sicherheitsschlüssel als Token setzen, damit Cloud-Suche funktioniert
|
||||||
val authTokenManager = org.koin.core.context.GlobalContext.get().get<AuthTokenManager>()
|
val authTokenManager = org.koin.core.context.GlobalContext.get().get<AuthTokenManager>()
|
||||||
authTokenManager.setToken(finalSettings.sharedKey)
|
authTokenManager.setToken(finalSettings.sharedKey)
|
||||||
onSettingsChange(finalSettings)
|
onSettingsChange(finalSettings)
|
||||||
// nav.navigateToScreen(...) wird hier nicht direkt gerufen, sondern onNavigate
|
|
||||||
onNavigate(AppScreen.EventVerwaltung)
|
onNavigate(AppScreen.EventVerwaltung)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceInitializationScreen(viewModel = viewModel)
|
DeviceInitializationScreen(viewModel = viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user