Implemented settings, new scan, enhanced UI/UX
This commit is contained in:
@ -1,27 +1,52 @@
|
||||
import 'package:hl_lieferservice/model/delivery.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'delivery_update.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class DeliveryOptionUpdateDTO {
|
||||
DeliveryOptionUpdateDTO({
|
||||
required this.numerical,
|
||||
required this.value,
|
||||
required this.key,
|
||||
});
|
||||
|
||||
bool numerical;
|
||||
String value;
|
||||
String key;
|
||||
|
||||
factory DeliveryOptionUpdateDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$DeliveryOptionUpdateDTOFromJson(json);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => _$DeliveryOptionUpdateDTOToJson(this);
|
||||
|
||||
factory DeliveryOptionUpdateDTO.fromEntity(DeliveryOption option) {
|
||||
return DeliveryOptionUpdateDTO(
|
||||
numerical: option.numerical,
|
||||
value: option.value,
|
||||
key: option.key,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class DeliveryUpdateDTO {
|
||||
DeliveryUpdateDTO({
|
||||
required this.deliveryId,
|
||||
this.note,
|
||||
this.finishedDate,
|
||||
this.discount,
|
||||
this.selectedPaymentMethodId,
|
||||
this.options,
|
||||
this.state,
|
||||
this.carId,
|
||||
});
|
||||
|
||||
String deliveryId;
|
||||
String? note;
|
||||
String? finishedDate;
|
||||
String? state;
|
||||
int? carId;
|
||||
String? carId;
|
||||
String? selectedPaymentMethodId;
|
||||
double? discount;
|
||||
List<DeliveryOptionUpdateDTO>? options;
|
||||
|
||||
factory DeliveryUpdateDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$DeliveryUpdateDTOFromJson(json);
|
||||
@ -47,7 +72,10 @@ class DeliveryUpdateDTO {
|
||||
return DeliveryUpdateDTO(
|
||||
deliveryId: delivery.id,
|
||||
state: state,
|
||||
carId: delivery.carId,
|
||||
carId: delivery.carId?.toString() ,
|
||||
selectedPaymentMethodId: delivery.payment.id,
|
||||
options: delivery.options.map(DeliveryOptionUpdateDTO.fromEntity).toList(),
|
||||
finishedDate: DateTime.now().millisecondsSinceEpoch.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -6,24 +6,44 @@ part of 'delivery_update.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DeliveryOptionUpdateDTO _$DeliveryOptionUpdateDTOFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => DeliveryOptionUpdateDTO(
|
||||
numerical: json['numerical'] as bool,
|
||||
value: json['value'] as String,
|
||||
key: json['key'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DeliveryOptionUpdateDTOToJson(
|
||||
DeliveryOptionUpdateDTO instance,
|
||||
) => <String, dynamic>{
|
||||
'numerical': instance.numerical,
|
||||
'value': instance.value,
|
||||
'key': instance.key,
|
||||
};
|
||||
|
||||
DeliveryUpdateDTO _$DeliveryUpdateDTOFromJson(Map<String, dynamic> json) =>
|
||||
DeliveryUpdateDTO(
|
||||
deliveryId: json['delivery_id'] as String,
|
||||
note: json['note'] as String?,
|
||||
finishedDate: json['finished_date'] as String?,
|
||||
discount: (json['discount'] as num?)?.toDouble(),
|
||||
selectedPaymentMethodId: json['selected_payment_method_id'] as String?,
|
||||
options:
|
||||
(json['options'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) =>
|
||||
DeliveryOptionUpdateDTO.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
state: json['state'] as String?,
|
||||
carId: (json['car_id'] as num?)?.toInt(),
|
||||
carId: json['car_id'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DeliveryUpdateDTOToJson(DeliveryUpdateDTO instance) =>
|
||||
<String, dynamic>{
|
||||
'delivery_id': instance.deliveryId,
|
||||
'note': instance.note,
|
||||
'finished_date': instance.finishedDate,
|
||||
'state': instance.state,
|
||||
'car_id': instance.carId,
|
||||
'selected_payment_method_id': instance.selectedPaymentMethodId,
|
||||
'discount': instance.discount,
|
||||
'options': instance.options,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user