feat(App): update Finlytic Flutter app UI and blocs
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:finlytic_app/features/calendar/models/corporate_event_model.dart';
|
||||
|
||||
abstract class CalendarState extends Equatable {
|
||||
const CalendarState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class CalendarInitial extends CalendarState {}
|
||||
|
||||
class CalendarLoading extends CalendarState {}
|
||||
|
||||
class CalendarLoaded extends CalendarState {
|
||||
final List<CorporateEventModel> allEvents;
|
||||
final String selectedCategory;
|
||||
final DateTime currentMonth;
|
||||
final DateTime? selectedDate;
|
||||
|
||||
const CalendarLoaded({
|
||||
required this.allEvents,
|
||||
this.selectedCategory = 'Alle',
|
||||
required this.currentMonth,
|
||||
this.selectedDate,
|
||||
});
|
||||
|
||||
List<CorporateEventModel> get filteredEvents {
|
||||
return allEvents.where((e) {
|
||||
if (selectedCategory != 'Alle' && e.eventType != selectedCategory) {
|
||||
return false;
|
||||
}
|
||||
if (selectedDate != null) {
|
||||
if (e.eventDate.year != selectedDate!.year ||
|
||||
e.eventDate.month != selectedDate!.month ||
|
||||
e.eventDate.day != selectedDate!.day) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
CalendarLoaded copyWith({
|
||||
List<CorporateEventModel>? allEvents,
|
||||
String? selectedCategory,
|
||||
DateTime? currentMonth,
|
||||
DateTime? selectedDate,
|
||||
bool clearSelectedDate = false,
|
||||
}) {
|
||||
return CalendarLoaded(
|
||||
allEvents: allEvents ?? this.allEvents,
|
||||
selectedCategory: selectedCategory ?? this.selectedCategory,
|
||||
currentMonth: currentMonth ?? this.currentMonth,
|
||||
selectedDate: clearSelectedDate ? null : (selectedDate ?? this.selectedDate),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [allEvents, selectedCategory, currentMonth, selectedDate];
|
||||
}
|
||||
|
||||
class CalendarError extends CalendarState {
|
||||
final String message;
|
||||
|
||||
const CalendarError(this.message);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
Reference in New Issue
Block a user