feat: Add calendar page, enhance activity search and approval logic, and refactor activity filtering UI.
This commit is contained in:
@@ -68,7 +68,9 @@ class ActivityLoaded extends ActivityState {
|
||||
|
||||
/// Gets activities by category
|
||||
List<Activity> getActivitiesByCategory(String category) {
|
||||
return activities.where((activity) => activity.category == category).toList();
|
||||
return activities
|
||||
.where((activity) => activity.category == category)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Gets top rated activities
|
||||
@@ -77,14 +79,14 @@ class ActivityLoaded extends ActivityState {
|
||||
sorted.sort((a, b) {
|
||||
final aScore = a.totalVotes;
|
||||
final bScore = b.totalVotes;
|
||||
|
||||
|
||||
if (aScore != bScore) {
|
||||
return bScore.compareTo(aScore);
|
||||
}
|
||||
|
||||
|
||||
return (b.rating ?? 0).compareTo(a.rating ?? 0);
|
||||
});
|
||||
|
||||
|
||||
return sorted.take(limit).toList();
|
||||
}
|
||||
}
|
||||
@@ -94,26 +96,35 @@ class ActivitySearchResults extends ActivityState {
|
||||
final List<Activity> searchResults;
|
||||
final String query;
|
||||
final bool isLoading;
|
||||
final Activity? newlyAddedActivity;
|
||||
|
||||
const ActivitySearchResults({
|
||||
required this.searchResults,
|
||||
required this.query,
|
||||
this.isLoading = false,
|
||||
this.newlyAddedActivity,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [searchResults, query, isLoading];
|
||||
List<Object?> get props => [
|
||||
searchResults,
|
||||
query,
|
||||
isLoading,
|
||||
newlyAddedActivity,
|
||||
];
|
||||
|
||||
/// Creates a copy with optional modifications
|
||||
ActivitySearchResults copyWith({
|
||||
List<Activity>? searchResults,
|
||||
String? query,
|
||||
bool? isLoading,
|
||||
Activity? newlyAddedActivity,
|
||||
}) {
|
||||
return ActivitySearchResults(
|
||||
searchResults: searchResults ?? this.searchResults,
|
||||
query: query ?? this.query,
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
newlyAddedActivity: newlyAddedActivity ?? this.newlyAddedActivity,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -123,10 +134,7 @@ class ActivityOperationSuccess extends ActivityState {
|
||||
final String message;
|
||||
final String? operationType;
|
||||
|
||||
const ActivityOperationSuccess(
|
||||
this.message, {
|
||||
this.operationType,
|
||||
});
|
||||
const ActivityOperationSuccess(this.message, {this.operationType});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, operationType];
|
||||
@@ -138,11 +146,7 @@ class ActivityError extends ActivityState {
|
||||
final String? errorCode;
|
||||
final dynamic error;
|
||||
|
||||
const ActivityError(
|
||||
this.message, {
|
||||
this.errorCode,
|
||||
this.error,
|
||||
});
|
||||
const ActivityError(this.message, {this.errorCode, this.error});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, errorCode, error];
|
||||
@@ -153,10 +157,7 @@ class ActivityVoting extends ActivityState {
|
||||
final String activityId;
|
||||
final List<Activity> activities;
|
||||
|
||||
const ActivityVoting({
|
||||
required this.activityId,
|
||||
required this.activities,
|
||||
});
|
||||
const ActivityVoting({required this.activityId, required this.activities});
|
||||
|
||||
@override
|
||||
List<Object> get props => [activityId, activities];
|
||||
@@ -167,10 +168,7 @@ class ActivityUpdating extends ActivityState {
|
||||
final String activityId;
|
||||
final List<Activity> activities;
|
||||
|
||||
const ActivityUpdating({
|
||||
required this.activityId,
|
||||
required this.activities,
|
||||
});
|
||||
const ActivityUpdating({required this.activityId, required this.activities});
|
||||
|
||||
@override
|
||||
List<Object> get props => [activityId, activities];
|
||||
@@ -200,10 +198,7 @@ class ActivityAdded extends ActivityState {
|
||||
final Activity activity;
|
||||
final String message;
|
||||
|
||||
const ActivityAdded({
|
||||
required this.activity,
|
||||
required this.message,
|
||||
});
|
||||
const ActivityAdded({required this.activity, required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [activity, message];
|
||||
@@ -214,10 +209,7 @@ class ActivityDeleted extends ActivityState {
|
||||
final String activityId;
|
||||
final String message;
|
||||
|
||||
const ActivityDeleted({
|
||||
required this.activityId,
|
||||
required this.message,
|
||||
});
|
||||
const ActivityDeleted({required this.activityId, required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [activityId, message];
|
||||
@@ -237,4 +229,4 @@ class ActivityVoteRecorded extends ActivityState {
|
||||
|
||||
@override
|
||||
List<Object> get props => [activityId, vote, userId];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user