chahinebrini d54bd06727 feat(magic): post-login Device-Hub als zentraler Einstieg + Limit 3->5
Redesign:
- Nach Login landet User direkt im neuen DeviceHubView statt
  Auto-Mac-Registrierung. Hub zeigt: User-Email, X/5-Slot-Counter,
  Liste aller registrierten Geraete + 'Geraet hinzufuegen' mit
  iPhone/iPad vs Mac Wahl.
- Mac wird NUR registriert wenn User aktiv 'Mac' im Hub waehlt
  (frueher: auto on app-start, frass Slot).
- iOS-Pfad: Hub -> Welcome/Preflight/Supervise/Enroll/Configure
  -> Done -> 'Zurueck zur Geraete-Uebersicht'.
- Mac-Pfad: Hub -> MacRegistrationView (Register+DNS-Install)
  -> 'Fertig -> Hub'.
- Wizard-Header hat jetzt Grid-Icon 'Zur Geraete-Uebersicht' als
  Escape-Hatch jederzeit.
- Per-Device-Loeschung im Hub: Trash-Icon -> Confirm-Dialog
  ('Auf X muss Freigabe bestaetigt werden, 24h Cooldown') ->
  request-release-Endpoint (existing infra).
- Device-Limit 3 -> 5 in backend (Staging-Testing + Legend-Wert
  fuer spaeter).
- StepIndicator/Step-Counter: macRegistration zaehlt nicht im
  iOS-Flow.
2026-06-03 10:39:51 +02:00

136 lines
4.6 KiB
Swift

import AppKit
import SwiftUI
struct ContentView: View {
@Environment(WizardModel.self) private var model
@State private var showingHelp = false
var body: some View {
Group {
if model.showingLogin {
LoginView { session in
model.handleLogin(session: session)
}
} else if model.showingHub {
DeviceHubView()
} else {
mainWizardView
}
}
.sheet(isPresented: Binding(
get: { model.showingManageBindings },
set: { model.showingManageBindings = $0 }
)) {
ManageBindingsView {
model.showingManageBindings = false
}
}
}
@ViewBuilder
private var mainWizardView: some View {
VStack(spacing: 0) {
VStack(spacing: 8) {
HStack {
appBadge
VStack(alignment: .leading, spacing: 1) {
Text("Rebreak Magic")
.font(.headline)
Text("iPhone bind ohne Werks-Reset")
.font(.caption)
.foregroundStyle(.secondary)
}
Spacer()
// Back to Hub
Button(action: { model.returnToHub() }) {
Image(systemName: "rectangle.grid.2x2")
.font(.title3)
.foregroundStyle(.secondary)
}
.buttonStyle(.plain)
.help("Zur Geräte-Übersicht")
.padding(.trailing, 4)
// Help-Button
Button(action: { showingHelp = true }) {
Image(systemName: "questionmark.circle")
.font(.title3)
.foregroundStyle(.secondary)
}
.buttonStyle(.plain)
.help("Hilfe & FAQ (⌘?)")
.keyboardShortcut("?", modifiers: .command)
if model.step != .done && model.step != .macRegistration {
Text("Schritt \(model.step.stepNumber - 1) von \(WizardStep.total - 1)")
.font(.caption)
.foregroundStyle(.secondary)
.padding(.leading, 12)
}
}
.padding(.horizontal, 20)
.padding(.top, 16)
StepIndicator(current: model.step)
}
.background(Color(NSColor.windowBackgroundColor))
Divider()
// Main content
Group {
switch model.step {
case .macRegistration: MacRegistrationView()
case .welcome: WelcomeView()
case .preflight: PreflightView()
case .supervise: SuperviseView()
case .enroll: EnrollView()
case .configure: ConfigureView()
case .done: DoneView()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.sheet(isPresented: $showingHelp) {
HelpView()
}
}
@ViewBuilder
private var appBadge: some View {
if let icon = resolvedAppIcon {
Image(nsImage: icon)
.resizable()
.frame(width: 28, height: 28)
.clipShape(RoundedRectangle(cornerRadius: 7, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 7, style: .continuous)
.strokeBorder(.white.opacity(0.25), lineWidth: 1)
)
} else {
ZStack {
RoundedRectangle(cornerRadius: 7, style: .continuous)
.fill(Color.accentColor.opacity(0.15))
Image(systemName: "shield.lefthalf.filled")
.foregroundStyle(.tint)
}
.frame(width: 28, height: 28)
}
}
private var resolvedAppIcon: NSImage? {
if let icon = NSApplication.shared.applicationIconImage,
icon.size.width > 2,
icon.size.height > 2 {
return icon
}
let bundleIcon = NSWorkspace.shared.icon(forFile: Bundle.main.bundlePath)
if bundleIcon.size.width > 2, bundleIcon.size.height > 2 {
return bundleIcon
}
return nil
}
}