96 lines
2.4 KiB
Dart
96 lines
2.4 KiB
Dart
part of 'tour_bloc.dart';
|
|
|
|
abstract class TourState extends Equatable {
|
|
const TourState();
|
|
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
class TourInitial extends TourState {}
|
|
|
|
class TourLoading extends TourState {}
|
|
|
|
class ToursLoaded extends TourState {
|
|
final List<Tour> tours;
|
|
final List<Tour> completedTours;
|
|
final List<Tour> allTours;
|
|
final Tour? selectedTour;
|
|
final List<LogisticObject>? selectedTourObjects;
|
|
final TourStatistics? selectedTourStats;
|
|
final bool isSyncing;
|
|
final bool isLoadingDetails;
|
|
final bool showCompleted;
|
|
|
|
const ToursLoaded({
|
|
required this.tours,
|
|
this.completedTours = const [],
|
|
required this.allTours,
|
|
this.selectedTour,
|
|
this.selectedTourObjects,
|
|
this.selectedTourStats,
|
|
this.isSyncing = false,
|
|
this.isLoadingDetails = false,
|
|
this.showCompleted = true,
|
|
});
|
|
|
|
ToursLoaded copyWith({
|
|
List<Tour>? tours,
|
|
List<Tour>? completedTours,
|
|
List<Tour>? allTours,
|
|
Tour? selectedTour,
|
|
List<LogisticObject>? selectedTourObjects,
|
|
TourStatistics? selectedTourStats,
|
|
bool? isSyncing,
|
|
bool? isLoadingDetails,
|
|
bool? showCompleted,
|
|
}) {
|
|
return ToursLoaded(
|
|
tours: tours ?? this.tours,
|
|
completedTours: completedTours ?? this.completedTours,
|
|
allTours: allTours ?? this.allTours,
|
|
selectedTour: selectedTour ?? this.selectedTour,
|
|
selectedTourObjects: selectedTourObjects ?? this.selectedTourObjects,
|
|
selectedTourStats: selectedTourStats ?? this.selectedTourStats,
|
|
isSyncing: isSyncing ?? this.isSyncing,
|
|
isLoadingDetails: isLoadingDetails ?? this.isLoadingDetails,
|
|
showCompleted: showCompleted ?? this.showCompleted,
|
|
);
|
|
}
|
|
|
|
int get completedCount => completedTours.length;
|
|
int get totalCount => allTours.length;
|
|
double get completionPercentage => totalCount > 0 ? (completedCount / totalCount) * 100 : 0;
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
tours,
|
|
completedTours,
|
|
allTours,
|
|
selectedTour,
|
|
selectedTourObjects,
|
|
selectedTourStats,
|
|
isSyncing,
|
|
isLoadingDetails,
|
|
showCompleted,
|
|
];
|
|
}
|
|
|
|
class TourError extends TourState {
|
|
final String message;
|
|
|
|
const TourError({required this.message});
|
|
|
|
@override
|
|
List<Object?> get props => [message];
|
|
}
|
|
|
|
class SyncError extends TourState {
|
|
final String message;
|
|
|
|
const SyncError({required this.message});
|
|
|
|
@override
|
|
List<Object?> get props => [message];
|
|
}
|