diff --git a/apps/mobile_app/config/staging.json b/apps/mobile_app/config/staging.json index 86a4cc7a..d7454ae7 100644 --- a/apps/mobile_app/config/staging.json +++ b/apps/mobile_app/config/staging.json @@ -1,5 +1,5 @@ { "env": "staging", "apiBaseUrl": "https://api-platform.pre.savefamilygps.net/gateway/api/", - "apiOrigin": "https://platform.pre.savefamilygps.net/" -} + "apiOrigin": "https://platform.pre.savefamilygps.net" +} \ No newline at end of file diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart index 96204fdd..9e1203d9 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart @@ -34,7 +34,7 @@ class ControlPanelRemoteDatasourceImpl implements ControlPanelRemoteDatasource { }) async { try { final response = await _repository.get>( - '/positions/identificator/$deviceId/positions', + '/devices/identificator/$deviceId/positions', ); final data = response.data; diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart index beb3b1e8..9acb4b0b 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart @@ -26,7 +26,7 @@ abstract class LatestPositionsItemResponseModel required double longitude, required int hpe, int? ncell, - required int type, + required String type, int? steps, LatestPositionsAddressResponseModel? address, required int createdAt, diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.freezed.dart index 675f05d5..2c513897 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.freezed.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.freezed.dart @@ -284,7 +284,7 @@ as List, /// @nodoc mixin _$LatestPositionsItemResponseModel { - String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; int get type; int? get steps; LatestPositionsAddressResponseModel? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List get networks; bool get ignore; bool get suspect; bool get frequentPlace; + String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; String get type; int? get steps; LatestPositionsAddressResponseModel? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List get networks; bool get ignore; bool get suspect; bool get frequentPlace; /// Create a copy of LatestPositionsItemResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -317,7 +317,7 @@ abstract mixin class $LatestPositionsItemResponseModelCopyWith<$Res> { factory $LatestPositionsItemResponseModelCopyWith(LatestPositionsItemResponseModel value, $Res Function(LatestPositionsItemResponseModel) _then) = _$LatestPositionsItemResponseModelCopyWithImpl; @useResult $Res call({ - String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace + String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace }); @@ -343,7 +343,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore: as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable +as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable as LatestPositionsAddressResponseModel?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable @@ -451,7 +451,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LatestPositionsItemResponseModel() when $default != null: return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -472,7 +472,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this; switch (_that) { case _LatestPositionsItemResponseModel(): return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -492,7 +492,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this; switch (_that) { case _LatestPositionsItemResponseModel() when $default != null: return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -516,7 +516,7 @@ class _LatestPositionsItemResponseModel implements LatestPositionsItemResponseMo @override final double longitude; @override final int hpe; @override final int? ncell; -@override final int type; +@override final String type; @override final int? steps; @override final LatestPositionsAddressResponseModel? address; @override final int createdAt; @@ -568,7 +568,7 @@ abstract mixin class _$LatestPositionsItemResponseModelCopyWith<$Res> implements factory _$LatestPositionsItemResponseModelCopyWith(_LatestPositionsItemResponseModel value, $Res Function(_LatestPositionsItemResponseModel) _then) = __$LatestPositionsItemResponseModelCopyWithImpl; @override @useResult $Res call({ - String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace + String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace }); @@ -594,7 +594,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore: as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable +as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable as LatestPositionsAddressResponseModel?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.g.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.g.dart index 9d44f2b0..e0ff3b41 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.g.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.g.dart @@ -31,7 +31,7 @@ _LatestPositionsItemResponseModel _$LatestPositionsItemResponseModelFromJson( longitude: (json['longitude'] as num).toDouble(), hpe: (json['hpe'] as num).toInt(), ncell: (json['ncell'] as num?)?.toInt(), - type: (json['type'] as num).toInt(), + type: json['type'] as String, steps: (json['steps'] as num?)?.toInt(), address: json['address'] == null ? null diff --git a/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart index 3bd0d5f3..4e4ba11a 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart @@ -13,7 +13,7 @@ abstract class PositionEntity with _$PositionEntity { required double longitude, required int hpe, int? ncell, - required int type, + required String type, int? steps, AddressEntity? address, required int createdAt, diff --git a/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart index 098dc68d..5dec9495 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$PositionEntity { - String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; int get type; int? get steps; AddressEntity? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List get networks; bool get ignore; bool get suspect; bool get frequentPlace; + String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; String get type; int? get steps; AddressEntity? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List get networks; bool get ignore; bool get suspect; bool get frequentPlace; /// Create a copy of PositionEntity /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -45,7 +45,7 @@ abstract mixin class $PositionEntityCopyWith<$Res> { factory $PositionEntityCopyWith(PositionEntity value, $Res Function(PositionEntity) _then) = _$PositionEntityCopyWithImpl; @useResult $Res call({ - String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace + String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace }); @@ -71,7 +71,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore: as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable +as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable as AddressEntity?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable @@ -179,7 +179,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _PositionEntity() when $default != null: return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -200,7 +200,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this; switch (_that) { case _PositionEntity(): return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -220,7 +220,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this; switch (_that) { case _PositionEntity() when $default != null: return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _: @@ -244,7 +244,7 @@ class _PositionEntity implements PositionEntity { @override final double longitude; @override final int hpe; @override final int? ncell; -@override final int type; +@override final String type; @override final int? steps; @override final AddressEntity? address; @override final int createdAt; @@ -293,7 +293,7 @@ abstract mixin class _$PositionEntityCopyWith<$Res> implements $PositionEntityCo factory _$PositionEntityCopyWith(_PositionEntity value, $Res Function(_PositionEntity) _then) = __$PositionEntityCopyWithImpl; @override @useResult $Res call({ - String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace + String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List networks, bool ignore, bool suspect, bool frequentPlace }); @@ -319,7 +319,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore: as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable +as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable as AddressEntity?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart index d3c14cdc..4dccf18d 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart @@ -228,17 +228,30 @@ class _MapSection extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final theme = ref.read(themePortProvider); final state = ref.watch(controlPanelViewModelProvider); + final vm = ref.read(controlPanelViewModelProvider.notifier); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - context.translate(I18n.watchesOnMap), - style: TextStyle( - fontSize: SizeUtils.getByScreen(small: 20, big: 19), - fontWeight: FontWeight.bold, - color: theme.getColorFor(ThemeCode.legacyPrimary), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + context.translate(I18n.watchesOnMap), + style: TextStyle( + fontSize: SizeUtils.getByScreen(small: 20, big: 19), + fontWeight: FontWeight.bold, + color: theme.getColorFor(ThemeCode.legacyPrimary), + ), + ), + IconButton( + onPressed: vm.refreshPositions, + icon: Icon( + Icons.refresh, + color: theme.getColorFor(ThemeCode.legacyPrimary), + ), + ), + ], ), SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)), SizedBox( diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart index 838db8b1..9a6c973f 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart @@ -63,7 +63,10 @@ class ControlPanelViewModel extends Notifier { void _applyPositions(List> positionLists) { final latestPositions = positionLists .where((list) => list.isNotEmpty) - .map((list) => list.first) + .map((list) { + final valid = list.where((p) => p.latitude != 0 || p.longitude != 0); + return valid.isNotEmpty ? valid.last : list.last; + }) .toList(); final selectedPosition = state.selectedDevice != null @@ -82,6 +85,22 @@ class ControlPanelViewModel extends Notifier { ); } + Future refreshPositions() async { + if (state.devices.isEmpty) return; + try { + final positionLists = await Future.wait( + state.devices.map( + (d) => _repository.getLatestPositions(deviceId: d.identificator), + ), + ); + if (!ref.mounted) return; + _applyPositions(positionLists); + } catch (e) { + if (!ref.mounted) return; + state = state.copyWith(errorMessage: formatErrorMessage(e)); + } + } + void setSelectedDevice(DeviceEntity device) { final selectedPosition = state.positions .where((p) => p.deviceIdentificator == device.identificator) diff --git a/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart b/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart index fd38d112..a83c5d7f 100644 --- a/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart +++ b/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart @@ -92,7 +92,7 @@ class _DeviceMapState extends ConsumerState { child: Align( alignment: Alignment.topCenter, child: SvgPicture.asset( - 'assets/images/ui/location.svg', + 'assets/shared/images/location.svg', height: 80, ), ), diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart index ff2d86b2..4a9e1dc9 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart @@ -28,21 +28,6 @@ class LegacyOnboardingScreen extends ConsumerWidget { final viewModel = ref.read(legacyOnBoardingViewModelProvider.notifier); final pageController = ref.watch(legacyOnboardingPageControllerProvider); - ref.listen( - legacyOnBoardingViewModelProvider.select((s) => s.isSessionValid), - (previous, isValid) { - if (isValid) { - navigationContract.goTo(AppRoutes.controlPanel); - } - }, - ); - - if (state.isCheckingSession) { - return const Scaffold( - body: Center(child: CircularProgressIndicator()), - ); - } - final isLast = state.cardIndex >= onboardingPages.length - 1; void goToNext() { diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart index bb84a663..915a0141 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart @@ -1,6 +1,5 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:legacy_auth/src/features/onboarding/presentation/onboarding_view_state.dart'; -import 'package:sf_shared/sf_shared.dart'; final legacyOnBoardingViewModelProvider = NotifierProvider.autoDispose( @@ -10,21 +9,9 @@ final legacyOnBoardingViewModelProvider = class LegacyOnBoardingViewModel extends Notifier { @override LegacyOnboardingViewState build() { - _checkSession(); return const LegacyOnboardingViewState(); } - Future _checkSession() async { - try { - await ref.read(getUserInfoUseCaseProvider).getUserInfo(); - if (!ref.mounted) return; - state = state.copyWith(isCheckingSession: false, isSessionValid: true); - } catch (_) { - if (!ref.mounted) return; - state = state.copyWith(isCheckingSession: false, isSessionValid: false); - } - } - void onPageChanged(int index) { state = state.copyWith(cardIndex: index); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart index b493e91c..7672ad3c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart @@ -6,8 +6,5 @@ part 'onboarding_view_state.freezed.dart'; abstract class LegacyOnboardingViewState with _$LegacyOnboardingViewState { const factory LegacyOnboardingViewState({ @Default(0) int cardIndex, - @Default(true) bool isCheckingSession, - @Default(false) bool isSessionValid, - String? error, }) = _LegacyOnboardingViewState; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart index 34b8e872..38c71fe8 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacyOnboardingViewState { - int get cardIndex; bool get isCheckingSession; bool get isSessionValid; String? get error; + int get cardIndex; /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $LegacyOnboardingViewStateCopyWith get copyWith => _$ @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)); } @override -int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error); +int get hashCode => Object.hash(runtimeType,cardIndex); @override String toString() { - return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)'; + return 'LegacyOnboardingViewState(cardIndex: $cardIndex)'; } @@ -45,7 +45,7 @@ abstract mixin class $LegacyOnboardingViewStateCopyWith<$Res> { factory $LegacyOnboardingViewStateCopyWith(LegacyOnboardingViewState value, $Res Function(LegacyOnboardingViewState) _then) = _$LegacyOnboardingViewStateCopyWithImpl; @useResult $Res call({ - int cardIndex, bool isCheckingSession, bool isSessionValid, String? error + int cardIndex }); @@ -62,13 +62,10 @@ class _$LegacyOnboardingViewStateCopyWithImpl<$Res> /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,}) { return _then(_self.copyWith( cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable -as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable -as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable -as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable -as String?, +as int, )); } @@ -153,10 +150,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( int cardIndex)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LegacyOnboardingViewState() when $default != null: -return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: +return $default(_that.cardIndex);case _: return orElse(); } @@ -174,10 +171,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( int cardIndex) $default,) {final _that = this; switch (_that) { case _LegacyOnboardingViewState(): -return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: +return $default(_that.cardIndex);case _: throw StateError('Unexpected subclass'); } @@ -194,10 +191,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int cardIndex)? $default,) {final _that = this; switch (_that) { case _LegacyOnboardingViewState() when $default != null: -return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: +return $default(_that.cardIndex);case _: return null; } @@ -209,13 +206,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th class _LegacyOnboardingViewState implements LegacyOnboardingViewState { - const _LegacyOnboardingViewState({this.cardIndex = 0, this.isCheckingSession = true, this.isSessionValid = false, this.error}); + const _LegacyOnboardingViewState({this.cardIndex = 0}); @override@JsonKey() final int cardIndex; -@override@JsonKey() final bool isCheckingSession; -@override@JsonKey() final bool isSessionValid; -@override final String? error; /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. @@ -227,16 +221,16 @@ _$LegacyOnboardingViewStateCopyWith<_LegacyOnboardingViewState> get copyWith => @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)); } @override -int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error); +int get hashCode => Object.hash(runtimeType,cardIndex); @override String toString() { - return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)'; + return 'LegacyOnboardingViewState(cardIndex: $cardIndex)'; } @@ -247,7 +241,7 @@ abstract mixin class _$LegacyOnboardingViewStateCopyWith<$Res> implements $Legac factory _$LegacyOnboardingViewStateCopyWith(_LegacyOnboardingViewState value, $Res Function(_LegacyOnboardingViewState) _then) = __$LegacyOnboardingViewStateCopyWithImpl; @override @useResult $Res call({ - int cardIndex, bool isCheckingSession, bool isSessionValid, String? error + int cardIndex }); @@ -264,13 +258,10 @@ class __$LegacyOnboardingViewStateCopyWithImpl<$Res> /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,}) { return _then(_LegacyOnboardingViewState( cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable -as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable -as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable -as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable -as String?, +as int, )); } diff --git a/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart b/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart index 3e174530..89f7e5d5 100644 --- a/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart +++ b/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart @@ -21,11 +21,12 @@ class TreezorTokenInterceptor extends Interceptor { _handling = true; _onTokenExpired(); Future.delayed(const Duration(seconds: 2), () => _handling = false); - } else if (err.response?.statusCode == 401) { - _handling = true; - _onUnauthorized(); - Future.delayed(const Duration(seconds: 2), () => _handling = false); } + // else if (err.response?.statusCode == 401) { + // _handling = true; + // _onUnauthorized(); + // Future.delayed(const Duration(seconds: 2), () => _handling = false); + // } // } else if (err.response?.statusCode == 500) { // _handling = true; // _onTokenExpired();