Files
HHA/app/lib/domain/entities/logistic_object.dart
2026-03-24 15:03:35 +01:00

251 lines
6.0 KiB
Dart

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
class LogisticObject extends Equatable {
final int id;
final int objectId;
final int type;
final int version;
final int? locationId;
final String code;
final String? remark;
final String state;
final String subtype;
final String? origin;
final bool isManual;
final DateTime? lastModified;
final String? typeName;
final String? typeMnemonic;
const LogisticObject({
required this.id,
required this.objectId,
required this.type,
required this.version,
this.locationId,
required this.code,
this.remark,
required this.state,
required this.subtype,
this.origin,
this.isManual = false,
this.lastModified,
this.typeName,
this.typeMnemonic,
});
LogisticObject copyWith({
int? id,
int? objectId,
int? type,
int? version,
int? locationId,
String? code,
String? remark,
String? state,
String? subtype,
String? origin,
bool? isManual,
DateTime? lastModified,
String? typeName,
String? typeMnemonic,
}) {
return LogisticObject(
id: id ?? this.id,
objectId: objectId ?? this.objectId,
type: type ?? this.type,
version: version ?? this.version,
locationId: locationId ?? this.locationId,
code: code ?? this.code,
remark: remark ?? this.remark,
state: state ?? this.state,
subtype: subtype ?? this.subtype,
origin: origin ?? this.origin,
isManual: isManual ?? this.isManual,
lastModified: lastModified ?? this.lastModified,
typeName: typeName ?? this.typeName,
typeMnemonic: typeMnemonic ?? this.typeMnemonic,
);
}
@override
List<Object?> get props => [
id,
objectId,
type,
version,
locationId,
code,
remark,
state,
subtype,
origin,
isManual,
lastModified,
typeName,
typeMnemonic,
];
}
class ObjectMetadata extends Equatable {
final int id;
final int type;
final int version;
final String mnemonic;
final String name;
final String prefix;
final String subtype;
final String counterText;
const ObjectMetadata({
required this.id,
required this.type,
required this.version,
required this.mnemonic,
required this.name,
required this.prefix,
required this.subtype,
required this.counterText,
});
@override
List<Object?> get props => [
id,
type,
version,
mnemonic,
name,
prefix,
subtype,
counterText,
];
}
class ObjectStateInfo {
final String state;
final String displayName;
final int colorValue;
final String iconName;
const ObjectStateInfo({
required this.state,
required this.displayName,
required this.colorValue,
required this.iconName,
});
static const Map<String, ObjectStateInfo> stateInfos = {
'unknown': ObjectStateInfo(
state: 'unknown',
displayName: 'Unbekannt',
colorValue: 0xFFFFFFFF,
iconName: 'help',
),
'delivery': ObjectStateInfo(
state: 'delivery',
displayName: 'Im Fahrzeug',
colorValue: 0xFFB3B3B3,
iconName: 'local_shipping',
),
'to_delivery': ObjectStateInfo(
state: 'to_delivery',
displayName: 'Zum Fahrzeug',
colorValue: 0xFFB3B3B3,
iconName: 'local_shipping_outlined',
),
'station': ObjectStateInfo(
state: 'station',
displayName: 'An Station',
colorValue: 0xFFFFDD00,
iconName: 'location_on',
),
'in_fa': ObjectStateInfo(
state: 'in_fa',
displayName: 'Im Fahrscheinautomat',
colorValue: 0xFF9CDA7A,
iconName: 'confirmation_number',
),
'in_vs': ObjectStateInfo(
state: 'in_vs',
displayName: 'In Versorgungsstelle',
colorValue: 0xFFFAE14B,
iconName: 'inventory',
),
'ret_fail': ObjectStateInfo(
state: 'ret_fail',
displayName: 'Fehler - zur Dienststelle',
colorValue: 0xFFFF9081,
iconName: 'error',
),
'ret_fail_fzg': ObjectStateInfo(
state: 'ret_fail_fzg',
displayName: 'Fehler - im Fahrzeug',
colorValue: 0xFFFF9081,
iconName: 'error_outline',
),
'ret_ds': ObjectStateInfo(
state: 'ret_ds',
displayName: 'Zur Dienststelle',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance',
),
'ret_ds_fzg': ObjectStateInfo(
state: 'ret_ds_fzg',
displayName: 'Zur Dienststelle (Fzg)',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_outlined',
),
'ret_gi': ObjectStateInfo(
state: 'ret_gi',
displayName: 'Zum Geldinstitut',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_wallet',
),
'ret_gi_fzg': ObjectStateInfo(
state: 'ret_gi_fzg',
displayName: 'Zum Geldinstitut (Fzg)',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_wallet_outlined',
),
'fin_ds': ObjectStateInfo(
state: 'fin_ds',
displayName: 'In Dienststelle',
colorValue: 0xFF29B7FB,
iconName: 'check_circle',
),
'fin_gi': ObjectStateInfo(
state: 'fin_gi',
displayName: 'In Geldinstitut',
colorValue: 0xFF25BAFC,
iconName: 'check_circle_outline',
),
'hdl': ObjectStateInfo(
state: 'hdl',
displayName: 'Handel',
colorValue: 0xFF9E9E9E,
iconName: 'shopping_cart',
),
'ret_ds_empty': ObjectStateInfo(
state: 'ret_ds_empty',
displayName: 'Leer - zur Dienststelle',
colorValue: 0xFFAFE0ED,
iconName: 'remove_circle_outline',
),
};
static Color getColorForState(String state) {
final info = stateInfos[state];
return info != null ? Color(info.colorValue) : const Color(0xFFFFFFFF);
}
static String getDisplayName(String state) {
final info = stateInfos[state];
return info?.displayName ?? 'Unbekannt';
}
static String getIconName(String state) {
final info = stateInfos[state];
return info?.iconName ?? 'help';
}
}