refactor(legacy): non-blocking position refresh with loading state
Position refresh on the location map and the control panel used to await showInfoDialog with a 60s autoDismiss, blocking the actual request until the user tapped the modal. Replaced with a fire-and-forget info dialog + dismissActiveFeedback when the request completes. Added isRefreshingPosition flag in LocationMapState and LegacyDeviceViewState so the refresh button shows a spinner and ignores taps while in-flight. AutoDismiss tuned to 8s as a natural safety net.
This commit is contained in:
@@ -236,8 +236,52 @@ class _MapSection extends ConsumerWidget {
|
||||
|
||||
const _MapSection({required this.state, required this.navigationContract});
|
||||
|
||||
Future<void> _handleRefreshPosition(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
) async {
|
||||
if (!await guardDeviceCommand(context, ref)) return;
|
||||
if (!context.mounted) return;
|
||||
final vm = ref.read(legacyDeviceViewModelProvider.notifier);
|
||||
final device = ref.read(legacyDeviceViewModelProvider).value?.selectedDevice;
|
||||
if (device == null) return;
|
||||
|
||||
vm.setRefreshingPosition(true);
|
||||
showInfoDialog(
|
||||
context,
|
||||
I18n.positionUpdating,
|
||||
autoDismiss: const Duration(seconds: 8),
|
||||
);
|
||||
|
||||
try {
|
||||
final position = await vm.requestPositionUpdate(
|
||||
deviceIdentificator: device.identificator,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
dismissActiveFeedback();
|
||||
if (position != null) {
|
||||
await showSuccessDialog(context, I18n.positionUpdated);
|
||||
} else {
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
} on TimeoutException {
|
||||
if (!context.mounted) return;
|
||||
dismissActiveFeedback();
|
||||
await showErrorDialog(context, I18n.positionUpdateTimeout);
|
||||
} catch (_) {
|
||||
if (!context.mounted) return;
|
||||
dismissActiveFeedback();
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
} finally {
|
||||
if (ref.context.mounted) vm.setRefreshingPosition(false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final primaryColor = context.sfColors.legacyPrimary;
|
||||
final isRefreshing = state.isRefreshingPosition;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => navigationContract.goTo(AppRoutes.legacyLocation),
|
||||
child: Column(
|
||||
@@ -251,47 +295,23 @@ class _MapSection extends ConsumerWidget {
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: context.sfColors.legacyPrimary,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
if (!await guardDeviceCommand(context, ref)) return;
|
||||
if (!context.mounted) return;
|
||||
final device = ref
|
||||
.read(legacyDeviceViewModelProvider)
|
||||
.value
|
||||
?.selectedDevice;
|
||||
if (device == null) return;
|
||||
try {
|
||||
await showInfoDialog(
|
||||
context,
|
||||
I18n.positionUpdating,
|
||||
autoDismiss: const Duration(seconds: 60),
|
||||
);
|
||||
final position = await ref
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.requestPositionUpdate(
|
||||
deviceIdentificator: device.identificator,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
if (position != null) {
|
||||
await showSuccessDialog(context, I18n.positionUpdated);
|
||||
} else {
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
} on TimeoutException {
|
||||
if (!context.mounted) return;
|
||||
await showErrorDialog(context, I18n.positionUpdateTimeout);
|
||||
} catch (_) {
|
||||
if (!context.mounted) return;
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.refresh,
|
||||
color: context.sfColors.legacyPrimary,
|
||||
),
|
||||
onPressed: isRefreshing
|
||||
? null
|
||||
: () => _handleRefreshPosition(context, ref),
|
||||
icon: isRefreshing
|
||||
? SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.4,
|
||||
valueColor: AlwaysStoppedAnimation(primaryColor),
|
||||
),
|
||||
)
|
||||
: Icon(Icons.refresh, color: primaryColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -308,6 +308,11 @@ class LocationMapController extends _$LocationMapController {
|
||||
_recenterTimer?.cancel();
|
||||
}
|
||||
|
||||
void setRefreshingPosition(bool refreshing) {
|
||||
if (state.isRefreshingPosition == refreshing) return;
|
||||
state = state.copyWith(isRefreshingPosition: refreshing);
|
||||
}
|
||||
|
||||
String _modeName(PlacingMode mode) {
|
||||
switch (mode) {
|
||||
case PlacingMode.geofence:
|
||||
|
||||
@@ -42,7 +42,7 @@ final class LocationMapControllerProvider
|
||||
}
|
||||
|
||||
String _$locationMapControllerHash() =>
|
||||
r'565ab5147dd5ac16cf80210c55e28316bafe2f5a';
|
||||
r'a913d21c62f737dddffd107fc728467dd44dc9be';
|
||||
|
||||
abstract class _$LocationMapController extends $Notifier<LocationMapState> {
|
||||
LocationMapState build();
|
||||
|
||||
@@ -32,5 +32,6 @@ abstract class LocationMapState with _$LocationMapState {
|
||||
@Default(false) bool historyPlaying,
|
||||
@Default(false) bool isRevealAnimating,
|
||||
int? historyRevealCount,
|
||||
@Default(false) bool isRefreshingPosition,
|
||||
}) = _LocationMapState;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LocationMapState {
|
||||
|
||||
bool get showGeofences; bool get showFrequentPlaces; PlacingMode get placingMode; bool get adjustingRadius; double get previewRadius; LatLng? get previewPoint; GeofenceEntity? get selectedGeofence; GeofenceEntity? get editingGeofence; FrequentPlaceEntity? get selectedFrequentPlace; FrequentPlaceEntity? get editingFrequentPlace; PositionEntity? get selectedHistoryPosition; bool get isFollowing; bool get actionsExpanded; bool get frequencyExpanded; double get mapZoom; int get historyNavigationIndex; bool get historyPlaying; bool get isRevealAnimating; int? get historyRevealCount;
|
||||
bool get showGeofences; bool get showFrequentPlaces; PlacingMode get placingMode; bool get adjustingRadius; double get previewRadius; LatLng? get previewPoint; GeofenceEntity? get selectedGeofence; GeofenceEntity? get editingGeofence; FrequentPlaceEntity? get selectedFrequentPlace; FrequentPlaceEntity? get editingFrequentPlace; PositionEntity? get selectedHistoryPosition; bool get isFollowing; bool get actionsExpanded; bool get frequencyExpanded; double get mapZoom; int get historyNavigationIndex; bool get historyPlaying; bool get isRevealAnimating; int? get historyRevealCount; bool get isRefreshingPosition;
|
||||
/// Create a copy of LocationMapState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LocationMapStateCopyWith<LocationMapState> get copyWith => _$LocationMapStateCo
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LocationMapState&&(identical(other.showGeofences, showGeofences) || other.showGeofences == showGeofences)&&(identical(other.showFrequentPlaces, showFrequentPlaces) || other.showFrequentPlaces == showFrequentPlaces)&&(identical(other.placingMode, placingMode) || other.placingMode == placingMode)&&(identical(other.adjustingRadius, adjustingRadius) || other.adjustingRadius == adjustingRadius)&&(identical(other.previewRadius, previewRadius) || other.previewRadius == previewRadius)&&(identical(other.previewPoint, previewPoint) || other.previewPoint == previewPoint)&&(identical(other.selectedGeofence, selectedGeofence) || other.selectedGeofence == selectedGeofence)&&(identical(other.editingGeofence, editingGeofence) || other.editingGeofence == editingGeofence)&&(identical(other.selectedFrequentPlace, selectedFrequentPlace) || other.selectedFrequentPlace == selectedFrequentPlace)&&(identical(other.editingFrequentPlace, editingFrequentPlace) || other.editingFrequentPlace == editingFrequentPlace)&&(identical(other.selectedHistoryPosition, selectedHistoryPosition) || other.selectedHistoryPosition == selectedHistoryPosition)&&(identical(other.isFollowing, isFollowing) || other.isFollowing == isFollowing)&&(identical(other.actionsExpanded, actionsExpanded) || other.actionsExpanded == actionsExpanded)&&(identical(other.frequencyExpanded, frequencyExpanded) || other.frequencyExpanded == frequencyExpanded)&&(identical(other.mapZoom, mapZoom) || other.mapZoom == mapZoom)&&(identical(other.historyNavigationIndex, historyNavigationIndex) || other.historyNavigationIndex == historyNavigationIndex)&&(identical(other.historyPlaying, historyPlaying) || other.historyPlaying == historyPlaying)&&(identical(other.isRevealAnimating, isRevealAnimating) || other.isRevealAnimating == isRevealAnimating)&&(identical(other.historyRevealCount, historyRevealCount) || other.historyRevealCount == historyRevealCount));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LocationMapState&&(identical(other.showGeofences, showGeofences) || other.showGeofences == showGeofences)&&(identical(other.showFrequentPlaces, showFrequentPlaces) || other.showFrequentPlaces == showFrequentPlaces)&&(identical(other.placingMode, placingMode) || other.placingMode == placingMode)&&(identical(other.adjustingRadius, adjustingRadius) || other.adjustingRadius == adjustingRadius)&&(identical(other.previewRadius, previewRadius) || other.previewRadius == previewRadius)&&(identical(other.previewPoint, previewPoint) || other.previewPoint == previewPoint)&&(identical(other.selectedGeofence, selectedGeofence) || other.selectedGeofence == selectedGeofence)&&(identical(other.editingGeofence, editingGeofence) || other.editingGeofence == editingGeofence)&&(identical(other.selectedFrequentPlace, selectedFrequentPlace) || other.selectedFrequentPlace == selectedFrequentPlace)&&(identical(other.editingFrequentPlace, editingFrequentPlace) || other.editingFrequentPlace == editingFrequentPlace)&&(identical(other.selectedHistoryPosition, selectedHistoryPosition) || other.selectedHistoryPosition == selectedHistoryPosition)&&(identical(other.isFollowing, isFollowing) || other.isFollowing == isFollowing)&&(identical(other.actionsExpanded, actionsExpanded) || other.actionsExpanded == actionsExpanded)&&(identical(other.frequencyExpanded, frequencyExpanded) || other.frequencyExpanded == frequencyExpanded)&&(identical(other.mapZoom, mapZoom) || other.mapZoom == mapZoom)&&(identical(other.historyNavigationIndex, historyNavigationIndex) || other.historyNavigationIndex == historyNavigationIndex)&&(identical(other.historyPlaying, historyPlaying) || other.historyPlaying == historyPlaying)&&(identical(other.isRevealAnimating, isRevealAnimating) || other.isRevealAnimating == isRevealAnimating)&&(identical(other.historyRevealCount, historyRevealCount) || other.historyRevealCount == historyRevealCount)&&(identical(other.isRefreshingPosition, isRefreshingPosition) || other.isRefreshingPosition == isRefreshingPosition));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([runtimeType,showGeofences,showFrequentPlaces,placingMode,adjustingRadius,previewRadius,previewPoint,selectedGeofence,editingGeofence,selectedFrequentPlace,editingFrequentPlace,selectedHistoryPosition,isFollowing,actionsExpanded,frequencyExpanded,mapZoom,historyNavigationIndex,historyPlaying,isRevealAnimating,historyRevealCount]);
|
||||
int get hashCode => Object.hashAll([runtimeType,showGeofences,showFrequentPlaces,placingMode,adjustingRadius,previewRadius,previewPoint,selectedGeofence,editingGeofence,selectedFrequentPlace,editingFrequentPlace,selectedHistoryPosition,isFollowing,actionsExpanded,frequencyExpanded,mapZoom,historyNavigationIndex,historyPlaying,isRevealAnimating,historyRevealCount,isRefreshingPosition]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LocationMapState(showGeofences: $showGeofences, showFrequentPlaces: $showFrequentPlaces, placingMode: $placingMode, adjustingRadius: $adjustingRadius, previewRadius: $previewRadius, previewPoint: $previewPoint, selectedGeofence: $selectedGeofence, editingGeofence: $editingGeofence, selectedFrequentPlace: $selectedFrequentPlace, editingFrequentPlace: $editingFrequentPlace, selectedHistoryPosition: $selectedHistoryPosition, isFollowing: $isFollowing, actionsExpanded: $actionsExpanded, frequencyExpanded: $frequencyExpanded, mapZoom: $mapZoom, historyNavigationIndex: $historyNavigationIndex, historyPlaying: $historyPlaying, isRevealAnimating: $isRevealAnimating, historyRevealCount: $historyRevealCount)';
|
||||
return 'LocationMapState(showGeofences: $showGeofences, showFrequentPlaces: $showFrequentPlaces, placingMode: $placingMode, adjustingRadius: $adjustingRadius, previewRadius: $previewRadius, previewPoint: $previewPoint, selectedGeofence: $selectedGeofence, editingGeofence: $editingGeofence, selectedFrequentPlace: $selectedFrequentPlace, editingFrequentPlace: $editingFrequentPlace, selectedHistoryPosition: $selectedHistoryPosition, isFollowing: $isFollowing, actionsExpanded: $actionsExpanded, frequencyExpanded: $frequencyExpanded, mapZoom: $mapZoom, historyNavigationIndex: $historyNavigationIndex, historyPlaying: $historyPlaying, isRevealAnimating: $isRevealAnimating, historyRevealCount: $historyRevealCount, isRefreshingPosition: $isRefreshingPosition)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $LocationMapStateCopyWith<$Res> {
|
||||
factory $LocationMapStateCopyWith(LocationMapState value, $Res Function(LocationMapState) _then) = _$LocationMapStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount
|
||||
bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount, bool isRefreshingPosition
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _$LocationMapStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LocationMapState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? showGeofences = null,Object? showFrequentPlaces = null,Object? placingMode = null,Object? adjustingRadius = null,Object? previewRadius = null,Object? previewPoint = freezed,Object? selectedGeofence = freezed,Object? editingGeofence = freezed,Object? selectedFrequentPlace = freezed,Object? editingFrequentPlace = freezed,Object? selectedHistoryPosition = freezed,Object? isFollowing = null,Object? actionsExpanded = null,Object? frequencyExpanded = null,Object? mapZoom = null,Object? historyNavigationIndex = null,Object? historyPlaying = null,Object? isRevealAnimating = null,Object? historyRevealCount = freezed,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? showGeofences = null,Object? showFrequentPlaces = null,Object? placingMode = null,Object? adjustingRadius = null,Object? previewRadius = null,Object? previewPoint = freezed,Object? selectedGeofence = freezed,Object? editingGeofence = freezed,Object? selectedFrequentPlace = freezed,Object? editingFrequentPlace = freezed,Object? selectedHistoryPosition = freezed,Object? isFollowing = null,Object? actionsExpanded = null,Object? frequencyExpanded = null,Object? mapZoom = null,Object? historyNavigationIndex = null,Object? historyPlaying = null,Object? isRevealAnimating = null,Object? historyRevealCount = freezed,Object? isRefreshingPosition = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
showGeofences: null == showGeofences ? _self.showGeofences : showGeofences // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showFrequentPlaces: null == showFrequentPlaces ? _self.showFrequentPlaces : showFrequentPlaces // ignore: cast_nullable_to_non_nullable
|
||||
@@ -83,7 +83,8 @@ as double,historyNavigationIndex: null == historyNavigationIndex ? _self.history
|
||||
as int,historyPlaying: null == historyPlaying ? _self.historyPlaying : historyPlaying // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isRevealAnimating: null == isRevealAnimating ? _self.isRevealAnimating : isRevealAnimating // ignore: cast_nullable_to_non_nullable
|
||||
as bool,historyRevealCount: freezed == historyRevealCount ? _self.historyRevealCount : historyRevealCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
as int?,isRefreshingPosition: null == isRefreshingPosition ? _self.isRefreshingPosition : isRefreshingPosition // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LocationMapState
|
||||
@@ -228,10 +229,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount, bool isRefreshingPosition)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocationMapState() when $default != null:
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount);case _:
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount,_that.isRefreshingPosition);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -249,10 +250,10 @@ return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount, bool isRefreshingPosition) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocationMapState():
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount);case _:
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount,_that.isRefreshingPosition);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -269,10 +270,10 @@ return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount, bool isRefreshingPosition)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LocationMapState() when $default != null:
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount);case _:
|
||||
return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_that.adjustingRadius,_that.previewRadius,_that.previewPoint,_that.selectedGeofence,_that.editingGeofence,_that.selectedFrequentPlace,_that.editingFrequentPlace,_that.selectedHistoryPosition,_that.isFollowing,_that.actionsExpanded,_that.frequencyExpanded,_that.mapZoom,_that.historyNavigationIndex,_that.historyPlaying,_that.isRevealAnimating,_that.historyRevealCount,_that.isRefreshingPosition);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -284,7 +285,7 @@ return $default(_that.showGeofences,_that.showFrequentPlaces,_that.placingMode,_
|
||||
|
||||
|
||||
class _LocationMapState implements LocationMapState {
|
||||
const _LocationMapState({this.showGeofences = true, this.showFrequentPlaces = true, this.placingMode = PlacingMode.none, this.adjustingRadius = false, this.previewRadius = 200.0, this.previewPoint, this.selectedGeofence, this.editingGeofence, this.selectedFrequentPlace, this.editingFrequentPlace, this.selectedHistoryPosition, this.isFollowing = false, this.actionsExpanded = false, this.frequencyExpanded = false, this.mapZoom = _defaultZoom, this.historyNavigationIndex = -1, this.historyPlaying = false, this.isRevealAnimating = false, this.historyRevealCount});
|
||||
const _LocationMapState({this.showGeofences = true, this.showFrequentPlaces = true, this.placingMode = PlacingMode.none, this.adjustingRadius = false, this.previewRadius = 200.0, this.previewPoint, this.selectedGeofence, this.editingGeofence, this.selectedFrequentPlace, this.editingFrequentPlace, this.selectedHistoryPosition, this.isFollowing = false, this.actionsExpanded = false, this.frequencyExpanded = false, this.mapZoom = _defaultZoom, this.historyNavigationIndex = -1, this.historyPlaying = false, this.isRevealAnimating = false, this.historyRevealCount, this.isRefreshingPosition = false});
|
||||
|
||||
|
||||
@override@JsonKey() final bool showGeofences;
|
||||
@@ -306,6 +307,7 @@ class _LocationMapState implements LocationMapState {
|
||||
@override@JsonKey() final bool historyPlaying;
|
||||
@override@JsonKey() final bool isRevealAnimating;
|
||||
@override final int? historyRevealCount;
|
||||
@override@JsonKey() final bool isRefreshingPosition;
|
||||
|
||||
/// Create a copy of LocationMapState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -317,16 +319,16 @@ _$LocationMapStateCopyWith<_LocationMapState> get copyWith => __$LocationMapStat
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LocationMapState&&(identical(other.showGeofences, showGeofences) || other.showGeofences == showGeofences)&&(identical(other.showFrequentPlaces, showFrequentPlaces) || other.showFrequentPlaces == showFrequentPlaces)&&(identical(other.placingMode, placingMode) || other.placingMode == placingMode)&&(identical(other.adjustingRadius, adjustingRadius) || other.adjustingRadius == adjustingRadius)&&(identical(other.previewRadius, previewRadius) || other.previewRadius == previewRadius)&&(identical(other.previewPoint, previewPoint) || other.previewPoint == previewPoint)&&(identical(other.selectedGeofence, selectedGeofence) || other.selectedGeofence == selectedGeofence)&&(identical(other.editingGeofence, editingGeofence) || other.editingGeofence == editingGeofence)&&(identical(other.selectedFrequentPlace, selectedFrequentPlace) || other.selectedFrequentPlace == selectedFrequentPlace)&&(identical(other.editingFrequentPlace, editingFrequentPlace) || other.editingFrequentPlace == editingFrequentPlace)&&(identical(other.selectedHistoryPosition, selectedHistoryPosition) || other.selectedHistoryPosition == selectedHistoryPosition)&&(identical(other.isFollowing, isFollowing) || other.isFollowing == isFollowing)&&(identical(other.actionsExpanded, actionsExpanded) || other.actionsExpanded == actionsExpanded)&&(identical(other.frequencyExpanded, frequencyExpanded) || other.frequencyExpanded == frequencyExpanded)&&(identical(other.mapZoom, mapZoom) || other.mapZoom == mapZoom)&&(identical(other.historyNavigationIndex, historyNavigationIndex) || other.historyNavigationIndex == historyNavigationIndex)&&(identical(other.historyPlaying, historyPlaying) || other.historyPlaying == historyPlaying)&&(identical(other.isRevealAnimating, isRevealAnimating) || other.isRevealAnimating == isRevealAnimating)&&(identical(other.historyRevealCount, historyRevealCount) || other.historyRevealCount == historyRevealCount));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LocationMapState&&(identical(other.showGeofences, showGeofences) || other.showGeofences == showGeofences)&&(identical(other.showFrequentPlaces, showFrequentPlaces) || other.showFrequentPlaces == showFrequentPlaces)&&(identical(other.placingMode, placingMode) || other.placingMode == placingMode)&&(identical(other.adjustingRadius, adjustingRadius) || other.adjustingRadius == adjustingRadius)&&(identical(other.previewRadius, previewRadius) || other.previewRadius == previewRadius)&&(identical(other.previewPoint, previewPoint) || other.previewPoint == previewPoint)&&(identical(other.selectedGeofence, selectedGeofence) || other.selectedGeofence == selectedGeofence)&&(identical(other.editingGeofence, editingGeofence) || other.editingGeofence == editingGeofence)&&(identical(other.selectedFrequentPlace, selectedFrequentPlace) || other.selectedFrequentPlace == selectedFrequentPlace)&&(identical(other.editingFrequentPlace, editingFrequentPlace) || other.editingFrequentPlace == editingFrequentPlace)&&(identical(other.selectedHistoryPosition, selectedHistoryPosition) || other.selectedHistoryPosition == selectedHistoryPosition)&&(identical(other.isFollowing, isFollowing) || other.isFollowing == isFollowing)&&(identical(other.actionsExpanded, actionsExpanded) || other.actionsExpanded == actionsExpanded)&&(identical(other.frequencyExpanded, frequencyExpanded) || other.frequencyExpanded == frequencyExpanded)&&(identical(other.mapZoom, mapZoom) || other.mapZoom == mapZoom)&&(identical(other.historyNavigationIndex, historyNavigationIndex) || other.historyNavigationIndex == historyNavigationIndex)&&(identical(other.historyPlaying, historyPlaying) || other.historyPlaying == historyPlaying)&&(identical(other.isRevealAnimating, isRevealAnimating) || other.isRevealAnimating == isRevealAnimating)&&(identical(other.historyRevealCount, historyRevealCount) || other.historyRevealCount == historyRevealCount)&&(identical(other.isRefreshingPosition, isRefreshingPosition) || other.isRefreshingPosition == isRefreshingPosition));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([runtimeType,showGeofences,showFrequentPlaces,placingMode,adjustingRadius,previewRadius,previewPoint,selectedGeofence,editingGeofence,selectedFrequentPlace,editingFrequentPlace,selectedHistoryPosition,isFollowing,actionsExpanded,frequencyExpanded,mapZoom,historyNavigationIndex,historyPlaying,isRevealAnimating,historyRevealCount]);
|
||||
int get hashCode => Object.hashAll([runtimeType,showGeofences,showFrequentPlaces,placingMode,adjustingRadius,previewRadius,previewPoint,selectedGeofence,editingGeofence,selectedFrequentPlace,editingFrequentPlace,selectedHistoryPosition,isFollowing,actionsExpanded,frequencyExpanded,mapZoom,historyNavigationIndex,historyPlaying,isRevealAnimating,historyRevealCount,isRefreshingPosition]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LocationMapState(showGeofences: $showGeofences, showFrequentPlaces: $showFrequentPlaces, placingMode: $placingMode, adjustingRadius: $adjustingRadius, previewRadius: $previewRadius, previewPoint: $previewPoint, selectedGeofence: $selectedGeofence, editingGeofence: $editingGeofence, selectedFrequentPlace: $selectedFrequentPlace, editingFrequentPlace: $editingFrequentPlace, selectedHistoryPosition: $selectedHistoryPosition, isFollowing: $isFollowing, actionsExpanded: $actionsExpanded, frequencyExpanded: $frequencyExpanded, mapZoom: $mapZoom, historyNavigationIndex: $historyNavigationIndex, historyPlaying: $historyPlaying, isRevealAnimating: $isRevealAnimating, historyRevealCount: $historyRevealCount)';
|
||||
return 'LocationMapState(showGeofences: $showGeofences, showFrequentPlaces: $showFrequentPlaces, placingMode: $placingMode, adjustingRadius: $adjustingRadius, previewRadius: $previewRadius, previewPoint: $previewPoint, selectedGeofence: $selectedGeofence, editingGeofence: $editingGeofence, selectedFrequentPlace: $selectedFrequentPlace, editingFrequentPlace: $editingFrequentPlace, selectedHistoryPosition: $selectedHistoryPosition, isFollowing: $isFollowing, actionsExpanded: $actionsExpanded, frequencyExpanded: $frequencyExpanded, mapZoom: $mapZoom, historyNavigationIndex: $historyNavigationIndex, historyPlaying: $historyPlaying, isRevealAnimating: $isRevealAnimating, historyRevealCount: $historyRevealCount, isRefreshingPosition: $isRefreshingPosition)';
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +339,7 @@ abstract mixin class _$LocationMapStateCopyWith<$Res> implements $LocationMapSta
|
||||
factory _$LocationMapStateCopyWith(_LocationMapState value, $Res Function(_LocationMapState) _then) = __$LocationMapStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount
|
||||
bool showGeofences, bool showFrequentPlaces, PlacingMode placingMode, bool adjustingRadius, double previewRadius, LatLng? previewPoint, GeofenceEntity? selectedGeofence, GeofenceEntity? editingGeofence, FrequentPlaceEntity? selectedFrequentPlace, FrequentPlaceEntity? editingFrequentPlace, PositionEntity? selectedHistoryPosition, bool isFollowing, bool actionsExpanded, bool frequencyExpanded, double mapZoom, int historyNavigationIndex, bool historyPlaying, bool isRevealAnimating, int? historyRevealCount, bool isRefreshingPosition
|
||||
});
|
||||
|
||||
|
||||
@@ -354,7 +356,7 @@ class __$LocationMapStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LocationMapState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? showGeofences = null,Object? showFrequentPlaces = null,Object? placingMode = null,Object? adjustingRadius = null,Object? previewRadius = null,Object? previewPoint = freezed,Object? selectedGeofence = freezed,Object? editingGeofence = freezed,Object? selectedFrequentPlace = freezed,Object? editingFrequentPlace = freezed,Object? selectedHistoryPosition = freezed,Object? isFollowing = null,Object? actionsExpanded = null,Object? frequencyExpanded = null,Object? mapZoom = null,Object? historyNavigationIndex = null,Object? historyPlaying = null,Object? isRevealAnimating = null,Object? historyRevealCount = freezed,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? showGeofences = null,Object? showFrequentPlaces = null,Object? placingMode = null,Object? adjustingRadius = null,Object? previewRadius = null,Object? previewPoint = freezed,Object? selectedGeofence = freezed,Object? editingGeofence = freezed,Object? selectedFrequentPlace = freezed,Object? editingFrequentPlace = freezed,Object? selectedHistoryPosition = freezed,Object? isFollowing = null,Object? actionsExpanded = null,Object? frequencyExpanded = null,Object? mapZoom = null,Object? historyNavigationIndex = null,Object? historyPlaying = null,Object? isRevealAnimating = null,Object? historyRevealCount = freezed,Object? isRefreshingPosition = null,}) {
|
||||
return _then(_LocationMapState(
|
||||
showGeofences: null == showGeofences ? _self.showGeofences : showGeofences // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showFrequentPlaces: null == showFrequentPlaces ? _self.showFrequentPlaces : showFrequentPlaces // ignore: cast_nullable_to_non_nullable
|
||||
@@ -375,7 +377,8 @@ as double,historyNavigationIndex: null == historyNavigationIndex ? _self.history
|
||||
as int,historyPlaying: null == historyPlaying ? _self.historyPlaying : historyPlaying // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isRevealAnimating: null == isRevealAnimating ? _self.isRevealAnimating : isRevealAnimating // ignore: cast_nullable_to_non_nullable
|
||||
as bool,historyRevealCount: freezed == historyRevealCount ? _self.historyRevealCount : historyRevealCount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
as int?,isRefreshingPosition: null == isRefreshingPosition ? _self.isRefreshingPosition : isRefreshingPosition // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,44 @@ class _LocationMapState extends ConsumerState<LocationMap>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleRefreshPosition() async {
|
||||
if (!await guardDeviceCommand(context, ref)) return;
|
||||
if (!mounted) return;
|
||||
final device = widget.selectedDevice;
|
||||
if (device == null) return;
|
||||
|
||||
unawaited(ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped());
|
||||
_vm.setRefreshingPosition(true);
|
||||
showInfoDialog(
|
||||
context,
|
||||
I18n.positionUpdating,
|
||||
autoDismiss: const Duration(seconds: 8),
|
||||
);
|
||||
|
||||
try {
|
||||
final position = await ref
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.requestPositionUpdate(deviceIdentificator: device.identificator);
|
||||
if (!mounted) return;
|
||||
dismissActiveFeedback();
|
||||
if (position != null) {
|
||||
await showSuccessDialog(context, I18n.positionUpdated);
|
||||
} else {
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
} on TimeoutException {
|
||||
if (!mounted) return;
|
||||
dismissActiveFeedback();
|
||||
await showErrorDialog(context, I18n.positionUpdateTimeout);
|
||||
} catch (_) {
|
||||
if (!mounted) return;
|
||||
dismissActiveFeedback();
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
} finally {
|
||||
if (mounted) _vm.setRefreshingPosition(false);
|
||||
}
|
||||
}
|
||||
|
||||
void _togglePlayback() {
|
||||
_vm.toggleHistoryPlayback(widget.positionHistory.length);
|
||||
final state = ref.read(locationMapControllerProvider);
|
||||
@@ -952,39 +990,8 @@ class _LocationMapState extends ConsumerState<LocationMap>
|
||||
top: 12,
|
||||
right: 12,
|
||||
child: GpsControlPanel(
|
||||
onRefresh: () async {
|
||||
if (!await guardDeviceCommand(context, ref)) return;
|
||||
if (!mounted) return;
|
||||
unawaited(
|
||||
ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped(),
|
||||
);
|
||||
final device = widget.selectedDevice;
|
||||
if (device == null) return;
|
||||
try {
|
||||
await showInfoDialog(
|
||||
context,
|
||||
I18n.positionUpdating,
|
||||
autoDismiss: const Duration(seconds: 60),
|
||||
);
|
||||
final position = await ref
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.requestPositionUpdate(
|
||||
deviceIdentificator: device.identificator,
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (position != null) {
|
||||
await showSuccessDialog(context, I18n.positionUpdated);
|
||||
} else {
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
} on TimeoutException {
|
||||
if (!mounted) return;
|
||||
await showErrorDialog(context, I18n.positionUpdateTimeout);
|
||||
} catch (_) {
|
||||
if (!mounted) return;
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
},
|
||||
isRefreshing: mapState.isRefreshingPosition,
|
||||
onRefresh: _handleRefreshPosition,
|
||||
onSettings: () => _showGpsFunctionsDialog(context, ref, mapState),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,11 +4,13 @@ import 'package:flutter/material.dart';
|
||||
class GpsControlPanel extends StatelessWidget {
|
||||
final VoidCallback onRefresh;
|
||||
final VoidCallback onSettings;
|
||||
final bool isRefreshing;
|
||||
|
||||
const GpsControlPanel({
|
||||
super.key,
|
||||
required this.onRefresh,
|
||||
required this.onSettings,
|
||||
this.isRefreshing = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -33,7 +35,8 @@ class GpsControlPanel extends StatelessWidget {
|
||||
children: [
|
||||
_PanelButton(
|
||||
icon: Icons.refresh,
|
||||
onTap: onRefresh,
|
||||
onTap: isRefreshing ? null : onRefresh,
|
||||
loading: isRefreshing,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
_PanelButton(
|
||||
@@ -48,11 +51,13 @@ class GpsControlPanel extends StatelessWidget {
|
||||
|
||||
class _PanelButton extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback? onTap;
|
||||
final bool loading;
|
||||
|
||||
const _PanelButton({
|
||||
required this.icon,
|
||||
required this.onTap,
|
||||
this.loading = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -63,14 +68,22 @@ class _PanelButton extends StatelessWidget {
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.2),
|
||||
color: Colors.white.withValues(alpha: onTap == null ? 0.1 : 0.2),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
child: loading
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.4,
|
||||
valueColor: AlwaysStoppedAnimation(Colors.white),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,6 +173,12 @@ class LegacyDeviceViewModel extends AsyncNotifier<LegacyDeviceViewState> {
|
||||
return position;
|
||||
}
|
||||
|
||||
void setRefreshingPosition(bool refreshing) {
|
||||
final current = state.value;
|
||||
if (current == null || current.isRefreshingPosition == refreshing) return;
|
||||
state = AsyncData(current.copyWith(isRefreshingPosition: refreshing));
|
||||
}
|
||||
|
||||
Future<void> setSelectedDevice(DeviceEntity device) async {
|
||||
final current = state.value;
|
||||
if (current == null) return;
|
||||
|
||||
@@ -12,5 +12,6 @@ abstract class LegacyDeviceViewState with _$LegacyDeviceViewState {
|
||||
@Default([]) List<PositionEntity> positions,
|
||||
PositionEntity? selectedPosition,
|
||||
@Default(false) bool positionsError,
|
||||
@Default(false) bool isRefreshingPosition,
|
||||
}) = _LegacyDeviceViewState;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyDeviceViewState {
|
||||
|
||||
List<DeviceEntity> get devices; DeviceEntity? get selectedDevice; List<PositionEntity> get positions; PositionEntity? get selectedPosition; bool get positionsError;
|
||||
List<DeviceEntity> get devices; DeviceEntity? get selectedDevice; List<PositionEntity> get positions; PositionEntity? get selectedPosition; bool get positionsError; bool get isRefreshingPosition;
|
||||
/// Create a copy of LegacyDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LegacyDeviceViewStateCopyWith<LegacyDeviceViewState> get copyWith => _$LegacyDe
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceViewState&&const DeepCollectionEquality().equals(other.devices, devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.positions, positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.positionsError, positionsError) || other.positionsError == positionsError));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceViewState&&const DeepCollectionEquality().equals(other.devices, devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.positions, positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.positionsError, positionsError) || other.positionsError == positionsError)&&(identical(other.isRefreshingPosition, isRefreshingPosition) || other.isRefreshingPosition == isRefreshingPosition));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition,positionsError);
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition,positionsError,isRefreshingPosition);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyDeviceViewState(devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, positionsError: $positionsError)';
|
||||
return 'LegacyDeviceViewState(devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, positionsError: $positionsError, isRefreshingPosition: $isRefreshingPosition)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $LegacyDeviceViewStateCopyWith<$Res> {
|
||||
factory $LegacyDeviceViewStateCopyWith(LegacyDeviceViewState value, $Res Function(LegacyDeviceViewState) _then) = _$LegacyDeviceViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError
|
||||
List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError, bool isRefreshingPosition
|
||||
});
|
||||
|
||||
|
||||
@@ -62,13 +62,14 @@ class _$LegacyDeviceViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LegacyDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? positionsError = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? positionsError = null,Object? isRefreshingPosition = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,positions: null == positions ? _self.positions : positions // ignore: cast_nullable_to_non_nullable
|
||||
as List<PositionEntity>,selectedPosition: freezed == selectedPosition ? _self.selectedPosition : selectedPosition // ignore: cast_nullable_to_non_nullable
|
||||
as PositionEntity?,positionsError: null == positionsError ? _self.positionsError : positionsError // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isRefreshingPosition: null == isRefreshingPosition ? _self.isRefreshingPosition : isRefreshingPosition // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
@@ -178,10 +179,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError, bool isRefreshingPosition)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyDeviceViewState() when $default != null:
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError);case _:
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError,_that.isRefreshingPosition);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -199,10 +200,10 @@ return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selecte
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError, bool isRefreshingPosition) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyDeviceViewState():
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError);case _:
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError,_that.isRefreshingPosition);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -219,10 +220,10 @@ return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selecte
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError, bool isRefreshingPosition)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyDeviceViewState() when $default != null:
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError);case _:
|
||||
return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.positionsError,_that.isRefreshingPosition);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -234,7 +235,7 @@ return $default(_that.devices,_that.selectedDevice,_that.positions,_that.selecte
|
||||
|
||||
|
||||
class _LegacyDeviceViewState implements LegacyDeviceViewState {
|
||||
const _LegacyDeviceViewState({final List<DeviceEntity> devices = const [], this.selectedDevice, final List<PositionEntity> positions = const [], this.selectedPosition, this.positionsError = false}): _devices = devices,_positions = positions;
|
||||
const _LegacyDeviceViewState({final List<DeviceEntity> devices = const [], this.selectedDevice, final List<PositionEntity> positions = const [], this.selectedPosition, this.positionsError = false, this.isRefreshingPosition = false}): _devices = devices,_positions = positions;
|
||||
|
||||
|
||||
final List<DeviceEntity> _devices;
|
||||
@@ -254,6 +255,7 @@ class _LegacyDeviceViewState implements LegacyDeviceViewState {
|
||||
|
||||
@override final PositionEntity? selectedPosition;
|
||||
@override@JsonKey() final bool positionsError;
|
||||
@override@JsonKey() final bool isRefreshingPosition;
|
||||
|
||||
/// Create a copy of LegacyDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -265,16 +267,16 @@ _$LegacyDeviceViewStateCopyWith<_LegacyDeviceViewState> get copyWith => __$Legac
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceViewState&&const DeepCollectionEquality().equals(other._devices, _devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._positions, _positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.positionsError, positionsError) || other.positionsError == positionsError));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceViewState&&const DeepCollectionEquality().equals(other._devices, _devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._positions, _positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.positionsError, positionsError) || other.positionsError == positionsError)&&(identical(other.isRefreshingPosition, isRefreshingPosition) || other.isRefreshingPosition == isRefreshingPosition));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition,positionsError);
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition,positionsError,isRefreshingPosition);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyDeviceViewState(devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, positionsError: $positionsError)';
|
||||
return 'LegacyDeviceViewState(devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, positionsError: $positionsError, isRefreshingPosition: $isRefreshingPosition)';
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +287,7 @@ abstract mixin class _$LegacyDeviceViewStateCopyWith<$Res> implements $LegacyDev
|
||||
factory _$LegacyDeviceViewStateCopyWith(_LegacyDeviceViewState value, $Res Function(_LegacyDeviceViewState) _then) = __$LegacyDeviceViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError
|
||||
List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool positionsError, bool isRefreshingPosition
|
||||
});
|
||||
|
||||
|
||||
@@ -302,13 +304,14 @@ class __$LegacyDeviceViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LegacyDeviceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? positionsError = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? positionsError = null,Object? isRefreshingPosition = null,}) {
|
||||
return _then(_LegacyDeviceViewState(
|
||||
devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,positions: null == positions ? _self._positions : positions // ignore: cast_nullable_to_non_nullable
|
||||
as List<PositionEntity>,selectedPosition: freezed == selectedPosition ? _self.selectedPosition : selectedPosition // ignore: cast_nullable_to_non_nullable
|
||||
as PositionEntity?,positionsError: null == positionsError ? _self.positionsError : positionsError // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isRefreshingPosition: null == isRefreshingPosition ? _self.isRefreshingPosition : isRefreshingPosition // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user