2024-01-15 17:26:13 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 18:10:56 +02:00
|
|
|
|
2023-08-27 07:07:35 +02:00
|
|
|
class MapState {
|
2024-01-15 17:26:13 +02:00
|
|
|
final ThemeMode themeMode;
|
2023-08-27 07:07:35 +02:00
|
|
|
final bool showFavoriteOnly;
|
2023-10-04 15:51:07 +02:00
|
|
|
final bool includeArchived;
|
2023-08-27 07:07:35 +02:00
|
|
|
final int relativeTime;
|
2024-01-15 17:26:13 +02:00
|
|
|
final bool shouldRefetchMarkers;
|
|
|
|
final AsyncValue<String> lightStyleFetched;
|
|
|
|
final AsyncValue<String> darkStyleFetched;
|
2023-08-27 07:07:35 +02:00
|
|
|
|
|
|
|
MapState({
|
2024-01-15 17:26:13 +02:00
|
|
|
this.themeMode = ThemeMode.system,
|
2023-08-27 07:07:35 +02:00
|
|
|
this.showFavoriteOnly = false,
|
2023-10-04 15:51:07 +02:00
|
|
|
this.includeArchived = false,
|
2023-08-27 07:07:35 +02:00
|
|
|
this.relativeTime = 0,
|
2024-01-15 17:26:13 +02:00
|
|
|
this.shouldRefetchMarkers = false,
|
|
|
|
this.lightStyleFetched = const AsyncLoading(),
|
|
|
|
this.darkStyleFetched = const AsyncLoading(),
|
2023-08-27 07:07:35 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
MapState copyWith({
|
2024-01-15 17:26:13 +02:00
|
|
|
ThemeMode? themeMode,
|
2023-08-27 07:07:35 +02:00
|
|
|
bool? showFavoriteOnly,
|
2023-10-04 15:51:07 +02:00
|
|
|
bool? includeArchived,
|
2023-08-27 07:07:35 +02:00
|
|
|
int? relativeTime,
|
2024-01-15 17:26:13 +02:00
|
|
|
bool? shouldRefetchMarkers,
|
|
|
|
AsyncValue<String>? lightStyleFetched,
|
|
|
|
AsyncValue<String>? darkStyleFetched,
|
2023-08-27 07:07:35 +02:00
|
|
|
}) {
|
|
|
|
return MapState(
|
2024-01-15 17:26:13 +02:00
|
|
|
themeMode: themeMode ?? this.themeMode,
|
2023-08-27 07:07:35 +02:00
|
|
|
showFavoriteOnly: showFavoriteOnly ?? this.showFavoriteOnly,
|
2023-10-04 15:51:07 +02:00
|
|
|
includeArchived: includeArchived ?? this.includeArchived,
|
2023-08-27 07:07:35 +02:00
|
|
|
relativeTime: relativeTime ?? this.relativeTime,
|
2024-01-15 17:26:13 +02:00
|
|
|
shouldRefetchMarkers: shouldRefetchMarkers ?? this.shouldRefetchMarkers,
|
|
|
|
lightStyleFetched: lightStyleFetched ?? this.lightStyleFetched,
|
|
|
|
darkStyleFetched: darkStyleFetched ?? this.darkStyleFetched,
|
2023-08-27 07:07:35 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2024-01-15 17:26:13 +02:00
|
|
|
return 'MapState(themeMode: $themeMode, showFavoriteOnly: $showFavoriteOnly, includeArchived: $includeArchived, relativeTime: $relativeTime, shouldRefetchMarkers: $shouldRefetchMarkers, lightStyleFetched: $lightStyleFetched, darkStyleFetched: $darkStyleFetched)';
|
2023-08-27 07:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2024-01-15 17:26:13 +02:00
|
|
|
bool operator ==(covariant MapState other) {
|
2023-08-27 07:07:35 +02:00
|
|
|
if (identical(this, other)) return true;
|
|
|
|
|
2024-01-15 17:26:13 +02:00
|
|
|
return other.themeMode == themeMode &&
|
2023-08-27 07:07:35 +02:00
|
|
|
other.showFavoriteOnly == showFavoriteOnly &&
|
2023-11-09 18:10:56 +02:00
|
|
|
other.includeArchived == includeArchived &&
|
2024-01-15 17:26:13 +02:00
|
|
|
other.relativeTime == relativeTime &&
|
|
|
|
other.shouldRefetchMarkers == shouldRefetchMarkers &&
|
|
|
|
other.lightStyleFetched == lightStyleFetched &&
|
|
|
|
other.darkStyleFetched == darkStyleFetched;
|
2023-08-27 07:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode {
|
2024-01-15 17:26:13 +02:00
|
|
|
return themeMode.hashCode ^
|
2023-08-27 07:07:35 +02:00
|
|
|
showFavoriteOnly.hashCode ^
|
2023-11-09 18:10:56 +02:00
|
|
|
includeArchived.hashCode ^
|
2024-01-15 17:26:13 +02:00
|
|
|
relativeTime.hashCode ^
|
|
|
|
shouldRefetchMarkers.hashCode ^
|
|
|
|
lightStyleFetched.hashCode ^
|
|
|
|
darkStyleFetched.hashCode;
|
2023-08-27 07:07:35 +02:00
|
|
|
}
|
|
|
|
}
|