41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../theme/app_theme.dart';
|
|
|
|
enum AuftragStatus {
|
|
offen,
|
|
geplant,
|
|
fertig,
|
|
}
|
|
|
|
extension AuftragStatusX on AuftragStatus {
|
|
/// Wert in Appwrite (englisch, stabil).
|
|
String get storageValue => name;
|
|
|
|
String get labelDe => switch (this) {
|
|
AuftragStatus.offen => 'Offen',
|
|
AuftragStatus.geplant => 'Geplant',
|
|
AuftragStatus.fertig => 'Fertig',
|
|
};
|
|
|
|
Color get badgeColor => switch (this) {
|
|
AuftragStatus.offen => AppTheme.statusOffen,
|
|
AuftragStatus.geplant => AppTheme.statusGeplant,
|
|
AuftragStatus.fertig => AppTheme.statusFertig,
|
|
};
|
|
}
|
|
|
|
AuftragStatus auftragStatusFromStorage(
|
|
String? raw, {
|
|
required String betragTextLegacy,
|
|
}) {
|
|
if (raw != null && raw.isNotEmpty) {
|
|
for (final s in AuftragStatus.values) {
|
|
if (s.name == raw) return s;
|
|
}
|
|
}
|
|
// Alte Datensätze ohne Feld: einmalig aus Betrag ableiten
|
|
if (betragTextLegacy.trim().isNotEmpty) return AuftragStatus.fertig;
|
|
return AuftragStatus.geplant;
|
|
}
|