Legacy modules refactor: auth, control panel, location module, and session persistence

This commit is contained in:
2026-03-09 02:28:31 +01:00
parent 01de94876b
commit 644d1c2abe
167 changed files with 4811 additions and 5035 deletions

1
.idea/modules.xml generated
View File

@@ -18,6 +18,7 @@
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/legacy_auth/melos_legacy_auth.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/legacy_auth/melos_legacy_auth.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/legacy_dashboard_shell/melos_legacy_dashboard_shell.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/legacy_dashboard_shell/melos_legacy_dashboard_shell.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/legacy/packages/legacy_shared/melos_legacy_shared.iml" filepath="$PROJECT_DIR$/modules/legacy/packages/legacy_shared/melos_legacy_shared.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/location/melos_location.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/location/melos_location.iml" />
<module fileurl="file://$PROJECT_DIR$/packages/navigation/melos_navigation.iml" filepath="$PROJECT_DIR$/packages/navigation/melos_navigation.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/notifications/melos_notifications.iml" filepath="$PROJECT_DIR$/modules/notifications/melos_notifications.iml" />
<module fileurl="file://$PROJECT_DIR$/packages/payments/melos_payments.iml" filepath="$PROJECT_DIR$/packages/payments/melos_payments.iml" />

View File

@@ -1,5 +1,5 @@
{
"env": "staging",
"apiBaseUrl": "https://api-neki-b2b.neki.es/gateway/api/",
"apiOrigin": "https://neki-b2b.neki.es"
"apiBaseUrl": "https://api-platform.pre.savefamilygps.net/gateway/api/",
"apiOrigin": "https://platform.pre.savefamilygps.net/"
}

View File

@@ -7,6 +7,7 @@ import 'package:dashboard_shell/dashboard_builder.dart';
import 'package:device_management/device_management.dart';
import 'package:control_panel/control_panel.dart';
import 'package:legacy_dashboard_shell/legacy_dashboard_builder.dart';
import 'package:location/location.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';
@@ -24,7 +25,7 @@ late final GoRouter appRouter;
void configureAppRouter() {
appRouter = GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: AppRoutes.legacyLogin,
initialLocation: AppRoutes.legacyOnboarding,
debugLogDiagnostics: true,
routes: [
GoRoute(
@@ -111,6 +112,30 @@ void configureAppRouter() {
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.legacyLocation,
name: 'legacy_location',
pageBuilder: const LocationBuilder().buildPage,
),
],
),
// TODO: Añadir branch para Chat (tab 4)
StatefulShellBranch(
routes: [
GoRoute(
path: '${ AppRoutes.legacyDashboard}/chat',
name: 'legacy_chat',
pageBuilder: (context, state) => MaterialPage<void>(
key: state.pageKey,
child: const Scaffold(
body: Center(child: Text('Chat - Coming soon')),
),
),
),
],
),
],
),
GoRoute(

View File

@@ -727,6 +727,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.1"
location:
dependency: "direct main"
description:
path: "../../modules/legacy/modules/location"
relative: true
source: path
version: "1.0.0+1"
logger:
dependency: transitive
description:

View File

@@ -61,6 +61,8 @@ dependencies:
path: ../../modules/legacy/modules/account
device_management:
path: ../../modules/legacy/modules/device_management
location:
path: ../../modules/legacy/modules/location
legacy_auth:
path: ../../modules/legacy/modules/legacy_auth
#packages dependencies go here

View File

@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management,legacy_auth
# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management,legacy_auth,location
dependency_overrides:
account:
path: ../../modules/legacy/modules/account
@@ -28,6 +28,8 @@ dependency_overrides:
path: ../../modules/legacy/modules/legacy_dashboard_shell
legacy_shared:
path: ../../modules/legacy/packages/legacy_shared
location:
path: ../../modules/legacy/modules/location
navigation:
path: ../../packages/navigation
notifications:

View File

@@ -1 +1,3 @@
export 'src/features/control_panel/control_panel_builder.dart';
export 'src/features/control_panel/control_panel_builder.dart';
export 'src/features/control_panel/presentation/state/control_panel_view_model.dart';
export 'src/shared/widgets/device_map.dart';

View File

@@ -1,8 +1,8 @@
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:legacy_shared/legacy_shared.dart';
abstract class ControlPanelRemoteDatasource {
Future<List<DeviceEntity>> getDevices({required String userId});
Future<List<DeviceEntity>> getDevices();
Future<List<PositionEntity>> getLatestPositions({required String deviceId});
}

View File

@@ -1,10 +1,9 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:control_panel/src/core/data/datasource/control_panel_remote_datasource.dart';
import 'package:dio/dio.dart';
import 'package:control_panel/src/core/data/models/get_devices_response_model.dart';
import 'package:control_panel/src/core/data/models/latest_positions_response_model.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/utils/dio_error_mapper.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
@@ -14,181 +13,40 @@ class ControlPanelRemoteDatasourceImpl implements ControlPanelRemoteDatasource {
final QuestiaRepository _repository;
@override
Future<List<DeviceEntity>> getDevices({required String userId}) async {
try {
/*final response = await _repository.get<Map<String, dynamic>>(
'/$userId/devices',
);
final data = response.data!['items'];
if (data == null || data.isEmpty) {
throw Exception('Empty response from /:userId/devices');
}
Future<List<DeviceEntity>> getDevices() async {
final response = await safeCall(
() => _repository.get<Map<String, dynamic>>('/devices'),
'Error getting devices',
);
final model = GetDevicesResponseModel.fromJson(data);*/
final model = GetDevicesResponseModel(items: [
GetDevicesItemResponseModel(
id: '1',
identificator: '1111',
carrierName: 'Carlos',
phone: '111111111',
settings: GetDevicesSettingsResponseModel(
frequency: 0,
frequencyHeartRate: 0,
timezone: 0,
pedometer: true,
language: 'es',
alerts: []
),
protocol: '',
type: '',
connectionServer: '',
createdAt: 0,
flags: GetDevicesFlagsResponseModel(
isInOrOut: 'out',
geofenceId: '1',
isBatteryLow: false,
isDisconnect: false
)
),
GetDevicesItemResponseModel(
id: '2',
identificator: '1112',
carrierName: 'Ana',
phone: '222222222',
settings: GetDevicesSettingsResponseModel(
frequency: 0,
frequencyHeartRate: 0,
timezone: 0,
pedometer: true,
language: 'es',
alerts: []
),
protocol: '',
type: '',
connectionServer: '',
createdAt: 0,
flags: GetDevicesFlagsResponseModel(
isInOrOut: 'out',
geofenceId: '2',
isBatteryLow: false,
isDisconnect: false
)
),
]);
return model.toEntity();
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: error.message ?? 'Error getting devices',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /devices');
}
final model = GetDevicesResponseModel.fromJson(data);
return model.toEntity();
}
@override
Future<List<PositionEntity>> getLatestPositions({required String deviceId}) async {
Future<List<PositionEntity>> getLatestPositions({
required String deviceId,
}) async {
try {
final response = await _repository.get<Map<String, dynamic>>(
'/positions/identificator/$deviceId/positions',
);
final data = response.data?['items'] ?? [];
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /identificator/:deviceId/positions');
return [];
}
final model = LatestPositionsResponseModel.fromJson(data);
/*final model = LatestPositionsResponseModel(items: [
LatestPositionsItemResponseModel(
latitude: 43.327116830678186,
longitude: -3.083269100434551,
address: LatestPositionsAddressResponseModel(
street: 'street',
city: 'city',
province: 'province',
state: 'state',
country: 'country',
),
positionDate: DateTime.now().millisecondsSinceEpoch,
frequentPlace: false,
frequentPlaceName: '',
id: '1',
deviceIdentificator: deviceId,
hpe: 0,
ncell: 65,
type: 0,
createdAt: DateTime.now().millisecondsSinceEpoch,
positionDateOriginal: null,
message: '',
networks: [LatestPositionsNetworkResponseModel(SSID: 'SSID', BSSID: 'BSSID', signal: 'signal')],
ignore: false,
suspect: false
),
LatestPositionsItemResponseModel(
latitude: 43.32729043118528,
longitude: -3.08320596406992,
address: LatestPositionsAddressResponseModel(
street: 'street',
city: 'city',
province: 'province',
state: 'state',
country: 'country',
),
positionDate: DateTime.now().millisecondsSinceEpoch,
frequentPlace: true,
frequentPlaceName: 'La cafetería',
id: '2',
deviceIdentificator: deviceId,
hpe: 0,
ncell: 65,
type: 0,
createdAt: DateTime.now().millisecondsSinceEpoch,
positionDateOriginal: null,
message: '',
networks: [],
ignore: false,
suspect: false
),
]);*/
return model.toEntity();
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: error.message ?? 'Error getting latest position',
);
} on DioException catch (e) {
if (e.response?.statusCode == 404) return [];
throw mapDioError(e, defaultMessage: 'Error getting latest position');
}
}
}
Exception _mapDioError(DioException error, {required String defaultMessage}) {
final apiMsg = _extractApiMessage(error.response?.data);
final msg = apiMsg ?? error.message ?? defaultMessage;
return Exception(msg);
}
String? _extractApiMessage(Object? data) {
if (data == null) return null;
if (data is Map) {
final errorObj = data['error'];
if (errorObj is Map && errorObj['message'] is String) {
return (errorObj['message'] as String).trim();
}
if (data['message'] is String) {
return (data['message'] as String).trim();
}
return null;
}
if (data is String) {
final raw = data.trim();
if (raw.isEmpty) return null;
try {
final decoded = jsonDecode(raw);
return _extractApiMessage(decoded);
} catch (_) {
return raw;
}
}
return null;
}

View File

@@ -1,4 +1,4 @@
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'get_devices_response_model.freezed.dart';
@@ -17,18 +17,23 @@ abstract class GetDevicesResponseModel with _$GetDevicesResponseModel {
@freezed
abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
const factory GetDevicesItemResponseModel({
required String identificator,
required String carrierName,
required String phone,
required String id,
required String identificator,
int? battery,
String? userId,
required GetDevicesFlagsResponseModel flags,
String? carrierGenre,
int? carrierBirthday,
int? carrierWeight,
int? carrierStepLength,
required String carrierName,
String? phone,
required GetDevicesSettingsResponseModel settings,
required String connectionServer,
required String protocol,
required String type,
required String connectionServer,
required int createdAt,
required GetDevicesFlagsResponseModel flags,
}) =
_GetDevicesItemResponseModel;
}) = _GetDevicesItemResponseModel;
factory GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) =>
_$GetDevicesItemResponseModelFromJson(json);
@@ -36,23 +41,34 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
extension GetDevicesResponseModelMapper on GetDevicesResponseModel {
List<DeviceEntity> toEntity() {
return items.map((GetDevicesItemResponseModel item) => DeviceEntity(
identificator: item.identificator,
carrierName: item.carrierName,
phone: item.phone,
id: item.id,
settings: item.settings.toEntity(),
protocol: item.protocol,
type: item.type,
connectionServer: item.connectionServer,
createdAt: item.createdAt,
flags: item.flags.toEntity(),
)).toList();
return items
.map(
(item) => DeviceEntity(
id: item.id,
identificator: item.identificator,
battery: item.battery,
userId: item.userId,
flags: item.flags.toEntity(),
carrierGenre: item.carrierGenre,
carrierBirthday: item.carrierBirthday,
carrierWeight: item.carrierWeight,
carrierStepLength: item.carrierStepLength,
carrierName: item.carrierName,
phone: item.phone,
settings: item.settings.toEntity(),
connectionServer: item.connectionServer,
protocol: item.protocol,
type: item.type,
createdAt: item.createdAt,
),
)
.toList();
}
}
@freezed
abstract class GetDevicesSettingsResponseModel with _$GetDevicesSettingsResponseModel {
abstract class GetDevicesSettingsResponseModel
with _$GetDevicesSettingsResponseModel {
const factory GetDevicesSettingsResponseModel({
required int frequency,
required int frequencyHeartRate,
@@ -62,11 +78,14 @@ abstract class GetDevicesSettingsResponseModel with _$GetDevicesSettingsResponse
required List<String> alerts,
}) = _GetDevicesSettingsResponseModel;
factory GetDevicesSettingsResponseModel.fromJson(Map<String, dynamic> json) =>
factory GetDevicesSettingsResponseModel.fromJson(
Map<String, dynamic> json,
) =>
_$GetDevicesSettingsResponseModelFromJson(json);
}
extension GetDevicesSettingsResponseModelMapper on GetDevicesSettingsResponseModel {
extension GetDevicesSettingsResponseModelMapper
on GetDevicesSettingsResponseModel {
DeviceSettingsEntity toEntity() {
return DeviceSettingsEntity(
frequency: frequency,
@@ -80,15 +99,18 @@ extension GetDevicesSettingsResponseModelMapper on GetDevicesSettingsResponseMod
}
@freezed
abstract class GetDevicesFlagsResponseModel with _$GetDevicesFlagsResponseModel {
abstract class GetDevicesFlagsResponseModel
with _$GetDevicesFlagsResponseModel {
const factory GetDevicesFlagsResponseModel({
required String isInOrOut,
required String geofenceId,
String? geofenceId,
required bool isBatteryLow,
required bool isDisconnect,
}) = _GetDevicesFlagsResponseModel;
factory GetDevicesFlagsResponseModel.fromJson(Map<String, dynamic> json) =>
factory GetDevicesFlagsResponseModel.fromJson(
Map<String, dynamic> json,
) =>
_$GetDevicesFlagsResponseModelFromJson(json);
}
@@ -101,4 +123,4 @@ extension GetDevicesFlagsResponseModelMapper on GetDevicesFlagsResponseModel {
isDisconnect: isDisconnect,
);
}
}
}

View File

@@ -284,7 +284,7 @@ as List<GetDevicesItemResponseModel>,
/// @nodoc
mixin _$GetDevicesItemResponseModel {
String get identificator; String get carrierName; String get phone; String get id; GetDevicesSettingsResponseModel get settings; String get protocol; String get type; String get connectionServer; int get createdAt; GetDevicesFlagsResponseModel get flags;
String get id; String get identificator; int? get battery; String? get userId; GetDevicesFlagsResponseModel get flags; String? get carrierGenre; int? get carrierBirthday; int? get carrierWeight; int? get carrierStepLength; String get carrierName; String? get phone; GetDevicesSettingsResponseModel get settings; String get connectionServer; String get protocol; String get type; int get createdAt;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -297,16 +297,16 @@ $GetDevicesItemResponseModelCopyWith<GetDevicesItemResponseModel> get copyWith =
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.flags, flags) || other.flags == flags));
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.flags, flags) || other.flags == flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,settings,protocol,type,connectionServer,createdAt,flags);
int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,flags,carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,settings,connectionServer,protocol,type,createdAt);
@override
String toString() {
return 'GetDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)';
}
@@ -317,11 +317,11 @@ abstract mixin class $GetDevicesItemResponseModelCopyWith<$Res> {
factory $GetDevicesItemResponseModelCopyWith(GetDevicesItemResponseModel value, $Res Function(GetDevicesItemResponseModel) _then) = _$GetDevicesItemResponseModelCopyWithImpl;
@useResult
$Res call({
String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags
String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt
});
$GetDevicesSettingsResponseModelCopyWith<$Res> get settings;$GetDevicesFlagsResponseModelCopyWith<$Res> get flags;
$GetDevicesFlagsResponseModelCopyWith<$Res> get flags;$GetDevicesSettingsResponseModelCopyWith<$Res> get settings;
}
/// @nodoc
@@ -334,39 +334,45 @@ class _$GetDevicesItemResponseModelCopyWithImpl<$Res>
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) {
return _then(_self.copyWith(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as GetDevicesSettingsResponseModel,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as GetDevicesFlagsResponseModel,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as GetDevicesSettingsResponseModel,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as GetDevicesFlagsResponseModel,
as int,
));
}
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GetDevicesSettingsResponseModelCopyWith<$Res> get settings {
return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) {
return _then(_self.copyWith(settings: value));
});
}/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GetDevicesFlagsResponseModelCopyWith<$Res> get flags {
return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) {
return _then(_self.copyWith(flags: value));
});
}/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GetDevicesSettingsResponseModelCopyWith<$Res> get settings {
return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) {
return _then(_self.copyWith(settings: value));
});
}
}
@@ -449,10 +455,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
return orElse();
}
@@ -470,10 +476,10 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt) $default,) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel():
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
throw StateError('Unexpected subclass');
}
@@ -490,10 +496,10 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt)? $default,) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
return null;
}
@@ -505,19 +511,25 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that
@JsonSerializable()
class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
const _GetDevicesItemResponseModel({required this.identificator, required this.carrierName, required this.phone, required this.id, required this.settings, required this.protocol, required this.type, required this.connectionServer, required this.createdAt, required this.flags});
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, required this.flags, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.phone, required this.settings, required this.connectionServer, required this.protocol, required this.type, required this.createdAt});
factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesItemResponseModelFromJson(json);
@override final String identificator;
@override final String carrierName;
@override final String phone;
@override final String id;
@override final String identificator;
@override final int? battery;
@override final String? userId;
@override final GetDevicesFlagsResponseModel flags;
@override final String? carrierGenre;
@override final int? carrierBirthday;
@override final int? carrierWeight;
@override final int? carrierStepLength;
@override final String carrierName;
@override final String? phone;
@override final GetDevicesSettingsResponseModel settings;
@override final String connectionServer;
@override final String protocol;
@override final String type;
@override final String connectionServer;
@override final int createdAt;
@override final GetDevicesFlagsResponseModel flags;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@@ -532,16 +544,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.flags, flags) || other.flags == flags));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.flags, flags) || other.flags == flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,settings,protocol,type,connectionServer,createdAt,flags);
int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,flags,carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,settings,connectionServer,protocol,type,createdAt);
@override
String toString() {
return 'GetDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)';
}
@@ -552,11 +564,11 @@ abstract mixin class _$GetDevicesItemResponseModelCopyWith<$Res> implements $Get
factory _$GetDevicesItemResponseModelCopyWith(_GetDevicesItemResponseModel value, $Res Function(_GetDevicesItemResponseModel) _then) = __$GetDevicesItemResponseModelCopyWithImpl;
@override @useResult
$Res call({
String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags
String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt
});
@override $GetDevicesSettingsResponseModelCopyWith<$Res> get settings;@override $GetDevicesFlagsResponseModelCopyWith<$Res> get flags;
@override $GetDevicesFlagsResponseModelCopyWith<$Res> get flags;@override $GetDevicesSettingsResponseModelCopyWith<$Res> get settings;
}
/// @nodoc
@@ -569,19 +581,25 @@ class __$GetDevicesItemResponseModelCopyWithImpl<$Res>
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) {
return _then(_GetDevicesItemResponseModel(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as GetDevicesSettingsResponseModel,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as GetDevicesFlagsResponseModel,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as GetDevicesSettingsResponseModel,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as GetDevicesFlagsResponseModel,
as int,
));
}
@@ -589,19 +607,19 @@ as GetDevicesFlagsResponseModel,
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GetDevicesSettingsResponseModelCopyWith<$Res> get settings {
$GetDevicesFlagsResponseModelCopyWith<$Res> get flags {
return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) {
return _then(_self.copyWith(settings: value));
return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) {
return _then(_self.copyWith(flags: value));
});
}/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GetDevicesFlagsResponseModelCopyWith<$Res> get flags {
$GetDevicesSettingsResponseModelCopyWith<$Res> get settings {
return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) {
return _then(_self.copyWith(flags: value));
return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) {
return _then(_self.copyWith(settings: value));
});
}
}
@@ -894,7 +912,7 @@ as List<String>,
/// @nodoc
mixin _$GetDevicesFlagsResponseModel {
String get isInOrOut; String get geofenceId; bool get isBatteryLow; bool get isDisconnect;
String get isInOrOut; String? get geofenceId; bool get isBatteryLow; bool get isDisconnect;
/// Create a copy of GetDevicesFlagsResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -927,7 +945,7 @@ abstract mixin class $GetDevicesFlagsResponseModelCopyWith<$Res> {
factory $GetDevicesFlagsResponseModelCopyWith(GetDevicesFlagsResponseModel value, $Res Function(GetDevicesFlagsResponseModel) _then) = _$GetDevicesFlagsResponseModelCopyWithImpl;
@useResult
$Res call({
String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect
String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect
});
@@ -944,11 +962,11 @@ class _$GetDevicesFlagsResponseModelCopyWithImpl<$Res>
/// Create a copy of GetDevicesFlagsResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isInOrOut = null,Object? geofenceId = null,Object? isBatteryLow = null,Object? isDisconnect = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isInOrOut = null,Object? geofenceId = freezed,Object? isBatteryLow = null,Object? isDisconnect = null,}) {
return _then(_self.copyWith(
isInOrOut: null == isInOrOut ? _self.isInOrOut : isInOrOut // ignore: cast_nullable_to_non_nullable
as String,geofenceId: null == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable
as String,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable
as String,geofenceId: freezed == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable
as String?,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable
as bool,isDisconnect: null == isDisconnect ? _self.isDisconnect : isDisconnect // ignore: cast_nullable_to_non_nullable
as bool,
));
@@ -1035,7 +1053,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _GetDevicesFlagsResponseModel() when $default != null:
return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _:
@@ -1056,7 +1074,7 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect) $default,) {final _that = this;
switch (_that) {
case _GetDevicesFlagsResponseModel():
return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _:
@@ -1076,7 +1094,7 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect)? $default,) {final _that = this;
switch (_that) {
case _GetDevicesFlagsResponseModel() when $default != null:
return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _:
@@ -1091,11 +1109,11 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc
@JsonSerializable()
class _GetDevicesFlagsResponseModel implements GetDevicesFlagsResponseModel {
const _GetDevicesFlagsResponseModel({required this.isInOrOut, required this.geofenceId, required this.isBatteryLow, required this.isDisconnect});
const _GetDevicesFlagsResponseModel({required this.isInOrOut, this.geofenceId, required this.isBatteryLow, required this.isDisconnect});
factory _GetDevicesFlagsResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesFlagsResponseModelFromJson(json);
@override final String isInOrOut;
@override final String geofenceId;
@override final String? geofenceId;
@override final bool isBatteryLow;
@override final bool isDisconnect;
@@ -1132,7 +1150,7 @@ abstract mixin class _$GetDevicesFlagsResponseModelCopyWith<$Res> implements $Ge
factory _$GetDevicesFlagsResponseModelCopyWith(_GetDevicesFlagsResponseModel value, $Res Function(_GetDevicesFlagsResponseModel) _then) = __$GetDevicesFlagsResponseModelCopyWithImpl;
@override @useResult
$Res call({
String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect
String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect
});
@@ -1149,11 +1167,11 @@ class __$GetDevicesFlagsResponseModelCopyWithImpl<$Res>
/// Create a copy of GetDevicesFlagsResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isInOrOut = null,Object? geofenceId = null,Object? isBatteryLow = null,Object? isDisconnect = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isInOrOut = null,Object? geofenceId = freezed,Object? isBatteryLow = null,Object? isDisconnect = null,}) {
return _then(_GetDevicesFlagsResponseModel(
isInOrOut: null == isInOrOut ? _self.isInOrOut : isInOrOut // ignore: cast_nullable_to_non_nullable
as String,geofenceId: null == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable
as String,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable
as String,geofenceId: freezed == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable
as String?,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable
as bool,isDisconnect: null == isDisconnect ? _self.isDisconnect : isDisconnect // ignore: cast_nullable_to_non_nullable
as bool,
));

View File

@@ -23,35 +23,47 @@ Map<String, dynamic> _$GetDevicesResponseModelToJson(
_GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson(
Map<String, dynamic> json,
) => _GetDevicesItemResponseModel(
identificator: json['identificator'] as String,
carrierName: json['carrierName'] as String,
phone: json['phone'] as String,
id: json['id'] as String,
settings: GetDevicesSettingsResponseModel.fromJson(
json['settings'] as Map<String, dynamic>,
),
protocol: json['protocol'] as String,
type: json['type'] as String,
connectionServer: json['connectionServer'] as String,
createdAt: (json['createdAt'] as num).toInt(),
identificator: json['identificator'] as String,
battery: (json['battery'] as num?)?.toInt(),
userId: json['userId'] as String?,
flags: GetDevicesFlagsResponseModel.fromJson(
json['flags'] as Map<String, dynamic>,
),
carrierGenre: json['carrierGenre'] as String?,
carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(),
carrierWeight: (json['carrierWeight'] as num?)?.toInt(),
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(),
carrierName: json['carrierName'] as String,
phone: json['phone'] as String?,
settings: GetDevicesSettingsResponseModel.fromJson(
json['settings'] as Map<String, dynamic>,
),
connectionServer: json['connectionServer'] as String,
protocol: json['protocol'] as String,
type: json['type'] as String,
createdAt: (json['createdAt'] as num).toInt(),
);
Map<String, dynamic> _$GetDevicesItemResponseModelToJson(
_GetDevicesItemResponseModel instance,
) => <String, dynamic>{
'id': instance.id,
'identificator': instance.identificator,
'battery': instance.battery,
'userId': instance.userId,
'flags': instance.flags,
'carrierGenre': instance.carrierGenre,
'carrierBirthday': instance.carrierBirthday,
'carrierWeight': instance.carrierWeight,
'carrierStepLength': instance.carrierStepLength,
'carrierName': instance.carrierName,
'phone': instance.phone,
'id': instance.id,
'settings': instance.settings,
'connectionServer': instance.connectionServer,
'protocol': instance.protocol,
'type': instance.type,
'connectionServer': instance.connectionServer,
'createdAt': instance.createdAt,
'flags': instance.flags,
};
_GetDevicesSettingsResponseModel _$GetDevicesSettingsResponseModelFromJson(
@@ -80,7 +92,7 @@ _GetDevicesFlagsResponseModel _$GetDevicesFlagsResponseModelFromJson(
Map<String, dynamic> json,
) => _GetDevicesFlagsResponseModel(
isInOrOut: json['isInOrOut'] as String,
geofenceId: json['geofenceId'] as String,
geofenceId: json['geofenceId'] as String?,
isBatteryLow: json['isBatteryLow'] as bool,
isDisconnect: json['isDisconnect'] as bool,
);

View File

@@ -1,7 +1,7 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/address_entity.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/network_entity.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/address_entity.dart';
import 'package:control_panel/src/core/domain/entities/network_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
part 'latest_positions_response_model.freezed.dart';
part 'latest_positions_response_model.g.dart';

View File

@@ -1,6 +1,6 @@
import 'package:control_panel/src/core/data/datasource/control_panel_remote_datasource.dart';
import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:legacy_shared/legacy_shared.dart';
class ControlPanelRepositoryImpl implements ControlPanelRepository {
@@ -9,8 +9,8 @@ class ControlPanelRepositoryImpl implements ControlPanelRepository {
final ControlPanelRemoteDatasource _remote;
@override
Future<List<DeviceEntity>> getDevices({required String userId}) async {
return _remote.getDevices(userId: userId);
Future<List<DeviceEntity>> getDevices() async {
return _remote.getDevices();
}
@override

View File

@@ -1,6 +1,6 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/address_entity.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/network_entity.dart';
import 'package:control_panel/src/core/domain/entities/address_entity.dart';
import 'package:control_panel/src/core/domain/entities/network_entity.dart';
part 'position_entity.freezed.dart';

View File

@@ -1,9 +1,8 @@
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:legacy_shared/legacy_shared.dart';
abstract class ControlPanelRepository {
Future<List<DeviceEntity>> getDevices({required String userId});
Future<List<DeviceEntity>> getDevices();
Future<List<PositionEntity>> getLatestPositions({required String deviceId});
}

View File

@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
IconData toBatteryIcon(int battery) {
if (battery < 15) return Icons.battery_0_bar;
if (battery < 30) return Icons.battery_1_bar;
if (battery < 45) return Icons.battery_2_bar;
if (battery < 60) return Icons.battery_3_bar;
if (battery < 75) return Icons.battery_4_bar;
if (battery < 90) return Icons.battery_5_bar;
return Icons.battery_6_bar;
}

View File

@@ -0,0 +1,9 @@
String formatPositionDate(int millisSinceEpoch) {
final d = DateTime.fromMillisecondsSinceEpoch(millisSinceEpoch);
final mm = d.month.toString().padLeft(2, '0');
final dd = d.day.toString().padLeft(2, '0');
final hh = d.hour.toString().padLeft(2, '0');
final min = d.minute.toString().padLeft(2, '0');
final ss = d.second.toString().padLeft(2, '0');
return '$mm-$dd $hh:$min:$ss';
}

View File

@@ -0,0 +1,57 @@
import 'dart:convert';
import 'package:dio/dio.dart';
Future<T> safeCall<T>(
Future<T> Function() call,
String fallbackMsg,
) async {
try {
return await call();
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: fallbackMsg);
}
}
Exception mapDioError(DioException error, {required String defaultMessage}) {
final apiMsg = _extractApiMessage(error.response?.data);
final msg = apiMsg ?? error.message ?? defaultMessage;
return Exception(msg);
}
String? _extractApiMessage(Object? data) {
if (data == null) return null;
if (data is Map) {
final errorObj = data['error'];
if (errorObj is Map && errorObj['message'] is String) {
return (errorObj['message'] as String).trim();
}
if (data['message'] is String) {
return (data['message'] as String).trim();
}
return null;
}
if (data is String) {
final raw = data.trim();
if (raw.isEmpty) return null;
try {
final decoded = jsonDecode(raw);
return _extractApiMessage(decoded);
} catch (_) {
return raw;
}
}
return null;
}
String formatErrorMessage(Object error) {
final raw = error.toString();
if (raw.startsWith('Exception: ')) {
return raw.substring('Exception: '.length);
}
return raw;
}

View File

@@ -12,7 +12,7 @@ class ControlPanelBuilder {
return MaterialPage<void>(
key: state.pageKey,
child: ControlPanelScreen(navigationContract: navigationContract, routerState: state),
child: ControlPanelScreen(navigationContract: navigationContract),
);
}
}

View File

@@ -1,10 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'get_devices_request_entity.freezed.dart';
@freezed
abstract class GetDevicesRequestEntity with _$GetDevicesRequestEntity {
const factory GetDevicesRequestEntity({
required String userId,
}) = _GetDevicesRequestEntity;
}

View File

@@ -1,271 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'get_devices_request_entity.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$GetDevicesRequestEntity {
String get userId;
/// Create a copy of GetDevicesRequestEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$GetDevicesRequestEntityCopyWith<GetDevicesRequestEntity> get copyWith => _$GetDevicesRequestEntityCopyWithImpl<GetDevicesRequestEntity>(this as GetDevicesRequestEntity, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesRequestEntity&&(identical(other.userId, userId) || other.userId == userId));
}
@override
int get hashCode => Object.hash(runtimeType,userId);
@override
String toString() {
return 'GetDevicesRequestEntity(userId: $userId)';
}
}
/// @nodoc
abstract mixin class $GetDevicesRequestEntityCopyWith<$Res> {
factory $GetDevicesRequestEntityCopyWith(GetDevicesRequestEntity value, $Res Function(GetDevicesRequestEntity) _then) = _$GetDevicesRequestEntityCopyWithImpl;
@useResult
$Res call({
String userId
});
}
/// @nodoc
class _$GetDevicesRequestEntityCopyWithImpl<$Res>
implements $GetDevicesRequestEntityCopyWith<$Res> {
_$GetDevicesRequestEntityCopyWithImpl(this._self, this._then);
final GetDevicesRequestEntity _self;
final $Res Function(GetDevicesRequestEntity) _then;
/// Create a copy of GetDevicesRequestEntity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? userId = null,}) {
return _then(_self.copyWith(
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [GetDevicesRequestEntity].
extension GetDevicesRequestEntityPatterns on GetDevicesRequestEntity {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetDevicesRequestEntity value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _GetDevicesRequestEntity() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetDevicesRequestEntity value) $default,){
final _that = this;
switch (_that) {
case _GetDevicesRequestEntity():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetDevicesRequestEntity value)? $default,){
final _that = this;
switch (_that) {
case _GetDevicesRequestEntity() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String userId)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _GetDevicesRequestEntity() when $default != null:
return $default(_that.userId);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String userId) $default,) {final _that = this;
switch (_that) {
case _GetDevicesRequestEntity():
return $default(_that.userId);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String userId)? $default,) {final _that = this;
switch (_that) {
case _GetDevicesRequestEntity() when $default != null:
return $default(_that.userId);case _:
return null;
}
}
}
/// @nodoc
class _GetDevicesRequestEntity implements GetDevicesRequestEntity {
const _GetDevicesRequestEntity({required this.userId});
@override final String userId;
/// Create a copy of GetDevicesRequestEntity
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$GetDevicesRequestEntityCopyWith<_GetDevicesRequestEntity> get copyWith => __$GetDevicesRequestEntityCopyWithImpl<_GetDevicesRequestEntity>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesRequestEntity&&(identical(other.userId, userId) || other.userId == userId));
}
@override
int get hashCode => Object.hash(runtimeType,userId);
@override
String toString() {
return 'GetDevicesRequestEntity(userId: $userId)';
}
}
/// @nodoc
abstract mixin class _$GetDevicesRequestEntityCopyWith<$Res> implements $GetDevicesRequestEntityCopyWith<$Res> {
factory _$GetDevicesRequestEntityCopyWith(_GetDevicesRequestEntity value, $Res Function(_GetDevicesRequestEntity) _then) = __$GetDevicesRequestEntityCopyWithImpl;
@override @useResult
$Res call({
String userId
});
}
/// @nodoc
class __$GetDevicesRequestEntityCopyWithImpl<$Res>
implements _$GetDevicesRequestEntityCopyWith<$Res> {
__$GetDevicesRequestEntityCopyWithImpl(this._self, this._then);
final _GetDevicesRequestEntity _self;
final $Res Function(_GetDevicesRequestEntity) _then;
/// Create a copy of GetDevicesRequestEntity
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? userId = null,}) {
return _then(_GetDevicesRequestEntity(
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -1,5 +0,0 @@
import 'package:legacy_shared/legacy_shared.dart';
abstract class GetDevicesUseCase {
Future<List<DeviceEntity>> getDevices({required String userId});
}

View File

@@ -1,13 +0,0 @@
import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart';
import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart';
import 'package:legacy_shared/legacy_shared.dart';
class GetDevicesUseCaseImpl implements GetDevicesUseCase {
GetDevicesUseCaseImpl(this._repository);
final ControlPanelRepository _repository;
@override
Future<List<DeviceEntity>> getDevices({required String userId}) async {
return _repository.getDevices(userId: userId);
}
}

View File

@@ -1,5 +0,0 @@
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
abstract class GetLatestPositionsUseCase {
Future<List<PositionEntity>> getLatestPositions({required String deviceId});
}

View File

@@ -1,14 +0,0 @@
import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart';
class GetLatestPositionsUseCaseImpl implements GetLatestPositionsUseCase {
GetLatestPositionsUseCaseImpl(this._repository);
final ControlPanelRepository _repository;
@override
Future<List<PositionEntity>> getLatestPositions({required String deviceId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _repository.getLatestPositions(deviceId: deviceId);
}
}

View File

@@ -1,11 +1,9 @@
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:control_panel/src/features/control_panel/presentation/state/control_panel_view_model.dart';
import 'package:control_panel/src/shared/widgets/device_map.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart';
@@ -13,17 +11,36 @@ import 'package:utils/utils.dart';
class ControlPanelScreen extends ConsumerWidget {
final NavigationContract navigationContract;
final GoRouterState routerState;
const ControlPanelScreen({
super.key,
required this.navigationContract,
required this.routerState,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final state = ref.watch(controlPanelViewModelProvider);
ref.listen(
controlPanelViewModelProvider.select((s) => s.errorMessage),
(previous, next) {
if (next.isNotEmpty) {
showTopSnackbar(
context,
message: next,
type: MessageType.error,
);
}
},
);
if (state.isLoading) {
return Scaffold(
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
body: const Center(child: CircularProgressIndicator()),
);
}
return Scaffold(
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
@@ -69,11 +86,11 @@ class _Header extends ConsumerWidget {
final vm = ref.read(controlPanelViewModelProvider.notifier);
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
height: SizeUtils.getByScreen(small: 36, big: 36),
Padding(
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 14, big: 14)),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image.asset(
'assets/shared/images/iso_sf.png',
@@ -81,13 +98,15 @@ class _Header extends ConsumerWidget {
),
SizedBox(width: SizeUtils.getByScreen(small: 8, big: 4)),
SizedBox(
width: SizeUtils.getByScreen(small: 104, big: 100),
width: SizeUtils.getByScreen(small: 130, big: 140),
height: 32,
child: CustomDropdown(
items: state.devices
.map(
(DeviceEntity device) => Text(
device.carrierName,
device.carrierName.length > 10
? '${device.carrierName.substring(0, 10)}...'
: device.carrierName,
overflow: TextOverflow.ellipsis,
),
)
@@ -100,16 +119,15 @@ class _Header extends ConsumerWidget {
height: 32,
color: Colors.transparent,
padding: EdgeInsets.zero,
showIcon: false,
),
),
],
),
),
Center(
child: SvgPicture.asset(
'assets/shared/images/logo_sf.svg',
height: SizeUtils.getByScreen(small: 36, big: 36),
),
SvgPicture.asset(
'assets/shared/images/logo_sf.svg',
height: SizeUtils.getByScreen(small: 36, big: 36),
),
],
);
@@ -157,6 +175,7 @@ class _MenuSection extends ConsumerWidget {
text: I18n.accountSettings,
),
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)),
// TODO: Implementar navegación a Device Settings
_SectionButton(
onPressed: () {},
icon: Icons.settings_outlined,
@@ -208,6 +227,7 @@ class _MapSection extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final state = ref.watch(controlPanelViewModelProvider);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -223,151 +243,12 @@ class _MapSection extends ConsumerWidget {
SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)),
SizedBox(
height: SizeUtils.getByScreen(small: 200, big: 300),
child: _Minimap(),
child: DeviceMap(
selectedPosition: state.selectedPosition,
selectedDevice: state.selectedDevice,
),
),
],
);
}
}
class _Minimap extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final viewState = ref.watch(controlPanelViewModelProvider);
final viewModel = ref.read(controlPanelViewModelProvider.notifier);
return FlutterMap(
mapController: viewModel.mapController,
options: MapOptions(
initialCenter: LatLng(45.32833189648895, -3.0830872665435085),
initialZoom: 15,
keepAlive: true,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.savefamily.sf_platform',
),
MarkerLayer(
markers: [
if (viewState.selectedPosition != null)
Marker(
point: LatLng(
viewState.selectedPosition!.latitude,
viewState.selectedPosition!.longitude,
),
width: 200,
height: 145,
child: Align(
alignment: Alignment.topCenter,
child: SvgPicture.asset(
'assets/images/ui/location.svg',
height: 80,
),
),
rotate: true,
),
],
),
if (viewState.selectedPosition != null)
Align(alignment: Alignment.bottomCenter, child: _LocationBanner()),
],
);
}
}
class _LocationBanner extends ConsumerWidget {
IconData toBatteryIcon(int battery) {
if (battery < 15) return Icons.battery_0_bar;
if (battery < 30) return Icons.battery_1_bar;
if (battery < 45) return Icons.battery_2_bar;
if (battery < 60) return Icons.battery_3_bar;
if (battery < 75) return Icons.battery_4_bar;
if (battery < 90) return Icons.battery_5_bar;
return Icons.battery_6_bar;
}
const _LocationBanner();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final viewState = ref.watch(controlPanelViewModelProvider);
final battery = viewState.selectedPosition?.ncell ?? 0;
final IconData batteryIcon = toBatteryIcon(battery);
final positionDate = DateTime.fromMillisecondsSinceEpoch(
viewState.selectedPosition?.positionDate ?? 0,
);
return Container(
height: SizeUtils.getByScreen(small: 60, big: 58),
width: SizeUtils.getByScreen(small: 300, big: 298),
margin: EdgeInsets.only(
bottom: SizeUtils.getByScreen(small: 20, big: 16),
),
decoration: BoxDecoration(
color: theme.getColorFor(ThemeCode.backgroundPrimary),
borderRadius: BorderRadius.all(
Radius.circular(SizeUtils.getByScreen(small: 9, big: 8)),
),
),
child: Row(
children: [
Icon(
SFIcons.location,
size: SizeUtils.getByScreen(small: 40, big: 38),
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: SizeUtils.getByScreen(small: 250, big: 248),
child: Text(
'${viewState.selectedPosition!.address?.street}, '
'${viewState.selectedPosition!.address?.province}, '
'${viewState.selectedPosition!.address?.country}',
overflow: TextOverflow.ellipsis,
),
),
Row(
children: [
Text(
'${positionDate.month.toString().padLeft(2, '0')}-'
'${positionDate.day.toString().padLeft(2, '0')} '
'${positionDate.hour.toString().padLeft(2, '0')}:'
'${positionDate.minute.toString().padLeft(2, '0')}:'
'${positionDate.second.toString().padLeft(2, '0')}',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
if (viewState.selectedPosition!.networks.isNotEmpty)
Text(
' | ${viewState.selectedPosition!.networks.first.signal}',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
Icon(batteryIcon),
Text(
'${viewState.selectedPosition!.ncell ?? 0}%',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
],
),
],
),
],
),
);
}
}

View File

@@ -1,10 +0,0 @@
import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart';
import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart';
import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final getDevicesUseCaseProvider =
Provider.autoDispose<GetDevicesUseCase>((ref) {
final authRepository = ref.read(controlPanelRepositoryProvider);
return GetDevicesUseCaseImpl(authRepository);
});

View File

@@ -1,10 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart';
import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart';
import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart';
final getLatestPositionsUseCaseProvider =
Provider.autoDispose<GetLatestPositionsUseCase>((ref) {
final authRepository = ref.read(controlPanelRepositoryProvider);
return GetLatestPositionsUseCaseImpl(authRepository);
});

View File

@@ -1,93 +1,97 @@
import 'dart:async';
import 'package:flutter_map/flutter_map.dart';
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart';
import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart';
import 'package:control_panel/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart';
import 'package:control_panel/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart';
import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart';
import 'package:control_panel/src/core/utils/dio_error_mapper.dart';
import 'package:control_panel/src/features/control_panel/presentation/state/control_panel_view_state.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:latlong2/latlong.dart';
final controlPanelViewModelProvider =
NotifierProvider.autoDispose<ControlPanelViewModel, ControlPanelViewState>(
NotifierProvider.autoDispose<ControlPanelViewModel, ControlPanelViewState>(
ControlPanelViewModel.new,
);
class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
late final GetDevicesUseCase _getDevicesUseCase;
late final GetLatestPositionsUseCase _getLatestPositionsUseCase;
late final SelectedDeviceNotifier selectedDeviceNotifier;
late final MapController mapController;
late final ControlPanelRepository _repository;
late final SelectedDeviceNotifier _selectedDeviceNotifier;
@override
ControlPanelViewState build() {
_getDevicesUseCase = ref.read(getDevicesUseCaseProvider);
_getLatestPositionsUseCase = ref.read(getLatestPositionsUseCaseProvider);
selectedDeviceNotifier = ref.read(selectedDeviceProvider.notifier);
mapController = MapControllerImpl();
ref.read(loggedUserProvider.future)
.then((loggedUser) {
state = state.copyWith(loggedUser: loggedUser);
return _getDevicesUseCase.getDevices(
userId: loggedUser.id
);
}).then((List<DeviceEntity> res){
state = state.copyWith(
devices: res,
selectedDevice: res.first
);
return Future.wait(res.map((device) =>
_getLatestPositionsUseCase.getLatestPositions(
deviceId: device.identificator
)
));
}).then(
(List<List<PositionEntity>> res) {
setPositions(res);
}
);
ref.onDispose(disposeControllers);
return ControlPanelViewState();
_repository = ref.read(controlPanelRepositoryProvider);
_selectedDeviceNotifier = ref.read(selectedDeviceProvider.notifier);
_init();
return const ControlPanelViewState();
}
void setPositions(List<List<PositionEntity>> positions) {
final devicePositions = positions.map((List<PositionEntity> devicePositions)=>devicePositions[0]).toList();
final selectedPosition = devicePositions.where((p)=>
p.deviceIdentificator == state.selectedDevice!.identificator).firstOrNull;
state = state.copyWith(
positions: devicePositions,
selectedPosition: selectedPosition,
);
if (selectedPosition != null) {
mapController.move(LatLng(
selectedPosition.latitude,
selectedPosition.longitude,
), 15);
Future<void> _init() async {
try {
final loggedUser = await ref.read(loggedUserProvider.future);
if (!ref.mounted) return;
state = state.copyWith(loggedUser: loggedUser);
final devices = await _repository.getDevices();
if (!ref.mounted) return;
if (devices.isEmpty) {
state = state.copyWith(isLoading: false);
return;
}
state = state.copyWith(
devices: devices,
selectedDevice: devices.first,
);
final positionLists = await Future.wait(
devices.map(
(d) => _repository.getLatestPositions(deviceId: d.identificator),
),
);
if (!ref.mounted) return;
_applyPositions(positionLists);
state = state.copyWith(isLoading: false);
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith(
isLoading: false,
errorMessage: formatErrorMessage(e),
);
}
}
void _applyPositions(List<List<PositionEntity>> positionLists) {
final latestPositions = positionLists
.where((list) => list.isNotEmpty)
.map((list) => list.first)
.toList();
final selectedPosition = state.selectedDevice != null
? latestPositions
.where(
(p) =>
p.deviceIdentificator ==
state.selectedDevice!.identificator,
)
.firstOrNull
: null;
state = state.copyWith(
positions: latestPositions,
selectedPosition: selectedPosition,
);
}
void setSelectedDevice(DeviceEntity device) {
final selectedPosition = state.positions.where((p)=>
p.deviceIdentificator == device.identificator).firstOrNull;
final selectedPosition = state.positions
.where((p) => p.deviceIdentificator == device.identificator)
.firstOrNull;
state = state.copyWith(
selectedDevice: device,
selectedPosition: selectedPosition,
);
selectedDeviceNotifier.setSelectedDevice(device);
}
void disposeControllers(){
mapController.dispose();
_selectedDeviceNotifier.setSelectedDevice(device);
}
}

View File

@@ -1,4 +1,4 @@
import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:legacy_shared/legacy_shared.dart';
@@ -11,6 +11,8 @@ abstract class ControlPanelViewState with _$ControlPanelViewState {
@Default([]) List<DeviceEntity> devices,
DeviceEntity? selectedDevice,
@Default([]) List<PositionEntity> positions,
PositionEntity? selectedPosition
PositionEntity? selectedPosition,
@Default(true) bool isLoading,
@Default('') String errorMessage,
}) = _ControlPanelViewState;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ControlPanelViewState {
UserEntity? get loggedUser; List<DeviceEntity> get devices; DeviceEntity? get selectedDevice; List<PositionEntity> get positions; PositionEntity? get selectedPosition;
UserEntity? get loggedUser; List<DeviceEntity> get devices; DeviceEntity? get selectedDevice; List<PositionEntity> get positions; PositionEntity? get selectedPosition; bool get isLoading; String get errorMessage;
/// Create a copy of ControlPanelViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ControlPanelViewStateCopyWith<ControlPanelViewState> get copyWith => _$ControlP
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&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.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition);
int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition,isLoading,errorMessage);
@override
String toString() {
return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition)';
return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, isLoading: $isLoading, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $ControlPanelViewStateCopyWith<$Res> {
factory $ControlPanelViewStateCopyWith(ControlPanelViewState value, $Res Function(ControlPanelViewState) _then) = _$ControlPanelViewStateCopyWithImpl;
@useResult
$Res call({
UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition
UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage
});
@@ -62,14 +62,16 @@ class _$ControlPanelViewStateCopyWithImpl<$Res>
/// Create a copy of ControlPanelViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? isLoading = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
as UserEntity?,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?,
as PositionEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
/// Create a copy of ControlPanelViewState
@@ -190,10 +192,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ControlPanelViewState() when $default != null:
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _:
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _:
return orElse();
}
@@ -211,10 +213,10 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _ControlPanelViewState():
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _:
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -231,10 +233,10 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _ControlPanelViewState() when $default != null:
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _:
return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _:
return null;
}
@@ -246,7 +248,7 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi
class _ControlPanelViewState implements ControlPanelViewState {
const _ControlPanelViewState({this.loggedUser, final List<DeviceEntity> devices = const [], this.selectedDevice, final List<PositionEntity> positions = const [], this.selectedPosition}): _devices = devices,_positions = positions;
const _ControlPanelViewState({this.loggedUser, final List<DeviceEntity> devices = const [], this.selectedDevice, final List<PositionEntity> positions = const [], this.selectedPosition, this.isLoading = true, this.errorMessage = ''}): _devices = devices,_positions = positions;
@override final UserEntity? loggedUser;
@@ -266,6 +268,8 @@ class _ControlPanelViewState implements ControlPanelViewState {
}
@override final PositionEntity? selectedPosition;
@override@JsonKey() final bool isLoading;
@override@JsonKey() final String errorMessage;
/// Create a copy of ControlPanelViewState
/// with the given fields replaced by the non-null parameter values.
@@ -277,16 +281,16 @@ _$ControlPanelViewStateCopyWith<_ControlPanelViewState> get copyWith => __$Contr
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&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.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition);
int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition,isLoading,errorMessage);
@override
String toString() {
return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition)';
return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, isLoading: $isLoading, errorMessage: $errorMessage)';
}
@@ -297,7 +301,7 @@ abstract mixin class _$ControlPanelViewStateCopyWith<$Res> implements $ControlPa
factory _$ControlPanelViewStateCopyWith(_ControlPanelViewState value, $Res Function(_ControlPanelViewState) _then) = __$ControlPanelViewStateCopyWithImpl;
@override @useResult
$Res call({
UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition
UserEntity? loggedUser, List<DeviceEntity> devices, DeviceEntity? selectedDevice, List<PositionEntity> positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage
});
@@ -314,14 +318,16 @@ class __$ControlPanelViewStateCopyWithImpl<$Res>
/// Create a copy of ControlPanelViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? isLoading = null,Object? errorMessage = null,}) {
return _then(_ControlPanelViewState(
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
as UserEntity?,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?,
as PositionEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}

View File

@@ -0,0 +1,198 @@
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
import 'package:control_panel/src/core/utils/battery_utils.dart';
import 'package:control_panel/src/core/utils/date_format_utils.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:latlong2/latlong.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:utils/utils.dart';
const _defaultCenter = LatLng(40.4168, -3.7038);
const _defaultZoom = 15.0;
const _tileServerUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
class DeviceMap extends ConsumerStatefulWidget {
final PositionEntity? selectedPosition;
final DeviceEntity? selectedDevice;
const DeviceMap({
super.key,
required this.selectedPosition,
required this.selectedDevice,
});
@override
ConsumerState<DeviceMap> createState() => _DeviceMapState();
}
class _DeviceMapState extends ConsumerState<DeviceMap> {
late final MapController _mapController;
@override
void initState() {
super.initState();
_mapController = MapControllerImpl();
}
@override
void dispose() {
_mapController.dispose();
super.dispose();
}
@override
void didUpdateWidget(DeviceMap oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.selectedPosition != null &&
widget.selectedPosition != oldWidget.selectedPosition) {
_mapController.move(
LatLng(
widget.selectedPosition!.latitude,
widget.selectedPosition!.longitude,
),
_defaultZoom,
);
}
}
@override
Widget build(BuildContext context) {
final initialCenter = widget.selectedPosition != null
? LatLng(
widget.selectedPosition!.latitude,
widget.selectedPosition!.longitude,
)
: _defaultCenter;
return FlutterMap(
mapController: _mapController,
options: MapOptions(
initialCenter: initialCenter,
initialZoom: _defaultZoom,
keepAlive: true,
),
children: [
TileLayer(
urlTemplate: _tileServerUrl,
userAgentPackageName: 'com.savefamily.sf_platform',
),
MarkerLayer(
markers: [
if (widget.selectedPosition != null)
Marker(
point: LatLng(
widget.selectedPosition!.latitude,
widget.selectedPosition!.longitude,
),
width: 200,
height: 145,
child: Align(
alignment: Alignment.topCenter,
child: SvgPicture.asset(
'assets/images/ui/location.svg',
height: 80,
),
),
rotate: true,
),
],
),
if (widget.selectedPosition != null)
Align(
alignment: Alignment.bottomCenter,
child: LocationBanner(
position: widget.selectedPosition!,
battery: widget.selectedDevice?.battery ?? 0,
),
),
],
);
}
}
class LocationBanner extends ConsumerWidget {
final PositionEntity position;
final int battery;
const LocationBanner({
super.key,
required this.position,
required this.battery,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final batteryIcon = toBatteryIcon(battery);
final dateText = formatPositionDate(position.positionDate);
final addressText = [
position.address?.street,
position.address?.province,
position.address?.country,
].whereType<String>().where((s) => s.isNotEmpty).join(', ');
return Container(
height: SizeUtils.getByScreen(small: 60, big: 58),
width: SizeUtils.getByScreen(small: 300, big: 298),
margin: EdgeInsets.only(
bottom: SizeUtils.getByScreen(small: 20, big: 16),
),
decoration: BoxDecoration(
color: theme.getColorFor(ThemeCode.backgroundPrimary),
borderRadius: BorderRadius.all(
Radius.circular(SizeUtils.getByScreen(small: 9, big: 8)),
),
),
child: Row(
children: [
Icon(
SFIcons.location,
size: SizeUtils.getByScreen(small: 40, big: 38),
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: SizeUtils.getByScreen(small: 250, big: 248),
child: Text(
addressText,
overflow: TextOverflow.ellipsis,
),
),
Row(
children: [
Text(
dateText,
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
if (position.networks.isNotEmpty)
Text(
' | ${position.networks.first.signal}',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
Icon(batteryIcon),
Text(
'$battery%',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
],
),
],
),
],
),
);
}
}

View File

@@ -1,32 +1,10 @@
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
abstract class LegacyAuthRemoteDatasource {
Future<void> requestPhoneCode({required String phone});
Future<void> verifyPhoneCode({required String phone, required String code});
Future<LegacyLoginResponseModel> login({
required String email,
required String password,
});
Future<void> twoFARequestCode({
required String token,
required String methodType,
});
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
});
// Future<String> totpLogin({required String token, required String code});
Future<LegacySignUpResponseModel> signUp({required LegacySignUpRequestModel request});
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({required String token});
Future<String> verifyTwoFACodeSignUp({
@@ -39,18 +17,4 @@ abstract class LegacyAuthRemoteDatasource {
Future<void> recoverPassword({required newPassword, required token});
Future<void> logout();
Future<LegacyChildProfileResponseModel> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
});
}

View File

@@ -1,13 +1,6 @@
import 'dart:convert';
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
import 'auth_remote_datasource.dart';
@@ -17,180 +10,46 @@ class LegacyAuthRemoteDatasourceImpl implements LegacyAuthRemoteDatasource {
final QuestiaRepository _repository;
@override
Future<void> requestPhoneCode({required String phone}) async {
try {
await _repository.post<void>(
'/auth/link-phone/request-code',
body: <String, dynamic>{'phone': phone},
Future<void> requestPhoneCode({required String phone}) =>
safeCall(
() => _repository.post<void>(
'/auth/link-phone/request-code',
body: <String, dynamic>{'phone': phone},
),
'Error to request phone code',
);
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: error.response?.data ?? 'Error to request phone code',
);
}
}
@override
Future<void> verifyPhoneCode({
required String phone,
required String code,
}) async {
try {
await _repository.post<void>(
'/auth/link-phone/verify-code',
body: <String, dynamic>{'phone': phone, 'code': code},
}) =>
safeCall(
() => _repository.post<void>(
'/auth/link-phone/verify-code',
body: <String, dynamic>{'phone': phone, 'code': code},
),
'Error in verification code',
);
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in verification code');
}
}
@override
Future<LegacyLoginResponseModel> login({
required String email,
required String password,
}) async {
try {
final response = await _repository.post<Map<String, dynamic>>(
'/auth/login',
body: <String, dynamic>{'email': email, 'password': password},
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/login');
}
final parsed = LegacyLoginResponseModel.fromJson(data);
return parsed;
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: error.message ?? 'Error in login',
);
}
}
@override
Future<void> twoFARequestCode({
//this gonna send a request to the backend to send email code to the user for default
required String token,
required String methodType,
}) async {
try {
await _repository.post<void>(
'/auth/2fa/request-code',
body: <String, dynamic>{'token': token, 'methodType': methodType},
);
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in twoFARequestCode');
}
}
@override
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
}) async {
try {
await _repository.post<void>(
'/auth/twofa/login',
body: <String, dynamic>{
'token': token,
'code': code,
'methodType': methodType,
'rememberMe': true,
},
);
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in twoFASendCode');
}
}
// @override
// Future<String> totpLogin({
// required String token,
// required String code,
// }) async {
// try {
// final response = await _repository.post<String>(
// '/auth/totp/login',
// body: <String, dynamic>{
// 'token': token,
// 'code': code,
// 'rememberMe': true,
// },
// );
// final data = response.data;
// if (data == null || data.isEmpty) {
// throw Exception('Empty response from /auth/totp/login');
// }
// return data;
// } on DioException catch (error) {
// throw _mapDioError(error, defaultMessage: 'Error in totpLogin');
// }
// }
@override
Future<LegacySignUpResponseModel> signUp({
required LegacySignUpRequestModel request,
}) async {
try {
final body = request.toJson();
debugPrint(const JsonEncoder.withIndent(' ').convert(body));
final response = await _repository.post<Map<String, dynamic>>(
'/auth/signup',
body: body,
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/signup');
}
final parsed = LegacySignUpResponseModel.fromJson(data);
if (!parsed.isCreated) {
throw Exception('Sign up failed: isCreated=false');
}
final userId = parsed.item.userId.trim();
if (userId.isEmpty) {
throw Exception('Sign up response has empty userId');
}
return parsed;
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in signUp');
}
}
@override
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({
required String token,
}) async {
try {
final response = await _repository.post<Map<String, dynamic>>(
final response = await safeCall(
() => _repository.post<Map<String, dynamic>>(
'/auth/totp/secret',
body: <String, dynamic>{'token': token},
);
),
'Error in twoFASignUp',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/totp/secret');
}
final model = LegacyTwoFASecretResponseModel.fromJson(data);
return model;
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in twoFASignUp');
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/totp/secret');
}
return LegacyTwoFASecretResponseModel.fromJson(data);
}
@override
@@ -198,146 +57,54 @@ class LegacyAuthRemoteDatasourceImpl implements LegacyAuthRemoteDatasource {
required String token,
required String code,
}) async {
try {
final response = await _repository.post<String>(
final response = await safeCall(
() => _repository.post<String>(
'/auth/totp/code',
body: <String, dynamic>{'token': token, 'code': code},
);
),
'Error in twoFaCodeSignUp',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/totp/code');
}
return data;
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in twoFaCodeSignUp');
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/totp/code');
}
return data;
}
@override
Future<String> requestPasswordReset({required String email}) async {
try {
late final Map<String, dynamic> body;
body = {'email': email};
final response = await _repository.put<String>(
final response = await safeCall(
() => _repository.put<String>(
'/auth/reset-password',
body: body,
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/totp/code');
}
body: <String, dynamic>{'email': email},
),
'Error to request password reset',
);
return data;
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: 'Error to request password reset',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/reset-password');
}
return data;
}
@override
Future<void> recoverPassword({required newPassword, required token}) async {
try {
await _repository.put<void>(
'/auth/recovery-password',
body: <String, dynamic>{'newPassword': newPassword, 'token': token},
Future<void> recoverPassword({required newPassword, required token}) =>
safeCall(
() => _repository.put<void>(
'/auth/recovery-password',
body: <String, dynamic>{'newPassword': newPassword, 'token': token},
),
'Error to request password recovery',
);
} on DioException catch (error) {
throw _mapDioError(
error,
defaultMessage: 'Error to request password recovery',
);
}
}
@override
Future<void> logout() async {
try {
await _repository.post<void>('/auth/logout');
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in logout');
}
}
@override
Future<LegacyChildProfileResponseModel> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
}) async {
try {
final response = await _repository.post<Map<String, dynamic>>(
'/child-profiles',
body: <String, dynamic>{
'address': address,
'bornAt': bornAt,
'cardPublicKey': cardPublicKey,
'deviceActivationCode': deviceActivationCode,
'firstName': firstName,
'genre': genrer,
'id': id,
'lastName': lastName,
'parentId': parentId,
'relationType': relationType,
'scaProof': scaProof,
},
Future<void> logout() => safeCall(
() => _repository.post<void>('/auth/logout'),
'Error in logout',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/child-profiles');
}
return LegacyChildProfileResponseModel.fromJson(data);
} on DioException catch (error) {
throw _mapDioError(error, defaultMessage: 'Error in createChildProfile');
}
}
}
Exception _mapDioError(DioException error, {required String defaultMessage}) {
final apiMsg = _extractApiMessage(error.response?.data);
final msg = apiMsg ?? error.message ?? defaultMessage;
return Exception(msg);
}
String? _extractApiMessage(Object? data) {
if (data == null) return null;
if (data is Map) {
final errorObj = data['error'];
if (errorObj is Map && errorObj['message'] is String) {
return (errorObj['message'] as String).trim();
}
if (data['message'] is String) {
return (data['message'] as String).trim();
}
return null;
}
if (data is String) {
final raw = data.trim();
if (raw.isEmpty) return null;
try {
final decoded = jsonDecode(raw);
return _extractApiMessage(decoded);
} catch (_) {
return raw;
}
}
return null;
}

View File

@@ -0,0 +1,13 @@
import 'package:legacy_auth/src/core/data/models/device_response_model.dart';
abstract class LegacyDeviceSetupRemoteDatasource {
Future<LegacyDeviceResponseModel> createDevice({
required String name,
required String genrer,
required int weight,
required int stepLength,
required int bornAt,
required String relationType,
required String activationKey,
});
}

View File

@@ -0,0 +1,45 @@
import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/models/device_response_model.dart';
import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
class LegacyDeviceSetupRemoteDatasourceImpl
implements LegacyDeviceSetupRemoteDatasource {
LegacyDeviceSetupRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<LegacyDeviceResponseModel> createDevice({
required String name,
required String genrer,
required int weight,
required int stepLength,
required int bornAt,
required String relationType,
required String activationKey,
}) async {
final response = await safeCall(
() => _repository.post<Map<String, dynamic>>(
'/devices',
body: <String, dynamic>{
'name': name,
'genre': genrer,
'weight': weight,
'stepLength': stepLength,
'bornAt': bornAt,
'relationType': relationType,
'activationKey': activationKey,
},
),
'Error in createDevice',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /devices');
}
return LegacyDeviceResponseModel.fromJson(data);
}
}

View File

@@ -0,0 +1,21 @@
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
abstract class LegacyLoginRemoteDatasource {
Future<LegacyLoginResponseModel> login({
required String email,
required String password,
});
Future<void> twoFARequestCode({
required String token,
required String methodType,
});
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
});
Future<bool> hasDevices();
}

View File

@@ -0,0 +1,77 @@
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart';
class LegacyLoginRemoteDatasourceImpl implements LegacyLoginRemoteDatasource {
const LegacyLoginRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<LegacyLoginResponseModel> login({
required String email,
required String password,
}) async {
final response = await safeCall(
() => _repository.post<Map<String, dynamic>>(
'/auth/login',
body: <String, dynamic>{'email': email, 'password': password},
),
'Error in login',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/login');
}
return LegacyLoginResponseModel.fromJson(data);
}
@override
Future<void> twoFARequestCode({
required String token,
required String methodType,
}) =>
safeCall(
() => _repository.post<void>(
'/auth/2fa/request-code',
body: <String, dynamic>{'token': token, 'methodType': methodType},
),
'Error in twoFARequestCode',
);
@override
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
}) =>
safeCall(
() => _repository.post<void>(
'/auth/twofa/login',
body: <String, dynamic>{
'token': token,
'code': code,
'methodType': methodType,
'rememberMe': true,
},
),
'Error in twoFASendCode',
);
@override
Future<bool> hasDevices() async {
final response = await safeCall(
() => _repository.get<Map<String, dynamic>>('/devices'),
'Error fetching devices',
);
final data = response.data;
if (data == null) return false;
final total = data['total'] as int? ?? 0;
return total > 0;
}
}

View File

@@ -0,0 +1,8 @@
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
abstract class LegacySignUpRemoteDatasource {
Future<LegacySignUpResponseModel> signUp({
required LegacySignUpRequestModel request,
});
}

View File

@@ -0,0 +1,43 @@
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'sign_up_remote_datasource.dart';
class LegacySignUpRemoteDatasourceImpl implements LegacySignUpRemoteDatasource {
const LegacySignUpRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<LegacySignUpResponseModel> signUp({
required LegacySignUpRequestModel request,
}) =>
safeCall(() async {
final body = request.toJson();
final response = await _repository.post<Map<String, dynamic>>(
'/auth/signup',
body: body,
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /auth/signup');
}
final parsed = LegacySignUpResponseModel.fromJson(data);
if (!parsed.isCreated) {
throw Exception('Sign up failed: isCreated=false');
}
final userId = parsed.item.trim();
if (userId.isEmpty) {
throw Exception('Sign up response has empty userId');
}
return parsed;
}, 'Error in signUp');
}

View File

@@ -1,56 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'child_profile_response_model.freezed.dart';
part 'child_profile_response_model.g.dart';
@freezed
abstract class LegacyChildProfileResponseModel with _$LegacyChildProfileResponseModel {
const factory LegacyChildProfileResponseModel({
required bool isCreated,
required LegacyChildProfileItemResponseModel item,
}) = _LegacyChildProfileResponseModel;
factory LegacyChildProfileResponseModel.fromJson(Map<String, dynamic> json) =>
_$LegacyChildProfileResponseModelFromJson(json);
}
@freezed
abstract class LegacyChildProfileItemResponseModel
with _$LegacyChildProfileItemResponseModel {
const factory LegacyChildProfileItemResponseModel({
required String id,
required String deviceIdentificator,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String address,
required int createdAt,
int? updatedAt,
String? profileImageId,
}) = _LegacyChildProfileItemResponseModel;
factory LegacyChildProfileItemResponseModel.fromJson(Map<String, dynamic> json) =>
_$LegacyChildProfileItemResponseModelFromJson(json);
}
extension LegacyChildProfileResponseModelMapper on LegacyChildProfileResponseModel {
LegacyChildProfileEntity toEntity() {
return LegacyChildProfileEntity(
isCreated: isCreated,
item: LegacyChildProfileItemEntity(
id: item.id,
deviceIdentificator: item.deviceIdentificator,
parentId: item.parentId,
firstName: item.firstName,
lastName: item.lastName,
bornAt: item.bornAt,
address: item.address,
createdAt: item.createdAt,
updatedAt: item.updatedAt,
profileImageId: item.profileImageId,
),
);
}
}

View File

@@ -1,588 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'child_profile_response_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacyChildProfileResponseModel {
bool get isCreated; LegacyChildProfileItemResponseModel get item;
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyChildProfileResponseModelCopyWith<LegacyChildProfileResponseModel> get copyWith => _$LegacyChildProfileResponseModelCopyWithImpl<LegacyChildProfileResponseModel>(this as LegacyChildProfileResponseModel, _$identity);
/// Serializes this LegacyChildProfileResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class $LegacyChildProfileResponseModelCopyWith<$Res> {
factory $LegacyChildProfileResponseModelCopyWith(LegacyChildProfileResponseModel value, $Res Function(LegacyChildProfileResponseModel) _then) = _$LegacyChildProfileResponseModelCopyWithImpl;
@useResult
$Res call({
bool isCreated, LegacyChildProfileItemResponseModel item
});
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item;
}
/// @nodoc
class _$LegacyChildProfileResponseModelCopyWithImpl<$Res>
implements $LegacyChildProfileResponseModelCopyWith<$Res> {
_$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then);
final LegacyChildProfileResponseModel _self;
final $Res Function(LegacyChildProfileResponseModel) _then;
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyChildProfileItemResponseModel,
));
}
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item {
return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// Adds pattern-matching-related methods to [LegacyChildProfileResponseModel].
extension LegacyChildProfileResponseModelPatterns on LegacyChildProfileResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyChildProfileResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyChildProfileResponseModel value) $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyChildProfileResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemResponseModel item) $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel():
return $default(_that.isCreated,_that.item);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyChildProfileItemResponseModel item)? $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _LegacyChildProfileResponseModel implements LegacyChildProfileResponseModel {
const _LegacyChildProfileResponseModel({required this.isCreated, required this.item});
factory _LegacyChildProfileResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyChildProfileResponseModelFromJson(json);
@override final bool isCreated;
@override final LegacyChildProfileItemResponseModel item;
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyChildProfileResponseModelCopyWith<_LegacyChildProfileResponseModel> get copyWith => __$LegacyChildProfileResponseModelCopyWithImpl<_LegacyChildProfileResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LegacyChildProfileResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class _$LegacyChildProfileResponseModelCopyWith<$Res> implements $LegacyChildProfileResponseModelCopyWith<$Res> {
factory _$LegacyChildProfileResponseModelCopyWith(_LegacyChildProfileResponseModel value, $Res Function(_LegacyChildProfileResponseModel) _then) = __$LegacyChildProfileResponseModelCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, LegacyChildProfileItemResponseModel item
});
@override $LegacyChildProfileItemResponseModelCopyWith<$Res> get item;
}
/// @nodoc
class __$LegacyChildProfileResponseModelCopyWithImpl<$Res>
implements _$LegacyChildProfileResponseModelCopyWith<$Res> {
__$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then);
final _LegacyChildProfileResponseModel _self;
final $Res Function(_LegacyChildProfileResponseModel) _then;
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_LegacyChildProfileResponseModel(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyChildProfileItemResponseModel,
));
}
/// Create a copy of LegacyChildProfileResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item {
return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// @nodoc
mixin _$LegacyChildProfileItemResponseModel {
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId;
/// Create a copy of LegacyChildProfileItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyChildProfileItemResponseModelCopyWith<LegacyChildProfileItemResponseModel> get copyWith => _$LegacyChildProfileItemResponseModelCopyWithImpl<LegacyChildProfileItemResponseModel>(this as LegacyChildProfileItemResponseModel, _$identity);
/// Serializes this LegacyChildProfileItemResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
@override
String toString() {
return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
}
}
/// @nodoc
abstract mixin class $LegacyChildProfileItemResponseModelCopyWith<$Res> {
factory $LegacyChildProfileItemResponseModelCopyWith(LegacyChildProfileItemResponseModel value, $Res Function(LegacyChildProfileItemResponseModel) _then) = _$LegacyChildProfileItemResponseModelCopyWithImpl;
@useResult
$Res call({
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
});
}
/// @nodoc
class _$LegacyChildProfileItemResponseModelCopyWithImpl<$Res>
implements $LegacyChildProfileItemResponseModelCopyWith<$Res> {
_$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then);
final LegacyChildProfileItemResponseModel _self;
final $Res Function(LegacyChildProfileItemResponseModel) _then;
/// Create a copy of LegacyChildProfileItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [LegacyChildProfileItemResponseModel].
extension LegacyChildProfileItemResponseModelPatterns on LegacyChildProfileItemResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyChildProfileItemResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyChildProfileItemResponseModel value) $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyChildProfileItemResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel():
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemResponseModel() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _LegacyChildProfileItemResponseModel implements LegacyChildProfileItemResponseModel {
const _LegacyChildProfileItemResponseModel({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId});
factory _LegacyChildProfileItemResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyChildProfileItemResponseModelFromJson(json);
@override final String id;
@override final String deviceIdentificator;
@override final String parentId;
@override final String firstName;
@override final String lastName;
@override final int bornAt;
@override final String address;
@override final int createdAt;
@override final int? updatedAt;
@override final String? profileImageId;
/// Create a copy of LegacyChildProfileItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyChildProfileItemResponseModelCopyWith<_LegacyChildProfileItemResponseModel> get copyWith => __$LegacyChildProfileItemResponseModelCopyWithImpl<_LegacyChildProfileItemResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LegacyChildProfileItemResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
@override
String toString() {
return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
}
}
/// @nodoc
abstract mixin class _$LegacyChildProfileItemResponseModelCopyWith<$Res> implements $LegacyChildProfileItemResponseModelCopyWith<$Res> {
factory _$LegacyChildProfileItemResponseModelCopyWith(_LegacyChildProfileItemResponseModel value, $Res Function(_LegacyChildProfileItemResponseModel) _then) = __$LegacyChildProfileItemResponseModelCopyWithImpl;
@override @useResult
$Res call({
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
});
}
/// @nodoc
class __$LegacyChildProfileItemResponseModelCopyWithImpl<$Res>
implements _$LegacyChildProfileItemResponseModelCopyWith<$Res> {
__$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then);
final _LegacyChildProfileItemResponseModel _self;
final $Res Function(_LegacyChildProfileItemResponseModel) _then;
/// Create a copy of LegacyChildProfileItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
return _then(_LegacyChildProfileItemResponseModel(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on

View File

@@ -1,50 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'child_profile_response_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_LegacyChildProfileResponseModel _$LegacyChildProfileResponseModelFromJson(
Map<String, dynamic> json,
) => _LegacyChildProfileResponseModel(
isCreated: json['isCreated'] as bool,
item: LegacyChildProfileItemResponseModel.fromJson(
json['item'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$LegacyChildProfileResponseModelToJson(
_LegacyChildProfileResponseModel instance,
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
_LegacyChildProfileItemResponseModel
_$LegacyChildProfileItemResponseModelFromJson(Map<String, dynamic> json) =>
_LegacyChildProfileItemResponseModel(
id: json['id'] as String,
deviceIdentificator: json['deviceIdentificator'] as String,
parentId: json['parentId'] as String,
firstName: json['firstName'] as String,
lastName: json['lastName'] as String,
bornAt: (json['bornAt'] as num).toInt(),
address: json['address'] as String,
createdAt: (json['createdAt'] as num).toInt(),
updatedAt: (json['updatedAt'] as num?)?.toInt(),
profileImageId: json['profileImageId'] as String?,
);
Map<String, dynamic> _$LegacyChildProfileItemResponseModelToJson(
_LegacyChildProfileItemResponseModel instance,
) => <String, dynamic>{
'id': instance.id,
'deviceIdentificator': instance.deviceIdentificator,
'parentId': instance.parentId,
'firstName': instance.firstName,
'lastName': instance.lastName,
'bornAt': instance.bornAt,
'address': instance.address,
'createdAt': instance.createdAt,
'updatedAt': instance.updatedAt,
'profileImageId': instance.profileImageId,
};

View File

@@ -0,0 +1,41 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'device_response_model.freezed.dart';
part 'device_response_model.g.dart';
@freezed
abstract class LegacyDeviceResponseModel with _$LegacyDeviceResponseModel {
const factory LegacyDeviceResponseModel({
required bool isCreated,
required LegacyDeviceItemResponseModel item,
}) = _LegacyDeviceResponseModel;
factory LegacyDeviceResponseModel.fromJson(Map<String, dynamic> json) =>
_$LegacyDeviceResponseModelFromJson(json);
}
@freezed
abstract class LegacyDeviceItemResponseModel
with _$LegacyDeviceItemResponseModel {
const factory LegacyDeviceItemResponseModel({
required String id,
required String identificator,
required String carrierName,
String? carrierGenre,
int? carrierWeight,
int? carrierStepLength,
int? carrierBirthday,
String? userId,
int? battery,
required String protocol,
required String connectionServer,
required String type,
@Default({}) Map<String, dynamic> flags,
@Default({}) Map<String, dynamic> settings,
Map<String, dynamic>? capabilities,
required int createdAt,
}) = _LegacyDeviceItemResponseModel;
factory LegacyDeviceItemResponseModel.fromJson(Map<String, dynamic> json) =>
_$LegacyDeviceItemResponseModelFromJson(json);
}

View File

@@ -0,0 +1,626 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'device_response_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacyDeviceResponseModel {
bool get isCreated; LegacyDeviceItemResponseModel get item;
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyDeviceResponseModelCopyWith<LegacyDeviceResponseModel> get copyWith => _$LegacyDeviceResponseModelCopyWithImpl<LegacyDeviceResponseModel>(this as LegacyDeviceResponseModel, _$identity);
/// Serializes this LegacyDeviceResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyDeviceResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class $LegacyDeviceResponseModelCopyWith<$Res> {
factory $LegacyDeviceResponseModelCopyWith(LegacyDeviceResponseModel value, $Res Function(LegacyDeviceResponseModel) _then) = _$LegacyDeviceResponseModelCopyWithImpl;
@useResult
$Res call({
bool isCreated, LegacyDeviceItemResponseModel item
});
$LegacyDeviceItemResponseModelCopyWith<$Res> get item;
}
/// @nodoc
class _$LegacyDeviceResponseModelCopyWithImpl<$Res>
implements $LegacyDeviceResponseModelCopyWith<$Res> {
_$LegacyDeviceResponseModelCopyWithImpl(this._self, this._then);
final LegacyDeviceResponseModel _self;
final $Res Function(LegacyDeviceResponseModel) _then;
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyDeviceItemResponseModel,
));
}
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyDeviceItemResponseModelCopyWith<$Res> get item {
return $LegacyDeviceItemResponseModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// Adds pattern-matching-related methods to [LegacyDeviceResponseModel].
extension LegacyDeviceResponseModelPatterns on LegacyDeviceResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyDeviceResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyDeviceResponseModel value) $default,){
final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyDeviceResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, LegacyDeviceItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyDeviceItemResponseModel item) $default,) {final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel():
return $default(_that.isCreated,_that.item);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyDeviceItemResponseModel item)? $default,) {final _that = this;
switch (_that) {
case _LegacyDeviceResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _LegacyDeviceResponseModel implements LegacyDeviceResponseModel {
const _LegacyDeviceResponseModel({required this.isCreated, required this.item});
factory _LegacyDeviceResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyDeviceResponseModelFromJson(json);
@override final bool isCreated;
@override final LegacyDeviceItemResponseModel item;
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyDeviceResponseModelCopyWith<_LegacyDeviceResponseModel> get copyWith => __$LegacyDeviceResponseModelCopyWithImpl<_LegacyDeviceResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LegacyDeviceResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyDeviceResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class _$LegacyDeviceResponseModelCopyWith<$Res> implements $LegacyDeviceResponseModelCopyWith<$Res> {
factory _$LegacyDeviceResponseModelCopyWith(_LegacyDeviceResponseModel value, $Res Function(_LegacyDeviceResponseModel) _then) = __$LegacyDeviceResponseModelCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, LegacyDeviceItemResponseModel item
});
@override $LegacyDeviceItemResponseModelCopyWith<$Res> get item;
}
/// @nodoc
class __$LegacyDeviceResponseModelCopyWithImpl<$Res>
implements _$LegacyDeviceResponseModelCopyWith<$Res> {
__$LegacyDeviceResponseModelCopyWithImpl(this._self, this._then);
final _LegacyDeviceResponseModel _self;
final $Res Function(_LegacyDeviceResponseModel) _then;
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_LegacyDeviceResponseModel(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyDeviceItemResponseModel,
));
}
/// Create a copy of LegacyDeviceResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyDeviceItemResponseModelCopyWith<$Res> get item {
return $LegacyDeviceItemResponseModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// @nodoc
mixin _$LegacyDeviceItemResponseModel {
String get id; String get identificator; String get carrierName; String? get carrierGenre; int? get carrierWeight; int? get carrierStepLength; int? get carrierBirthday; String? get userId; int? get battery; String get protocol; String get connectionServer; String get type; Map<String, dynamic> get flags; Map<String, dynamic> get settings; Map<String, dynamic>? get capabilities; int get createdAt;
/// Create a copy of LegacyDeviceItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyDeviceItemResponseModelCopyWith<LegacyDeviceItemResponseModel> get copyWith => _$LegacyDeviceItemResponseModelCopyWithImpl<LegacyDeviceItemResponseModel>(this as LegacyDeviceItemResponseModel, _$identity);
/// Serializes this LegacyDeviceItemResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.flags, flags)&&const DeepCollectionEquality().equals(other.settings, settings)&&const DeepCollectionEquality().equals(other.capabilities, capabilities)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,identificator,carrierName,carrierGenre,carrierWeight,carrierStepLength,carrierBirthday,userId,battery,protocol,connectionServer,type,const DeepCollectionEquality().hash(flags),const DeepCollectionEquality().hash(settings),const DeepCollectionEquality().hash(capabilities),createdAt);
@override
String toString() {
return 'LegacyDeviceItemResponseModel(id: $id, identificator: $identificator, carrierName: $carrierName, carrierGenre: $carrierGenre, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierBirthday: $carrierBirthday, userId: $userId, battery: $battery, protocol: $protocol, connectionServer: $connectionServer, type: $type, flags: $flags, settings: $settings, capabilities: $capabilities, createdAt: $createdAt)';
}
}
/// @nodoc
abstract mixin class $LegacyDeviceItemResponseModelCopyWith<$Res> {
factory $LegacyDeviceItemResponseModelCopyWith(LegacyDeviceItemResponseModel value, $Res Function(LegacyDeviceItemResponseModel) _then) = _$LegacyDeviceItemResponseModelCopyWithImpl;
@useResult
$Res call({
String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map<String, dynamic> flags, Map<String, dynamic> settings, Map<String, dynamic>? capabilities, int createdAt
});
}
/// @nodoc
class _$LegacyDeviceItemResponseModelCopyWithImpl<$Res>
implements $LegacyDeviceItemResponseModelCopyWith<$Res> {
_$LegacyDeviceItemResponseModelCopyWithImpl(this._self, this._then);
final LegacyDeviceItemResponseModel _self;
final $Res Function(LegacyDeviceItemResponseModel) _then;
/// Create a copy of LegacyDeviceItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? identificator = null,Object? carrierName = null,Object? carrierGenre = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierBirthday = freezed,Object? userId = freezed,Object? battery = freezed,Object? protocol = null,Object? connectionServer = null,Object? type = null,Object? flags = null,Object? settings = null,Object? capabilities = freezed,Object? createdAt = null,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,capabilities: freezed == capabilities ? _self.capabilities : capabilities // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// Adds pattern-matching-related methods to [LegacyDeviceItemResponseModel].
extension LegacyDeviceItemResponseModelPatterns on LegacyDeviceItemResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyDeviceItemResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyDeviceItemResponseModel value) $default,){
final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyDeviceItemResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map<String, dynamic> flags, Map<String, dynamic> settings, Map<String, dynamic>? capabilities, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel() when $default != null:
return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map<String, dynamic> flags, Map<String, dynamic> settings, Map<String, dynamic>? capabilities, int createdAt) $default,) {final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel():
return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map<String, dynamic> flags, Map<String, dynamic> settings, Map<String, dynamic>? capabilities, int createdAt)? $default,) {final _that = this;
switch (_that) {
case _LegacyDeviceItemResponseModel() when $default != null:
return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _LegacyDeviceItemResponseModel implements LegacyDeviceItemResponseModel {
const _LegacyDeviceItemResponseModel({required this.id, required this.identificator, required this.carrierName, this.carrierGenre, this.carrierWeight, this.carrierStepLength, this.carrierBirthday, this.userId, this.battery, required this.protocol, required this.connectionServer, required this.type, final Map<String, dynamic> flags = const {}, final Map<String, dynamic> settings = const {}, final Map<String, dynamic>? capabilities, required this.createdAt}): _flags = flags,_settings = settings,_capabilities = capabilities;
factory _LegacyDeviceItemResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyDeviceItemResponseModelFromJson(json);
@override final String id;
@override final String identificator;
@override final String carrierName;
@override final String? carrierGenre;
@override final int? carrierWeight;
@override final int? carrierStepLength;
@override final int? carrierBirthday;
@override final String? userId;
@override final int? battery;
@override final String protocol;
@override final String connectionServer;
@override final String type;
final Map<String, dynamic> _flags;
@override@JsonKey() Map<String, dynamic> get flags {
if (_flags is EqualUnmodifiableMapView) return _flags;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_flags);
}
final Map<String, dynamic> _settings;
@override@JsonKey() Map<String, dynamic> get settings {
if (_settings is EqualUnmodifiableMapView) return _settings;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_settings);
}
final Map<String, dynamic>? _capabilities;
@override Map<String, dynamic>? get capabilities {
final value = _capabilities;
if (value == null) return null;
if (_capabilities is EqualUnmodifiableMapView) return _capabilities;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override final int createdAt;
/// Create a copy of LegacyDeviceItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyDeviceItemResponseModelCopyWith<_LegacyDeviceItemResponseModel> get copyWith => __$LegacyDeviceItemResponseModelCopyWithImpl<_LegacyDeviceItemResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LegacyDeviceItemResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._flags, _flags)&&const DeepCollectionEquality().equals(other._settings, _settings)&&const DeepCollectionEquality().equals(other._capabilities, _capabilities)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,identificator,carrierName,carrierGenre,carrierWeight,carrierStepLength,carrierBirthday,userId,battery,protocol,connectionServer,type,const DeepCollectionEquality().hash(_flags),const DeepCollectionEquality().hash(_settings),const DeepCollectionEquality().hash(_capabilities),createdAt);
@override
String toString() {
return 'LegacyDeviceItemResponseModel(id: $id, identificator: $identificator, carrierName: $carrierName, carrierGenre: $carrierGenre, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierBirthday: $carrierBirthday, userId: $userId, battery: $battery, protocol: $protocol, connectionServer: $connectionServer, type: $type, flags: $flags, settings: $settings, capabilities: $capabilities, createdAt: $createdAt)';
}
}
/// @nodoc
abstract mixin class _$LegacyDeviceItemResponseModelCopyWith<$Res> implements $LegacyDeviceItemResponseModelCopyWith<$Res> {
factory _$LegacyDeviceItemResponseModelCopyWith(_LegacyDeviceItemResponseModel value, $Res Function(_LegacyDeviceItemResponseModel) _then) = __$LegacyDeviceItemResponseModelCopyWithImpl;
@override @useResult
$Res call({
String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map<String, dynamic> flags, Map<String, dynamic> settings, Map<String, dynamic>? capabilities, int createdAt
});
}
/// @nodoc
class __$LegacyDeviceItemResponseModelCopyWithImpl<$Res>
implements _$LegacyDeviceItemResponseModelCopyWith<$Res> {
__$LegacyDeviceItemResponseModelCopyWithImpl(this._self, this._then);
final _LegacyDeviceItemResponseModel _self;
final $Res Function(_LegacyDeviceItemResponseModel) _then;
/// Create a copy of LegacyDeviceItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? identificator = null,Object? carrierName = null,Object? carrierGenre = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierBirthday = freezed,Object? userId = freezed,Object? battery = freezed,Object? protocol = null,Object? connectionServer = null,Object? type = null,Object? flags = null,Object? settings = null,Object? capabilities = freezed,Object? createdAt = null,}) {
return _then(_LegacyDeviceItemResponseModel(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,settings: null == settings ? _self._settings : settings // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,capabilities: freezed == capabilities ? _self._capabilities : capabilities // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
// dart format on

View File

@@ -0,0 +1,62 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'device_response_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_LegacyDeviceResponseModel _$LegacyDeviceResponseModelFromJson(
Map<String, dynamic> json,
) => _LegacyDeviceResponseModel(
isCreated: json['isCreated'] as bool,
item: LegacyDeviceItemResponseModel.fromJson(
json['item'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$LegacyDeviceResponseModelToJson(
_LegacyDeviceResponseModel instance,
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
_LegacyDeviceItemResponseModel _$LegacyDeviceItemResponseModelFromJson(
Map<String, dynamic> json,
) => _LegacyDeviceItemResponseModel(
id: json['id'] as String,
identificator: json['identificator'] as String,
carrierName: json['carrierName'] as String,
carrierGenre: json['carrierGenre'] as String?,
carrierWeight: (json['carrierWeight'] as num?)?.toInt(),
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(),
carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(),
userId: json['userId'] as String?,
battery: (json['battery'] as num?)?.toInt(),
protocol: json['protocol'] as String,
connectionServer: json['connectionServer'] as String,
type: json['type'] as String,
flags: json['flags'] as Map<String, dynamic>? ?? const {},
settings: json['settings'] as Map<String, dynamic>? ?? const {},
capabilities: json['capabilities'] as Map<String, dynamic>?,
createdAt: (json['createdAt'] as num).toInt(),
);
Map<String, dynamic> _$LegacyDeviceItemResponseModelToJson(
_LegacyDeviceItemResponseModel instance,
) => <String, dynamic>{
'id': instance.id,
'identificator': instance.identificator,
'carrierName': instance.carrierName,
'carrierGenre': instance.carrierGenre,
'carrierWeight': instance.carrierWeight,
'carrierStepLength': instance.carrierStepLength,
'carrierBirthday': instance.carrierBirthday,
'userId': instance.userId,
'battery': instance.battery,
'protocol': instance.protocol,
'connectionServer': instance.connectionServer,
'type': instance.type,
'flags': instance.flags,
'settings': instance.settings,
'capabilities': instance.capabilities,
'createdAt': instance.createdAt,
};

View File

@@ -8,23 +8,14 @@ part 'sign_up_response_model.g.dart';
abstract class LegacySignUpResponseModel with _$LegacySignUpResponseModel {
const factory LegacySignUpResponseModel({
required bool isCreated,
required LegacySignUpResponseItemModel item,
required String item,
}) = _LegacySignUpResponseModel;
factory LegacySignUpResponseModel.fromJson(Map<String, dynamic> json) =>
_$LegacySignUpResponseModelFromJson(json);
}
@freezed
abstract class LegacySignUpResponseItemModel with _$LegacySignUpResponseItemModel {
const factory LegacySignUpResponseItemModel({required String userId}) =
_LegacySignUpResponseItemModel;
factory LegacySignUpResponseItemModel.fromJson(Map<String, dynamic> json) =>
_$LegacySignUpResponseItemModelFromJson(json);
}
extension LegacySignUpResponseModelMapper on LegacySignUpResponseModel {
LegacySignUpResponseEntity toEntity() =>
LegacySignUpResponseEntity(isCreated: isCreated, userId: item.userId);
LegacySignUpResponseEntity(isCreated: isCreated, userId: item);
}

View File

@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacySignUpResponseModel {
bool get isCreated; LegacySignUpResponseItemModel get item;
bool get isCreated; String get item;
/// Create a copy of LegacySignUpResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -48,11 +48,11 @@ abstract mixin class $LegacySignUpResponseModelCopyWith<$Res> {
factory $LegacySignUpResponseModelCopyWith(LegacySignUpResponseModel value, $Res Function(LegacySignUpResponseModel) _then) = _$LegacySignUpResponseModelCopyWithImpl;
@useResult
$Res call({
bool isCreated, LegacySignUpResponseItemModel item
bool isCreated, String item
});
$LegacySignUpResponseItemModelCopyWith<$Res> get item;
}
/// @nodoc
@@ -69,19 +69,10 @@ class _$LegacySignUpResponseModelCopyWithImpl<$Res>
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacySignUpResponseItemModel,
as String,
));
}
/// Create a copy of LegacySignUpResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacySignUpResponseItemModelCopyWith<$Res> get item {
return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
@@ -163,7 +154,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, LegacySignUpResponseItemModel item)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, String item)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacySignUpResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
@@ -184,7 +175,7 @@ return $default(_that.isCreated,_that.item);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacySignUpResponseItemModel item) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, String item) $default,) {final _that = this;
switch (_that) {
case _LegacySignUpResponseModel():
return $default(_that.isCreated,_that.item);case _:
@@ -204,7 +195,7 @@ return $default(_that.isCreated,_that.item);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacySignUpResponseItemModel item)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, String item)? $default,) {final _that = this;
switch (_that) {
case _LegacySignUpResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
@@ -223,7 +214,7 @@ class _LegacySignUpResponseModel implements LegacySignUpResponseModel {
factory _LegacySignUpResponseModel.fromJson(Map<String, dynamic> json) => _$LegacySignUpResponseModelFromJson(json);
@override final bool isCreated;
@override final LegacySignUpResponseItemModel item;
@override final String item;
/// Create a copy of LegacySignUpResponseModel
/// with the given fields replaced by the non-null parameter values.
@@ -258,11 +249,11 @@ abstract mixin class _$LegacySignUpResponseModelCopyWith<$Res> implements $Legac
factory _$LegacySignUpResponseModelCopyWith(_LegacySignUpResponseModel value, $Res Function(_LegacySignUpResponseModel) _then) = __$LegacySignUpResponseModelCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, LegacySignUpResponseItemModel item
bool isCreated, String item
});
@override $LegacySignUpResponseItemModelCopyWith<$Res> get item;
}
/// @nodoc
@@ -279,278 +270,6 @@ class __$LegacySignUpResponseModelCopyWithImpl<$Res>
return _then(_LegacySignUpResponseModel(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacySignUpResponseItemModel,
));
}
/// Create a copy of LegacySignUpResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacySignUpResponseItemModelCopyWith<$Res> get item {
return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// @nodoc
mixin _$LegacySignUpResponseItemModel {
String get userId;
/// Create a copy of LegacySignUpResponseItemModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacySignUpResponseItemModelCopyWith<LegacySignUpResponseItemModel> get copyWith => _$LegacySignUpResponseItemModelCopyWithImpl<LegacySignUpResponseItemModel>(this as LegacySignUpResponseItemModel, _$identity);
/// Serializes this LegacySignUpResponseItemModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,userId);
@override
String toString() {
return 'LegacySignUpResponseItemModel(userId: $userId)';
}
}
/// @nodoc
abstract mixin class $LegacySignUpResponseItemModelCopyWith<$Res> {
factory $LegacySignUpResponseItemModelCopyWith(LegacySignUpResponseItemModel value, $Res Function(LegacySignUpResponseItemModel) _then) = _$LegacySignUpResponseItemModelCopyWithImpl;
@useResult
$Res call({
String userId
});
}
/// @nodoc
class _$LegacySignUpResponseItemModelCopyWithImpl<$Res>
implements $LegacySignUpResponseItemModelCopyWith<$Res> {
_$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then);
final LegacySignUpResponseItemModel _self;
final $Res Function(LegacySignUpResponseItemModel) _then;
/// Create a copy of LegacySignUpResponseItemModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? userId = null,}) {
return _then(_self.copyWith(
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [LegacySignUpResponseItemModel].
extension LegacySignUpResponseItemModelPatterns on LegacySignUpResponseItemModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacySignUpResponseItemModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacySignUpResponseItemModel value) $default,){
final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacySignUpResponseItemModel value)? $default,){
final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String userId)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel() when $default != null:
return $default(_that.userId);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String userId) $default,) {final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel():
return $default(_that.userId);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String userId)? $default,) {final _that = this;
switch (_that) {
case _LegacySignUpResponseItemModel() when $default != null:
return $default(_that.userId);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _LegacySignUpResponseItemModel implements LegacySignUpResponseItemModel {
const _LegacySignUpResponseItemModel({required this.userId});
factory _LegacySignUpResponseItemModel.fromJson(Map<String, dynamic> json) => _$LegacySignUpResponseItemModelFromJson(json);
@override final String userId;
/// Create a copy of LegacySignUpResponseItemModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacySignUpResponseItemModelCopyWith<_LegacySignUpResponseItemModel> get copyWith => __$LegacySignUpResponseItemModelCopyWithImpl<_LegacySignUpResponseItemModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LegacySignUpResponseItemModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,userId);
@override
String toString() {
return 'LegacySignUpResponseItemModel(userId: $userId)';
}
}
/// @nodoc
abstract mixin class _$LegacySignUpResponseItemModelCopyWith<$Res> implements $LegacySignUpResponseItemModelCopyWith<$Res> {
factory _$LegacySignUpResponseItemModelCopyWith(_LegacySignUpResponseItemModel value, $Res Function(_LegacySignUpResponseItemModel) _then) = __$LegacySignUpResponseItemModelCopyWithImpl;
@override @useResult
$Res call({
String userId
});
}
/// @nodoc
class __$LegacySignUpResponseItemModelCopyWithImpl<$Res>
implements _$LegacySignUpResponseItemModelCopyWith<$Res> {
__$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then);
final _LegacySignUpResponseItemModel _self;
final $Res Function(_LegacySignUpResponseItemModel) _then;
/// Create a copy of LegacySignUpResponseItemModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? userId = null,}) {
return _then(_LegacySignUpResponseItemModel(
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String,
));
}

View File

@@ -10,19 +10,9 @@ _LegacySignUpResponseModel _$LegacySignUpResponseModelFromJson(
Map<String, dynamic> json,
) => _LegacySignUpResponseModel(
isCreated: json['isCreated'] as bool,
item: LegacySignUpResponseItemModel.fromJson(
json['item'] as Map<String, dynamic>,
),
item: json['item'] as String,
);
Map<String, dynamic> _$LegacySignUpResponseModelToJson(
_LegacySignUpResponseModel instance,
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
_LegacySignUpResponseItemModel _$LegacySignUpResponseItemModelFromJson(
Map<String, dynamic> json,
) => _LegacySignUpResponseItemModel(userId: json['userId'] as String);
Map<String, dynamic> _$LegacySignUpResponseItemModelToJson(
_LegacySignUpResponseItemModel instance,
) => <String, dynamic>{'userId': instance.userId};

View File

@@ -1,14 +1,6 @@
import 'package:legacy_auth/src/core/data/datasource/auth_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
class LegacyAuthRepositoryImpl implements LegacyAuthRepository {
const LegacyAuthRepositoryImpl(this._remote);
@@ -25,51 +17,6 @@ class LegacyAuthRepositoryImpl implements LegacyAuthRepository {
return _remote.verifyPhoneCode(phone: phone, code: code);
}
@override
Future<LegacyLoginResponseEntity> login({
required String email,
required String password,
}) async {
final responseModel = await _remote.login(email: email, password: password);
return LegacyLoginResponseModelMapper(responseModel).toEntity();
}
@override
Future<void> twoFARequestCode({
required String token,
required String methodType,
}) {
return _remote.twoFARequestCode(token: token, methodType: methodType);
}
@override
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
}) {
return _remote.twoFASendCode(
token: token,
code: code,
methodType: methodType,
);
}
// @override
// Future<String> totpLogin({required String token, required String code}) {
// return _remote.totpLogin(token: token, code: code);
// }
@override
Future<LegacySignUpResponseEntity> signUp({
required LegacySignUpRequestEntity request,
}) async {
final model = request.toModel();
final responseModel = await _remote.signUp(request: model);
return responseModel.toEntity();
}
@override
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({
required String token,
@@ -102,59 +49,4 @@ class LegacyAuthRepositoryImpl implements LegacyAuthRepository {
Future<void> logout() {
return _remote.logout();
}
@override
Future<LegacyChildProfileEntity> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
}) async {
final model = await _remote.createChildProfile(
id: id,
parentId: parentId,
firstName: firstName,
lastName: lastName,
bornAt: bornAt,
genrer: genrer,
relationType: relationType,
address: address,
cardPublicKey: cardPublicKey,
deviceActivationCode: deviceActivationCode,
scaProof: scaProof,
);
if (!model.isCreated) {
throw Exception('Child profile creation failed: isCreated=false');
}
return model.toEntity();
}
}
extension LegacyLoginResponseModelMapper on LegacyLoginResponseModel {
LegacyLoginResponseEntity toEntity() {
return LegacyLoginResponseEntity(
token: token,
availableMethods: availableMethods
.map(
(m) => LegacyAvailableMethodEntity(
id: m.id,
userId: m.userId,
methodType: m.methodType,
status: m.status,
isDefault: m.isDefault,
createdAt: m.createdAt,
),
)
.toList(),
);
}
}

View File

@@ -0,0 +1,33 @@
import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart';
import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart';
class LegacyDeviceSetupRepositoryImpl implements LegacyDeviceSetupRepository {
const LegacyDeviceSetupRepositoryImpl(this._remote);
final LegacyDeviceSetupRemoteDatasource _remote;
@override
Future<void> createDevice({
required String name,
required String genrer,
required int weight,
required int stepLength,
required int bornAt,
required String relationType,
required String activationKey,
}) async {
final model = await _remote.createDevice(
name: name,
genrer: genrer,
weight: weight,
stepLength: stepLength,
bornAt: bornAt,
relationType: relationType,
activationKey: activationKey,
);
if (!model.isCreated) {
throw Exception('Device creation failed: isCreated=false');
}
}
}

View File

@@ -0,0 +1,37 @@
import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
import 'package:legacy_auth/src/core/domain/repositories/login_repository.dart';
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
class LegacyLoginRepositoryImpl implements LegacyLoginRepository {
const LegacyLoginRepositoryImpl(this._remote);
final LegacyLoginRemoteDatasource _remote;
@override
Future<LegacyLoginResponseEntity> login({
required String email,
required String password,
}) async {
final model = await _remote.login(email: email, password: password);
return model.toEntity();
}
@override
Future<void> twoFARequestCode({
required String token,
required String methodType,
}) =>
_remote.twoFARequestCode(token: token, methodType: methodType);
@override
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
}) =>
_remote.twoFASendCode(token: token, code: code, methodType: methodType);
@override
Future<bool> hasDevices() => _remote.hasDevices();
}

View File

@@ -0,0 +1,21 @@
import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
import 'package:legacy_auth/src/core/domain/repositories/sign_up_repository.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
class LegacySignUpRepositoryImpl implements LegacySignUpRepository {
const LegacySignUpRepositoryImpl(this._remote);
final LegacySignUpRemoteDatasource _remote;
@override
Future<LegacySignUpResponseEntity> signUp({
required LegacySignUpRequestEntity request,
}) async {
final model = request.toModel();
final responseModel = await _remote.signUp(request: model);
return responseModel.toEntity();
}
}

View File

@@ -1,30 +1,10 @@
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
abstract class LegacyAuthRepository {
Future<void> requestPhoneCode({required String phone});
Future<void> verifyPhoneCode({required String phone, required String code});
Future<LegacyLoginResponseEntity> login({
required String email,
required String password,
});
Future<void> twoFARequestCode({
required String token,
required String methodType,
});
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
});
Future<LegacySignUpResponseEntity> signUp({required LegacySignUpRequestEntity request});
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({required String token});
Future<String> verifyTwoFACodeSignUp({
@@ -40,18 +20,4 @@ abstract class LegacyAuthRepository {
});
Future<void> logout();
Future<LegacyChildProfileEntity> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
});
}

View File

@@ -0,0 +1,11 @@
abstract class LegacyDeviceSetupRepository {
Future<void> createDevice({
required String name,
required String genrer,
required int weight,
required int stepLength,
required int bornAt,
required String relationType,
required String activationKey,
});
}

View File

@@ -0,0 +1,21 @@
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
abstract class LegacyLoginRepository {
Future<LegacyLoginResponseEntity> login({
required String email,
required String password,
});
Future<void> twoFARequestCode({
required String token,
required String methodType,
});
Future<void> twoFASendCode({
required String token,
required String code,
required String methodType,
});
Future<bool> hasDevices();
}

View File

@@ -1,6 +1,8 @@
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
abstract class LegacySignUpUseCase {
Future<LegacySignUpResponseEntity> signUp({required LegacySignUpRequestEntity request});
abstract class LegacySignUpRepository {
Future<LegacySignUpResponseEntity> signUp({
required LegacySignUpRequestEntity request,
});
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource_impl.dart';
final legacyDeviceSetupRemoteDatasourceProvider =
Provider<LegacyDeviceSetupRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return LegacyDeviceSetupRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/src/core/data/repositories/device_setup_repository_impl.dart';
import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart';
import 'package:legacy_auth/src/core/providers/device_setup_remote_datasource_provider.dart';
final legacyDeviceSetupRepositoryProvider =
Provider<LegacyDeviceSetupRepository>((ref) {
final remote = ref.read(legacyDeviceSetupRemoteDatasourceProvider);
return LegacyDeviceSetupRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource_impl.dart';
final legacyLoginRemoteDatasourceProvider =
Provider<LegacyLoginRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return LegacyLoginRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,9 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/src/core/data/repositories/login_repository_impl.dart';
import 'package:legacy_auth/src/core/domain/repositories/login_repository.dart';
import 'package:legacy_auth/src/core/providers/login_remote_datasource_provider.dart';
final legacyLoginRepositoryProvider = Provider<LegacyLoginRepository>((ref) {
final remote = ref.read(legacyLoginRemoteDatasourceProvider);
return LegacyLoginRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource.dart';
import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource_impl.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
final legacySignUpRemoteDatasourceProvider =
Provider<LegacySignUpRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return LegacySignUpRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,9 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/src/core/data/repositories/sign_up_repository_impl.dart';
import 'package:legacy_auth/src/core/domain/repositories/sign_up_repository.dart';
import 'package:legacy_auth/src/core/providers/sign_up_remote_datasource_provider.dart';
final legacySignUpRepositoryProvider = Provider<LegacySignUpRepository>((ref) {
final remote = ref.read(legacySignUpRemoteDatasourceProvider);
return LegacySignUpRepositoryImpl(remote);
});

View File

@@ -0,0 +1,25 @@
String formatDateDMY(DateTime date) {
final dd = date.day.toString().padLeft(2, '0');
final mm = date.month.toString().padLeft(2, '0');
final yyyy = date.year.toString();
return '$dd/$mm/$yyyy';
}
DateTime? tryParseDMY(String value) {
final v = value.trim();
if (v.isEmpty) return null;
final parts = v.split('/');
if (parts.length != 3) return null;
final d = int.tryParse(parts[0]);
final m = int.tryParse(parts[1]);
final y = int.tryParse(parts[2]);
if (d == null || m == null || y == null) return null;
final date = DateTime(y, m, d);
if (date.year != y || date.month != m || date.day != d) return null;
return date;
}

View File

@@ -0,0 +1,57 @@
import 'dart:convert';
import 'package:dio/dio.dart';
Future<T> safeCall<T>(
Future<T> Function() call,
String fallbackMsg,
) async {
try {
return await call();
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: fallbackMsg);
}
}
Exception mapDioError(DioException error, {required String defaultMessage}) {
final apiMsg = _extractApiMessage(error.response?.data);
final msg = apiMsg ?? error.message ?? defaultMessage;
return Exception(msg);
}
String? _extractApiMessage(Object? data) {
if (data == null) return null;
if (data is Map) {
final errorObj = data['error'];
if (errorObj is Map && errorObj['message'] is String) {
return (errorObj['message'] as String).trim();
}
if (data['message'] is String) {
return (data['message'] as String).trim();
}
return null;
}
if (data is String) {
final raw = data.trim();
if (raw.isEmpty) return null;
try {
final decoded = jsonDecode(raw);
return _extractApiMessage(decoded);
} catch (_) {
return raw;
}
}
return null;
}
String formatErrorMessage(Object error) {
final raw = error.toString();
if (raw.startsWith('Exception: ')) {
return raw.substring('Exception: '.length);
}
return raw;
}

View File

@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
String toCapitalized(String text) => text.splitMapJoin(
RegExp(r'\S+'),
onMatch: (m) {
final word = m[0]!;
return word[0].toUpperCase() + word.substring(1).toLowerCase();
},
onNonMatch: (s) => s,
);
void toCapitalizedController(TextEditingController controller) {
final text = controller.text;
final capitalized = toCapitalized(text);
if (text == capitalized) return;
final offset = controller.selection.baseOffset.clamp(0, capitalized.length);
controller.value = TextEditingValue(
text: capitalized,
selection: TextSelection.collapsed(offset: offset),
);
}
void toUpperCaseController(TextEditingController controller) {
final text = controller.text;
final upper = text.toUpperCase();
if (text == upper) return;
final offset = controller.selection.baseOffset.clamp(0, upper.length);
controller.value = TextEditingValue(
text: upper,
selection: TextSelection.collapsed(offset: offset),
);
}

View File

@@ -1,17 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
abstract class LegacyCreateChildProfileUseCase {
Future<LegacyChildProfileEntity> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
});
}

View File

@@ -1,38 +0,0 @@
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
class LegacyCreateChildProfileUseCaseImpl implements LegacyCreateChildProfileUseCase {
LegacyCreateChildProfileUseCaseImpl(this._repository);
final LegacyAuthRepository _repository;
@override
Future<LegacyChildProfileEntity> createChildProfile({
required String id,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String genrer,
required String relationType,
required String address,
required String cardPublicKey,
required String deviceActivationCode,
required String scaProof,
}) {
return _repository.createChildProfile(
id: id,
parentId: parentId,
firstName: firstName,
lastName: lastName,
bornAt: bornAt,
genrer: genrer,
relationType: relationType,
address: address,
cardPublicKey: cardPublicKey,
deviceActivationCode: deviceActivationCode,
scaProof: scaProof,
);
}
}

View File

@@ -1,27 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'child_profile_entity.freezed.dart';
@freezed
abstract class LegacyChildProfileEntity with _$LegacyChildProfileEntity {
const factory LegacyChildProfileEntity({
required bool isCreated,
required LegacyChildProfileItemEntity item,
}) = _LegacyChildProfileEntity;
}
@freezed
abstract class LegacyChildProfileItemEntity with _$LegacyChildProfileItemEntity {
const factory LegacyChildProfileItemEntity({
required String id,
required String deviceIdentificator,
required String parentId,
required String firstName,
required String lastName,
required int bornAt,
required String address,
required int createdAt,
int? updatedAt,
String? profileImageId,
}) = _LegacyChildProfileItemEntity;
}

View File

@@ -1,576 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'child_profile_entity.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacyChildProfileEntity {
bool get isCreated; LegacyChildProfileItemEntity get item;
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyChildProfileEntityCopyWith<LegacyChildProfileEntity> get copyWith => _$LegacyChildProfileEntityCopyWithImpl<LegacyChildProfileEntity>(this as LegacyChildProfileEntity, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class $LegacyChildProfileEntityCopyWith<$Res> {
factory $LegacyChildProfileEntityCopyWith(LegacyChildProfileEntity value, $Res Function(LegacyChildProfileEntity) _then) = _$LegacyChildProfileEntityCopyWithImpl;
@useResult
$Res call({
bool isCreated, LegacyChildProfileItemEntity item
});
$LegacyChildProfileItemEntityCopyWith<$Res> get item;
}
/// @nodoc
class _$LegacyChildProfileEntityCopyWithImpl<$Res>
implements $LegacyChildProfileEntityCopyWith<$Res> {
_$LegacyChildProfileEntityCopyWithImpl(this._self, this._then);
final LegacyChildProfileEntity _self;
final $Res Function(LegacyChildProfileEntity) _then;
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyChildProfileItemEntity,
));
}
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyChildProfileItemEntityCopyWith<$Res> get item {
return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// Adds pattern-matching-related methods to [LegacyChildProfileEntity].
extension LegacyChildProfileEntityPatterns on LegacyChildProfileEntity {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyChildProfileEntity value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyChildProfileEntity() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyChildProfileEntity value) $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileEntity():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyChildProfileEntity value)? $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileEntity() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemEntity item)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyChildProfileEntity() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemEntity item) $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileEntity():
return $default(_that.isCreated,_that.item);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyChildProfileItemEntity item)? $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileEntity() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return null;
}
}
}
/// @nodoc
class _LegacyChildProfileEntity implements LegacyChildProfileEntity {
const _LegacyChildProfileEntity({required this.isCreated, required this.item});
@override final bool isCreated;
@override final LegacyChildProfileItemEntity item;
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyChildProfileEntityCopyWith<_LegacyChildProfileEntity> get copyWith => __$LegacyChildProfileEntityCopyWithImpl<_LegacyChildProfileEntity>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class _$LegacyChildProfileEntityCopyWith<$Res> implements $LegacyChildProfileEntityCopyWith<$Res> {
factory _$LegacyChildProfileEntityCopyWith(_LegacyChildProfileEntity value, $Res Function(_LegacyChildProfileEntity) _then) = __$LegacyChildProfileEntityCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, LegacyChildProfileItemEntity item
});
@override $LegacyChildProfileItemEntityCopyWith<$Res> get item;
}
/// @nodoc
class __$LegacyChildProfileEntityCopyWithImpl<$Res>
implements _$LegacyChildProfileEntityCopyWith<$Res> {
__$LegacyChildProfileEntityCopyWithImpl(this._self, this._then);
final _LegacyChildProfileEntity _self;
final $Res Function(_LegacyChildProfileEntity) _then;
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_LegacyChildProfileEntity(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as LegacyChildProfileItemEntity,
));
}
/// Create a copy of LegacyChildProfileEntity
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LegacyChildProfileItemEntityCopyWith<$Res> get item {
return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// @nodoc
mixin _$LegacyChildProfileItemEntity {
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId;
/// Create a copy of LegacyChildProfileItemEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LegacyChildProfileItemEntityCopyWith<LegacyChildProfileItemEntity> get copyWith => _$LegacyChildProfileItemEntityCopyWithImpl<LegacyChildProfileItemEntity>(this as LegacyChildProfileItemEntity, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
}
@override
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
@override
String toString() {
return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
}
}
/// @nodoc
abstract mixin class $LegacyChildProfileItemEntityCopyWith<$Res> {
factory $LegacyChildProfileItemEntityCopyWith(LegacyChildProfileItemEntity value, $Res Function(LegacyChildProfileItemEntity) _then) = _$LegacyChildProfileItemEntityCopyWithImpl;
@useResult
$Res call({
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
});
}
/// @nodoc
class _$LegacyChildProfileItemEntityCopyWithImpl<$Res>
implements $LegacyChildProfileItemEntityCopyWith<$Res> {
_$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then);
final LegacyChildProfileItemEntity _self;
final $Res Function(LegacyChildProfileItemEntity) _then;
/// Create a copy of LegacyChildProfileItemEntity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [LegacyChildProfileItemEntity].
extension LegacyChildProfileItemEntityPatterns on LegacyChildProfileItemEntity {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LegacyChildProfileItemEntity value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LegacyChildProfileItemEntity value) $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LegacyChildProfileItemEntity value)? $default,){
final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity():
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this;
switch (_that) {
case _LegacyChildProfileItemEntity() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
return null;
}
}
}
/// @nodoc
class _LegacyChildProfileItemEntity implements LegacyChildProfileItemEntity {
const _LegacyChildProfileItemEntity({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId});
@override final String id;
@override final String deviceIdentificator;
@override final String parentId;
@override final String firstName;
@override final String lastName;
@override final int bornAt;
@override final String address;
@override final int createdAt;
@override final int? updatedAt;
@override final String? profileImageId;
/// Create a copy of LegacyChildProfileItemEntity
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LegacyChildProfileItemEntityCopyWith<_LegacyChildProfileItemEntity> get copyWith => __$LegacyChildProfileItemEntityCopyWithImpl<_LegacyChildProfileItemEntity>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
}
@override
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
@override
String toString() {
return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
}
}
/// @nodoc
abstract mixin class _$LegacyChildProfileItemEntityCopyWith<$Res> implements $LegacyChildProfileItemEntityCopyWith<$Res> {
factory _$LegacyChildProfileItemEntityCopyWith(_LegacyChildProfileItemEntity value, $Res Function(_LegacyChildProfileItemEntity) _then) = __$LegacyChildProfileItemEntityCopyWithImpl;
@override @useResult
$Res call({
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
});
}
/// @nodoc
class __$LegacyChildProfileItemEntityCopyWithImpl<$Res>
implements _$LegacyChildProfileItemEntityCopyWith<$Res> {
__$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then);
final _LegacyChildProfileItemEntity _self;
final $Res Function(_LegacyChildProfileItemEntity) _then;
/// Create a copy of LegacyChildProfileItemEntity
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
return _then(_LegacyChildProfileItemEntity(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on

View File

@@ -1,19 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
extension LegacyAddKidStepMapper on LegacyAddKidStep {
LegacyAddKidMainStep get mainStep {
switch (this) {
case LegacyAddKidStep.linkInfo:
case LegacyAddKidStep.scanStrap:
case LegacyAddKidStep.scanWatch:
return LegacyAddKidMainStep.linkDevice;
case LegacyAddKidStep.profile:
return LegacyAddKidMainStep.profile;
case LegacyAddKidStep.allowance:
return LegacyAddKidMainStep.allowance;
case LegacyAddKidStep.intro:
return LegacyAddKidMainStep.linkDevice;
}
}
}

View File

@@ -1,74 +0,0 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class LegacyContactScreen extends ConsumerWidget {
const LegacyContactScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
return Scaffold(
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
body: Container(
margin: EdgeInsets.all(30),
child: Center(
child: Column(
spacing: 10,
children: [
Text(
"Contáctanos",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30),
),
Text(
"Trasládanos tus dudas e intentaremos responderte lo antes posible",
),
DropdownMenu(
initialSelection: "es",
label: Text("País"),
dropdownMenuEntries: [
DropdownMenuEntry(value: "es", label: "España"),
DropdownMenuEntry(value: "fr", label: "Francia"),
DropdownMenuEntry(value: "pt", label: "Portugal"),
],
),
DropdownMenu(
initialSelection: "online",
label: Text("Canal de compra"),
dropdownMenuEntries: [
DropdownMenuEntry(value: "online", label: "SF online shop"),
],
),
Expanded(
child: CustomTextField(
label: "Nombre",
hint: "Nombre y apellidos",
),
),
Expanded(
child: CustomTextField(
label: "Correo electrónico",
hint: "Correo electrónico",
),
),
Expanded(
child: CustomTextField(
lines: 3,
label: "Asunto del mensaje",
hint: "Escribe tu mensaje",
),
),
Expanded(
child: FilledButton(
onPressed: () => Navigator.pop(context),
child: Text("Enviar"),
),
),
],
),
),
),
);
}
}

View File

@@ -1,6 +1,4 @@
import 'package:legacy_auth/src/features/device_setup/presentation/add_kid_step_mapper.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/step_body.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/success_screen.dart';
@@ -10,7 +8,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/app_routes.dart';
import 'package:navigation/navigation_contract.dart';
import 'package:payments/payments.dart';
import 'package:sf_localizations/sf_localizations.dart';
class LegacyDeviceSetupScreen extends ConsumerWidget {
@@ -23,17 +20,28 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
final state = ref.watch(legacyDeviceSetupViewModelProvider);
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
final theme = ref.watch(themePortProvider);
final mainStep = state.step.mainStep;
final isIntro = state.step == LegacyAddKidStep.intro;
final isAllowance = state.step == LegacyAddKidStep.allowance;
final canPopRoute = state.step == LegacyAddKidStep.intro;
ref.listen(
legacyDeviceSetupViewModelProvider.select((s) => s.errorMessage),
(previous, next) {
if (next.isNotEmpty) {
showTopSnackbar(
context,
message: context.translate(next),
type: MessageType.error,
);
}
},
);
return PopScope(
canPop: canPopRoute,
onPopInvokedWithResult: (didPop, result) {
if (didPop || isAllowance) return;
if (didPop) return;
vm.back();
},
child: Scaffold(
@@ -45,7 +53,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
padding: const EdgeInsets.only(top: 12, left: 8, right: 8),
child: Row(
children: [
if (isIntro || isAllowance)
if (isIntro)
const SizedBox(width: 48)
else
IconButton(
@@ -60,17 +68,12 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
child: isIntro
? const SizedBox.shrink()
: StepIndicator(
total: LegacyAddKidMainStep.values.length,
current: mainStep.index + 1,
total: LegacyAddKidStep.mainStepCount,
current: state.step.mainStepIndex + 1,
color: theme.getColorFor(ThemeCode.buttonPrimary),
),
),
IconButton(
onPressed: () =>
navigationContract.goTo(AppRoutes.dashboardHome),
icon: const Icon(Icons.close),
color: theme.getColorFor(ThemeCode.textPrimary),
),
const SizedBox(width: 48),
],
),
),
@@ -87,7 +90,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
onPrimary: () async {
if (state.step == LegacyAddKidStep.profile) {
if (!vm.validateProfile()) return;
final ok = await vm.createChildProfile();
final ok = await vm.createDevice();
if (!context.mounted) return;
if (ok) {
Navigator.of(context).push(
@@ -96,18 +99,8 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
}
return;
}
if (state.step == LegacyAddKidStep.allowance) {
_pushHiPayScreen(context, ref);
return;
}
vm.next();
},
secondaryText: isAllowance
? context.translate(I18n.deviceSetup_skipAndConfigureLater)
: null,
onSecondary: isAllowance
? () => navigationContract.pushTo(AppRoutes.dashboardHome)
: null,
theme: theme,
),
],
@@ -117,38 +110,10 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
);
}
Future<void> _pushHiPayScreen(BuildContext context, WidgetRef ref) async {
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
final result = await Navigator.of(context).push<HiPayResult>(
MaterialPageRoute(
builder: (_) =>
HiPayWebViewScreen(navigationContract: navigationContract),
),
);
if (!context.mounted) return;
if (result == HiPayResult.success) {
vm.setError('');
showTopSnackbar(
context,
message: context.translate(I18n.deviceSetup_cardRegistered),
type: MessageType.success,
);
navigationContract.pushTo(AppRoutes.dashboardHome);
} else {
showTopSnackbar(
context,
message: context.translate(I18n.deviceSetup_paymentCancelled),
type: MessageType.error,
);
}
}
String primaryButtonText(LegacyAddKidStep step) {
switch (step) {
case LegacyAddKidStep.intro:
return I18n.deviceSetup_start;
case LegacyAddKidStep.allowance:
return I18n.deviceSetup_addCreditCard;
default:
return I18n.continueKey;
}

View File

@@ -1 +0,0 @@
enum LegacyAddKidMainStep { linkDevice, profile, allowance }

View File

@@ -1 +1,20 @@
enum LegacyAddKidStep { intro, linkInfo, scanStrap, scanWatch, profile, allowance }
enum LegacyAddKidStep {
intro,
linkInfo,
scanWatch,
profile;
/// Maps detailed steps to the 2 main indicator steps.
int get mainStepIndex {
switch (this) {
case LegacyAddKidStep.intro:
case LegacyAddKidStep.linkInfo:
case LegacyAddKidStep.scanWatch:
return 0;
case LegacyAddKidStep.profile:
return 1;
}
}
static const int mainStepCount = 2;
}

View File

@@ -1 +0,0 @@
enum LegacyScanLinkStep { strap, watch }

View File

@@ -1,10 +0,0 @@
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final legacyCreateChildProfileUseCaseProvider =
Provider.autoDispose<LegacyCreateChildProfileUseCase>((ref) {
final authRepository = ref.read(legacyAuthRepositoryProvider);
return LegacyCreateChildProfileUseCaseImpl(authRepository);
});

View File

@@ -1,13 +1,12 @@
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart';
import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart';
import 'package:legacy_auth/src/core/providers/device_setup_repository_provider.dart';
import 'package:legacy_auth/src/core/utils/date_format_utils.dart';
import 'package:legacy_auth/src/core/utils/text_format_utils.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:uuid/uuid.dart';
final legacyDeviceSetupViewModelProvider =
NotifierProvider<LegacyDeviceSetupViewModel, LegacyDeviceSetupViewState>(
@@ -15,20 +14,18 @@ final legacyDeviceSetupViewModelProvider =
);
class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
late final LegacyCreateChildProfileUseCase _createChildProfileUseCase;
late final GetUserInfoUseCase _getUserInfoUseCase;
late final LegacyDeviceSetupRepository _deviceSetupRepository;
late final TextEditingController bornAtController;
late final TextEditingController firstNameController;
late final TextEditingController lastNameController;
late final TextEditingController addressController;
late final TextEditingController strapCodeController;
late final TextEditingController bornAtController;
late final TextEditingController weightController;
late final TextEditingController heightController;
late final TextEditingController watchCodeController;
late final TextEditingController allowanceAmountController;
@override
LegacyDeviceSetupViewState build() {
final initial = LegacyDeviceSetupViewState(id: const Uuid().v4());
final initial = const LegacyDeviceSetupViewState();
_initControllers(initial);
_addListeners();
@@ -38,30 +35,25 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
}
void _initControllers(LegacyDeviceSetupViewState s) {
_createChildProfileUseCase = ref.read(legacyCreateChildProfileUseCaseProvider);
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
_deviceSetupRepository = ref.read(legacyDeviceSetupRepositoryProvider);
firstNameController = TextEditingController(text: s.firstName);
lastNameController = TextEditingController(text: s.lastName);
bornAtController = TextEditingController(
text: s.bornAt == null ? '' : _formatDate(s.bornAt!),
text: s.bornAt == null ? '' : formatDateDMY(s.bornAt!),
);
addressController = TextEditingController(text: s.address);
strapCodeController = TextEditingController(text: s.strapCode);
weightController = TextEditingController(text: s.weight);
heightController = TextEditingController(text: s.height);
watchCodeController = TextEditingController(text: s.watchCode);
allowanceAmountController = TextEditingController(text: s.allowanceAmount);
}
void _addListeners() {
firstNameController.addListener(_onFirstNameChanged);
lastNameController.addListener(_onLastNameChanged);
bornAtController.addListener(_onBornAtTextChanged);
addressController.addListener(_onAddressChanged);
strapCodeController.addListener(_onStrapCodeChanged);
weightController.addListener(_onWeightChanged);
heightController.addListener(_onHeightChanged);
watchCodeController.addListener(_onWatchCodeChanged);
allowanceAmountController.addListener(_onAllowanceAmountChanged);
}
void next() {
@@ -70,19 +62,12 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
state = state.copyWith(step: LegacyAddKidStep.linkInfo);
return;
case LegacyAddKidStep.linkInfo:
state = state.copyWith(step: LegacyAddKidStep.scanStrap);
return;
case LegacyAddKidStep.scanStrap:
final hasStrap = state.strapQr.isNotEmpty || state.strapCode.isNotEmpty;
if (!hasStrap) {
state = state.copyWith(errorMessage: I18n.errorScanStrapRequired);
return;
}
state = state.copyWith(step: LegacyAddKidStep.scanWatch, errorMessage: '');
state = state.copyWith(step: LegacyAddKidStep.scanWatch);
return;
case LegacyAddKidStep.scanWatch:
final hasWatch = state.watchQr.isNotEmpty || state.watchCode.isNotEmpty;
if (!hasWatch) {
state = state.copyWith(errorMessage: '');
state = state.copyWith(errorMessage: I18n.errorScanWatchRequired);
return;
}
@@ -90,8 +75,6 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
return;
case LegacyAddKidStep.profile:
return;
case LegacyAddKidStep.allowance:
return;
}
}
@@ -99,89 +82,52 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
switch (state.step) {
case LegacyAddKidStep.intro:
return;
case LegacyAddKidStep.linkInfo:
state = state.copyWith(step: LegacyAddKidStep.intro, errorMessage: '');
return;
case LegacyAddKidStep.scanStrap:
state = state.copyWith(step: LegacyAddKidStep.linkInfo);
return;
case LegacyAddKidStep.scanWatch:
state = state.copyWith(step: LegacyAddKidStep.scanStrap);
state = state.copyWith(step: LegacyAddKidStep.linkInfo);
return;
case LegacyAddKidStep.profile:
state = state.copyWith(step: LegacyAddKidStep.scanWatch);
return;
case LegacyAddKidStep.allowance:
state = state.copyWith(step: LegacyAddKidStep.profile);
return;
}
}
void onQrScanned({required LegacyScanLinkStep step, required String qr}) {
switch (step) {
case LegacyScanLinkStep.strap:
state = state.copyWith(strapQr: qr, step: LegacyAddKidStep.scanWatch);
break;
case LegacyScanLinkStep.watch:
state = state.copyWith(watchQr: qr, step: LegacyAddKidStep.profile);
break;
}
}
Future<void> pickBornAt(BuildContext context) async {
FocusManager.instance.primaryFocus?.unfocus();
final now = DateTime.now();
final initial = state.bornAt ?? DateTime(now.year - 18, now.month, now.day);
final safeInitial = initial.isAfter(now) ? now : initial;
final picked = await showDatePicker(
context: context,
initialDate: safeInitial,
firstDate: DateTime(1900, 1, 1),
lastDate: now,
);
if (!ref.mounted) return;
if (picked == null) return;
setBornAt(picked);
void onWatchQrScanned(String qr) {
state = state.copyWith(watchQr: qr, step: LegacyAddKidStep.profile);
}
void setBornAt(DateTime date) {
bornAtController.text = _formatDate(date);
bornAtController.text = formatDateDMY(date);
state = state.copyWith(bornAt: date);
}
Future<bool> createChildProfile() async {
await getUserInfo();
final firstName = state.firstName.trim();
final lastName = state.lastName.trim();
Future<bool> createDevice() async {
final name =
'${state.firstName.trim()} ${state.lastName.trim()}'.trim().toUpperCase();
final birth = state.bornAt!;
final bornAt = DateTime.utc(birth.year, birth.month, birth.day)
.millisecondsSinceEpoch;
final address = state.address.trim();
final weight = int.parse(state.weight.trim());
final heightCm = double.parse(state.height.trim());
final stepLength = (heightCm * 0.40).round();
final genrer = state.genrer.trim();
final relationType = state.relationType.trim();
final activationKey =
state.watchCode.isNotEmpty ? state.watchCode : state.watchQr;
state = state.copyWith(isLoading: true);
try {
await _createChildProfileUseCase.createChildProfile(
id: state.id,
parentId: state.parentId,
firstName: firstName,
lastName: lastName,
bornAt: bornAt,
await _deviceSetupRepository.createDevice(
name: name,
genrer: genrer,
weight: weight,
stepLength: stepLength,
bornAt: bornAt,
relationType: relationType,
address: address,
cardPublicKey: state.strapCode,
deviceActivationCode: state.watchCode,
scaProof: '',
activationKey: activationKey,
);
if (!ref.mounted) return false;
@@ -199,58 +145,35 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
}
}
Future<UserEntity?> getUserInfo() async {
state = state.copyWith(isLoading: true, errorMessage: '');
try {
final user = await _getUserInfoUseCase.getUserInfo();
if (ref.mounted) {
state = state.copyWith(isLoading: false);
}
debugPrint('[getUserInfo] userId => ${user.id}');
state = state.copyWith(parentId: user.id);
return user;
} catch (e) {
if (ref.mounted) {
state = state.copyWith(isLoading: false, errorMessage: e.toString());
}
return null;
}
}
bool validateProfile() {
final isInvalid =
state.firstName.trim().isEmpty ||
state.lastName.trim().isEmpty ||
state.bornAt == null ||
state.address.trim().isEmpty ||
state.genrer.trim().isEmpty ||
state.relationType.trim().isEmpty;
state.relationType.trim().isEmpty ||
state.weight.trim().isEmpty ||
int.tryParse(state.weight.trim()) == null ||
state.height.trim().isEmpty ||
double.tryParse(state.height.trim()) == null;
if (isInvalid) {
state = state.copyWith(errorMessage: '');
state = state.copyWith(errorMessage: I18n.errorAllFieldsRequired);
return false;
}
return true;
}
String _formatDate(DateTime date) {
final dd = date.day.toString().padLeft(2, '0');
final mm = date.month.toString().padLeft(2, '0');
final yyyy = date.year.toString();
return '$dd/$mm/$yyyy';
}
void _onFirstNameChanged() {
toCapitalizedController(firstNameController);
final text = firstNameController.text;
if (text == state.firstName) return;
state = state.copyWith(firstName: text, errorMessage: '');
}
void _onLastNameChanged() {
toCapitalizedController(lastNameController);
final text = lastNameController.text;
if (text == state.lastName) return;
state = state.copyWith(lastName: text, errorMessage: '');
@@ -258,7 +181,7 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
void _onBornAtTextChanged() {
final text = bornAtController.text;
final parsed = _tryParseDate(text);
final parsed = tryParseDMY(text);
if (text.trim().isEmpty) {
if (state.bornAt != null) {
@@ -272,16 +195,16 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
}
}
void _onAddressChanged() {
final text = addressController.text;
if (text == state.address) return;
state = state.copyWith(address: text, errorMessage: '');
void _onWeightChanged() {
final text = weightController.text;
if (text == state.weight) return;
state = state.copyWith(weight: text, errorMessage: '');
}
void _onStrapCodeChanged() {
final text = strapCodeController.text;
if (text == state.strapCode) return;
state = state.copyWith(strapCode: text, errorMessage: '');
void _onHeightChanged() {
final text = heightController.text;
if (text == state.height) return;
state = state.copyWith(height: text, errorMessage: '');
}
void _onWatchCodeChanged() {
@@ -290,20 +213,10 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
state = state.copyWith(watchCode: text, errorMessage: '');
}
void _onAllowanceAmountChanged() {
final text = allowanceAmountController.text;
if (text == state.allowanceAmount) return;
state = state.copyWith(allowanceAmount: text, errorMessage: '');
}
void setError(String message) {
state = state.copyWith(errorMessage: message);
}
void goToAllowance() {
state = state.copyWith(step: LegacyAddKidStep.allowance, errorMessage: '');
}
void onGenrerChanged(String? value) {
final v = value ?? '';
if (v == state.genrer) return;
@@ -316,40 +229,23 @@ class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
state = state.copyWith(relationType: v, errorMessage: '');
}
DateTime? _tryParseDate(String value) {
final v = value.trim();
if (v.isEmpty) return null;
final parts = v.split('/');
if (parts.length != 3) return null;
final d = int.tryParse(parts[0]);
final m = int.tryParse(parts[1]);
final y = int.tryParse(parts[2]);
if (d == null || m == null || y == null) return null;
final date = DateTime(y, m, d);
if (date.year != y || date.month != m || date.day != d) return null;
return date;
}
void resetForNewKid() {
firstNameController.clear();
lastNameController.clear();
bornAtController.clear();
addressController.clear();
strapCodeController.clear();
weightController.clear();
heightController.clear();
watchCodeController.clear();
allowanceAmountController.clear();
state = LegacyDeviceSetupViewState(id: const Uuid().v4());
state = const LegacyDeviceSetupViewState();
}
void disposeControllers() {
// firstNameController.dispose();
// lastNameController.dispose();
firstNameController.dispose();
lastNameController.dispose();
bornAtController.dispose();
weightController.dispose();
heightController.dispose();
watchCodeController.dispose();
}
}

View File

@@ -7,24 +7,19 @@ part 'device_setup_view_state.freezed.dart';
abstract class LegacyDeviceSetupViewState with _$LegacyDeviceSetupViewState {
const factory LegacyDeviceSetupViewState({
@Default(LegacyAddKidStep.intro) LegacyAddKidStep step,
@Default('') String id,
@Default('') String parentId,
@Default('') String firstName,
@Default('') String lastName,
DateTime? bornAt,
@Default('') String address,
@Default('') String genrer,
@Default('') String relationType,
@Default('') String weight,
@Default('') String height,
@Default('') String strapQr,
@Default('') String strapCode,
@Default('') String watchQr,
@Default('') String watchCode,
@Default(false) bool isLoading,
@Default('') String errorMessage,
@Default(false) bool isSuccess,
@Default('') String allowanceAmount,
}) = _AddKidFlowState;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacyDeviceSetupViewState {
LegacyAddKidStep get step; String get id; String get parentId; String get firstName; String get lastName; DateTime? get bornAt; String get address; String get genrer; String get relationType; String get strapQr; String get strapCode; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess; String get allowanceAmount;
LegacyAddKidStep get step; String get firstName; String get lastName; DateTime? get bornAt; String get genrer; String get relationType; String get weight; String get height; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess;
/// Create a copy of LegacyDeviceSetupViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $LegacyDeviceSetupViewStateCopyWith<LegacyDeviceSetupViewState> get copyWith =>
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount));
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess));
}
@override
int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount);
int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess);
@override
String toString() {
return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)';
return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)';
}
@@ -45,7 +45,7 @@ abstract mixin class $LegacyDeviceSetupViewStateCopyWith<$Res> {
factory $LegacyDeviceSetupViewStateCopyWith(LegacyDeviceSetupViewState value, $Res Function(LegacyDeviceSetupViewState) _then) = _$LegacyDeviceSetupViewStateCopyWithImpl;
@useResult
$Res call({
LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount
LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess
});
@@ -62,26 +62,22 @@ class _$LegacyDeviceSetupViewStateCopyWithImpl<$Res>
/// Create a copy of LegacyDeviceSetupViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) {
return _then(_self.copyWith(
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
as DateTime?,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable
as String,strapCode: null == strapCode ? _self.strapCode : strapCode // ignore: cast_nullable_to_non_nullable
as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable
as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable
as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable
as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable
as String,
as bool,
));
}
@@ -166,10 +162,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _AddKidFlowState() when $default != null:
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _:
return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _:
return orElse();
}
@@ -187,10 +183,10 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess) $default,) {final _that = this;
switch (_that) {
case _AddKidFlowState():
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _:
return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _:
throw StateError('Unexpected subclass');
}
@@ -207,10 +203,10 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,) {final _that = this;
switch (_that) {
case _AddKidFlowState() when $default != null:
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _:
return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _:
return null;
}
@@ -222,26 +218,22 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam
class _AddKidFlowState implements LegacyDeviceSetupViewState {
const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.id = '', this.parentId = '', this.firstName = '', this.lastName = '', this.bornAt, this.address = '', this.genrer = '', this.relationType = '', this.strapQr = '', this.strapCode = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false, this.allowanceAmount = ''});
const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.firstName = '', this.lastName = '', this.bornAt, this.genrer = '', this.relationType = '', this.weight = '', this.height = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false});
@override@JsonKey() final LegacyAddKidStep step;
@override@JsonKey() final String id;
@override@JsonKey() final String parentId;
@override@JsonKey() final String firstName;
@override@JsonKey() final String lastName;
@override final DateTime? bornAt;
@override@JsonKey() final String address;
@override@JsonKey() final String genrer;
@override@JsonKey() final String relationType;
@override@JsonKey() final String strapQr;
@override@JsonKey() final String strapCode;
@override@JsonKey() final String weight;
@override@JsonKey() final String height;
@override@JsonKey() final String watchQr;
@override@JsonKey() final String watchCode;
@override@JsonKey() final bool isLoading;
@override@JsonKey() final String errorMessage;
@override@JsonKey() final bool isSuccess;
@override@JsonKey() final String allowanceAmount;
/// Create a copy of LegacyDeviceSetupViewState
/// with the given fields replaced by the non-null parameter values.
@@ -253,16 +245,16 @@ _$AddKidFlowStateCopyWith<_AddKidFlowState> get copyWith => __$AddKidFlowStateCo
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess));
}
@override
int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount);
int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess);
@override
String toString() {
return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)';
return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)';
}
@@ -273,7 +265,7 @@ abstract mixin class _$AddKidFlowStateCopyWith<$Res> implements $LegacyDeviceSet
factory _$AddKidFlowStateCopyWith(_AddKidFlowState value, $Res Function(_AddKidFlowState) _then) = __$AddKidFlowStateCopyWithImpl;
@override @useResult
$Res call({
LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount
LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess
});
@@ -290,26 +282,22 @@ class __$AddKidFlowStateCopyWithImpl<$Res>
/// Create a copy of LegacyDeviceSetupViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) {
return _then(_AddKidFlowState(
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
as DateTime?,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable
as String,strapCode: null == strapCode ? _self.strapCode : strapCode // ignore: cast_nullable_to_non_nullable
as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable
as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable
as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable
as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable
as String,
as bool,
));
}

View File

@@ -1,11 +1,9 @@
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/intro_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/link_info_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/allowance_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/profile_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/scan_watch_step.dart';
import 'package:flutter/material.dart';
class LegacyStepBody extends StatelessWidget {
@@ -19,14 +17,10 @@ class LegacyStepBody extends StatelessWidget {
return LegacyIntroStepScreen();
case LegacyAddKidStep.linkInfo:
return LegacyLinkInfoStepScreen();
case LegacyAddKidStep.scanStrap:
return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.strap);
case LegacyAddKidStep.scanWatch:
return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.watch);
return LegacyScanWatchStepScreen();
case LegacyAddKidStep.profile:
return LegacyProfileStepScreen();
case LegacyAddKidStep.allowance:
return LegacyAllowanceStepScreen();
}
}
}

View File

@@ -1,40 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
class LegacyAllowanceStepScreen extends ConsumerWidget {
const LegacyAllowanceStepScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
Text(
context.translate(I18n.deviceSetup_addCreditCard_title),
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
Text(
context.translate(I18n.deviceSetup_addCreditCard_subtitle),
style: const TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
Text(
context.translate(I18n.deviceSetup_addCreditCard_info),
style: const TextStyle(fontSize: 14),
textAlign: TextAlign.center,
),
],
),
),
);
}
}

View File

@@ -12,7 +12,7 @@ class LegacyIntroStepScreen extends ConsumerWidget {
final theme = ref.watch(themePortProvider);
return Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
@@ -30,50 +30,9 @@ class LegacyIntroStepScreen extends ConsumerWidget {
steps: [
context.translate(I18n.deviceSetup_intro_step_1),
context.translate(I18n.deviceSetup_intro_step_2),
context.translate(I18n.deviceSetup_intro_step_3),
],
color: theme.getColorFor(ThemeCode.buttonPrimary),
),
SizedBox(height: 40),
Text(
context.translate(I18n.deviceSetup_intro_ready_title),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 40),
Text(
context.translate(I18n.deviceSetup_intro_remember_prefix),
style: TextStyle(fontSize: 16),
),
Text(
context.translate(I18n.deviceSetup_intro_plan_name),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: context.translate(I18n.deviceSetup_intro_web_prefix),
style: TextStyle(fontSize: 16, color: Colors.black),
children: [
TextSpan(
text: context.translate(I18n.deviceSetup_intro_web_link),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black,
decoration: TextDecoration.underline,
),
),
],
),
),
),
],
);
}

View File

@@ -17,7 +17,7 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 65),
child: Text(
context.translate(I18n.deviceSetup_linkInfo_title),
context.translate(I18n.legacy_deviceSetup_linkInfo_title),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
@@ -39,27 +39,23 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget {
children: [
LegacyLinkInfoItem(
number: 1,
boldWord: context.translate(
I18n.deviceSetup_linkInfo_item1_boldWord,
),
boldWord: '',
titlePrefix: context.translate(
I18n.deviceSetup_linkInfo_item1_prefix,
I18n.legacy_deviceSetup_linkInfo_item1_title,
),
subtitle: context.translate(
I18n.deviceSetup_linkInfo_item1_subtitle,
I18n.legacy_deviceSetup_linkInfo_item1_subtitle,
),
),
SizedBox(height: 20),
LegacyLinkInfoItem(
number: 2,
boldWord: context.translate(
I18n.deviceSetup_linkInfo_item2_boldWord,
),
boldWord: '',
titlePrefix: context.translate(
I18n.deviceSetup_linkInfo_item2_prefix,
I18n.legacy_deviceSetup_linkInfo_item2_title,
),
subtitle: context.translate(
I18n.deviceSetup_linkInfo_item2_subtitle,
I18n.legacy_deviceSetup_linkInfo_item2_subtitle,
),
),
],

View File

@@ -4,21 +4,42 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
Future<void> _pickBornAt(
BuildContext context,
DateTime? currentBornAt,
void Function(DateTime) onPicked,
) async {
FocusManager.instance.primaryFocus?.unfocus();
final now = DateTime.now();
final initial = currentBornAt ?? DateTime(now.year - 18, now.month, now.day);
final safeInitial = initial.isAfter(now) ? now : initial;
final picked = await showDatePicker(
context: context,
initialDate: safeInitial,
firstDate: DateTime(1900, 1, 1),
lastDate: now,
);
if (picked != null) onPicked(picked);
}
class LegacyProfileStepScreen extends ConsumerWidget {
const LegacyProfileStepScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
const Map<String, String> genrer = <String, String>{
'F': 'Femenino',
'M': 'Masculino',
'O': 'Otro',
final genrerItems = <String, String>{
'F': context.translate(I18n.genderFemale),
'M': context.translate(I18n.genderMale),
'O': context.translate(I18n.genderOther),
};
const Map<String, String> relationship = <String, String>{
'FATHER': 'Padre',
'MOTHER': 'Madre',
'OTHER': 'Otro',
final relationshipItems = <String, String>{
'FATHER': context.translate(I18n.relationshipFather),
'MOTHER': context.translate(I18n.relationshipMother),
'OTHER': context.translate(I18n.relationshipOther),
};
final state = ref.watch(legacyDeviceSetupViewModelProvider);
@@ -31,14 +52,17 @@ class LegacyProfileStepScreen extends ConsumerWidget {
children: [
const SizedBox(height: 30),
Text(
context.translate(I18n.deviceSetup_intro_step_1),
context.translate(I18n.deviceSetup_intro_step_2),
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
const SizedBox(height: 30),
Text(
context.translate(I18n.deviceSetup_accountData_info),
style: const TextStyle(fontSize: 18),
textAlign: TextAlign.center,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(
context.translate(I18n.legacy_deviceSetup_accountData_info),
style: const TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 20),
Text(
@@ -65,7 +89,7 @@ class LegacyProfileStepScreen extends ConsumerWidget {
const SizedBox(height: 8),
GestureDetector(
onTap: () => vm.pickBornAt(context),
onTap: () => _pickBornAt(context, state.bornAt, vm.setBornAt),
child: AbsorbPointer(
child: CustomTextField(
label: context.translate(I18n.birthDateLabel),
@@ -80,31 +104,43 @@ class LegacyProfileStepScreen extends ConsumerWidget {
const SizedBox(height: 8),
CustomDropdown(
items: genrer.values.map(Text.new).toList(growable: false),
values: genrer.keys.toList(growable: false),
items: genrerItems.values.map(Text.new).toList(growable: false),
values: genrerItems.keys.toList(growable: false),
value: state.genrer.isEmpty ? null : state.genrer,
hint: 'Género',
label: context.translate(I18n.genderLabel),
hint: context.translate(I18n.genderHint),
onChanged: (v) => vm.onGenrerChanged(v as String?),
),
const SizedBox(height: 8),
CustomDropdown(
items: relationship.values
items: relationshipItems.values
.map(Text.new)
.toList(growable: false),
values: relationship.keys.toList(growable: false),
values: relationshipItems.keys.toList(growable: false),
value: state.relationType.isEmpty ? null : state.relationType,
hint: 'Relación',
label: context.translate(I18n.relationshipLabel),
hint: context.translate(I18n.relationshipHint),
onChanged: (v) => vm.onRelationTypeChanged(v as String?),
),
const SizedBox(height: 8),
CustomTextField(
label: 'Dirección',
hint: 'Dirección',
controller: vm.addressController,
label: context.translate(I18n.deviceSetup_weightLabel),
hint: context.translate(I18n.deviceSetup_weightHint),
controller: vm.weightController,
keyboardType: TextInputType.number,
),
const SizedBox(height: 8),
CustomTextField(
label: context.translate(I18n.deviceSetup_heightLabel),
hint: context.translate(I18n.deviceSetup_heightHint),
controller: vm.heightController,
keyboardType: TextInputType.number,
),
const SizedBox(height: 8),

View File

@@ -1,210 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/qr_scanner_screen.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:sf_localizations/sf_localizations.dart';
class LegacyScanStrapAndWatchStepScreen extends ConsumerWidget {
const LegacyScanStrapAndWatchStepScreen({super.key, required this.step});
final LegacyScanLinkStep step;
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final activeColor = theme.getColorFor(ThemeCode.buttonPrimary);
final inactiveCircleColor = theme.getColorFor(
ThemeCode.backgroundSecondary,
);
final inactiveLineColor = Colors.grey.shade200;
final textPrimary = theme.getColorFor(ThemeCode.textPrimary);
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
final state = ref.watch(legacyDeviceSetupViewModelProvider);
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 65),
child: Text(
context.translate(I18n.deviceSetup_linkInfo_title),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
height: 1.2,
),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 18),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100),
child: LegacyScanLinkStepsIndicator(
step: step,
activeColor: activeColor,
inactiveCircleColor: inactiveCircleColor,
inactiveLineColor: inactiveLineColor,
textPrimary: textPrimary,
),
),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 35),
child: Row(
children: [
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: context.translate(
I18n.deviceSetup_linkInfo_item1_prefix,
),
),
TextSpan(
text: context.translate(
I18n.deviceSetup_linkInfo_item1_boldWord,
),
style: TextStyle(fontWeight: FontWeight.w800),
),
],
),
style: const TextStyle(fontSize: 18),
),
),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: context.translate(
I18n.deviceSetup_linkInfo_item2_prefix,
),
),
TextSpan(
text: context.translate(
I18n.deviceSetup_linkInfo_item2_boldWord,
),
style: TextStyle(fontWeight: FontWeight.w800),
),
],
),
style: const TextStyle(fontSize: 18),
),
),
),
],
),
),
const SizedBox(height: 28),
InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () async {
final result = await Navigator.of(context).push<String>(
MaterialPageRoute(builder: (_) => const LegacyQrScannerScreen()),
);
if (result == null || result.isEmpty) return;
vm.onQrScanned(step: step, qr: result);
},
child: Container(
width: 170,
height: 170,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade500, width: 1),
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: SvgPicture.asset(
"assets/shared/images/qr.svg",
width: 90,
height: 90,
fit: BoxFit.contain,
),
),
),
),
const SizedBox(height: 22),
// if (step == LegacyScanLinkStep.watch) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.translate(I18n.deviceSetup_watchCode_orInsert),
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: CustomTextField(
hint: "XXXXXXXXXX",
controller: LegacyScanLinkStep.strap == step
? vm.strapCodeController
: vm.watchCodeController,
// controller: vm.codeController,
),
),
const SizedBox(width: 12),
// Expanded(
// child: PrimaryButton(
// onPressed: () {},
// text: context.translate(
// I18n.deviceSetup_watchCode_continueWithCode,
// ),
// size: 14,
// color: theme.getColorFor(ThemeCode.buttonSecondary),
// ),
// ),
],
),
],
),
),
// ],
const SizedBox(height: 10),
Column(
children: [
Text(
context.translate(I18n.deviceSetup_linkTroubleshoot_title),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18),
),
CustomTextButton(
onPressed: () {},
text: context.translate(I18n.deviceSetup_contactUs),
weight: FontWeight.w800,
size: 18,
),
],
),
],
),
);
}
}

View File

@@ -0,0 +1,113 @@
import 'package:legacy_auth/src/features/device_setup/presentation/qr_scanner_screen.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:sf_localizations/sf_localizations.dart';
class LegacyScanWatchStepScreen extends ConsumerWidget {
const LegacyScanWatchStepScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 65),
child: Text(
context.translate(I18n.legacy_deviceSetup_scanWatch_title),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
height: 1.2,
),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 28),
InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () async {
final result = await Navigator.of(context).push<String>(
MaterialPageRoute(builder: (_) => const LegacyQrScannerScreen()),
);
if (result == null || result.isEmpty) return;
vm.onWatchQrScanned(result);
},
child: Container(
width: 170,
height: 170,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade500, width: 1),
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: SvgPicture.asset(
"assets/shared/images/qr.svg",
width: 90,
height: 90,
fit: BoxFit.contain,
),
),
),
),
const SizedBox(height: 22),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.translate(I18n.deviceSetup_watchCode_orInsert),
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: CustomTextField(
hint: "XXXXXXXXXX",
controller: vm.watchCodeController,
),
),
const SizedBox(width: 12),
],
),
],
),
),
const SizedBox(height: 10),
Column(
children: [
Text(
context.translate(I18n.legacy_deviceSetup_linkTroubleshoot_title),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18),
),
CustomTextButton(
onPressed: () {},
text: context.translate(I18n.deviceSetup_contactUs),
weight: FontWeight.w800,
size: 18,
),
],
),
],
),
);
}
}

View File

@@ -1,66 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
class LegacySuccessStepScreen extends ConsumerWidget {
const LegacySuccessStepScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final state = ref.watch(legacyDeviceSetupViewModelProvider);
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
return Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.check,
color: theme.getColorFor(ThemeCode.buttonPrimary),
size: 50,
),
const SizedBox(height: 20),
Text(
context.translate(I18n.accountCreatedTitle),
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
const SizedBox(height: 30),
Text(
context.translate(I18n.accountCreatedForLabel),
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
Text(
'${state.firstName} ${state.lastName}',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
SizedBox(height: 40),
Text(
'Reloj: ${state.watchCode}',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16),
),
Text(
'ID de la tarjeta: ${state.strapCode} ',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16),
),
SizedBox(height: 40),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
context.translate(I18n.deviceSetup_firstAllowance_title),
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
],
);
}
}

View File

@@ -1,5 +1,4 @@
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/steps/success_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_footer.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
@@ -12,6 +11,7 @@ class LegacySuccessScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
final state = ref.watch(legacyDeviceSetupViewModelProvider);
final theme = ref.watch(themePortProvider);
return Scaffold(
@@ -20,13 +20,44 @@ class LegacySuccessScreen extends ConsumerWidget {
child: Column(
children: [
const SizedBox(height: 20),
Expanded(child: LegacySuccessStepScreen()),
LegacyFlowFooter(
primaryText: context.translate(
I18n.deviceSetup_giveFirstAllowance,
Expanded(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.check,
color: theme.getColorFor(ThemeCode.buttonPrimary),
size: 50,
),
const SizedBox(height: 20),
Text(
context.translate(I18n.accountCreatedTitle),
style: const TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 30),
Text(
context.translate(I18n.accountCreatedForLabel),
style: const TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
Text(
'${state.firstName} ${state.lastName}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
],
),
),
LegacyFlowFooter(
primaryText: context.translate(I18n.continueKey),
onPrimary: () {
vm.goToAllowance();
Navigator.of(context).pop();
},
secondaryText: context.translate(I18n.deviceSetup_addAnotherKid),

View File

@@ -9,7 +9,6 @@ class LegacyFlowFooter extends StatelessWidget {
required this.theme,
this.secondaryText,
this.onSecondary,
this.error,
});
final String primaryText;
@@ -19,8 +18,6 @@ class LegacyFlowFooter extends StatelessWidget {
final String? secondaryText;
final VoidCallback? onSecondary;
final String? error;
@override
Widget build(BuildContext context) {
return Container(
@@ -30,18 +27,10 @@ class LegacyFlowFooter extends StatelessWidget {
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 10),
padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (error != null) ...[
Text(
error!,
style: const TextStyle(color: Colors.red, fontSize: 13),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
],
PrimaryButton(
text: primaryText,
onPressed: onPrimary,

View File

@@ -17,6 +17,8 @@ class LegacyLinkInfoItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textColor = Theme.of(context).colorScheme.onSurfaceVariant;
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -32,18 +34,18 @@ class LegacyLinkInfoItem extends StatelessWidget {
children: [
TextSpan(
text: titlePrefix,
style: const TextStyle(
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Color(0xFF4B4B4B),
color: textColor,
),
),
TextSpan(
text: boldWord,
style: const TextStyle(
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w800,
color: Color(0xFF4B4B4B),
color: textColor,
),
),
],

View File

@@ -1,9 +1,16 @@
import 'package:flutter/material.dart';
class LegacyNumberCircle extends StatelessWidget {
const LegacyNumberCircle({super.key, required this.number});
const LegacyNumberCircle({
super.key,
required this.number,
this.backgroundColor,
this.textColor,
});
final int number;
final Color? backgroundColor;
final Color? textColor;
@override
Widget build(BuildContext context) {
@@ -11,16 +18,16 @@ class LegacyNumberCircle extends StatelessWidget {
width: 48,
height: 48,
alignment: Alignment.center,
decoration: const BoxDecoration(
color: Color(0xFFF2F2F2),
decoration: BoxDecoration(
color: backgroundColor ?? Theme.of(context).colorScheme.surfaceContainerHighest,
shape: BoxShape.circle,
),
child: Text(
number.toString(),
style: const TextStyle(
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w700,
color: Color(0xFF5A5A5A),
color: textColor ?? Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);

View File

@@ -16,7 +16,6 @@ class LegacyNumberedSteps extends StatelessWidget {
final TextStyle? textStyle;
@override
@override
Widget build(BuildContext context) {
final Color resolvedColor =
@@ -44,10 +43,22 @@ class LegacyNumberedSteps extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_LegacyStepCircle(
number: index + 1,
size: 32,
color: resolvedColor,
Container(
width: 32,
height: 32,
alignment: Alignment.center,
decoration: BoxDecoration(
color: resolvedColor,
shape: BoxShape.circle,
),
child: Text(
'${index + 1}',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 32 * 0.55,
),
),
),
if (!isLast)
Container(
@@ -72,33 +83,3 @@ class LegacyNumberedSteps extends StatelessWidget {
);
}
}
class _LegacyStepCircle extends StatelessWidget {
const _LegacyStepCircle({
required this.number,
required this.size,
required this.color,
});
final int number;
final double size;
final Color color;
@override
Widget build(BuildContext context) {
return Container(
width: size,
height: size,
alignment: Alignment.center,
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
child: Text(
'$number',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: size * 0.55,
),
),
);
}
}

View File

@@ -1,60 +0,0 @@
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/step_circle.dart';
import 'package:flutter/material.dart';
class LegacyScanLinkStepsIndicator extends StatelessWidget {
const LegacyScanLinkStepsIndicator({
super.key,
required this.step,
required this.activeColor,
required this.inactiveCircleColor,
required this.inactiveLineColor,
required this.textPrimary,
});
final LegacyScanLinkStep step;
final Color activeColor;
final Color inactiveCircleColor;
final Color inactiveLineColor;
final Color textPrimary;
bool get isWatch => step == LegacyScanLinkStep.watch;
@override
Widget build(BuildContext context) {
const circleSize = 48.0;
const lineHeight = 4.0;
return Row(
children: [
LegacyStepCircle(
label: "1",
size: circleSize,
background: activeColor,
textColor: Colors.white,
),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.circular(99),
child: SizedBox(
height: lineHeight,
child: Row(
children: [
Expanded(child: Container(color: activeColor)),
if (!isWatch)
Expanded(child: Container(color: inactiveLineColor)),
],
),
),
),
),
LegacyStepCircle(
label: "2",
size: circleSize,
background: isWatch ? activeColor : inactiveCircleColor,
textColor: isWatch ? Colors.white : textPrimary,
),
],
);
}
}

Some files were not shown because too many files have changed in this diff Show More