Added separate car loaded event
This commit is contained in:
@ -58,17 +58,10 @@ class _CarManagementPageState extends State<CarManagementPage> {
|
|||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is CarsLoaded &&
|
if (state is CarsLoaded &&
|
||||||
context.read<TourBloc>().state is TourLoaded) {
|
context.read<TourBloc>().state is TourLoaded) {
|
||||||
var tour =
|
context.read<TourBloc>().add(CarsLoadedEvent(cars: state.cars));
|
||||||
(context.read<TourBloc>().state as TourLoaded).tour.copyWith();
|
|
||||||
tour.driver.cars = state.cars;
|
|
||||||
context.read<TourBloc>().add(
|
|
||||||
TourUpdated(tour: tour, payments: tour.paymentMethods),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
debugPrint('BlocBuilder rebuilding with state: $state');
|
|
||||||
|
|
||||||
if (state is CarsLoading) {
|
if (state is CarsLoading) {
|
||||||
return Center(child: const CircularProgressIndicator());
|
return Center(child: const CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ class TourBloc extends Bloc<TourEvent, TourState> {
|
|||||||
on<RequestDeliveryDistanceEvent>(_calculateDistances);
|
on<RequestDeliveryDistanceEvent>(_calculateDistances);
|
||||||
on<RequestSortingInformationEvent>(_requestSortingInformation);
|
on<RequestSortingInformationEvent>(_requestSortingInformation);
|
||||||
on<ReorderDeliveryEvent>(_reorderDelivery);
|
on<ReorderDeliveryEvent>(_reorderDelivery);
|
||||||
|
on<CarsLoadedEvent>(_carsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -63,6 +64,14 @@ class TourBloc extends Bloc<TourEvent, TourState> {
|
|||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _carsLoaded(CarsLoadedEvent event, Emitter<TourState> emit) {
|
||||||
|
final currentState = state;
|
||||||
|
if (currentState is TourLoaded) {
|
||||||
|
currentState.tour.driver.cars = event.cars;
|
||||||
|
emit(currentState.copyWith());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _reorderDelivery(
|
void _reorderDelivery(
|
||||||
ReorderDeliveryEvent event,
|
ReorderDeliveryEvent event,
|
||||||
Emitter<TourState> emit,
|
Emitter<TourState> emit,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:hl_lieferservice/model/car.dart';
|
||||||
import 'package:hl_lieferservice/model/tour.dart';
|
import 'package:hl_lieferservice/model/tour.dart';
|
||||||
|
|
||||||
import '../../../../model/delivery.dart';
|
import '../../../../model/delivery.dart';
|
||||||
@ -24,7 +25,11 @@ class RequestSortingInformationEvent extends TourEvent {
|
|||||||
List<Payment> payments;
|
List<Payment> payments;
|
||||||
Map<String, double>? distances;
|
Map<String, double>? distances;
|
||||||
|
|
||||||
RequestSortingInformationEvent({required this.tour, required this.payments, this.distances});
|
RequestSortingInformationEvent({
|
||||||
|
required this.tour,
|
||||||
|
required this.payments,
|
||||||
|
this.distances,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReorderDeliveryEvent extends TourEvent {
|
class ReorderDeliveryEvent extends TourEvent {
|
||||||
@ -65,11 +70,19 @@ class IncrementArticleScanAmount extends TourEvent {
|
|||||||
String deliveryId;
|
String deliveryId;
|
||||||
String carId;
|
String carId;
|
||||||
|
|
||||||
IncrementArticleScanAmount({required this.internalArticleId, required this.deliveryId, required this.carId});
|
IncrementArticleScanAmount({
|
||||||
|
required this.internalArticleId,
|
||||||
|
required this.deliveryId,
|
||||||
|
required this.carId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScanArticleEvent extends TourEvent {
|
class ScanArticleEvent extends TourEvent {
|
||||||
ScanArticleEvent({required this.articleNumber, required this.carId, required this.deliveryId});
|
ScanArticleEvent({
|
||||||
|
required this.articleNumber,
|
||||||
|
required this.carId,
|
||||||
|
required this.deliveryId,
|
||||||
|
});
|
||||||
|
|
||||||
String articleNumber;
|
String articleNumber;
|
||||||
String deliveryId;
|
String deliveryId;
|
||||||
@ -105,7 +118,7 @@ class UnscanArticleEvent extends TourEvent {
|
|||||||
required this.articleId,
|
required this.articleId,
|
||||||
required this.newAmount,
|
required this.newAmount,
|
||||||
required this.reason,
|
required this.reason,
|
||||||
required this.deliveryId
|
required this.deliveryId,
|
||||||
});
|
});
|
||||||
|
|
||||||
String articleId;
|
String articleId;
|
||||||
@ -151,8 +164,18 @@ class UpdateDiscountEvent extends TourEvent {
|
|||||||
int? value;
|
int? value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CarsLoadedEvent extends TourEvent {
|
||||||
|
List<Car> cars;
|
||||||
|
|
||||||
|
CarsLoadedEvent({required this.cars});
|
||||||
|
}
|
||||||
|
|
||||||
class UpdateDeliveryOptionEvent extends TourEvent {
|
class UpdateDeliveryOptionEvent extends TourEvent {
|
||||||
UpdateDeliveryOptionEvent({required this.key, required this.value, required this.deliveryId});
|
UpdateDeliveryOptionEvent({
|
||||||
|
required this.key,
|
||||||
|
required this.value,
|
||||||
|
required this.deliveryId,
|
||||||
|
});
|
||||||
|
|
||||||
String deliveryId;
|
String deliveryId;
|
||||||
String key;
|
String key;
|
||||||
@ -160,7 +183,10 @@ class UpdateDeliveryOptionEvent extends TourEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UpdateSelectedPaymentMethodEvent extends TourEvent {
|
class UpdateSelectedPaymentMethodEvent extends TourEvent {
|
||||||
UpdateSelectedPaymentMethodEvent({required this.payment, required this.deliveryId});
|
UpdateSelectedPaymentMethodEvent({
|
||||||
|
required this.payment,
|
||||||
|
required this.deliveryId,
|
||||||
|
});
|
||||||
|
|
||||||
Payment payment;
|
Payment payment;
|
||||||
String deliveryId;
|
String deliveryId;
|
||||||
@ -176,4 +202,4 @@ class FinishDeliveryEvent extends TourEvent {
|
|||||||
String deliveryId;
|
String deliveryId;
|
||||||
Uint8List customerSignature;
|
Uint8List customerSignature;
|
||||||
Uint8List driverSignature;
|
Uint8List driverSignature;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user