diff --git a/ios/Sources/DashboardCards.swift b/ios/Sources/DashboardCards.swift index 4481f8d..72569ca 100644 --- a/ios/Sources/DashboardCards.swift +++ b/ios/Sources/DashboardCards.swift @@ -295,7 +295,7 @@ struct ExpiryCard: View { .font(.caption2).foregroundStyle(.secondary) } Spacer() - Text(item.daysLeft < 0 ? "abgelaufen" : "\(item.daysLeft) Tage") + Text(item.restlaufzeitText) .font(.caption).bold() .foregroundStyle(item.daysLeft < 0 ? .red : .orange) } diff --git a/ios/Sources/ListViews.swift b/ios/Sources/ListViews.swift index 965ba4d..39cf856 100644 --- a/ios/Sources/ListViews.swift +++ b/ios/Sources/ListViews.swift @@ -146,7 +146,7 @@ struct ExpiringView: View { .font(.caption).foregroundStyle(.secondary) } Spacer() - Text(restText(item.daysLeft)) + Text(item.restlaufzeitText) .font(.caption).bold() .foregroundStyle(item.daysLeft < 0 ? .red : .orange) } @@ -181,11 +181,6 @@ struct ExpiringView: View { return "\(formatAmount(item.quantity / faktor)) \(item.unitName)" } - private func restText(_ days: Int) -> String { - if days < 0 { return "abgelaufen" } - if days == 0 { return "heute" } - return days == 1 ? "1 Tag" : "\(days) Tage" - } } // MARK: - Mindestbestände diff --git a/ios/Sources/Models.swift b/ios/Sources/Models.swift index 88643d4..bade83e 100644 --- a/ios/Sources/Models.swift +++ b/ios/Sources/Models.swift @@ -504,6 +504,15 @@ struct ExpiringItem: Codable, Identifiable { var id: Int { lotId } + /// Restlaufzeit als kurzer Text. „0 Tage" ergibt keinen Sinn - am Ablauftag + /// selbst steht „heute". Karte und Liste nutzen dieselbe Formulierung. + var restlaufzeitText: String { + if daysLeft < 0 { return "abgelaufen" } + if daysLeft == 0 { return "heute" } + if daysLeft == 1 { return "morgen" } + return "\(daysLeft) Tage" + } + enum CodingKeys: String, CodingKey { case quantity case lotId = "lot_id"