Compare commits
2 Commits
feature/vi
...
feature/de
| Author | SHA1 | Date | |
|---|---|---|---|
| daa64f3db0 | |||
| 680b6d960d |
@@ -1,7 +0,0 @@
|
|||||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
|
||||||
|
|
||||||
abstract class DevicesRemoteDatasource {
|
|
||||||
Future<void> deleteDevice({required String deviceId});
|
|
||||||
|
|
||||||
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
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 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 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,20 +0,0 @@
|
|||||||
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 deviceId}) {
|
|
||||||
return _remote.deleteDevice(deviceId: deviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) {
|
|
||||||
return _remote.updateDevice(request: request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
|
||||||
|
|
||||||
abstract class DevicesRepository {
|
|
||||||
Future<void> deleteDevice({required String deviceId});
|
|
||||||
|
|
||||||
Future<void> updateDevice({
|
|
||||||
required UpdateDeviceRequestEntity request
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
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);
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
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);
|
|
||||||
});
|
|
||||||
@@ -54,7 +54,7 @@ class _NewPasswordSection extends ConsumerWidget {
|
|||||||
|
|
||||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||||
final showPassword = ref.watch(
|
final showPassword = ref.watch(
|
||||||
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
|
changePasswordViewModelProvider.select((s)=>s.showNewPassword)
|
||||||
);
|
);
|
||||||
|
|
||||||
return CustomTextField(
|
return CustomTextField(
|
||||||
@@ -77,7 +77,7 @@ class _RepeatPasswordSection extends ConsumerWidget {
|
|||||||
|
|
||||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||||
final showPassword = ref.watch(
|
final showPassword = ref.watch(
|
||||||
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
|
changePasswordViewModelProvider.select((s)=>s.showRepeatedPassword)
|
||||||
);
|
);
|
||||||
|
|
||||||
return CustomTextField(
|
return CustomTextField(
|
||||||
|
|||||||
@@ -37,12 +37,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
|||||||
ref.onDispose(disposeControllers);
|
ref.onDispose(disposeControllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleCurrentPasswordVisibility() {
|
|
||||||
state = state.copyWith(
|
|
||||||
showCurrentPassword: !state.showCurrentPassword
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggleNewPasswordVisibility() {
|
void toggleNewPasswordVisibility() {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
showNewPassword: !state.showNewPassword
|
showNewPassword: !state.showNewPassword
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$ChangePasswordViewState {
|
mixin _$ChangePasswordViewState {
|
||||||
|
|
||||||
bool get isLoading; bool get isComplete; bool get showCurrentPassword; bool get showNewPassword; bool get showRepeatedPassword; String get currentPassword; String get newPassword; String get repeatPassword; String get errorMessage;
|
bool get isLoading; bool get isComplete; bool get showNewPassword; bool get showRepeatedPassword; String get newPassword; String get repeatPassword; String get errorMessage;
|
||||||
/// Create a copy of ChangePasswordViewState
|
/// Create a copy of ChangePasswordViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -25,16 +25,16 @@ $ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$Chan
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
|
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ abstract mixin class $ChangePasswordViewStateCopyWith<$Res> {
|
|||||||
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
|
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -62,15 +62,13 @@ class _$ChangePasswordViewStateCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of ChangePasswordViewState
|
/// Create a copy of ChangePasswordViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
|
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
|
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
@@ -158,10 +156,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ChangePasswordViewState() when $default != null:
|
case _ChangePasswordViewState() when $default != null:
|
||||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -179,10 +177,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ChangePasswordViewState():
|
case _ChangePasswordViewState():
|
||||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||||
throw StateError('Unexpected subclass');
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -199,10 +197,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ChangePasswordViewState() when $default != null:
|
case _ChangePasswordViewState() when $default != null:
|
||||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -214,15 +212,13 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
|
|||||||
|
|
||||||
|
|
||||||
class _ChangePasswordViewState implements ChangePasswordViewState {
|
class _ChangePasswordViewState implements ChangePasswordViewState {
|
||||||
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showCurrentPassword = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
|
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
|
||||||
|
|
||||||
|
|
||||||
@override@JsonKey() final bool isLoading;
|
@override@JsonKey() final bool isLoading;
|
||||||
@override@JsonKey() final bool isComplete;
|
@override@JsonKey() final bool isComplete;
|
||||||
@override@JsonKey() final bool showCurrentPassword;
|
|
||||||
@override@JsonKey() final bool showNewPassword;
|
@override@JsonKey() final bool showNewPassword;
|
||||||
@override@JsonKey() final bool showRepeatedPassword;
|
@override@JsonKey() final bool showRepeatedPassword;
|
||||||
@override@JsonKey() final String currentPassword;
|
|
||||||
@override@JsonKey() final String newPassword;
|
@override@JsonKey() final String newPassword;
|
||||||
@override@JsonKey() final String repeatPassword;
|
@override@JsonKey() final String repeatPassword;
|
||||||
@override@JsonKey() final String errorMessage;
|
@override@JsonKey() final String errorMessage;
|
||||||
@@ -237,16 +233,16 @@ _$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$C
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
|
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,7 +253,7 @@ abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangeP
|
|||||||
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
|
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -274,15 +270,13 @@ class __$ChangePasswordViewStateCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of ChangePasswordViewState
|
/// Create a copy of ChangePasswordViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||||
return _then(_ChangePasswordViewState(
|
return _then(_ChangePasswordViewState(
|
||||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
|
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
|
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
||||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:account/src/core/domain/repositories/users_repository.dart';
|
import 'package:account/src/core/domain/repositories/users_repository.dart';
|
||||||
import 'package:account/src/core/providers/users_repository_provider.dart';
|
import 'package:account/src/core/providers/users_repository_provider.dart';
|
||||||
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
|
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:legacy_shared/legacy_shared.dart';
|
import 'package:legacy_shared/legacy_shared.dart';
|
||||||
import 'package:sf_shared/sf_shared.dart';
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
@@ -14,18 +13,12 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
|||||||
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||||
late final UsersRepository _usersRepository;
|
late final UsersRepository _usersRepository;
|
||||||
late final SharedDevicesRepository _devicesRepository;
|
late final SharedDevicesRepository _devicesRepository;
|
||||||
late final TextEditingController passwordController;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DeleteAccountViewState build() {
|
DeleteAccountViewState build() {
|
||||||
_usersRepository = ref.read(usersRepositoryProvider);
|
_usersRepository = ref.read(usersRepositoryProvider);
|
||||||
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||||
|
|
||||||
passwordController = TextEditingController();
|
|
||||||
passwordController.addListener(_onPasswordChanged);
|
|
||||||
|
|
||||||
ref.onDispose(disposeListeners);
|
|
||||||
|
|
||||||
Future.microtask(() => load());
|
Future.microtask(() => load());
|
||||||
|
|
||||||
return const DeleteAccountViewState();
|
return const DeleteAccountViewState();
|
||||||
@@ -45,13 +38,13 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
|||||||
|
|
||||||
void setDevices(List<DeviceEntity> devices) {
|
void setDevices(List<DeviceEntity> devices) {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
deviceNames: devices.map((device) => device.carrierName!).toList(),
|
devices: devices.toList(),
|
||||||
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
|
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleDeleteDevice(int index) {
|
void toggleDeleteDevice(int index) {
|
||||||
List<bool> deleteDevices = state.deleteDevices;
|
List<bool> deleteDevices = state.deleteDevices.toList();
|
||||||
deleteDevices[index] = !deleteDevices[index];
|
deleteDevices[index] = !deleteDevices[index];
|
||||||
|
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
@@ -59,40 +52,6 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPasswordChanged() {
|
|
||||||
final value = passwordController.text;
|
|
||||||
if (value == state.password) return;
|
|
||||||
|
|
||||||
state = state.copyWith(
|
|
||||||
password: value,
|
|
||||||
errorMessage: ''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _validateForm() {
|
|
||||||
if (state.password.trim().isEmpty) {
|
|
||||||
state = state.copyWith(errorMessage: 'errorMessagePasswordIsEmpty');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/*if (state.password.trim() != state.loggedUser.password.trim()) {
|
|
||||||
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nextStep() {
|
|
||||||
final step = state.confirmStep;
|
|
||||||
|
|
||||||
if (step == 0 && !_validateForm()) return;
|
|
||||||
|
|
||||||
state = state.copyWith(confirmStep: step + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetConfirmStep() {
|
|
||||||
state = state.copyWith(confirmStep: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteAccount() async {
|
Future<void> deleteAccount() async {
|
||||||
if (state.isLoading) return;
|
if (state.isLoading) return;
|
||||||
|
|
||||||
@@ -102,6 +61,12 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
|||||||
isComplete: false,
|
isComplete: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await state.devices.indexed.map(((int i, DeviceEntity device) element) async {
|
||||||
|
if (state.deleteDevices[element.$1]){
|
||||||
|
return await _devicesRepository.deleteDevice(deviceId: element.$2.id);
|
||||||
|
}
|
||||||
|
}).wait;
|
||||||
|
|
||||||
await _usersRepository.deleteUser(userId: state.loggedUser!.id);
|
await _usersRepository.deleteUser(userId: state.loggedUser!.id);
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
|
|
||||||
@@ -123,9 +88,4 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
|||||||
errorMessage: message,
|
errorMessage: message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void disposeListeners() {
|
|
||||||
passwordController.removeListener(_onPasswordChanged);
|
|
||||||
passwordController.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ abstract class DeleteAccountViewState with _$DeleteAccountViewState {
|
|||||||
@Default(false) bool isLoading,
|
@Default(false) bool isLoading,
|
||||||
@Default(false) bool isComplete,
|
@Default(false) bool isComplete,
|
||||||
@Default(0) int confirmStep,
|
@Default(0) int confirmStep,
|
||||||
@Default([]) List<String> deviceNames,
|
@Default([]) List<DeviceEntity> devices,
|
||||||
@Default([]) List<bool> deleteDevices,
|
@Default([]) List<bool> deleteDevices,
|
||||||
@Default('') String errorMessage,
|
@Default('') String errorMessage,
|
||||||
}) = _DeleteAccountViewState;
|
}) = _DeleteAccountViewState;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$DeleteAccountViewState {
|
mixin _$DeleteAccountViewState {
|
||||||
|
|
||||||
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isComplete; int get confirmStep; List<String> get deviceNames; List<bool> get deleteDevices; String get errorMessage;
|
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isComplete; int get confirmStep; List<DeviceEntity> get devices; List<bool> get deleteDevices; String get errorMessage;
|
||||||
/// Create a copy of DeleteAccountViewState
|
/// Create a copy of DeleteAccountViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -25,16 +25,16 @@ $DeleteAccountViewStateCopyWith<DeleteAccountViewState> get copyWith => _$Delete
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.deviceNames, deviceNames)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.devices, devices)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
|
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(devices),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ abstract mixin class $DeleteAccountViewStateCopyWith<$Res> {
|
|||||||
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
|
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -62,15 +62,15 @@ class _$DeleteAccountViewStateCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of DeleteAccountViewState
|
/// Create a copy of DeleteAccountViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? devices = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||||
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
as String,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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||||
as int,deviceNames: null == deviceNames ? _self.deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
as int,devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable
|
||||||
as List<String>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||||
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
));
|
));
|
||||||
@@ -169,10 +169,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _DeleteAccountViewState() when $default != null:
|
case _DeleteAccountViewState() when $default != null:
|
||||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -190,10 +190,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _DeleteAccountViewState():
|
case _DeleteAccountViewState():
|
||||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||||
throw StateError('Unexpected subclass');
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -210,10 +210,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _DeleteAccountViewState() when $default != null:
|
case _DeleteAccountViewState() when $default != null:
|
||||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
|
|||||||
|
|
||||||
|
|
||||||
class _DeleteAccountViewState implements DeleteAccountViewState {
|
class _DeleteAccountViewState implements DeleteAccountViewState {
|
||||||
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isComplete = false, this.confirmStep = 0, final List<String> deviceNames = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _deviceNames = deviceNames,_deleteDevices = deleteDevices;
|
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isComplete = false, this.confirmStep = 0, final List<DeviceEntity> devices = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _devices = devices,_deleteDevices = deleteDevices;
|
||||||
|
|
||||||
|
|
||||||
@override final UserEntity? loggedUser;
|
@override final UserEntity? loggedUser;
|
||||||
@@ -233,11 +233,11 @@ class _DeleteAccountViewState implements DeleteAccountViewState {
|
|||||||
@override@JsonKey() final bool isLoading;
|
@override@JsonKey() final bool isLoading;
|
||||||
@override@JsonKey() final bool isComplete;
|
@override@JsonKey() final bool isComplete;
|
||||||
@override@JsonKey() final int confirmStep;
|
@override@JsonKey() final int confirmStep;
|
||||||
final List<String> _deviceNames;
|
final List<DeviceEntity> _devices;
|
||||||
@override@JsonKey() List<String> get deviceNames {
|
@override@JsonKey() List<DeviceEntity> get devices {
|
||||||
if (_deviceNames is EqualUnmodifiableListView) return _deviceNames;
|
if (_devices is EqualUnmodifiableListView) return _devices;
|
||||||
// ignore: implicit_dynamic_type
|
// ignore: implicit_dynamic_type
|
||||||
return EqualUnmodifiableListView(_deviceNames);
|
return EqualUnmodifiableListView(_devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<bool> _deleteDevices;
|
final List<bool> _deleteDevices;
|
||||||
@@ -259,16 +259,16 @@ _$DeleteAccountViewStateCopyWith<_DeleteAccountViewState> get copyWith => __$Del
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._deviceNames, _deviceNames)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._devices, _devices)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
|
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_devices),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ abstract mixin class _$DeleteAccountViewStateCopyWith<$Res> implements $DeleteAc
|
|||||||
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
|
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -296,15 +296,15 @@ class __$DeleteAccountViewStateCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of DeleteAccountViewState
|
/// Create a copy of DeleteAccountViewState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? devices = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||||
return _then(_DeleteAccountViewState(
|
return _then(_DeleteAccountViewState(
|
||||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||||
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
as String,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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||||
as int,deviceNames: null == deviceNames ? _self._deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
as int,devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable
|
||||||
as List<String>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||||
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:navigation/app_routes.dart';
|
import 'package:navigation/app_routes.dart';
|
||||||
import 'package:navigation/navigation_contract.dart';
|
import 'package:navigation/navigation_contract.dart';
|
||||||
import 'package:sf_localizations/sf_localizations.dart';
|
import 'package:sf_localizations/sf_localizations.dart';
|
||||||
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
import 'package:utils/utils.dart';
|
import 'package:utils/utils.dart';
|
||||||
|
|
||||||
class ConfirmDialog extends ConsumerWidget{
|
class ConfirmDialog extends ConsumerWidget{
|
||||||
@@ -24,20 +25,12 @@ class ConfirmDialog extends ConsumerWidget{
|
|||||||
final state = ref.watch(deleteAccountViewModelProvider);
|
final state = ref.watch(deleteAccountViewModelProvider);
|
||||||
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
|
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
|
||||||
|
|
||||||
final steps = [
|
return _ConfirmRequestStep(
|
||||||
_VerifyAccountStep(
|
|
||||||
theme: theme,
|
|
||||||
email: state.loggedUser!.email,
|
|
||||||
passwordController: viewModel.passwordController,
|
|
||||||
errorMessage: state.errorMessage,
|
|
||||||
nextStep: viewModel.nextStep,
|
|
||||||
),
|
|
||||||
_ConfirmRequestStep(
|
|
||||||
theme: theme,
|
theme: theme,
|
||||||
toggleDeleteDevice: viewModel.toggleDeleteDevice,
|
toggleDeleteDevice: viewModel.toggleDeleteDevice,
|
||||||
deviceNames: state.deviceNames,
|
devices: state.devices,
|
||||||
|
deleteDevices: state.deleteDevices,
|
||||||
onCancel: (){
|
onCancel: (){
|
||||||
viewModel.resetConfirmStep();
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
@@ -51,113 +44,24 @@ class ConfirmDialog extends ConsumerWidget{
|
|||||||
navigationContract.goTo(AppRoutes.login);
|
navigationContract.goTo(AppRoutes.login);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
return steps[state.confirmStep];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _VerifyAccountStep extends StatelessWidget {
|
|
||||||
|
|
||||||
final String email;
|
|
||||||
final TextEditingController passwordController;
|
|
||||||
final String errorMessage;
|
|
||||||
final VoidCallback nextStep;
|
|
||||||
final ThemePort theme;
|
|
||||||
|
|
||||||
const _VerifyAccountStep({
|
|
||||||
required this.email,
|
|
||||||
required this.passwordController,
|
|
||||||
required this.errorMessage,
|
|
||||||
required this.nextStep,
|
|
||||||
required this.theme,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
height: 210,
|
|
||||||
width: 500,
|
|
||||||
color: Colors.white,
|
|
||||||
padding: SizeUtils.getByScreen(
|
|
||||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 11),
|
|
||||||
big: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(context.translate(I18n.verifyAccount),
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
|
|
||||||
Text('${context.translate(I18n.email)}: ${email}'),
|
|
||||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 6)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text('${context.translate(I18n.password)}: '),
|
|
||||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
|
||||||
Expanded(child: TextField(
|
|
||||||
controller: passwordController,
|
|
||||||
style: TextStyle(fontSize: 12),
|
|
||||||
decoration: InputDecoration(hintText: context.translate(I18n.password)),
|
|
||||||
obscureText: true,
|
|
||||||
enableSuggestions: false,
|
|
||||||
autocorrect: true,
|
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (errorMessage.isNotEmpty)
|
|
||||||
Text(
|
|
||||||
errorMessage,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.error,
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(child: SecondaryButton(
|
|
||||||
onPressed: (){Navigator.pop(context);},
|
|
||||||
text: context.translate(I18n.cancel),
|
|
||||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
|
||||||
height: 40,
|
|
||||||
radius: 20,
|
|
||||||
)),
|
|
||||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
|
||||||
Expanded(child: PrimaryButton(
|
|
||||||
onPressed: nextStep,
|
|
||||||
text: context.translate(I18n.accept),
|
|
||||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
|
||||||
height: 40,
|
|
||||||
radius: 20,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ConfirmRequestStep extends StatelessWidget {
|
class _ConfirmRequestStep extends StatelessWidget {
|
||||||
|
|
||||||
final ThemePort theme;
|
final ThemePort theme;
|
||||||
final Function toggleDeleteDevice;
|
final Function toggleDeleteDevice;
|
||||||
final List<String> deviceNames;
|
final List<DeviceEntity> devices;
|
||||||
|
final List<bool> deleteDevices;
|
||||||
final VoidCallback onCancel;
|
final VoidCallback onCancel;
|
||||||
final VoidCallback onSubmit;
|
final VoidCallback onSubmit;
|
||||||
|
|
||||||
const _ConfirmRequestStep({
|
const _ConfirmRequestStep({
|
||||||
required this.theme,
|
required this.theme,
|
||||||
required this.toggleDeleteDevice,
|
required this.toggleDeleteDevice,
|
||||||
required this.deviceNames,
|
required this.devices,
|
||||||
|
required this.deleteDevices,
|
||||||
required this.onCancel,
|
required this.onCancel,
|
||||||
required this.onSubmit,
|
required this.onSubmit,
|
||||||
});
|
});
|
||||||
@@ -165,7 +69,7 @@ class _ConfirmRequestStep extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 300,
|
height: 370,
|
||||||
width: 500,
|
width: 500,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
padding: SizeUtils.getByScreen(
|
padding: SizeUtils.getByScreen(
|
||||||
@@ -189,16 +93,16 @@ class _ConfirmRequestStep extends StatelessWidget {
|
|||||||
style: TextStyle(height: 1.5),
|
style: TextStyle(height: 1.5),
|
||||||
),
|
),
|
||||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||||
...List<Widget>.generate(deviceNames.length, (int index) =>
|
...List<Widget>.generate(devices.length, (int index) =>
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text(context.translate(I18n.deleteDeviceData,
|
title: Text(context.translate(I18n.deleteDeviceData,
|
||||||
args: {'name': deviceNames[index]}
|
args: {'name': devices[index].carrierName}
|
||||||
),
|
),
|
||||||
style: TextStyle(height: 0),
|
style: TextStyle(height: 0),
|
||||||
),
|
),
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
value: false,
|
value: deleteDevices[index],
|
||||||
onChanged: (_){
|
onChanged: (_){
|
||||||
toggleDeleteDevice(index);
|
toggleDeleteDevice(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
part of 'update_device_request_entity.dart';
|
|
||||||
@@ -1,28 +1,23 @@
|
|||||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
import 'package:legacy_shared/src/data/models/entities/update_device_request_entity.dart';
|
||||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
|
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:legacy_shared/legacy_shared.dart';
|
import 'package:legacy_shared/legacy_shared.dart';
|
||||||
import 'package:sf_shared/sf_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 =
|
final linkedDevicesViewModelProvider =
|
||||||
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
|
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
|
||||||
LinkedDevicesViewModel.new,
|
LinkedDevicesViewModel.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||||
late final SharedDevicesRepository _getDevicesRepository;
|
late final SharedDevicesRepository _devicesRepository;
|
||||||
late final DevicesRepository _devicesRepository;
|
|
||||||
|
|
||||||
late final TextEditingController deviceNameController;
|
late final TextEditingController deviceNameController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
LinkedDevicesViewState build() {
|
LinkedDevicesViewState build() {
|
||||||
_getDevicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||||
_devicesRepository = ref.read(devicesRepositoryProvider);
|
|
||||||
|
|
||||||
_initControllers();
|
_initControllers();
|
||||||
_init();
|
_init();
|
||||||
@@ -41,7 +36,7 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
|||||||
final user = await ref.read(userInfoProvider.future);
|
final user = await ref.read(userInfoProvider.future);
|
||||||
state = state.copyWith(loggedUser: user);
|
state = state.copyWith(loggedUser: user);
|
||||||
|
|
||||||
final linkedDevices = await _getDevicesRepository.getDevices();
|
final linkedDevices = await _devicesRepository.getDevices();
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
linkedDevices: linkedDevices,
|
linkedDevices: linkedDevices,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.step == LegacyAddKidStep.scanWatch) {
|
if (state.step == LegacyAddKidStep.scanWatch && state.errorMessage.isEmpty) {
|
||||||
showActivationCodeDialog(context);
|
showActivationCodeDialog(context);
|
||||||
}
|
}
|
||||||
await vm.next();
|
await vm.next();
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import 'package:sf_shared/sf_shared.dart';
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
|
|
||||||
|
import '../models/entities/update_device_request_entity.dart';
|
||||||
|
|
||||||
abstract class DevicesRemoteDatasource {
|
abstract class DevicesRemoteDatasource {
|
||||||
Future<List<DeviceEntity>> getDevices();
|
Future<List<DeviceEntity>> getDevices();
|
||||||
|
|
||||||
|
Future<void> deleteDevice({required String deviceId});
|
||||||
|
|
||||||
|
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:legacy_shared/legacy_shared.dart';
|
import 'package:legacy_shared/legacy_shared.dart';
|
||||||
|
import 'package:legacy_shared/src/data/models/update_device_request_model.dart';
|
||||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||||
import 'package:sf_shared/sf_shared.dart';
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
|
|
||||||
|
import '../models/entities/update_device_request_entity.dart';
|
||||||
import 'devices_remote_datasource.dart';
|
import 'devices_remote_datasource.dart';
|
||||||
|
|
||||||
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||||
@@ -24,4 +27,28 @@ class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
|||||||
final model = GetDevicesResponseModel.fromJson(data);
|
final model = GetDevicesResponseModel.fromJson(data);
|
||||||
return model.toEntity();
|
return model.toEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteDevice({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 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,6 +1,7 @@
|
|||||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
import 'entities/update_device_request_entity.dart';
|
||||||
|
|
||||||
part 'update_device_request_model.freezed.dart';
|
part 'update_device_request_model.freezed.dart';
|
||||||
part 'update_device_request_model.g.dart';
|
part 'update_device_request_model.g.dart';
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ import 'package:sf_shared/sf_shared.dart';
|
|||||||
|
|
||||||
import '../../domain/repositories/devices_repository.dart';
|
import '../../domain/repositories/devices_repository.dart';
|
||||||
import '../datasources/devices_remote_datasource.dart';
|
import '../datasources/devices_remote_datasource.dart';
|
||||||
|
import '../models/entities/update_device_request_entity.dart';
|
||||||
|
|
||||||
class DevicesRepositoryImpl implements SharedDevicesRepository {
|
class DevicesRepositoryImpl implements SharedDevicesRepository {
|
||||||
const DevicesRepositoryImpl(this._remote);
|
const DevicesRepositoryImpl(this._remote);
|
||||||
@@ -12,4 +13,14 @@ class DevicesRepositoryImpl implements SharedDevicesRepository {
|
|||||||
Future<List<DeviceEntity>> getDevices() async {
|
Future<List<DeviceEntity>> getDevices() async {
|
||||||
return _remote.getDevices();
|
return _remote.getDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteDevice({required String deviceId}) {
|
||||||
|
return _remote.deleteDevice(deviceId: deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) {
|
||||||
|
return _remote.updateDevice(request: request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import 'package:sf_shared/sf_shared.dart';
|
import 'package:sf_shared/sf_shared.dart';
|
||||||
|
|
||||||
|
import '../../data/models/entities/update_device_request_entity.dart';
|
||||||
|
|
||||||
abstract class SharedDevicesRepository {
|
abstract class SharedDevicesRepository {
|
||||||
Future<List<DeviceEntity>> getDevices();
|
Future<List<DeviceEntity>> getDevices();
|
||||||
|
|
||||||
|
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
|
||||||
|
|
||||||
|
Future<void> deleteDevice({required String deviceId});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user