iOS-App angefangen; Import-Modi; MHD-Formatierung; Gebinde in Ablauf-Ansichten
iOS (neu, ios/):
- SwiftUI-App: Login (Server + Keychain-Token), Kamera-Scanner (EAN/UPC/Code128),
Einlagern mit mehreren Chargen und eigenem MHD, Auslagern mit Chargenauswahl
oder FEFO, Artikelsuche, Anlegen mit Open-Food-Facts-Vorbefuellung.
- Home-Screen-Shortcuts: Schnellaktionen (langer Druck) und URL-Schema
projectgood://checkin | ://checkout fuer eigene Symbole via Kurzbefehle.
- project.yml (XcodeGen) + README mit Build-Anleitung. NICHT kompiliert - auf
diesem Rechner ist kein Xcode vorhanden.
Import-Modi (wie besprochen sinnvoll):
- add (Standard, nichts loeschen), replace_listed (Bestaende der in der Datei
genannten Produkte ersetzen - fuer Inventur), replace_all (alles ersetzen).
Geleerte Bestaende werden als Korrektur-Bewegung protokolliert; die Oberflaeche
fragt bei den zerstoerenden Modi nach.
Anzeige:
- "Bald ablaufend"/"Abgelaufen" zeigen jetzt das Gebinde ("1 Glas") mit der
Basiseinheit klein darunter (ExpiringItem liefert die Einheiten mit).
- MHD als Zeitspanne mit korrektem Numerus: "in 3 Tagen", "in 1 Woche",
"vor 2 Wochen", dazu heute/morgen/gestern.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
69
ios/Sources/ProjectGoodApp.swift
Normal file
69
ios/Sources/ProjectGoodApp.swift
Normal file
@@ -0,0 +1,69 @@
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
/// Zielbildschirm, der über Home-Screen-Shortcut oder URL angesprungen wird.
|
||||
enum Route: String {
|
||||
case checkin
|
||||
case checkout
|
||||
}
|
||||
|
||||
final class Router: ObservableObject {
|
||||
@Published var route: Route?
|
||||
|
||||
func handle(shortcut type: String) {
|
||||
if type.hasSuffix("checkin") { route = .checkin }
|
||||
if type.hasSuffix("checkout") { route = .checkout }
|
||||
}
|
||||
|
||||
/// projectgood://checkin bzw. projectgood://checkout
|
||||
func handle(url: URL) {
|
||||
guard url.scheme == "projectgood" else { return }
|
||||
let target = (url.host ?? url.path.replacingOccurrences(of: "/", with: "")).lowercased()
|
||||
if let route = Route(rawValue: target) { self.route = route }
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
struct ProjectGoodApp: App {
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
@StateObject private var session = Session.shared
|
||||
@StateObject private var router = Router()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
RootView()
|
||||
.environmentObject(session)
|
||||
.environmentObject(router)
|
||||
.onOpenURL { router.handle(url: $0) }
|
||||
.onAppear {
|
||||
if let type = AppDelegate.pendingShortcut {
|
||||
router.handle(shortcut: type)
|
||||
AppDelegate.pendingShortcut = nil
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: AppDelegate.shortcutNotification)) { note in
|
||||
if let type = note.object as? String { router.handle(shortcut: type) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Nimmt Home-Screen-Quick-Actions entgegen (auch beim Kaltstart).
|
||||
final class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
static let shortcutNotification = Notification.Name("ProjectGoodShortcut")
|
||||
static var pendingShortcut: String?
|
||||
|
||||
func application(_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
|
||||
if let item = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem {
|
||||
AppDelegate.pendingShortcut = item.type
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication,
|
||||
performActionFor shortcutItem: UIApplicationShortcutItem) async -> Bool {
|
||||
NotificationCenter.default.post(name: AppDelegate.shortcutNotification, object: shortcutItem.type)
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user