linked devices state and models fix
This commit is contained in:
@@ -22,6 +22,15 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/build" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
|
||||
@@ -5,4 +5,4 @@ export 'src/features/personal_data/personal_data_builder.dart';
|
||||
export 'src/features/change_password/change_password_builder.dart';
|
||||
export 'src/features/linked_devices/linked_devices_builder.dart';
|
||||
export 'src/features/app_users/app_users_builder.dart';
|
||||
export 'src/features/delete_account/delete_account_builder.dart';
|
||||
export 'src/features/delete_account/delete_account_builder.dart';
|
||||
@@ -1,14 +1,7 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class AccountRemoteDatasource {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request});
|
||||
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
|
||||
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
|
||||
@@ -1,68 +1,17 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
|
||||
import 'package:account/src/core/data/models/get_app_users_response_model.dart';
|
||||
import 'package:account/src/core/data/models/update_device_request_model.dart';
|
||||
import 'package:account/src/core/data/models/update_user_request_model.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../models/get_linked_devices_response_model.dart';
|
||||
|
||||
class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
|
||||
AccountRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({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');
|
||||
}
|
||||
|
||||
final model = GetLinkedDevicesResponseModel.fromJson(data);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
|
||||
throw UnimplementedError();
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) async {
|
||||
try {
|
||||
@@ -72,7 +21,7 @@ class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update user');
|
||||
throw mapDioError(error, defaultMessage: 'Error to update user');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +71,7 @@ class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
|
||||
]);*/
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
throw mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
@@ -137,42 +86,7 @@ class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
|
||||
'/users/$userId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
throw mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class DevicesRemoteDatasource {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:account/src/core/data/models/update_device_request_model.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import 'devices_remote_datasource.dart';
|
||||
|
||||
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||
DevicesRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
try {
|
||||
await _repository.delete<void>(
|
||||
'/devices/$deviceId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/devices',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to update device');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
part 'get_linked_devices_response_model.freezed.dart';
|
||||
part 'get_linked_devices_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesResponseModel with _$GetLinkedDevicesResponseModel {
|
||||
const factory GetLinkedDevicesResponseModel({
|
||||
required List<GetLinkedDevicesItemResponseModel> items,
|
||||
}) = _GetLinkedDevicesResponseModel;
|
||||
|
||||
factory GetLinkedDevicesResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesItemResponseModel with _$GetLinkedDevicesItemResponseModel {
|
||||
const factory GetLinkedDevicesItemResponseModel({
|
||||
required String identificator,
|
||||
required String carrierName,
|
||||
required String phone,
|
||||
required String id,
|
||||
@Default({}) Map<String, dynamic> settings,
|
||||
required String protocol,
|
||||
required String type,
|
||||
required String connectionServer,
|
||||
required String createdAt,
|
||||
@Default({}) Map<String, dynamic> flags,
|
||||
}) =
|
||||
_GetLinkedDevicesItemResponseModel;
|
||||
|
||||
factory GetLinkedDevicesItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetDevicesResponseModelMapper on GetLinkedDevicesResponseModel {
|
||||
List<DeviceEntity> toEntity() {
|
||||
return items.map((GetLinkedDevicesItemResponseModel item) => DeviceEntity(
|
||||
identificator: item.identificator,
|
||||
carrierName: item.carrierName,
|
||||
phone: item.phone,
|
||||
id: item.id,
|
||||
settings: item.settings,
|
||||
protocol: item.protocol,
|
||||
type: item.type,
|
||||
connectionServer: item.connectionServer,
|
||||
createdAt: item.createdAt,
|
||||
flags: item.flags,
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesSettingsResponseModel with _$GetLinkedDevicesSettingsResponseModel {
|
||||
const factory GetLinkedDevicesSettingsResponseModel({
|
||||
required int frequency,
|
||||
required int frequencyHeartRate,
|
||||
required int timezone,
|
||||
required bool pedometer,
|
||||
required String language,
|
||||
required List<String> alerts,
|
||||
}) = _GetLinkedDevicesSettingsResponseModel;
|
||||
|
||||
factory GetLinkedDevicesSettingsResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesSettingsResponseModelFromJson(json);
|
||||
}
|
||||
@@ -1,869 +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_linked_devices_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesResponseModel {
|
||||
|
||||
List<GetLinkedDevicesItemResponseModel> get items;
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesResponseModelCopyWith<GetLinkedDevicesResponseModel> get copyWith => _$GetLinkedDevicesResponseModelCopyWithImpl<GetLinkedDevicesResponseModel>(this as GetLinkedDevicesResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesResponseModel&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesResponseModelCopyWith(GetLinkedDevicesResponseModel value, $Res Function(GetLinkedDevicesResponseModel) _then) = _$GetLinkedDevicesResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GetLinkedDevicesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetLinkedDevicesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesResponseModel].
|
||||
extension GetLinkedDevicesResponseModelPatterns on GetLinkedDevicesResponseModel {
|
||||
/// 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( _GetLinkedDevicesResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() 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( _GetLinkedDevicesResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel():
|
||||
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( _GetLinkedDevicesResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() 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( List<GetLinkedDevicesItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() when $default != null:
|
||||
return $default(_that.items);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( List<GetLinkedDevicesItemResponseModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel():
|
||||
return $default(_that.items);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( List<GetLinkedDevicesItemResponseModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesResponseModel implements GetLinkedDevicesResponseModel {
|
||||
const _GetLinkedDevicesResponseModel({required final List<GetLinkedDevicesItemResponseModel> items}): _items = items;
|
||||
factory _GetLinkedDevicesResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesResponseModelFromJson(json);
|
||||
|
||||
final List<GetLinkedDevicesItemResponseModel> _items;
|
||||
@override List<GetLinkedDevicesItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesResponseModelCopyWith<_GetLinkedDevicesResponseModel> get copyWith => __$GetLinkedDevicesResponseModelCopyWithImpl<_GetLinkedDevicesResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesResponseModel&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesResponseModelCopyWith<$Res> implements $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesResponseModelCopyWith(_GetLinkedDevicesResponseModel value, $Res Function(_GetLinkedDevicesResponseModel) _then) = __$GetLinkedDevicesResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<GetLinkedDevicesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,}) {
|
||||
return _then(_GetLinkedDevicesResponseModel(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetLinkedDevicesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesItemResponseModel {
|
||||
|
||||
String get identificator; String get carrierName; String get phone; String get id; Map<String, dynamic> get settings; String get protocol; String get type; String get connectionServer; String get createdAt; Map<String, dynamic> get flags;
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesItemResponseModelCopyWith<GetLinkedDevicesItemResponseModel> get copyWith => _$GetLinkedDevicesItemResponseModelCopyWithImpl<GetLinkedDevicesItemResponseModel>(this as GetLinkedDevicesItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesItemResponseModel&&(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)&&const DeepCollectionEquality().equals(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)&&const DeepCollectionEquality().equals(other.flags, flags));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,const DeepCollectionEquality().hash(settings),protocol,type,connectionServer,createdAt,const DeepCollectionEquality().hash(flags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesItemResponseModelCopyWith(GetLinkedDevicesItemResponseModel value, $Res Function(GetLinkedDevicesItemResponseModel) _then) = _$GetLinkedDevicesItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesItemResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// 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,}) {
|
||||
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 Map<String, dynamic>,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 String,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesItemResponseModel].
|
||||
extension GetLinkedDevicesItemResponseModelPatterns on GetLinkedDevicesItemResponseModel {
|
||||
/// 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( _GetLinkedDevicesItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() 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( _GetLinkedDevicesItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel():
|
||||
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( _GetLinkedDevicesItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() 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 identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() 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 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 identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel():
|
||||
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);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 identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() 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 null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesItemResponseModel implements GetLinkedDevicesItemResponseModel {
|
||||
const _GetLinkedDevicesItemResponseModel({required this.identificator, required this.carrierName, required this.phone, required this.id, final Map<String, dynamic> settings = const {}, required this.protocol, required this.type, required this.connectionServer, required this.createdAt, final Map<String, dynamic> flags = const {}}): _settings = settings,_flags = flags;
|
||||
factory _GetLinkedDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesItemResponseModelFromJson(json);
|
||||
|
||||
@override final String identificator;
|
||||
@override final String carrierName;
|
||||
@override final String phone;
|
||||
@override final String id;
|
||||
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);
|
||||
}
|
||||
|
||||
@override final String protocol;
|
||||
@override final String type;
|
||||
@override final String connectionServer;
|
||||
@override final String createdAt;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesItemResponseModelCopyWith<_GetLinkedDevicesItemResponseModel> get copyWith => __$GetLinkedDevicesItemResponseModelCopyWithImpl<_GetLinkedDevicesItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesItemResponseModel&&(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)&&const DeepCollectionEquality().equals(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)&&const DeepCollectionEquality().equals(other._flags, _flags));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,const DeepCollectionEquality().hash(_settings),protocol,type,connectionServer,createdAt,const DeepCollectionEquality().hash(_flags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesItemResponseModelCopyWith<$Res> implements $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesItemResponseModelCopyWith(_GetLinkedDevicesItemResponseModel value, $Res Function(_GetLinkedDevicesItemResponseModel) _then) = __$GetLinkedDevicesItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesItemResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// 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,}) {
|
||||
return _then(_GetLinkedDevicesItemResponseModel(
|
||||
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 Map<String, dynamic>,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 String,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesSettingsResponseModel {
|
||||
|
||||
int get frequency; int get frequencyHeartRate; int get timezone; bool get pedometer; String get language; List<String> get alerts;
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesSettingsResponseModelCopyWith<GetLinkedDevicesSettingsResponseModel> get copyWith => _$GetLinkedDevicesSettingsResponseModelCopyWithImpl<GetLinkedDevicesSettingsResponseModel>(this as GetLinkedDevicesSettingsResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesSettingsResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesSettingsResponseModel&&(identical(other.frequency, frequency) || other.frequency == frequency)&&(identical(other.frequencyHeartRate, frequencyHeartRate) || other.frequencyHeartRate == frequencyHeartRate)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.pedometer, pedometer) || other.pedometer == pedometer)&&(identical(other.language, language) || other.language == language)&&const DeepCollectionEquality().equals(other.alerts, alerts));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,frequency,frequencyHeartRate,timezone,pedometer,language,const DeepCollectionEquality().hash(alerts));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesSettingsResponseModel(frequency: $frequency, frequencyHeartRate: $frequencyHeartRate, timezone: $timezone, pedometer: $pedometer, language: $language, alerts: $alerts)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesSettingsResponseModelCopyWith(GetLinkedDevicesSettingsResponseModel value, $Res Function(GetLinkedDevicesSettingsResponseModel) _then) = _$GetLinkedDevicesSettingsResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesSettingsResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesSettingsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesSettingsResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesSettingsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? frequency = null,Object? frequencyHeartRate = null,Object? timezone = null,Object? pedometer = null,Object? language = null,Object? alerts = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
frequency: null == frequency ? _self.frequency : frequency // ignore: cast_nullable_to_non_nullable
|
||||
as int,frequencyHeartRate: null == frequencyHeartRate ? _self.frequencyHeartRate : frequencyHeartRate // ignore: cast_nullable_to_non_nullable
|
||||
as int,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable
|
||||
as int,pedometer: null == pedometer ? _self.pedometer : pedometer // ignore: cast_nullable_to_non_nullable
|
||||
as bool,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,alerts: null == alerts ? _self.alerts : alerts // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesSettingsResponseModel].
|
||||
extension GetLinkedDevicesSettingsResponseModelPatterns on GetLinkedDevicesSettingsResponseModel {
|
||||
/// 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( _GetLinkedDevicesSettingsResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() 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( _GetLinkedDevicesSettingsResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel():
|
||||
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( _GetLinkedDevicesSettingsResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() 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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() when $default != null:
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel():
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() when $default != null:
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesSettingsResponseModel implements GetLinkedDevicesSettingsResponseModel {
|
||||
const _GetLinkedDevicesSettingsResponseModel({required this.frequency, required this.frequencyHeartRate, required this.timezone, required this.pedometer, required this.language, required final List<String> alerts}): _alerts = alerts;
|
||||
factory _GetLinkedDevicesSettingsResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesSettingsResponseModelFromJson(json);
|
||||
|
||||
@override final int frequency;
|
||||
@override final int frequencyHeartRate;
|
||||
@override final int timezone;
|
||||
@override final bool pedometer;
|
||||
@override final String language;
|
||||
final List<String> _alerts;
|
||||
@override List<String> get alerts {
|
||||
if (_alerts is EqualUnmodifiableListView) return _alerts;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_alerts);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesSettingsResponseModelCopyWith<_GetLinkedDevicesSettingsResponseModel> get copyWith => __$GetLinkedDevicesSettingsResponseModelCopyWithImpl<_GetLinkedDevicesSettingsResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesSettingsResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesSettingsResponseModel&&(identical(other.frequency, frequency) || other.frequency == frequency)&&(identical(other.frequencyHeartRate, frequencyHeartRate) || other.frequencyHeartRate == frequencyHeartRate)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.pedometer, pedometer) || other.pedometer == pedometer)&&(identical(other.language, language) || other.language == language)&&const DeepCollectionEquality().equals(other._alerts, _alerts));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,frequency,frequencyHeartRate,timezone,pedometer,language,const DeepCollectionEquality().hash(_alerts));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesSettingsResponseModel(frequency: $frequency, frequencyHeartRate: $frequencyHeartRate, timezone: $timezone, pedometer: $pedometer, language: $language, alerts: $alerts)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesSettingsResponseModelCopyWith<$Res> implements $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesSettingsResponseModelCopyWith(_GetLinkedDevicesSettingsResponseModel value, $Res Function(_GetLinkedDevicesSettingsResponseModel) _then) = __$GetLinkedDevicesSettingsResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesSettingsResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesSettingsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesSettingsResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesSettingsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? frequency = null,Object? frequencyHeartRate = null,Object? timezone = null,Object? pedometer = null,Object? language = null,Object? alerts = null,}) {
|
||||
return _then(_GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: null == frequency ? _self.frequency : frequency // ignore: cast_nullable_to_non_nullable
|
||||
as int,frequencyHeartRate: null == frequencyHeartRate ? _self.frequencyHeartRate : frequencyHeartRate // ignore: cast_nullable_to_non_nullable
|
||||
as int,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable
|
||||
as int,pedometer: null == pedometer ? _self.pedometer : pedometer // ignore: cast_nullable_to_non_nullable
|
||||
as bool,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,alerts: null == alerts ? _self._alerts : alerts // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -1,77 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_linked_devices_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetLinkedDevicesResponseModel _$GetLinkedDevicesResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLinkedDevicesResponseModel(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetLinkedDevicesItemResponseModel.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesResponseModelToJson(
|
||||
_GetLinkedDevicesResponseModel instance,
|
||||
) => <String, dynamic>{'items': instance.items};
|
||||
|
||||
_GetLinkedDevicesItemResponseModel _$GetLinkedDevicesItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLinkedDevicesItemResponseModel(
|
||||
identificator: json['identificator'] as String,
|
||||
carrierName: json['carrierName'] as String,
|
||||
phone: json['phone'] as String,
|
||||
id: json['id'] as String,
|
||||
settings: json['settings'] as Map<String, dynamic>? ?? const {},
|
||||
protocol: json['protocol'] as String,
|
||||
type: json['type'] as String,
|
||||
connectionServer: json['connectionServer'] as String,
|
||||
createdAt: json['createdAt'] as String,
|
||||
flags: json['flags'] as Map<String, dynamic>? ?? const {},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesItemResponseModelToJson(
|
||||
_GetLinkedDevicesItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'identificator': instance.identificator,
|
||||
'carrierName': instance.carrierName,
|
||||
'phone': instance.phone,
|
||||
'id': instance.id,
|
||||
'settings': instance.settings,
|
||||
'protocol': instance.protocol,
|
||||
'type': instance.type,
|
||||
'connectionServer': instance.connectionServer,
|
||||
'createdAt': instance.createdAt,
|
||||
'flags': instance.flags,
|
||||
};
|
||||
|
||||
_GetLinkedDevicesSettingsResponseModel
|
||||
_$GetLinkedDevicesSettingsResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: (json['frequency'] as num).toInt(),
|
||||
frequencyHeartRate: (json['frequencyHeartRate'] as num).toInt(),
|
||||
timezone: (json['timezone'] as num).toInt(),
|
||||
pedometer: json['pedometer'] as bool,
|
||||
language: json['language'] as String,
|
||||
alerts: (json['alerts'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesSettingsResponseModelToJson(
|
||||
_GetLinkedDevicesSettingsResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'frequency': instance.frequency,
|
||||
'frequencyHeartRate': instance.frequencyHeartRate,
|
||||
'timezone': instance.timezone,
|
||||
'pedometer': instance.pedometer,
|
||||
'language': instance.language,
|
||||
'alerts': instance.alerts,
|
||||
};
|
||||
@@ -8,7 +8,7 @@ part 'update_device_request_model.g.dart';
|
||||
abstract class UpdateDeviceRequestModel with _$UpdateDeviceRequestModel {
|
||||
const factory UpdateDeviceRequestModel({
|
||||
required String identificator,
|
||||
required String name,
|
||||
required String carrierName,
|
||||
}) = _UpdateDeviceRequestModel;
|
||||
|
||||
factory UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -18,6 +18,6 @@ abstract class UpdateDeviceRequestModel with _$UpdateDeviceRequestModel {
|
||||
extension UpdateDeviceRequestModelMapper on UpdateDeviceRequestEntity {
|
||||
UpdateDeviceRequestModel toModel() => UpdateDeviceRequestModel(
|
||||
identificator: identificator,
|
||||
name: name,
|
||||
carrierName: carrierName,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UpdateDeviceRequestModel {
|
||||
|
||||
String get identificator; String get name;
|
||||
String get identificator; String get carrierName;
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -28,16 +28,16 @@ $UpdateDeviceRequestModelCopyWith<UpdateDeviceRequestModel> get copyWith => _$Up
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, carrierName: $carrierName)';
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ abstract mixin class $UpdateDeviceRequestModelCopyWith<$Res> {
|
||||
factory $UpdateDeviceRequestModelCopyWith(UpdateDeviceRequestModel value, $Res Function(UpdateDeviceRequestModel) _then) = _$UpdateDeviceRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
String identificator, String carrierName
|
||||
});
|
||||
|
||||
|
||||
@@ -65,10 +65,10 @@ class _$UpdateDeviceRequestModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
@@ -154,10 +154,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -175,10 +175,10 @@ return $default(_that.identificator,_that.name);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel():
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -195,10 +195,10 @@ return $default(_that.identificator,_that.name);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -210,11 +210,11 @@ return $default(_that.identificator,_that.name);case _:
|
||||
@JsonSerializable()
|
||||
|
||||
class _UpdateDeviceRequestModel implements UpdateDeviceRequestModel {
|
||||
const _UpdateDeviceRequestModel({required this.identificator, required this.name});
|
||||
const _UpdateDeviceRequestModel({required this.identificator, required this.carrierName});
|
||||
factory _UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateDeviceRequestModelFromJson(json);
|
||||
|
||||
@override final String identificator;
|
||||
@override final String name;
|
||||
@override final String carrierName;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -229,16 +229,16 @@ Map<String, dynamic> toJson() {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, carrierName: $carrierName)';
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ abstract mixin class _$UpdateDeviceRequestModelCopyWith<$Res> implements $Update
|
||||
factory _$UpdateDeviceRequestModelCopyWith(_UpdateDeviceRequestModel value, $Res Function(_UpdateDeviceRequestModel) _then) = __$UpdateDeviceRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
String identificator, String carrierName
|
||||
});
|
||||
|
||||
|
||||
@@ -266,10 +266,10 @@ class __$UpdateDeviceRequestModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,}) {
|
||||
return _then(_UpdateDeviceRequestModel(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ _UpdateDeviceRequestModel _$UpdateDeviceRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateDeviceRequestModel(
|
||||
identificator: json['identificator'] as String,
|
||||
name: json['name'] as String,
|
||||
carrierName: json['carrierName'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateDeviceRequestModelToJson(
|
||||
_UpdateDeviceRequestModel instance,
|
||||
) => <String, dynamic>{
|
||||
'identificator': instance.identificator,
|
||||
'name': instance.name,
|
||||
'carrierName': instance.carrierName,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
@@ -9,21 +8,6 @@ class AccountRepositoryImpl implements AccountRepository {
|
||||
|
||||
final AccountRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _remote.getLinkedDevices(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) {
|
||||
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) {
|
||||
return _remote.updateDevice(userId: userId, deviceId: deviceId, request: request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
|
||||
return _remote.updateUser(userId: userId, request: request);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:account/src/core/data/datasource/devices_remote_datasource.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
import '../../domain/repositories/devices_repository.dart';
|
||||
|
||||
class DevicesRepositoryImpl implements DevicesRepository {
|
||||
const DevicesRepositoryImpl(this._remote);
|
||||
|
||||
final DevicesRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) {
|
||||
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) {
|
||||
return _remote.updateDevice(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,7 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class AccountRepository {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({
|
||||
required String userId,
|
||||
required String deviceId,
|
||||
required UpdateDeviceRequestEntity request
|
||||
});
|
||||
|
||||
Future<void> updateUser({
|
||||
required String userId,
|
||||
required UpdateUserRequestEntity request
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class DevicesRepository {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({
|
||||
required String userId,
|
||||
required UpdateDeviceRequestEntity request
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasource/devices_remote_datasource.dart';
|
||||
import '../data/datasource/devices_remote_datasource_impl.dart';
|
||||
|
||||
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return DevicesRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../data/repositories/devices_repository_impl.dart';
|
||||
import '../domain/repositories/devices_repository.dart';
|
||||
import 'devices_remote_datasource_provider.dart';
|
||||
|
||||
final devicesRepositoryProvider = Provider<DevicesRepository>((ref) {
|
||||
final remote = ref.read(devicesRemoteDatasourceProvider);
|
||||
return DevicesRepositoryImpl(remote);
|
||||
});
|
||||
@@ -1,15 +1,11 @@
|
||||
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
|
||||
import 'package:account/src/features/delete_account/presentation/providers/delete_account_use_case_provider.dart';
|
||||
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/get_linked_devices_use_case_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final deleteAccountViewModelProvider =
|
||||
NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
||||
DeleteAccountViewModel.new,
|
||||
@@ -17,13 +13,13 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
||||
|
||||
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
late final DeleteAccountUseCase _deleteAccountUseCase;
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final SharedDevicesRepository _devicesRepository;
|
||||
late final TextEditingController passwordController;
|
||||
|
||||
@override
|
||||
DeleteAccountViewState build() {
|
||||
_deleteAccountUseCase = ref.read(deleteAccountUseCaseProvider);
|
||||
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
|
||||
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
|
||||
passwordController = TextEditingController();
|
||||
passwordController.addListener(_onPasswordChanged);
|
||||
@@ -39,7 +35,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
setUser(user);
|
||||
|
||||
final devices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
final devices = await _devicesRepository.getDevices();
|
||||
setDevices(devices);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
abstract class DeleteDeviceUseCase {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
|
||||
class DeleteDeviceUseCaseImpl implements DeleteDeviceUseCase {
|
||||
DeleteDeviceUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
return _repository.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,6 @@ part 'update_device_request_entity.freezed.dart';
|
||||
abstract class UpdateDeviceRequestEntity with _$UpdateDeviceRequestEntity {
|
||||
const factory UpdateDeviceRequestEntity({
|
||||
required String identificator,
|
||||
required String name,
|
||||
required String carrierName,
|
||||
}) = _UpdateDeviceRequestEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UpdateDeviceRequestEntity {
|
||||
|
||||
String get identificator; String get name;
|
||||
String get identificator; String get carrierName;
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $UpdateDeviceRequestEntityCopyWith<UpdateDeviceRequestEntity> get copyWith => _$
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, carrierName: $carrierName)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $UpdateDeviceRequestEntityCopyWith<$Res> {
|
||||
factory $UpdateDeviceRequestEntityCopyWith(UpdateDeviceRequestEntity value, $Res Function(UpdateDeviceRequestEntity) _then) = _$UpdateDeviceRequestEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
String identificator, String carrierName
|
||||
});
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ class _$UpdateDeviceRequestEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
@@ -151,10 +151,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -172,10 +172,10 @@ return $default(_that.identificator,_that.name);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity():
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -192,10 +192,10 @@ return $default(_that.identificator,_that.name);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return $default(_that.identificator,_that.carrierName);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -207,11 +207,11 @@ return $default(_that.identificator,_that.name);case _:
|
||||
|
||||
|
||||
class _UpdateDeviceRequestEntity implements UpdateDeviceRequestEntity {
|
||||
const _UpdateDeviceRequestEntity({required this.identificator, required this.name});
|
||||
const _UpdateDeviceRequestEntity({required this.identificator, required this.carrierName});
|
||||
|
||||
|
||||
@override final String identificator;
|
||||
@override final String name;
|
||||
@override final String carrierName;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -223,16 +223,16 @@ _$UpdateDeviceRequestEntityCopyWith<_UpdateDeviceRequestEntity> get copyWith =>
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, carrierName: $carrierName)';
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ abstract mixin class _$UpdateDeviceRequestEntityCopyWith<$Res> implements $Updat
|
||||
factory _$UpdateDeviceRequestEntityCopyWith(_UpdateDeviceRequestEntity value, $Res Function(_UpdateDeviceRequestEntity) _then) = __$UpdateDeviceRequestEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
String identificator, String carrierName
|
||||
});
|
||||
|
||||
|
||||
@@ -260,10 +260,10 @@ class __$UpdateDeviceRequestEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,}) {
|
||||
return _then(_UpdateDeviceRequestEntity(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class GetLinkedDevicesUseCase {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
class GetLinkedDevicesUseCaseImpl implements GetLinkedDevicesUseCase {
|
||||
GetLinkedDevicesUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _repository.getLinkedDevices(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class UpdateDeviceUseCase {
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request});
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
// import 'package:account/src/features/linked_devices/domain/entities/device_entity.dart';
|
||||
// import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
|
||||
class UpdateDeviceUseCaseImpl implements UpdateDeviceUseCase {
|
||||
UpdateDeviceUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
|
||||
return _repository.updateDevice(userId: userId, deviceId: deviceId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -3,54 +3,30 @@ 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:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class EditLinkedDeviceScreen extends ConsumerWidget {
|
||||
//final NavigationContract navigationContract;
|
||||
final DeviceEntity device;
|
||||
|
||||
const EditLinkedDeviceScreen({super.key, required this.device /*required this.navigationContract*/});
|
||||
const EditLinkedDeviceScreen();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
// final state = ref.watch(linkedDevicesViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return /*LegacyPageLayout(
|
||||
theme: theme,
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
final device = ref.watch(
|
||||
linkedDevicesViewModelProvider.select((s)=>s.selectedDevice)
|
||||
);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.editDeviceTitle),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: body
|
||||
);*/
|
||||
Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
IconButton(onPressed: () {Navigator.pop(context);},
|
||||
icon: Icon(Icons.arrow_back)),
|
||||
Center(
|
||||
child: Text(context.translate(I18n.editDeviceTitle),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 28, big: 27)
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
Expanded(child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
@@ -65,6 +41,7 @@ theme: theme,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
DecoratedBox(decoration: BoxDecoration(color: Colors.blueAccent)),
|
||||
Center(child: SvgPicture.asset('assets/images/ui/profile.svg')),
|
||||
Center(child: SizedBox(
|
||||
width: 160,
|
||||
@@ -92,22 +69,53 @@ theme: theme,
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.deviceNameController,
|
||||
hint: device.carrierName!,
|
||||
hint: device!.carrierName!,
|
||||
label: context.translate(I18n.name),
|
||||
)
|
||||
],
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: (){vm.updateDevice(device);},
|
||||
text: context.translate(I18n.save),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
)
|
||||
],
|
||||
))
|
||||
),
|
||||
],
|
||||
),
|
||||
footer: _SaveSection(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SaveSection extends ConsumerWidget{
|
||||
|
||||
const _SaveSection();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10),
|
||||
child:
|
||||
PrimaryButton(
|
||||
onPressed: () async {
|
||||
await vm.updateDevice();
|
||||
|
||||
final errorMessage = ref.read(
|
||||
linkedDevicesViewModelProvider.select((s) => s.errorMessage)
|
||||
);
|
||||
|
||||
if (errorMessage.isNotEmpty) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: errorMessage,
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
},
|
||||
text: context.translate(I18n.save),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:account/src/features/linked_devices/presentation/edit_linked_device_screen.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_model.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/widgets/delete_device_dialog.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@@ -22,38 +23,32 @@ class LinkedDevicesScreen extends ConsumerWidget {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
theme: theme,
|
||||
title: context.translate(I18n.linkedDevices),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
body: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
|
||||
device: state.linkedDevices[index],
|
||||
isEditing: state.isEditing,
|
||||
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
|
||||
),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>LinkedDeviceCard(
|
||||
device: state.linkedDevices[index],
|
||||
isEditing: state.isEditing,
|
||||
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
|
||||
),
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.linkedDevices.length
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.linkedDevices.length
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LinkedDeviceCard extends ConsumerWidget {
|
||||
class _LinkedDeviceCard extends ConsumerWidget {
|
||||
|
||||
final DeviceEntity device;
|
||||
final bool isEditing;
|
||||
final Function onDelete;
|
||||
|
||||
const LinkedDeviceCard({
|
||||
const _LinkedDeviceCard({
|
||||
required this.device,
|
||||
required this.isEditing,
|
||||
required this.onDelete,
|
||||
@@ -63,6 +58,8 @@ class LinkedDeviceCard extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
@@ -113,46 +110,7 @@ class LinkedDeviceCard extends ConsumerWidget {
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.deleteDeviceDialog),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 4, big: 16)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: () async {
|
||||
await onDelete();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
text: context.translate(I18n.delete),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
child: DeleteDeviceDialog(device: device),
|
||||
));},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
@@ -168,13 +126,13 @@ class LinkedDeviceCard extends ConsumerWidget {
|
||||
),
|
||||
child:
|
||||
IconButton(
|
||||
onPressed: (){Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => EditLinkedDeviceScreen(
|
||||
device: device,
|
||||
/*navigationContract: navigationContract*/
|
||||
)),
|
||||
);},
|
||||
onPressed: (){
|
||||
vm.setSelectedDevice(device);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => EditLinkedDeviceScreen()),
|
||||
);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.edit_outlined,
|
||||
color: Colors.white,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final deleteDeviceUseCaseProvider = Provider.autoDispose<DeleteDeviceUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return DeleteDeviceUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final getLinkedDevicesUseCaseProvider = Provider.autoDispose<GetLinkedDevicesUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return GetLinkedDevicesUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final updateDeviceUseCaseProvider = Provider.autoDispose<UpdateDeviceUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return UpdateDeviceUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -1,59 +1,51 @@
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/delete_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/get_linked_devices_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/update_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../../../core/domain/repositories/devices_repository.dart';
|
||||
import '../../../../core/providers/devices_repository_provider.dart';
|
||||
|
||||
final linkedDevicesViewModelProvider =
|
||||
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
|
||||
LinkedDevicesViewModel.new,
|
||||
);
|
||||
|
||||
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final UpdateDeviceUseCase _updateDeviceUseCase;
|
||||
late final DeleteDeviceUseCase _deleteDeviceUseCase;
|
||||
late final SharedDevicesRepository _getDevicesRepository;
|
||||
late final DevicesRepository _devicesRepository;
|
||||
|
||||
late final TextEditingController deviceNameController;
|
||||
|
||||
@override
|
||||
LinkedDevicesViewState build() {
|
||||
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
|
||||
_updateDeviceUseCase = ref.read(updateDeviceUseCaseProvider);
|
||||
_deleteDeviceUseCase = ref.read(deleteDeviceUseCaseProvider);
|
||||
|
||||
deviceNameController = TextEditingController();
|
||||
deviceNameController.addListener(_onDeviceNameChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
_getDevicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
_devicesRepository = ref.read(devicesRepositoryProvider);
|
||||
|
||||
_initControllers();
|
||||
_init();
|
||||
|
||||
return const LinkedDevicesViewState();
|
||||
}
|
||||
|
||||
void _initControllers() {
|
||||
deviceNameController = TextEditingController();
|
||||
deviceNameController.addListener(_onDeviceNameChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
}
|
||||
|
||||
Future<void> _init() async {
|
||||
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
setUser(user);
|
||||
final linkedDevices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
setLinkedDevices(linkedDevices);
|
||||
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void setLinkedDevices(List<DeviceEntity> linkedDevices) {
|
||||
state = state.copyWith(linkedDevices: linkedDevices);
|
||||
final linkedDevices = await _getDevicesRepository.getDevices();
|
||||
state = state.copyWith(
|
||||
linkedDevices: linkedDevices,
|
||||
isLoading: false,
|
||||
);
|
||||
}
|
||||
|
||||
void toggleIsEditing() {
|
||||
@@ -70,9 +62,17 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
);
|
||||
}
|
||||
|
||||
void setSelectedDevice(DeviceEntity value) {
|
||||
if (value == state.selectedDevice) return;
|
||||
|
||||
state = state.copyWith(
|
||||
selectedDevice: value,
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> deleteDevice(DeviceEntity device) async {
|
||||
try {
|
||||
await _deleteDeviceUseCase.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
await _devicesRepository.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
List<DeviceEntity> newList = state.linkedDevices;
|
||||
newList.remove(device);
|
||||
|
||||
@@ -90,26 +90,32 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
|
||||
return UpdateDeviceRequestEntity(
|
||||
identificator: device.identificator,
|
||||
name: state.deviceName.trim(),
|
||||
carrierName: state.deviceName.trim(),
|
||||
// phone: /*state.dialCode.trim() + */state.phoneNumber.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
void updateDevice(DeviceEntity device) {
|
||||
Future<void> updateDevice() async {
|
||||
final deviceName = state.deviceName;
|
||||
final device = state.selectedDevice!;
|
||||
|
||||
if (deviceName.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: ''
|
||||
);
|
||||
return;
|
||||
}
|
||||
final userId = 'test';
|
||||
_updateDeviceUseCase.updateDevice(
|
||||
if (deviceName.isEmpty) return;
|
||||
|
||||
try {
|
||||
final userId = state.loggedUser!.id;
|
||||
_devicesRepository.updateDevice(
|
||||
userId: userId,
|
||||
deviceId: device.identificator,
|
||||
request: _toRequest(device));
|
||||
|
||||
} catch(e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
isComplete: false,
|
||||
errorMessage: e.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
|
||||
@@ -6,8 +6,10 @@ part 'linked_devices_view_state.freezed.dart';
|
||||
@freezed
|
||||
abstract class LinkedDevicesViewState with _$LinkedDevicesViewState {
|
||||
const factory LinkedDevicesViewState({
|
||||
@Default(false) bool isLoading,
|
||||
@Default(null) UserEntity? loggedUser,
|
||||
@Default(true) bool isLoading,
|
||||
@Default(true) bool isComplete,
|
||||
UserEntity? loggedUser,
|
||||
DeviceEntity? selectedDevice,
|
||||
@Default([]) List<DeviceEntity> linkedDevices,
|
||||
@Default(false) bool isEditing,
|
||||
@Default('') String deviceName,
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LinkedDevicesViewState {
|
||||
|
||||
bool get isLoading; UserEntity? get loggedUser; List<DeviceEntity> get linkedDevices; bool get isEditing; String get deviceName; String get errorMessage;
|
||||
bool get isLoading; bool get isComplete; UserEntity? get loggedUser; DeviceEntity? get selectedDevice; List<DeviceEntity> get linkedDevices; bool get isEditing; String get deviceName; String get errorMessage;
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LinkedDevicesViewStateCopyWith<LinkedDevicesViewState> get copyWith => _$Linked
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.linkedDevices, linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.linkedDevices, linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(linkedDevices),isEditing,deviceName,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,loggedUser,selectedDevice,const DeepCollectionEquality().hash(linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, isComplete: $isComplete, loggedUser: $loggedUser, selectedDevice: $selectedDevice, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ abstract mixin class $LinkedDevicesViewStateCopyWith<$Res> {
|
||||
factory $LinkedDevicesViewStateCopyWith(LinkedDevicesViewState value, $Res Function(LinkedDevicesViewState) _then) = _$LinkedDevicesViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;$DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -62,11 +62,13 @@ class _$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? loggedUser = freezed,Object? selectedDevice = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self.linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,linkedDevices: null == linkedDevices ? _self.linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
@@ -85,6 +87,18 @@ $UserEntityCopyWith<$Res>? get loggedUser {
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +181,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -188,10 +202,10 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState():
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -208,10 +222,10 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -223,11 +237,13 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
|
||||
|
||||
class _LinkedDevicesViewState implements LinkedDevicesViewState {
|
||||
const _LinkedDevicesViewState({this.isLoading = false, this.loggedUser = null, final List<DeviceEntity> linkedDevices = const [], this.isEditing = false, this.deviceName = '', this.errorMessage = ''}): _linkedDevices = linkedDevices;
|
||||
const _LinkedDevicesViewState({this.isLoading = true, this.isComplete = true, this.loggedUser, this.selectedDevice, final List<DeviceEntity> linkedDevices = const [], this.isEditing = false, this.deviceName = '', this.errorMessage = ''}): _linkedDevices = linkedDevices;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final UserEntity? loggedUser;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override final UserEntity? loggedUser;
|
||||
@override final DeviceEntity? selectedDevice;
|
||||
final List<DeviceEntity> _linkedDevices;
|
||||
@override@JsonKey() List<DeviceEntity> get linkedDevices {
|
||||
if (_linkedDevices is EqualUnmodifiableListView) return _linkedDevices;
|
||||
@@ -249,16 +265,16 @@ _$LinkedDevicesViewStateCopyWith<_LinkedDevicesViewState> get copyWith => __$Lin
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._linkedDevices, _linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._linkedDevices, _linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(_linkedDevices),isEditing,deviceName,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,loggedUser,selectedDevice,const DeepCollectionEquality().hash(_linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, isComplete: $isComplete, loggedUser: $loggedUser, selectedDevice: $selectedDevice, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -269,11 +285,11 @@ abstract mixin class _$LinkedDevicesViewStateCopyWith<$Res> implements $LinkedDe
|
||||
factory _$LinkedDevicesViewStateCopyWith(_LinkedDevicesViewState value, $Res Function(_LinkedDevicesViewState) _then) = __$LinkedDevicesViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;@override $DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -286,11 +302,13 @@ class __$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? loggedUser = freezed,Object? selectedDevice = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_LinkedDevicesViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self._linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,linkedDevices: null == linkedDevices ? _self._linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
@@ -310,6 +328,18 @@ $UserEntityCopyWith<$Res>? get loggedUser {
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_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';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class DeleteDeviceDialog extends ConsumerWidget {
|
||||
|
||||
final DeviceEntity device;
|
||||
|
||||
const DeleteDeviceDialog({required this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.deleteDeviceDialog),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 4, big: 16)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: () async {
|
||||
await vm.deleteDevice(device);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
text: context.translate(I18n.delete),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class ControlPanelRemoteDatasource {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
|
||||
Future<List<PositionEntity>> getLatestPositions({required String deviceId});
|
||||
}
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
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/core/domain/entities/position_entity.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
class ControlPanelRemoteDatasourceImpl implements ControlPanelRemoteDatasource {
|
||||
ControlPanelRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getDevices() async {
|
||||
final response = await safeCall(
|
||||
() => _repository.get<Map<String, dynamic>>('/devices'),
|
||||
'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,
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
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/core/domain/entities/position_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
class ControlPanelRepositoryImpl implements ControlPanelRepository {
|
||||
const ControlPanelRepositoryImpl(this._remote);
|
||||
|
||||
final ControlPanelRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getDevices() async {
|
||||
return _remote.getDevices();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<PositionEntity>> getLatestPositions({required String deviceId}) async {
|
||||
return _remote.getLatestPositions(deviceId: deviceId);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:control_panel/src/core/domain/entities/position_entity.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class ControlPanelRepository {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
|
||||
Future<List<PositionEntity>> getLatestPositions({required String deviceId});
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ final controlPanelViewModelProvider =
|
||||
);
|
||||
|
||||
class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
late final ControlPanelRepository _repository;
|
||||
late final ControlPanelRepository _controlPanelRepository;
|
||||
late final SharedDevicesRepository _devicesRepository;
|
||||
late final SelectedDeviceNotifier _selectedDeviceNotifier;
|
||||
|
||||
@override
|
||||
ControlPanelViewState build() {
|
||||
_repository = ref.read(controlPanelRepositoryProvider);
|
||||
_controlPanelRepository = ref.read(controlPanelRepositoryProvider);
|
||||
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
_selectedDeviceNotifier = ref.read(selectedDeviceProvider.notifier);
|
||||
_init();
|
||||
return const ControlPanelViewState();
|
||||
@@ -29,7 +31,7 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(loggedUser: user);
|
||||
|
||||
final devices = await _repository.getDevices();
|
||||
final devices = await _devicesRepository.getDevices();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
if (devices.isEmpty) {
|
||||
@@ -45,7 +47,7 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
|
||||
final positionLists = await Future.wait(
|
||||
devices.map(
|
||||
(d) => _repository.getLatestPositions(deviceId: d!.identificator),
|
||||
(d) => _controlPanelRepository.getLatestPositions(deviceId: d!.identificator),
|
||||
),
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
@@ -91,7 +93,7 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
try {
|
||||
final positionLists = await Future.wait(
|
||||
state.devices.map(
|
||||
(d) => _repository.getLatestPositions(deviceId: d!.identificator),
|
||||
(d) => _controlPanelRepository.getLatestPositions(deviceId: d!.identificator),
|
||||
),
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
@@ -9,14 +9,14 @@ final locateDeviceViewModelProvider =
|
||||
);
|
||||
|
||||
class LocateDeviceViewModel extends Notifier<LocateDeviceViewState> {
|
||||
late final SendCommandUseCase _sendCommandUseCase;
|
||||
late final CommandsRepository _commandsRepository;
|
||||
|
||||
late final TextEditingController nameController;
|
||||
late final TextEditingController phoneController;
|
||||
|
||||
@override
|
||||
LocateDeviceViewState build() {
|
||||
_sendCommandUseCase = ref.read(sendCommandUseCaseProvider);
|
||||
_commandsRepository = ref.read(commandsRepositoryProvider);
|
||||
|
||||
state = const LocateDeviceViewState();
|
||||
|
||||
@@ -42,7 +42,7 @@ class LocateDeviceViewModel extends Notifier<LocateDeviceViewState> {
|
||||
);
|
||||
|
||||
final request = SendCommandRequestModel(device: state.device!.identificator, command: 'FIND_DEVICE');
|
||||
await _sendCommandUseCase.send(request: request);
|
||||
await _commandsRepository.send(request: request);
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
|
||||
@@ -15,12 +15,12 @@ class RewardsViewModel extends Notifier<RewardsViewState> {
|
||||
static final _min = 1;
|
||||
|
||||
late final TextEditingController amountController;
|
||||
late final SendCommandUseCase _sendCommandUseCase;
|
||||
late final CommandsRepository _commandsRepository;
|
||||
|
||||
@override
|
||||
RewardsViewState build() {
|
||||
|
||||
_sendCommandUseCase = ref.read(sendCommandUseCaseProvider);
|
||||
_commandsRepository = ref.read(commandsRepositoryProvider);
|
||||
|
||||
amountController = TextEditingController();
|
||||
amountController.addListener(_onAmountChanged);
|
||||
@@ -87,7 +87,7 @@ class RewardsViewModel extends Notifier<RewardsViewState> {
|
||||
}
|
||||
);
|
||||
|
||||
await _sendCommandUseCase.send(request: request);
|
||||
await _commandsRepository.send(request: request);
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
|
||||
@@ -5,7 +5,10 @@ export 'src/widgets/layouts/page_layout.dart';
|
||||
export 'src/components/section_button.dart';
|
||||
export 'src/components/menu_button.dart';
|
||||
export 'src/data/models/device_response_model.dart';
|
||||
export 'src/providers/send_command_use_case_provider.dart';
|
||||
export 'src/domain/send_command_use_case.dart';
|
||||
export 'src/data/models/get_devices_response_model.dart';
|
||||
export 'src/data/models/send_command_request_model.dart';
|
||||
export 'src/utils/dio_error_mapper.dart';
|
||||
export 'src/utils/dio_error_mapper.dart';
|
||||
export 'src/domain/repositories/command_repository.dart';
|
||||
export 'src/providers/commands_repository_provider.dart';
|
||||
export 'src/domain/repositories/devices_repository.dart';
|
||||
export 'src/providers/devices_repository_provider.dart';
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class DevicesRemoteDatasource {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import 'devices_remote_datasource.dart';
|
||||
|
||||
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||
DevicesRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getDevices() async {
|
||||
final response = await safeCall(
|
||||
() => _repository.get<Map<String, dynamic>>('/devices'),
|
||||
'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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../domain/repositories/devices_repository.dart';
|
||||
import '../datasources/devices_remote_datasource.dart';
|
||||
|
||||
class DevicesRepositoryImpl implements SharedDevicesRepository {
|
||||
const DevicesRepositoryImpl(this._remote);
|
||||
|
||||
final DevicesRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getDevices() async {
|
||||
return _remote.getDevices();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class SharedDevicesRepository {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import 'package:legacy_shared/src/data/models/send_command_request_model.dart';
|
||||
|
||||
abstract class SendCommandUseCase {
|
||||
Future<void> send({required SendCommandRequestModel request});
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
import '../data/models/send_command_request_model.dart';
|
||||
import 'repositories/command_repository.dart';
|
||||
import 'send_command_use_case.dart';
|
||||
|
||||
class SendCommandUseCaseImpl implements SendCommandUseCase {
|
||||
SendCommandUseCaseImpl(this._repository);
|
||||
|
||||
final CommandsRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> send({required SendCommandRequestModel request}) async {
|
||||
return _repository.send(request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasources/devices_remote_datasource.dart';
|
||||
import '../data/datasources/devices_remote_datasource_impl.dart';
|
||||
|
||||
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return DevicesRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../legacy_shared.dart';
|
||||
import '../data/repositories/devices_repository_impl.dart';
|
||||
import 'devices_remote_datasource_repository_provider.dart';
|
||||
|
||||
final sharedDevicesRepositoryProvider = Provider<SharedDevicesRepository>((ref) {
|
||||
final remote = ref.read(devicesRemoteDatasourceProvider);
|
||||
return DevicesRepositoryImpl(remote);
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/src/providers/commands_repository_provider.dart';
|
||||
|
||||
import '../domain/send_command_use_case.dart';
|
||||
import '../domain/send_command_use_case_impl.dart';
|
||||
|
||||
final sendCommandUseCaseProvider = Provider.autoDispose<SendCommandUseCase>((ref) {
|
||||
final commandRepository = ref.read(commandsRepositoryProvider);
|
||||
return SendCommandUseCaseImpl(commandRepository);
|
||||
});
|
||||
@@ -7,6 +7,6 @@
|
||||
<versions>
|
||||
<version>2.6.4</version>
|
||||
</versions>
|
||||
<lastUpdated>20260310000000</lastUpdated>
|
||||
<lastUpdated>20260311000000</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
|
||||
@@ -1 +1 @@
|
||||
4d748a03a80705124d1ffe8143732218
|
||||
19ea2c76ca999c8a982c55187939d8e0
|
||||
@@ -1 +1 @@
|
||||
626b5ba9e1320d252d7286b888d11b14552a2a38
|
||||
8bef25662eb27826399185be236df53f41938964
|
||||
Reference in New Issue
Block a user