Compare commits
1 Commits
feature/de
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ea6b5875d |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"env": "development",
|
||||
"apiBaseUrl": "https://api-neki-b2b.neki.es/gateway/api/",
|
||||
"apiOrigin": "https://neki-b2b.neki.es"
|
||||
}
|
||||
"apiOrigin": "bde6ea73-d09c-475f-aabf-1d11137e4d0d"
|
||||
}
|
||||
|
||||
@@ -141,6 +141,11 @@ void configureAppRouter() {
|
||||
name: 'apps_use',
|
||||
pageBuilder: const AppsUseBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'do_not_disturb',
|
||||
name: 'do_not_disturb',
|
||||
pageBuilder: const DoNotDisturbBuilder().buildPage,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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,7 +1,6 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.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.g.dart';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
@@ -16,9 +16,6 @@ class ChangePasswordScreen extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final password = ref.watch(
|
||||
changePasswordViewModelProvider.select((s)=>s.newPassword)
|
||||
);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
@@ -31,11 +28,11 @@ class ChangePasswordScreen extends ConsumerWidget {
|
||||
child: SingleChildScrollView(child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const _PasswordSection(),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
const _NewPasswordSection(),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
const _RepeatPasswordSection(),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
_PasswordCriteriaList(password: password),
|
||||
const _ErrorMessageSection()
|
||||
],
|
||||
))
|
||||
@@ -45,6 +42,29 @@ class ChangePasswordScreen extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _PasswordSection extends ConsumerWidget {
|
||||
|
||||
const _PasswordSection();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
|
||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||
final showPassword = ref.watch(
|
||||
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
|
||||
);
|
||||
|
||||
return CustomTextField(
|
||||
controller: vm.currentPasswordController,
|
||||
hint: '********',
|
||||
label: context.translate(I18n.password),
|
||||
showPassword: showPassword,
|
||||
onVisibilityChanged: vm.toggleCurrentPasswordVisibility,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class _NewPasswordSection extends ConsumerWidget {
|
||||
|
||||
const _NewPasswordSection();
|
||||
@@ -54,7 +74,7 @@ class _NewPasswordSection extends ConsumerWidget {
|
||||
|
||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||
final showPassword = ref.watch(
|
||||
changePasswordViewModelProvider.select((s)=>s.showNewPassword)
|
||||
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
|
||||
);
|
||||
|
||||
return CustomTextField(
|
||||
@@ -77,7 +97,7 @@ class _RepeatPasswordSection extends ConsumerWidget {
|
||||
|
||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||
final showPassword = ref.watch(
|
||||
changePasswordViewModelProvider.select((s)=>s.showRepeatedPassword)
|
||||
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
|
||||
);
|
||||
|
||||
return CustomTextField(
|
||||
@@ -91,89 +111,6 @@ class _RepeatPasswordSection extends ConsumerWidget {
|
||||
|
||||
}
|
||||
|
||||
class _PasswordCriteriaList extends StatelessWidget {
|
||||
final String password;
|
||||
|
||||
const _PasswordCriteriaList({required this.password});
|
||||
|
||||
static final _upperRegex = RegExp(r'[A-Z]');
|
||||
static final _digitRegex = RegExp(r'[0-9]');
|
||||
static final _specialRegex =
|
||||
RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasInput = password.isNotEmpty;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 6,
|
||||
children: [
|
||||
_CriteriaRow(
|
||||
label: context.translate(I18n.passwordLength),
|
||||
met: password.length >= 8,
|
||||
hasInput: hasInput,
|
||||
),
|
||||
_CriteriaRow(
|
||||
label: context.translate(I18n.passwordCapital),
|
||||
met: _upperRegex.hasMatch(password),
|
||||
hasInput: hasInput,
|
||||
),
|
||||
_CriteriaRow(
|
||||
label: context.translate(I18n.passwordNumber),
|
||||
met: _digitRegex.hasMatch(password),
|
||||
hasInput: hasInput,
|
||||
),
|
||||
_CriteriaRow(
|
||||
label: context.translate(I18n.passwordSpecial),
|
||||
met: _specialRegex.hasMatch(password),
|
||||
hasInput: hasInput,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CriteriaRow extends StatelessWidget {
|
||||
final String label;
|
||||
final bool met;
|
||||
final bool hasInput;
|
||||
|
||||
const _CriteriaRow({
|
||||
required this.label,
|
||||
required this.met,
|
||||
required this.hasInput,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color color;
|
||||
final IconData icon;
|
||||
|
||||
if (!hasInput) {
|
||||
color = Colors.grey;
|
||||
icon = Icons.circle_outlined;
|
||||
} else if (met) {
|
||||
color = Colors.green;
|
||||
icon = Icons.check_circle;
|
||||
} else {
|
||||
color = Colors.red.shade400;
|
||||
icon = Icons.cancel;
|
||||
}
|
||||
|
||||
return Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(icon, size: 16, color: color),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 13, color: color),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ErrorMessageSection extends ConsumerWidget {
|
||||
|
||||
const _ErrorMessageSection();
|
||||
@@ -199,9 +136,7 @@ class _ErrorMessageSection extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
} else return SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ NotifierProvider.autoDispose<ChangePasswordViewModel, ChangePasswordViewState>(
|
||||
class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
late final ChangePasswordUseCase _changePasswordUseCase;
|
||||
|
||||
late final TextEditingController currentPasswordController;
|
||||
late final TextEditingController newPasswordController;
|
||||
late final TextEditingController repeatPasswordController;
|
||||
late final TextEditingController passwordController;
|
||||
@@ -28,6 +29,10 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
}
|
||||
|
||||
void _initControllers() {
|
||||
|
||||
currentPasswordController = TextEditingController();
|
||||
currentPasswordController.addListener(_onCurrentPasswordChanged);
|
||||
|
||||
newPasswordController = TextEditingController();
|
||||
newPasswordController.addListener(_onNewPasswordChanged);
|
||||
|
||||
@@ -37,6 +42,12 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
ref.onDispose(disposeControllers);
|
||||
}
|
||||
|
||||
void toggleCurrentPasswordVisibility() {
|
||||
state = state.copyWith(
|
||||
showCurrentPassword: !state.showCurrentPassword
|
||||
);
|
||||
}
|
||||
|
||||
void toggleNewPasswordVisibility() {
|
||||
state = state.copyWith(
|
||||
showNewPassword: !state.showNewPassword
|
||||
@@ -49,6 +60,17 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
);
|
||||
}
|
||||
|
||||
void _onCurrentPasswordChanged() {
|
||||
final value = currentPasswordController.text;
|
||||
|
||||
if (value == state.currentPassword) return;
|
||||
|
||||
state = state.copyWith(
|
||||
currentPassword: value,
|
||||
errorMessage: ''
|
||||
);
|
||||
}
|
||||
|
||||
void _onNewPasswordChanged() {
|
||||
final value = newPasswordController.text;
|
||||
|
||||
@@ -72,14 +94,11 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
}
|
||||
|
||||
bool _validateForm() {
|
||||
final _upperRegex = RegExp(r'[A-Z]');
|
||||
final _digitRegex = RegExp(r'[0-9]');
|
||||
final _specialRegex =
|
||||
RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]');
|
||||
|
||||
final password = state.newPassword.trim();
|
||||
|
||||
if (password.isEmpty){
|
||||
if (state.currentPassword.trim().isEmpty){
|
||||
state = state.copyWith(errorMessage: 'errorMessageCurrentPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
if (state.newPassword.trim().isEmpty){
|
||||
state = state.copyWith(errorMessage: 'errorMessageNewPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
@@ -87,26 +106,10 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
state = state.copyWith(errorMessage: 'errorMessageRepeatPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
if (password != state.repeatPassword.trim()){
|
||||
if (state.newPassword.trim() != state.repeatPassword.trim()){
|
||||
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
|
||||
return false;
|
||||
}
|
||||
if (password.length < 8){
|
||||
state = state.copyWith(errorMessage: 'errorPasswordMinLength');
|
||||
return false;
|
||||
}
|
||||
if (!_upperRegex.hasMatch(password)) {
|
||||
state = state.copyWith(errorMessage: 'errorPasswordUppercase');
|
||||
return false;
|
||||
}
|
||||
if (!_digitRegex.hasMatch(password)) {
|
||||
state = state.copyWith(errorMessage: 'errorPasswordDigits');
|
||||
return false;
|
||||
}
|
||||
if (!_specialRegex.hasMatch(password)) {
|
||||
state = state.copyWith(errorMessage: 'errorPasswordSpecial');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,6 +155,9 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
currentPasswordController.removeListener(_onCurrentPasswordChanged);
|
||||
currentPasswordController.dispose();
|
||||
|
||||
newPasswordController.removeListener(_onNewPasswordChanged);
|
||||
newPasswordController.dispose();
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ abstract class ChangePasswordViewState with _$ChangePasswordViewState {
|
||||
const factory ChangePasswordViewState({
|
||||
@Default(false) bool isLoading,
|
||||
@Default(false) bool isComplete,
|
||||
@Default(false) bool showCurrentPassword,
|
||||
@Default(false) bool showNewPassword,
|
||||
@Default(false) bool showRepeatedPassword,
|
||||
@Default('') String currentPassword,
|
||||
@Default('') String newPassword,
|
||||
@Default('') String repeatPassword,
|
||||
@Default('') String errorMessage
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChangePasswordViewState {
|
||||
|
||||
bool get isLoading; bool get isComplete; bool get showNewPassword; bool get showRepeatedPassword; String get newPassword; String get repeatPassword; String get errorMessage;
|
||||
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;
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$Chan
|
||||
|
||||
@override
|
||||
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.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));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ChangePasswordViewStateCopyWith<$Res> {
|
||||
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,13 +62,15 @@ class _$ChangePasswordViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// 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? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||
@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,}) {
|
||||
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,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,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
||||
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // 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,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
@@ -156,10 +158,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@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;
|
||||
@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;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -177,10 +179,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.sho
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@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;
|
||||
@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;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState():
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -197,10 +199,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.sho
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@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;
|
||||
@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;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -212,13 +214,15 @@ return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.sho
|
||||
|
||||
|
||||
class _ChangePasswordViewState implements ChangePasswordViewState {
|
||||
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
|
||||
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 = ''});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override@JsonKey() final bool showCurrentPassword;
|
||||
@override@JsonKey() final bool showNewPassword;
|
||||
@override@JsonKey() final bool showRepeatedPassword;
|
||||
@override@JsonKey() final String currentPassword;
|
||||
@override@JsonKey() final String newPassword;
|
||||
@override@JsonKey() final String repeatPassword;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@@ -233,16 +237,16 @@ _$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$C
|
||||
|
||||
@override
|
||||
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.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));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +257,7 @@ abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangeP
|
||||
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -270,13 +274,15 @@ class __$ChangePasswordViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// 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? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||
@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,}) {
|
||||
return _then(_ChangePasswordViewState(
|
||||
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,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,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
|
||||
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // 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,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:account/src/core/domain/repositories/users_repository.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:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
@@ -13,12 +14,18 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
||||
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
late final UsersRepository _usersRepository;
|
||||
late final SharedDevicesRepository _devicesRepository;
|
||||
late final TextEditingController passwordController;
|
||||
|
||||
@override
|
||||
DeleteAccountViewState build() {
|
||||
_usersRepository = ref.read(usersRepositoryProvider);
|
||||
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
|
||||
passwordController = TextEditingController();
|
||||
passwordController.addListener(_onPasswordChanged);
|
||||
|
||||
ref.onDispose(disposeListeners);
|
||||
|
||||
Future.microtask(() => load());
|
||||
|
||||
return const DeleteAccountViewState();
|
||||
@@ -38,13 +45,13 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
|
||||
void setDevices(List<DeviceEntity> devices) {
|
||||
state = state.copyWith(
|
||||
devices: devices.toList(),
|
||||
deviceNames: devices.map((device) => device.carrierName!).toList(),
|
||||
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
|
||||
);
|
||||
}
|
||||
|
||||
void toggleDeleteDevice(int index) {
|
||||
List<bool> deleteDevices = state.deleteDevices.toList();
|
||||
List<bool> deleteDevices = state.deleteDevices;
|
||||
deleteDevices[index] = !deleteDevices[index];
|
||||
|
||||
state = state.copyWith(
|
||||
@@ -52,6 +59,40 @@ 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 {
|
||||
if (state.isLoading) return;
|
||||
|
||||
@@ -61,12 +102,6 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
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);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
@@ -88,4 +123,9 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
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 isComplete,
|
||||
@Default(0) int confirmStep,
|
||||
@Default([]) List<DeviceEntity> devices,
|
||||
@Default([]) List<String> deviceNames,
|
||||
@Default([]) List<bool> deleteDevices,
|
||||
@Default('') String errorMessage,
|
||||
}) = _DeleteAccountViewState;
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$DeleteAccountViewState {
|
||||
|
||||
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;
|
||||
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;
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $DeleteAccountViewStateCopyWith<DeleteAccountViewState> get copyWith => _$Delete
|
||||
|
||||
@override
|
||||
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.devices, devices)&&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.deviceNames, deviceNames)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(devices),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $DeleteAccountViewStateCopyWith<$Res> {
|
||||
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,15 +62,15 @@ class _$DeleteAccountViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// 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? devices = 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? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
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 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,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||
as int,devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||
as int,deviceNames: null == deviceNames ? _self.deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,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 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<DeviceEntity> devices, 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<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
||||
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<DeviceEntity> devices, 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<String> deviceNames, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState():
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
||||
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<DeviceEntity> devices, 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<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -225,7 +225,7 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
|
||||
|
||||
|
||||
class _DeleteAccountViewState implements DeleteAccountViewState {
|
||||
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;
|
||||
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;
|
||||
|
||||
|
||||
@override final UserEntity? loggedUser;
|
||||
@@ -233,11 +233,11 @@ class _DeleteAccountViewState implements DeleteAccountViewState {
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override@JsonKey() final int confirmStep;
|
||||
final List<DeviceEntity> _devices;
|
||||
@override@JsonKey() List<DeviceEntity> get devices {
|
||||
if (_devices is EqualUnmodifiableListView) return _devices;
|
||||
final List<String> _deviceNames;
|
||||
@override@JsonKey() List<String> get deviceNames {
|
||||
if (_deviceNames is EqualUnmodifiableListView) return _deviceNames;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_devices);
|
||||
return EqualUnmodifiableListView(_deviceNames);
|
||||
}
|
||||
|
||||
final List<bool> _deleteDevices;
|
||||
@@ -259,16 +259,16 @@ _$DeleteAccountViewStateCopyWith<_DeleteAccountViewState> get copyWith => __$Del
|
||||
|
||||
@override
|
||||
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._devices, _devices)&&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._deviceNames, _deviceNames)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_devices),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ abstract mixin class _$DeleteAccountViewStateCopyWith<$Res> implements $DeleteAc
|
||||
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -296,15 +296,15 @@ class __$DeleteAccountViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// 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? devices = 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? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||
return _then(_DeleteAccountViewState(
|
||||
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 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,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||
as int,devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||
as int,deviceNames: null == deviceNames ? _self._deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,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 String,
|
||||
));
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/app_routes.dart';
|
||||
import 'package:navigation/navigation_contract.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class ConfirmDialog extends ConsumerWidget{
|
||||
@@ -25,43 +24,140 @@ class ConfirmDialog extends ConsumerWidget{
|
||||
final state = ref.watch(deleteAccountViewModelProvider);
|
||||
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
|
||||
|
||||
return _ConfirmRequestStep(
|
||||
theme: theme,
|
||||
toggleDeleteDevice: viewModel.toggleDeleteDevice,
|
||||
devices: state.devices,
|
||||
deleteDevices: state.deleteDevices,
|
||||
onCancel: (){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onSubmit: () async {
|
||||
viewModel.deleteAccount();
|
||||
if (!context.mounted) return;
|
||||
|
||||
final isComplete = ref.read(
|
||||
final steps = [
|
||||
_VerifyAccountStep(
|
||||
theme: theme,
|
||||
email: state.loggedUser!.email,
|
||||
passwordController: viewModel.passwordController,
|
||||
errorMessage: state.errorMessage,
|
||||
nextStep: viewModel.nextStep,
|
||||
),
|
||||
_ConfirmRequestStep(
|
||||
theme: theme,
|
||||
toggleDeleteDevice: viewModel.toggleDeleteDevice,
|
||||
deviceNames: state.deviceNames,
|
||||
onCancel: (){
|
||||
viewModel.resetConfirmStep();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onSubmit: () async {
|
||||
viewModel.deleteAccount();
|
||||
if (!context.mounted) return;
|
||||
|
||||
final isComplete = ref.read(
|
||||
deleteAccountViewModelProvider.select((s)=>s.isComplete)
|
||||
);
|
||||
if (isComplete) {
|
||||
navigationContract.goTo(AppRoutes.login);
|
||||
}
|
||||
},
|
||||
);
|
||||
if (isComplete) {
|
||||
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 {
|
||||
|
||||
final ThemePort theme;
|
||||
final Function toggleDeleteDevice;
|
||||
final List<DeviceEntity> devices;
|
||||
final List<bool> deleteDevices;
|
||||
final List<String> deviceNames;
|
||||
final VoidCallback onCancel;
|
||||
final VoidCallback onSubmit;
|
||||
|
||||
const _ConfirmRequestStep({
|
||||
required this.theme,
|
||||
required this.toggleDeleteDevice,
|
||||
required this.devices,
|
||||
required this.deleteDevices,
|
||||
required this.deviceNames,
|
||||
required this.onCancel,
|
||||
required this.onSubmit,
|
||||
});
|
||||
@@ -69,7 +165,7 @@ class _ConfirmRequestStep extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 370,
|
||||
height: 300,
|
||||
width: 500,
|
||||
color: Colors.white,
|
||||
padding: SizeUtils.getByScreen(
|
||||
@@ -93,16 +189,16 @@ class _ConfirmRequestStep extends StatelessWidget {
|
||||
style: TextStyle(height: 1.5),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
...List<Widget>.generate(devices.length, (int index) =>
|
||||
...List<Widget>.generate(deviceNames.length, (int index) =>
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(context.translate(I18n.deleteDeviceData,
|
||||
args: {'name': devices[index].carrierName}
|
||||
args: {'name': deviceNames[index]}
|
||||
),
|
||||
style: TextStyle(height: 0),
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: deleteDevices[index],
|
||||
value: false,
|
||||
onChanged: (_){
|
||||
toggleDeleteDevice(index);
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
part of 'update_device_request_entity.dart';
|
||||
@@ -27,20 +27,16 @@ class LinkedDevicesScreen extends ConsumerWidget {
|
||||
title: context.translate(I18n.linkedDevices),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
|
||||
navigationContract: navigationContract,
|
||||
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
|
||||
body: 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
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -48,13 +44,11 @@ class LinkedDevicesScreen extends ConsumerWidget {
|
||||
|
||||
class _LinkedDeviceCard extends ConsumerWidget {
|
||||
|
||||
final NavigationContract navigationContract;
|
||||
final DeviceEntity device;
|
||||
final bool isEditing;
|
||||
final Function onDelete;
|
||||
|
||||
const _LinkedDeviceCard({
|
||||
required this.navigationContract,
|
||||
required this.device,
|
||||
required this.isEditing,
|
||||
required this.onDelete,
|
||||
@@ -82,7 +76,7 @@ class _LinkedDeviceCard extends ConsumerWidget {
|
||||
shape: BoxShape.circle,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 8, big: 12)),
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
|
||||
child: Icon(SFIcons.watch,
|
||||
size: SizeUtils.getByScreen(small: 40, big: 44),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
@@ -116,10 +110,7 @@ class _LinkedDeviceCard extends ConsumerWidget {
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
|
||||
child: DeleteDeviceDialog(
|
||||
navigationContract: navigationContract,
|
||||
device: device,
|
||||
),
|
||||
child: DeleteDeviceDialog(device: device),
|
||||
));},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.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 SharedDevicesRepository _devicesRepository;
|
||||
late final SharedDevicesRepository _getDevicesRepository;
|
||||
late final DevicesRepository _devicesRepository;
|
||||
|
||||
late final TextEditingController deviceNameController;
|
||||
|
||||
@override
|
||||
LinkedDevicesViewState build() {
|
||||
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
_getDevicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
_devicesRepository = ref.read(devicesRepositoryProvider);
|
||||
|
||||
_initControllers();
|
||||
_init();
|
||||
@@ -36,7 +41,7 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
state = state.copyWith(loggedUser: user);
|
||||
|
||||
final linkedDevices = await _devicesRepository.getDevices();
|
||||
final linkedDevices = await _getDevicesRepository.getDevices();
|
||||
state = state.copyWith(
|
||||
linkedDevices: linkedDevices,
|
||||
isLoading: false,
|
||||
@@ -65,32 +70,19 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteDevice(DeviceEntity device) async {
|
||||
Future<bool> deleteDevice(DeviceEntity device) async {
|
||||
try {
|
||||
state = state.copyWith(
|
||||
isLoading: true,
|
||||
isComplete: false,
|
||||
);
|
||||
|
||||
await _devicesRepository.deleteDevice(deviceId: device.id);
|
||||
List<DeviceEntity> newList = state.linkedDevices.toList();
|
||||
await _devicesRepository.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
List<DeviceEntity> newList = state.linkedDevices;
|
||||
newList.remove(device);
|
||||
|
||||
if (device == state.selectedDevice) {
|
||||
ref.invalidate(selectedDeviceProvider);
|
||||
}
|
||||
state = state.copyWith(
|
||||
linkedDevices: newList
|
||||
);
|
||||
|
||||
state = state.copyWith(
|
||||
linkedDevices: newList,
|
||||
isLoading: false,
|
||||
isComplete: true,
|
||||
);
|
||||
return true;
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +102,9 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
if (deviceName.isEmpty) return;
|
||||
|
||||
try {
|
||||
final userId = state.loggedUser!.id;
|
||||
_devicesRepository.updateDevice(
|
||||
userId: userId,
|
||||
request: _toRequest(device));
|
||||
|
||||
} catch(e) {
|
||||
@@ -120,6 +114,8 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
errorMessage: e.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
|
||||
@@ -2,20 +2,15 @@ import 'package:account/src/features/linked_devices/presentation/state/linked_de
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/navigation.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 NavigationContract navigationContract;
|
||||
final DeviceEntity device;
|
||||
|
||||
const DeleteDeviceDialog({
|
||||
required this.navigationContract,
|
||||
required this.device
|
||||
});
|
||||
const DeleteDeviceDialog({required this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
@@ -26,15 +21,15 @@ class DeleteDeviceDialog extends ConsumerWidget {
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 24, vertical: 18)
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 184, big: 160),
|
||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.deleteDeviceDialog),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 17, big: 16)),
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
|
||||
Row(
|
||||
@@ -51,20 +46,7 @@ class DeleteDeviceDialog extends ConsumerWidget {
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: () async {
|
||||
await vm.deleteDevice(device);
|
||||
|
||||
final isComplete = ref.read(
|
||||
linkedDevicesViewModelProvider.select((s)=>s.isComplete)
|
||||
);
|
||||
if (isComplete) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
final noMoreDevices = ref.read(
|
||||
linkedDevicesViewModelProvider.select((s)=>s.linkedDevices)
|
||||
).isEmpty;
|
||||
if (noMoreDevices) {
|
||||
navigationContract.goTo(AppRoutes.legacyDeviceSetup);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
text: context.translate(I18n.delete),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
|
||||
@@ -9,4 +9,5 @@ export 'src/features/locate_device/locate_device_builder.dart';
|
||||
export 'src/features/health/health_builder.dart';
|
||||
export 'src/features/rewards/rewards_builder.dart';
|
||||
export 'src/features/activity_meter/activity_meter_builder.dart';
|
||||
export 'src/features/apps_use/apps_use_builder.dart';
|
||||
export 'src/features/apps_use/apps_use_builder.dart';
|
||||
export 'src/features/do_not_disturb/do_not_disturb_builder.dart';
|
||||
@@ -54,7 +54,7 @@ class DeviceManagementScreen extends ConsumerWidget {
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppMenuButton(
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
onPressed: () {},
|
||||
onPressed: () => navigationContract.pushTo(AppRoutes.doNotDisturb),
|
||||
icon: SFIcons.doNotDisturbCircle,
|
||||
negativeIcon: true,
|
||||
text: context.translate(I18n.doNotDisturb),
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
import 'presentation/do_not_disturb_screen.dart';
|
||||
|
||||
class DoNotDisturbBuilder {
|
||||
const DoNotDisturbBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: DoNotDisturbScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'time_range_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class TimeRangeEntity with _$TimeRangeEntity {
|
||||
const TimeRangeEntity._();
|
||||
|
||||
const factory TimeRangeEntity({
|
||||
required String id,
|
||||
required String deviceId,
|
||||
required bool active,
|
||||
required TimeOfDay startTime,
|
||||
required TimeOfDay endTime,
|
||||
@Default([false, false, false, false, false, false, false])
|
||||
List<bool> days,
|
||||
int? createdAt,
|
||||
int? updatedAt,
|
||||
}) = _TimeRangeEntity;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final sh = startTime.hour.toString().padLeft(2, '0');
|
||||
final sm = startTime.minute.toString().padLeft(2, '0');
|
||||
final eh = endTime.hour.toString().padLeft(2, '0');
|
||||
final em = endTime.minute.toString().padLeft(2, '0');
|
||||
|
||||
return '$sh:$sm - $eh:$em';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
// 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 'time_range_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$TimeRangeEntity {
|
||||
|
||||
String get id; String get deviceId; bool get active; TimeOfDay get startTime; TimeOfDay get endTime; List<bool> get days; int? get createdAt; int? get updatedAt;
|
||||
/// Create a copy of TimeRangeEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$TimeRangeEntityCopyWith<TimeRangeEntity> get copyWith => _$TimeRangeEntityCopyWithImpl<TimeRangeEntity>(this as TimeRangeEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is TimeRangeEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.active, active) || other.active == active)&&(identical(other.startTime, startTime) || other.startTime == startTime)&&(identical(other.endTime, endTime) || other.endTime == endTime)&&const DeepCollectionEquality().equals(other.days, days)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceId,active,startTime,endTime,const DeepCollectionEquality().hash(days),createdAt,updatedAt);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $TimeRangeEntityCopyWith<$Res> {
|
||||
factory $TimeRangeEntityCopyWith(TimeRangeEntity value, $Res Function(TimeRangeEntity) _then) = _$TimeRangeEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceId, bool active, TimeOfDay startTime, TimeOfDay endTime, List<bool> days, int? createdAt, int? updatedAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$TimeRangeEntityCopyWithImpl<$Res>
|
||||
implements $TimeRangeEntityCopyWith<$Res> {
|
||||
_$TimeRangeEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final TimeRangeEntity _self;
|
||||
final $Res Function(TimeRangeEntity) _then;
|
||||
|
||||
/// Create a copy of TimeRangeEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceId = null,Object? active = null,Object? startTime = null,Object? endTime = null,Object? days = null,Object? createdAt = freezed,Object? updatedAt = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable
|
||||
as bool,startTime: null == startTime ? _self.startTime : startTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,endTime: null == endTime ? _self.endTime : endTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,days: null == days ? _self.days : days // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [TimeRangeEntity].
|
||||
extension TimeRangeEntityPatterns on TimeRangeEntity {
|
||||
/// 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( _TimeRangeEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity() 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( _TimeRangeEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity():
|
||||
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( _TimeRangeEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceId, bool active, TimeOfDay startTime, TimeOfDay endTime, List<bool> days, int? createdAt, int? updatedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceId,_that.active,_that.startTime,_that.endTime,_that.days,_that.createdAt,_that.updatedAt);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceId, bool active, TimeOfDay startTime, TimeOfDay endTime, List<bool> days, int? createdAt, int? updatedAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity():
|
||||
return $default(_that.id,_that.deviceId,_that.active,_that.startTime,_that.endTime,_that.days,_that.createdAt,_that.updatedAt);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceId, bool active, TimeOfDay startTime, TimeOfDay endTime, List<bool> days, int? createdAt, int? updatedAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TimeRangeEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceId,_that.active,_that.startTime,_that.endTime,_that.days,_that.createdAt,_that.updatedAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _TimeRangeEntity extends TimeRangeEntity {
|
||||
const _TimeRangeEntity({required this.id, required this.deviceId, required this.active, required this.startTime, required this.endTime, final List<bool> days = const [false, false, false, false, false, false, false], this.createdAt, this.updatedAt}): _days = days,super._();
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String deviceId;
|
||||
@override final bool active;
|
||||
@override final TimeOfDay startTime;
|
||||
@override final TimeOfDay endTime;
|
||||
final List<bool> _days;
|
||||
@override@JsonKey() List<bool> get days {
|
||||
if (_days is EqualUnmodifiableListView) return _days;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_days);
|
||||
}
|
||||
|
||||
@override final int? createdAt;
|
||||
@override final int? updatedAt;
|
||||
|
||||
/// Create a copy of TimeRangeEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$TimeRangeEntityCopyWith<_TimeRangeEntity> get copyWith => __$TimeRangeEntityCopyWithImpl<_TimeRangeEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TimeRangeEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.active, active) || other.active == active)&&(identical(other.startTime, startTime) || other.startTime == startTime)&&(identical(other.endTime, endTime) || other.endTime == endTime)&&const DeepCollectionEquality().equals(other._days, _days)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceId,active,startTime,endTime,const DeepCollectionEquality().hash(_days),createdAt,updatedAt);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$TimeRangeEntityCopyWith<$Res> implements $TimeRangeEntityCopyWith<$Res> {
|
||||
factory _$TimeRangeEntityCopyWith(_TimeRangeEntity value, $Res Function(_TimeRangeEntity) _then) = __$TimeRangeEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceId, bool active, TimeOfDay startTime, TimeOfDay endTime, List<bool> days, int? createdAt, int? updatedAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$TimeRangeEntityCopyWithImpl<$Res>
|
||||
implements _$TimeRangeEntityCopyWith<$Res> {
|
||||
__$TimeRangeEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _TimeRangeEntity _self;
|
||||
final $Res Function(_TimeRangeEntity) _then;
|
||||
|
||||
/// Create a copy of TimeRangeEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceId = null,Object? active = null,Object? startTime = null,Object? endTime = null,Object? days = null,Object? createdAt = freezed,Object? updatedAt = freezed,}) {
|
||||
return _then(_TimeRangeEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable
|
||||
as bool,startTime: null == startTime ? _self.startTime : startTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,endTime: null == endTime ? _self.endTime : endTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,days: null == days ? _self._days : days // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,335 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:device_management/src/features/do_not_disturb/domain/entities/time_range_entity.dart';
|
||||
import 'package:device_management/src/features/do_not_disturb/presentation/state/do_not_disturb_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
import 'widgets/set_time_dialog.dart';
|
||||
|
||||
class DoNotDisturbScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const DoNotDisturbScreen({
|
||||
super.key,
|
||||
required this.navigationContract,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final state = ref.watch(doNotDisturbViewModelProvider);
|
||||
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
|
||||
|
||||
ref.listen(
|
||||
doNotDisturbViewModelProvider.select((s) => s.errorMessage),
|
||||
(_, errorMessage) {
|
||||
if (errorMessage.isNotEmpty) {
|
||||
showTopSnackbar(context, message: errorMessage, type: MessageType.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
doNotDisturbViewModelProvider.select((s) => s.successMessage),
|
||||
(_, successMessage) {
|
||||
if (successMessage.isNotEmpty) {
|
||||
showTopSnackbar(context, message: context.translate(successMessage), type: MessageType.success);
|
||||
ref.read(doNotDisturbViewModelProvider.notifier).clearSuccess();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: IconButton(
|
||||
onPressed: () => navigationContract.goBack(),
|
||||
icon: Icon(
|
||||
Icons.adaptive.arrow_back,
|
||||
color: primaryColor,
|
||||
size: SizeUtils.getByScreen(small: 32, big: 28),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
context.translate(I18n.doNotDisturb).toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: state.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: const _Body(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Body extends ConsumerWidget {
|
||||
|
||||
const _Body();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final primaryColor = ref.read(themePortProvider)
|
||||
.getColorFor(ThemeCode.legacyPrimary);
|
||||
|
||||
return Padding(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(SFIcons.doNotDisturbCircle,
|
||||
size: 140,
|
||||
color: primaryColor,
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(context.translate(I18n.doNotDisturbMessage)),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
_TimeRangesList(onEdit: (timeRange) => _openForm(context, timeRange: timeRange))
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void _openForm(BuildContext context, {TimeRangeEntity? timeRange}) {
|
||||
showTimeRangeForm(context, timeRange: timeRange);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class _TimeRangesList extends ConsumerWidget {
|
||||
final void Function(TimeRangeEntity timeRange) onEdit;
|
||||
|
||||
const _TimeRangesList({required this.onEdit});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final timeRanges = ref.watch(
|
||||
doNotDisturbViewModelProvider.select((s) => s.timeRanges),
|
||||
);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: List<Widget>.generate(DoNotDisturbViewModel.maxIntervals, (int i) {
|
||||
final timeRange = timeRanges.elementAtOrNull(i);
|
||||
|
||||
if (timeRange == null) {
|
||||
return _EmptyTimeRangeCard();
|
||||
} else {
|
||||
return _TimeRangeCard(
|
||||
index: i,
|
||||
timeRange: timeRange,
|
||||
onEdit: () => onEdit(timeRange),
|
||||
);
|
||||
}
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EmptyTimeRangeCard extends ConsumerWidget {
|
||||
|
||||
const _EmptyTimeRangeCard();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 12, big: 10),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
vertical: SizeUtils.getByScreen(small: 14, big: 12),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.addTimeRange),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
fontSize: SizeUtils.getByScreen(small: 18, big: 18),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: primaryColor
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: (){showTimeRangeForm(context);},
|
||||
color: theme.getColorFor(ThemeCode.textSecondary),
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class _TimeRangeCard extends ConsumerWidget {
|
||||
final TimeRangeEntity timeRange;
|
||||
final VoidCallback onEdit;
|
||||
final int index;
|
||||
|
||||
const _TimeRangeCard({
|
||||
required this.index,
|
||||
required this.timeRange,
|
||||
required this.onEdit,
|
||||
});
|
||||
|
||||
String weekDayShortLabel(BuildContext context, String i18nKey) {
|
||||
final fullName = context.translate(i18nKey);
|
||||
return fullName.length > 3 ? fullName.substring(0, 3) : fullName;
|
||||
}
|
||||
|
||||
String weekDaysLabel(BuildContext context, List<bool> days) {
|
||||
|
||||
const weekDayI18nKeys = [
|
||||
I18n.monday,
|
||||
I18n.tuesday,
|
||||
I18n.wednesday,
|
||||
I18n.thursday,
|
||||
I18n.friday,
|
||||
I18n.saturday,
|
||||
I18n.sunday,
|
||||
];
|
||||
|
||||
final daysLabels = days.indexed.fold<List<String>>([], (List<String> labels, (int i, bool d) day){
|
||||
if (day.$2) {
|
||||
final label = weekDayShortLabel(context, weekDayI18nKeys[day.$1]);
|
||||
labels.add(label);
|
||||
}
|
||||
return labels;
|
||||
}).join(', ');
|
||||
|
||||
return daysLabels;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
|
||||
final sh = timeRange.startTime.hour.toString().padLeft(2, '0');
|
||||
final sm = timeRange.startTime.minute.toString().padLeft(2, '0');
|
||||
final eh = timeRange.endTime.hour.toString().padLeft(2, '0');
|
||||
final em = timeRange.endTime.minute.toString().padLeft(2, '0');
|
||||
|
||||
final vm = ref.read(doNotDisturbViewModelProvider.notifier);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: (){showTimeRangeForm(context, timeRange: timeRange);},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 12, big: 10),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
vertical: SizeUtils.getByScreen(small: 14, big: 12),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'$sh:$sm - $eh:$em',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
fontSize: SizeUtils.getByScreen(small: 24, big: 26),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: timeRange.active,
|
||||
onChanged: (value){vm.setTimeRangeActive(index, value);},
|
||||
activeThumbColor: primaryColor,
|
||||
)
|
||||
],
|
||||
),
|
||||
Text(
|
||||
weekDaysLabel(context, timeRange.days),
|
||||
style: TextStyle(
|
||||
color: theme.getColorFor(ThemeCode.textTertiary)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionButton extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
const _ActionButton({
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.onPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onPressed,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 6, big: 8)),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: SizeUtils.getByScreen(small: 22, big: 24),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
import '../../domain/entities/time_range_entity.dart';
|
||||
import 'do_not_disturb_view_state.dart';
|
||||
|
||||
final doNotDisturbViewModelProvider = NotifierProvider.autoDispose<
|
||||
DoNotDisturbViewModel, DoNotDisturbViewState>(
|
||||
DoNotDisturbViewModel.new,
|
||||
);
|
||||
|
||||
class DoNotDisturbViewModel extends Notifier<DoNotDisturbViewState> {
|
||||
late final CommandsRepository _repository;
|
||||
|
||||
static const int maxIntervals = 4;
|
||||
|
||||
@override
|
||||
DoNotDisturbViewState build() {
|
||||
_repository = ref.read(commandsRepositoryProvider);
|
||||
Future.microtask(_load);
|
||||
return const DoNotDisturbViewState();
|
||||
}
|
||||
|
||||
String? get _identificator =>
|
||||
ref.read(selectedDeviceProvider)?.identificator;
|
||||
|
||||
Future<void> selectTimeRange(TimeRangeEntity range) async {
|
||||
if (range == state.timeRange) return;
|
||||
state = state.copyWith(timeRange: range, isLoading: true);
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
if (_identificator == null) return;
|
||||
|
||||
// final timeRanges = await _repository.getDoNotDisturb(deviceId: _identificator);
|
||||
final timeRanges = [
|
||||
TimeRangeEntity(id: '1', deviceId: '1111', active: true, startTime: TimeOfDay(hour: 0, minute: 0), endTime: TimeOfDay(hour: 6, minute: 0))
|
||||
];
|
||||
state = state.copyWith(timeRanges: timeRanges, isLoading: false);
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: formatErrorMessage(e),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateTimeRange({
|
||||
required String timeRangeId,
|
||||
required List<bool> days,
|
||||
required TimeOfDay startTime,
|
||||
required TimeOfDay endTime
|
||||
}) async {
|
||||
if (_identificator == null) return;
|
||||
|
||||
try {
|
||||
List<TimeRangeEntity> timeRanges = state.timeRanges.toList();
|
||||
final index = timeRanges.indexWhere((t)=>t.id == timeRangeId);
|
||||
TimeRangeEntity timeRange = timeRanges[index];
|
||||
|
||||
timeRange = timeRange.copyWith(
|
||||
days: days,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
);
|
||||
|
||||
await sendCommand(timeRange: timeRange);
|
||||
|
||||
timeRanges[index] = timeRange;
|
||||
|
||||
state = state.copyWith(
|
||||
timeRanges: timeRanges,
|
||||
successMessage: I18n.timePeriodUpdated,
|
||||
);
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createTimeRange({
|
||||
required TimeOfDay startTime,
|
||||
required TimeOfDay endTime,
|
||||
required List<bool> days,
|
||||
}) async {
|
||||
if (_identificator == null) return;
|
||||
|
||||
final newTimeRange = TimeRangeEntity(
|
||||
id: '',
|
||||
deviceId: _identificator!,
|
||||
active: true,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
);
|
||||
|
||||
await sendCommand(timeRange: newTimeRange);
|
||||
|
||||
List<TimeRangeEntity> timeRanges = state.timeRanges.toList();
|
||||
timeRanges.add(newTimeRange);
|
||||
|
||||
state = state.copyWith(
|
||||
timeRanges: timeRanges,
|
||||
successMessage: I18n.timePeriodCreated,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> sendCommand({required TimeRangeEntity timeRange}) async {
|
||||
final request = SendCommandRequestModel(
|
||||
device: _identificator!,
|
||||
command: DeviceCommand.setDoNotDisturb,
|
||||
// data: {},
|
||||
);
|
||||
await _repository.send(request: request);
|
||||
}
|
||||
|
||||
void clearSuccess() {
|
||||
state = state.copyWith(successMessage: '');
|
||||
}
|
||||
|
||||
String _formatError(Object e) {
|
||||
final msg = e.toString();
|
||||
return msg.startsWith('Exception: ') ? msg.substring(11) : msg;
|
||||
}
|
||||
|
||||
void setTimeRangeActive(int i, bool value) {
|
||||
|
||||
final timeRange = state.timeRanges[i];
|
||||
List <TimeRangeEntity> timeRanges = state.timeRanges.toList();
|
||||
timeRanges[i] = timeRange.copyWith(active: value);
|
||||
|
||||
state = state.copyWith(
|
||||
timeRanges: timeRanges,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../domain/entities/time_range_entity.dart';
|
||||
|
||||
part 'do_not_disturb_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class DoNotDisturbViewState with _$DoNotDisturbViewState {
|
||||
const factory DoNotDisturbViewState({
|
||||
@Default([]) List<TimeRangeEntity> timeRanges,
|
||||
TimeRangeEntity? timeRange,
|
||||
@Default(TimeOfDay(hour: 0, minute: 0)) TimeOfDay startTime,
|
||||
@Default(TimeOfDay(hour: 0, minute: 0)) TimeOfDay endTime,
|
||||
@Default(true) bool isLoading,
|
||||
@Default('') String errorMessage,
|
||||
@Default('') String successMessage,
|
||||
}) = _DoNotDisturbViewState;
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
// 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 'do_not_disturb_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$DoNotDisturbViewState {
|
||||
|
||||
List<TimeRangeEntity> get timeRanges; TimeRangeEntity? get timeRange; TimeOfDay get startTime; TimeOfDay get endTime; bool get isLoading; String get errorMessage; String get successMessage;
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$DoNotDisturbViewStateCopyWith<DoNotDisturbViewState> get copyWith => _$DoNotDisturbViewStateCopyWithImpl<DoNotDisturbViewState>(this as DoNotDisturbViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is DoNotDisturbViewState&&const DeepCollectionEquality().equals(other.timeRanges, timeRanges)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.startTime, startTime) || other.startTime == startTime)&&(identical(other.endTime, endTime) || other.endTime == endTime)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(timeRanges),timeRange,startTime,endTime,isLoading,errorMessage,successMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DoNotDisturbViewState(timeRanges: $timeRanges, timeRange: $timeRange, startTime: $startTime, endTime: $endTime, isLoading: $isLoading, errorMessage: $errorMessage, successMessage: $successMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $DoNotDisturbViewStateCopyWith<$Res> {
|
||||
factory $DoNotDisturbViewStateCopyWith(DoNotDisturbViewState value, $Res Function(DoNotDisturbViewState) _then) = _$DoNotDisturbViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<TimeRangeEntity> timeRanges, TimeRangeEntity? timeRange, TimeOfDay startTime, TimeOfDay endTime, bool isLoading, String errorMessage, String successMessage
|
||||
});
|
||||
|
||||
|
||||
$TimeRangeEntityCopyWith<$Res>? get timeRange;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$DoNotDisturbViewStateCopyWithImpl<$Res>
|
||||
implements $DoNotDisturbViewStateCopyWith<$Res> {
|
||||
_$DoNotDisturbViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final DoNotDisturbViewState _self;
|
||||
final $Res Function(DoNotDisturbViewState) _then;
|
||||
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? timeRanges = null,Object? timeRange = freezed,Object? startTime = null,Object? endTime = null,Object? isLoading = null,Object? errorMessage = null,Object? successMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
timeRanges: null == timeRanges ? _self.timeRanges : timeRanges // ignore: cast_nullable_to_non_nullable
|
||||
as List<TimeRangeEntity>,timeRange: freezed == timeRange ? _self.timeRange : timeRange // ignore: cast_nullable_to_non_nullable
|
||||
as TimeRangeEntity?,startTime: null == startTime ? _self.startTime : startTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,endTime: null == endTime ? _self.endTime : endTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,successMessage: null == successMessage ? _self.successMessage : successMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$TimeRangeEntityCopyWith<$Res>? get timeRange {
|
||||
if (_self.timeRange == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $TimeRangeEntityCopyWith<$Res>(_self.timeRange!, (value) {
|
||||
return _then(_self.copyWith(timeRange: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [DoNotDisturbViewState].
|
||||
extension DoNotDisturbViewStatePatterns on DoNotDisturbViewState {
|
||||
/// 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( _DoNotDisturbViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState() 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( _DoNotDisturbViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState():
|
||||
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( _DoNotDisturbViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState() 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<TimeRangeEntity> timeRanges, TimeRangeEntity? timeRange, TimeOfDay startTime, TimeOfDay endTime, bool isLoading, String errorMessage, String successMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState() when $default != null:
|
||||
return $default(_that.timeRanges,_that.timeRange,_that.startTime,_that.endTime,_that.isLoading,_that.errorMessage,_that.successMessage);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<TimeRangeEntity> timeRanges, TimeRangeEntity? timeRange, TimeOfDay startTime, TimeOfDay endTime, bool isLoading, String errorMessage, String successMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState():
|
||||
return $default(_that.timeRanges,_that.timeRange,_that.startTime,_that.endTime,_that.isLoading,_that.errorMessage,_that.successMessage);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<TimeRangeEntity> timeRanges, TimeRangeEntity? timeRange, TimeOfDay startTime, TimeOfDay endTime, bool isLoading, String errorMessage, String successMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DoNotDisturbViewState() when $default != null:
|
||||
return $default(_that.timeRanges,_that.timeRange,_that.startTime,_that.endTime,_that.isLoading,_that.errorMessage,_that.successMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _DoNotDisturbViewState implements DoNotDisturbViewState {
|
||||
const _DoNotDisturbViewState({final List<TimeRangeEntity> timeRanges = const [], this.timeRange, this.startTime = const TimeOfDay(hour: 0, minute: 0), this.endTime = const TimeOfDay(hour: 0, minute: 0), this.isLoading = true, this.errorMessage = '', this.successMessage = ''}): _timeRanges = timeRanges;
|
||||
|
||||
|
||||
final List<TimeRangeEntity> _timeRanges;
|
||||
@override@JsonKey() List<TimeRangeEntity> get timeRanges {
|
||||
if (_timeRanges is EqualUnmodifiableListView) return _timeRanges;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_timeRanges);
|
||||
}
|
||||
|
||||
@override final TimeRangeEntity? timeRange;
|
||||
@override@JsonKey() final TimeOfDay startTime;
|
||||
@override@JsonKey() final TimeOfDay endTime;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final String successMessage;
|
||||
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$DoNotDisturbViewStateCopyWith<_DoNotDisturbViewState> get copyWith => __$DoNotDisturbViewStateCopyWithImpl<_DoNotDisturbViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DoNotDisturbViewState&&const DeepCollectionEquality().equals(other._timeRanges, _timeRanges)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.startTime, startTime) || other.startTime == startTime)&&(identical(other.endTime, endTime) || other.endTime == endTime)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_timeRanges),timeRange,startTime,endTime,isLoading,errorMessage,successMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DoNotDisturbViewState(timeRanges: $timeRanges, timeRange: $timeRange, startTime: $startTime, endTime: $endTime, isLoading: $isLoading, errorMessage: $errorMessage, successMessage: $successMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$DoNotDisturbViewStateCopyWith<$Res> implements $DoNotDisturbViewStateCopyWith<$Res> {
|
||||
factory _$DoNotDisturbViewStateCopyWith(_DoNotDisturbViewState value, $Res Function(_DoNotDisturbViewState) _then) = __$DoNotDisturbViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<TimeRangeEntity> timeRanges, TimeRangeEntity? timeRange, TimeOfDay startTime, TimeOfDay endTime, bool isLoading, String errorMessage, String successMessage
|
||||
});
|
||||
|
||||
|
||||
@override $TimeRangeEntityCopyWith<$Res>? get timeRange;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$DoNotDisturbViewStateCopyWithImpl<$Res>
|
||||
implements _$DoNotDisturbViewStateCopyWith<$Res> {
|
||||
__$DoNotDisturbViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _DoNotDisturbViewState _self;
|
||||
final $Res Function(_DoNotDisturbViewState) _then;
|
||||
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? timeRanges = null,Object? timeRange = freezed,Object? startTime = null,Object? endTime = null,Object? isLoading = null,Object? errorMessage = null,Object? successMessage = null,}) {
|
||||
return _then(_DoNotDisturbViewState(
|
||||
timeRanges: null == timeRanges ? _self._timeRanges : timeRanges // ignore: cast_nullable_to_non_nullable
|
||||
as List<TimeRangeEntity>,timeRange: freezed == timeRange ? _self.timeRange : timeRange // ignore: cast_nullable_to_non_nullable
|
||||
as TimeRangeEntity?,startTime: null == startTime ? _self.startTime : startTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,endTime: null == endTime ? _self.endTime : endTime // ignore: cast_nullable_to_non_nullable
|
||||
as TimeOfDay,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,successMessage: null == successMessage ? _self.successMessage : successMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of DoNotDisturbViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$TimeRangeEntityCopyWith<$Res>? get timeRange {
|
||||
if (_self.timeRange == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $TimeRangeEntityCopyWith<$Res>(_self.timeRange!, (value) {
|
||||
return _then(_self.copyWith(timeRange: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,324 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:device_management/src/features/do_not_disturb/domain/entities/time_range_entity.dart';
|
||||
import 'package:device_management/src/features/do_not_disturb/presentation/state/do_not_disturb_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
void showTimeRangeForm(
|
||||
BuildContext context, {
|
||||
TimeRangeEntity? timeRange,
|
||||
int? weekDay,
|
||||
}) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) => ActivityFormSheet(timeRange: timeRange, weekDay: weekDay),
|
||||
);
|
||||
}
|
||||
|
||||
class ActivityFormSheet extends ConsumerStatefulWidget {
|
||||
final TimeRangeEntity? timeRange;
|
||||
final int? weekDay;
|
||||
|
||||
const ActivityFormSheet({super.key, this.timeRange, this.weekDay});
|
||||
|
||||
@override
|
||||
ConsumerState<ActivityFormSheet> createState() => _ActivityFormSheetState();
|
||||
}
|
||||
|
||||
class _ActivityFormSheetState extends ConsumerState<ActivityFormSheet> {
|
||||
late List<bool> _days;
|
||||
late TimeOfDay _startTime;
|
||||
late TimeOfDay _endTime;
|
||||
bool _showStartPicker = false;
|
||||
bool _showEndPicker = false;
|
||||
|
||||
bool get _isEditing => widget.timeRange != null;
|
||||
|
||||
bool get _isFormValid {
|
||||
return _timeToMinutes(_startTime) < _timeToMinutes(_endTime);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final timeRange = widget.timeRange;
|
||||
_days = timeRange?.days.toList() ?? [false, false, false, false, false, false, false];
|
||||
|
||||
if (timeRange != null) {
|
||||
_startTime = timeRange.startTime;
|
||||
_endTime = timeRange.endTime;
|
||||
} else {
|
||||
_startTime = const TimeOfDay(hour: 0, minute: 0);
|
||||
_endTime = const TimeOfDay(hour: 0, minute: 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int _timeToMinutes(TimeOfDay time) => time.hour * 60 + time.minute;
|
||||
|
||||
void _togglePicker({required bool isStart}) {
|
||||
setState(() {
|
||||
if (isStart) {
|
||||
_showStartPicker = !_showStartPicker;
|
||||
_showEndPicker = false;
|
||||
} else {
|
||||
_showEndPicker = !_showEndPicker;
|
||||
_showStartPicker = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
if (!_isFormValid) return;
|
||||
|
||||
final vm = ref.read(doNotDisturbViewModelProvider.notifier);
|
||||
|
||||
if (_isEditing) {
|
||||
vm.updateTimeRange(
|
||||
timeRangeId: widget.timeRange!.id,
|
||||
days: _days,
|
||||
startTime: _startTime,
|
||||
endTime: _endTime,
|
||||
);
|
||||
} else {
|
||||
vm.createTimeRange(
|
||||
startTime: _startTime,
|
||||
endTime: _endTime,
|
||||
days: _days,
|
||||
);
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: bottomInset),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 22, big: 20)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
context.translate(
|
||||
_isEditing
|
||||
? I18n.scheduledActivityEditTitle
|
||||
: I18n.scheduledActivityNewTitle,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 14)),
|
||||
WeekDayChips.multi(
|
||||
selectedDays: _days,
|
||||
theme: theme,
|
||||
onToggle: (index) =>
|
||||
setState(() => _days[index] = !_days[index]),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 14)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(
|
||||
I18n.scheduledActivityStartTime,
|
||||
),
|
||||
time: _startTime,
|
||||
isExpanded: _showStartPicker,
|
||||
onTap: () => _togglePicker(isStart: true),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(I18n.scheduledActivityEndTime),
|
||||
time: _endTime,
|
||||
isExpanded: _showEndPicker,
|
||||
onTap: () => _togglePicker(isStart: false),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_showStartPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _startTime,
|
||||
onChanged: (time) => setState(() => _startTime = time),
|
||||
),
|
||||
if (_showEndPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _endTime,
|
||||
onChanged: (time) => setState(() => _endTime = time),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 48, big: 46),
|
||||
child: ElevatedButton(
|
||||
onPressed: _isFormValid ? _submit : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.getColorFor(
|
||||
ThemeCode.legacyPrimary,
|
||||
),
|
||||
disabledBackgroundColor: Colors.grey[300],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
SizeUtils.getByScreen(small: 12, big: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
context.translate(I18n.save),
|
||||
style: TextStyle(
|
||||
color: _isFormValid ? Colors.white : Colors.grey,
|
||||
fontSize: SizeUtils.getByScreen(small: 16, big: 15),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TimeSelector extends StatelessWidget {
|
||||
final String label;
|
||||
final TimeOfDay time;
|
||||
final bool isExpanded;
|
||||
final VoidCallback onTap;
|
||||
final ThemePort theme;
|
||||
|
||||
const _TimeSelector({
|
||||
required this.label,
|
||||
required this.time,
|
||||
required this.isExpanded,
|
||||
required this.onTap,
|
||||
required this.theme,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 12, big: 10),
|
||||
vertical: SizeUtils.getByScreen(small: 14, big: 12),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: isExpanded
|
||||
? theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
: Colors.grey,
|
||||
width: isExpanded ? 2 : 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
|
||||
color: theme
|
||||
.getColorFor(ThemeCode.textPrimary)
|
||||
.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
time.format(context),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 16, big: 15),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
isExpanded
|
||||
? Icons.keyboard_arrow_up
|
||||
: Icons.keyboard_arrow_down,
|
||||
size: SizeUtils.getByScreen(small: 20, big: 18),
|
||||
color: theme
|
||||
.getColorFor(ThemeCode.textPrimary)
|
||||
.withValues(alpha: 0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InlineTimePicker extends StatelessWidget {
|
||||
final TimeOfDay initialTime;
|
||||
final ValueChanged<TimeOfDay> onChanged;
|
||||
|
||||
const _InlineTimePicker({required this.initialTime, required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: SizeUtils.getByScreen(small: 180, big: 160),
|
||||
margin: EdgeInsets.only(top: SizeUtils.getByScreen(small: 8, big: 6)),
|
||||
child: CupertinoDatePicker(
|
||||
mode: CupertinoDatePickerMode.time,
|
||||
use24hFormat: true,
|
||||
initialDateTime: DateTime(
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
initialTime.hour,
|
||||
initialTime.minute,
|
||||
),
|
||||
onDateTimeChanged: (dateTime) {
|
||||
onChanged(TimeOfDay(hour: dateTime.hour, minute: dateTime.minute));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/navigation_contract.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
import 'widgets/activation_code_dialog.dart';
|
||||
|
||||
class LegacyDeviceSetupScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
@@ -57,7 +54,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 4, big: 12), left: 8, right: 8),
|
||||
padding: const EdgeInsets.only(top: 12, left: 8, right: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (isIntro)
|
||||
@@ -117,9 +114,6 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state.step == LegacyAddKidStep.scanWatch && state.errorMessage.isEmpty) {
|
||||
showActivationCodeDialog(context);
|
||||
}
|
||||
await vm.next();
|
||||
},
|
||||
theme: theme,
|
||||
|
||||
@@ -3,7 +3,6 @@ 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:utils/utils.dart';
|
||||
|
||||
class LegacyIntroStepScreen extends ConsumerWidget {
|
||||
const LegacyIntroStepScreen({super.key});
|
||||
@@ -12,34 +11,29 @@ class LegacyIntroStepScreen extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 8, big: 2)
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_title),
|
||||
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_subtitle),
|
||||
style: TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
LegacyNumberedSteps(
|
||||
steps: [
|
||||
context.translate(I18n.deviceSetup_intro_step_1),
|
||||
context.translate(I18n.deviceSetup_intro_step_2),
|
||||
],
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_title),
|
||||
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_subtitle),
|
||||
style: TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
LegacyNumberedSteps(
|
||||
steps: [
|
||||
context.translate(I18n.deviceSetup_intro_step_1),
|
||||
context.translate(I18n.deviceSetup_intro_step_2),
|
||||
],
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class LegacyLinkInfoStepScreen extends ConsumerWidget {
|
||||
const LegacyLinkInfoStepScreen({super.key});
|
||||
@@ -14,7 +13,7 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 30)),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 65),
|
||||
child: Text(
|
||||
|
||||
@@ -147,7 +147,7 @@ class LegacyProfileStepScreen extends ConsumerWidget {
|
||||
|
||||
CustomTextField(
|
||||
label: context.translate(I18n.activationKeyLabel),
|
||||
hint: 'XXXXXXXX',
|
||||
hint: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
|
||||
controller: vm.activationKeyController,
|
||||
),
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
void showActivationCodeDialog(BuildContext context) {
|
||||
showDialog(context: context, builder: (context) =>
|
||||
Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: _ActivationCodeDialog(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
class _ActivationCodeDialog extends StatelessWidget {
|
||||
|
||||
const _ActivationCodeDialog();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 14, vertical: 24),
|
||||
big: EdgeInsets.symmetric(horizontal: 12, vertical: 20),
|
||||
),
|
||||
color: Colors.white,
|
||||
child: Text(context.translate(I18n.activationCodeMessage),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import 'dart:async';
|
||||
import 'package:legacy_auth/src/features/login/presentation/widgets/otp_code_fields.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class LegacyTwoFactorBottomSheetView extends StatelessWidget {
|
||||
const LegacyTwoFactorBottomSheetView({
|
||||
@@ -89,7 +88,6 @@ class LegacyTwoFactorBottomSheetView extends StatelessWidget {
|
||||
if (isOtpLoading || !_isValidOtp) return;
|
||||
unawaited(onVerify());
|
||||
},
|
||||
gap: SizeUtils.getByScreen(small: 10, big: 8),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
|
||||
@@ -13,26 +13,22 @@ class CommandsRemoteDatasourceImpl implements CommandsRemoteDatasource {
|
||||
Future<void> send({
|
||||
required SendCommandRequestModel request
|
||||
}) async {
|
||||
try{
|
||||
final response = await safeCall(
|
||||
() => _repository.post<Map<String, dynamic>>(
|
||||
'/commands',
|
||||
body: request.toJson(),
|
||||
),
|
||||
'Error in command ${request.command}',
|
||||
);
|
||||
final response = await safeCall(
|
||||
() => _repository.post<Map<String, dynamic>>(
|
||||
'/commands',
|
||||
body: request.toJson(),
|
||||
),
|
||||
'Error in command ${request.command}',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from command ${request.command}');
|
||||
}
|
||||
if (response.statusCode == 500) {
|
||||
throw Exception('Server error from command ${request.command}');
|
||||
}
|
||||
|
||||
// return CommandsResponseModel.fromJson(data);
|
||||
} catch(e) {
|
||||
return;
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from command ${request.command}');
|
||||
}
|
||||
if (response.statusCode == 500) {
|
||||
throw Exception('Server error from command ${request.command}');
|
||||
}
|
||||
|
||||
// return CommandsResponseModel.fromJson(data);¡
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../models/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class DevicesRemoteDatasource {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
|
||||
Future<void> deleteDevice({required String deviceId});
|
||||
|
||||
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'package:dio/dio.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_shared/sf_shared.dart';
|
||||
|
||||
import '../models/entities/update_device_request_entity.dart';
|
||||
import 'devices_remote_datasource.dart';
|
||||
|
||||
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||
@@ -27,28 +24,4 @@ class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||
final model = GetDevicesResponseModel.fromJson(data);
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ part 'send_command_request_model.freezed.dart';
|
||||
part 'send_command_request_model.g.dart';
|
||||
|
||||
enum DeviceCommand {
|
||||
@JsonValue('SET_DO_NOT_DISTURB')
|
||||
setDoNotDisturb,
|
||||
@JsonValue('FACTORY')
|
||||
factory,
|
||||
@JsonValue('FIND_DEVICE')
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../domain/repositories/devices_repository.dart';
|
||||
import '../datasources/devices_remote_datasource.dart';
|
||||
import '../models/entities/update_device_request_entity.dart';
|
||||
|
||||
class DevicesRepositoryImpl implements SharedDevicesRepository {
|
||||
const DevicesRepositoryImpl(this._remote);
|
||||
@@ -13,14 +12,4 @@ class DevicesRepositoryImpl implements SharedDevicesRepository {
|
||||
Future<List<DeviceEntity>> getDevices() async {
|
||||
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,11 +1,5 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../data/models/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class SharedDevicesRepository {
|
||||
Future<List<DeviceEntity>> getDevices();
|
||||
|
||||
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
|
||||
|
||||
Future<void> deleteDevice({required String deviceId});
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ class LegacyPageLayout extends StatelessWidget {
|
||||
|
||||
const LegacyPageLayout({
|
||||
super.key,
|
||||
required this.theme,
|
||||
required this.title,
|
||||
required this.body,
|
||||
this.footer,
|
||||
this.showBack = true,
|
||||
this.showEdit = false,
|
||||
this.onEditChange,
|
||||
required this.theme,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -298,13 +298,11 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
try {
|
||||
final treezorRepo = ref.read(treezorRepositoryProvider);
|
||||
|
||||
final validation = await treezorRepo
|
||||
final beneficiaryValidationId = await treezorRepo
|
||||
.validateTransactionBeneficiary(beneficiaryId: beneficiary.id);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final beneficiaryValidationId = validation.beneficiaryValidationId;
|
||||
|
||||
final url = 'https://savefamily.sandbox.treezor.co/v1/payouts';
|
||||
final scaInput = {
|
||||
'url': url,
|
||||
|
||||
@@ -70,7 +70,7 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
controller: _controller,
|
||||
onLoaded: (composition) {
|
||||
_controller
|
||||
..duration = composition.duration * 0.8
|
||||
..duration = composition.duration
|
||||
..forward();
|
||||
},
|
||||
),
|
||||
|
||||
@@ -63,6 +63,7 @@ class AppRoutes {
|
||||
static const rewards = '$deviceManagement/rewards';
|
||||
static const activityMeter = '$deviceManagement/activity_meter';
|
||||
static const appsUse = '$deviceManagement/apps_use';
|
||||
static const doNotDisturb = '$deviceManagement/do_not_disturb';
|
||||
|
||||
static const legacyLogin = '$legacy/login';
|
||||
static const legacySignup = '$legacy/signup';
|
||||
|
||||
@@ -16,19 +16,16 @@ class TreezorTokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (!_handling) {
|
||||
// final message = _extractApiMessage(err.response?.data);
|
||||
// if (message != null && message.contains('Treezor Token Expired')) {
|
||||
// _handling = true;
|
||||
// _onTokenExpired();
|
||||
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
// }
|
||||
// else if (err.response?.statusCode == 500) {
|
||||
// _handling = true;
|
||||
// _onTokenExpired();
|
||||
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
// }
|
||||
// else
|
||||
if (err.response?.statusCode == 401) {
|
||||
final message = _extractApiMessage(err.response?.data);
|
||||
if (message != null && message.contains('Treezor Token Expired')) {
|
||||
_handling = true;
|
||||
_onTokenExpired();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
} else if (err.response?.statusCode == 500) {
|
||||
_handling = true;
|
||||
_onTokenExpired();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
} else if (err.response?.statusCode == 401) {
|
||||
_handling = true;
|
||||
_onUnauthorized();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
|
||||
@@ -582,7 +582,7 @@
|
||||
"deviceSetup_weightHint": "30",
|
||||
"deviceSetup_heightLabel": "Height (cm)",
|
||||
"deviceSetup_heightHint": "120",
|
||||
"activationKeyLabel": "Activation key (check your email)",
|
||||
"activationKeyLabel": "Activation key",
|
||||
"rewardsMessage": "*Using this feature you can reward your child for goals achieved or good actions.",
|
||||
"sendRewards": "Send rewards!",
|
||||
"rewardsSent": "Rewards sent!",
|
||||
@@ -706,5 +706,8 @@
|
||||
"editChildProfile": "Edit profile",
|
||||
"editChildProfileSaveSuccess": "Child profile updated successfully",
|
||||
"editChildProfileTitle": "Edit child profile",
|
||||
"activationCodeMessage": "An activation key has been sent to your email"
|
||||
"doNotDisturbMessage": "Set the time period, all the functions except for SOS and GPS will be disabled.",
|
||||
"addTimeRange": "Add time period",
|
||||
"timePeriodUpdated": "Time period updated",
|
||||
"timePeriodCreated": "Time period created"
|
||||
}
|
||||
@@ -580,7 +580,7 @@
|
||||
"deviceSetup_weightHint": "30",
|
||||
"deviceSetup_heightLabel": "Altura (cm)",
|
||||
"deviceSetup_heightHint": "120",
|
||||
"activationKeyLabel": "Clave de activación (consulta tu correo electrónico)",
|
||||
"activationKeyLabel": "Clave de activación",
|
||||
"rewardsMessage": "*Usando esta función puedes recompensar a tu hijo por metas alcanzadas o buenas acciones.",
|
||||
"sendRewards": "¡Enviar recompensas!",
|
||||
"rewardsSent": "¡Recompensas enviadas!",
|
||||
@@ -704,5 +704,8 @@
|
||||
"editChildProfile": "Editar perfil",
|
||||
"editChildProfileTitle": "Editar perfil del niño",
|
||||
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente",
|
||||
"activationCodeMessage": "Se ha enviado un código de activación a tu correo electrónico"
|
||||
"doNotDisturbMessage": "Establece el periodo de tiempo, todas las funciones que no sean SOS y GPS se desactivarán.",
|
||||
"addTimeRange": "Agregar periodo de tiempo",
|
||||
"timePeriodUpdated": "Periodo de tiempo actualizado",
|
||||
"timePeriodCreated": "Periodo de tiempo creado"
|
||||
}
|
||||
@@ -829,5 +829,8 @@ class I18n {
|
||||
static const String editChildProfile = 'editChildProfile';
|
||||
static const String editChildProfileTitle = 'editChildProfileTitle';
|
||||
static const String editChildProfileSaveSuccess = 'editChildProfileSaveSuccess';
|
||||
static const String activationCodeMessage = 'activationCodeMessage';
|
||||
static const String doNotDisturbMessage = 'doNotDisturbMessage';
|
||||
static const String addTimeRange = 'addTimeRange';
|
||||
static const String timePeriodUpdated = 'timePeriodUpdated';
|
||||
static const String timePeriodCreated = 'timePeriodCreated';
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ export 'src/providers/user_info_provider.dart';
|
||||
export 'src/domain/repositories/user_repository.dart';
|
||||
export 'src/data/repositories/user_repository_impl.dart';
|
||||
export 'src/data/datasource/user_remote_datasource_impl.dart';
|
||||
export 'src/domain/entities/beneficiary_validation_entity.dart';
|
||||
export 'src/domain/entities/transaction_beneficiary_entity.dart';
|
||||
export 'src/data/models/payout_beneficiary_model.dart';
|
||||
export 'src/domain/entities/payout_beneficiary_entity.dart';
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:sf_shared/src/data/models/mcc_group_model.dart';
|
||||
import 'package:sf_shared/src/data/models/payment_profile_response_model.dart';
|
||||
import 'package:sf_shared/src/data/models/payout_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/sca_wallet_model.dart';
|
||||
import 'package:sf_shared/src/data/models/beneficiary_validation_model.dart';
|
||||
import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
|
||||
@@ -42,7 +41,7 @@ abstract class TreezorRemoteDatasource {
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
|
||||
Future<void> walletTransfer({
|
||||
required int beneficiaryId,
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:sf_shared/src/data/models/mcc_group_model.dart';
|
||||
import 'package:sf_shared/src/data/models/payment_profile_response_model.dart';
|
||||
import 'package:sf_shared/src/data/models/payout_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/sca_wallet_model.dart';
|
||||
import 'package:sf_shared/src/data/models/beneficiary_validation_model.dart';
|
||||
import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
|
||||
@@ -242,7 +241,7 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({
|
||||
Future<String> validateTransactionBeneficiary({
|
||||
required int beneficiaryId,
|
||||
}) async {
|
||||
try {
|
||||
@@ -255,9 +254,7 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
'Invalid response from /transaction-beneficiaries/$beneficiaryId/validation',
|
||||
);
|
||||
}
|
||||
return BeneficiaryValidationResponseModel.fromJson(
|
||||
Map<String, dynamic>.from(data),
|
||||
);
|
||||
return data['item'] as String;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/src/domain/entities/beneficiary_validation_entity.dart';
|
||||
|
||||
part 'beneficiary_validation_model.freezed.dart';
|
||||
part 'beneficiary_validation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class BeneficiaryValidationResponseModel
|
||||
with _$BeneficiaryValidationResponseModel {
|
||||
const BeneficiaryValidationResponseModel._();
|
||||
|
||||
const factory BeneficiaryValidationResponseModel({
|
||||
@Default(false) bool isCreated,
|
||||
required BeneficiaryValidationItemModel item,
|
||||
}) = _BeneficiaryValidationResponseModel;
|
||||
|
||||
factory BeneficiaryValidationResponseModel.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
) =>
|
||||
_$BeneficiaryValidationResponseModelFromJson(json);
|
||||
|
||||
BeneficiaryValidationEntity toEntity() => BeneficiaryValidationEntity(
|
||||
isCreated: isCreated,
|
||||
beneficiaryValidationId: item.beneficiaryValidationId,
|
||||
createdDate: item.createdDate,
|
||||
vopResult: item.vop?.result ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class BeneficiaryValidationItemModel
|
||||
with _$BeneficiaryValidationItemModel {
|
||||
const factory BeneficiaryValidationItemModel({
|
||||
required String beneficiaryValidationId,
|
||||
@Default('') String createdDate,
|
||||
BeneficiaryValidationVopModel? vop,
|
||||
}) = _BeneficiaryValidationItemModel;
|
||||
|
||||
factory BeneficiaryValidationItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$BeneficiaryValidationItemModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class BeneficiaryValidationVopModel
|
||||
with _$BeneficiaryValidationVopModel {
|
||||
const factory BeneficiaryValidationVopModel({
|
||||
@Default('') String matchedName,
|
||||
@Default('') String recurrenceType,
|
||||
@Default('') String result,
|
||||
}) = _BeneficiaryValidationVopModel;
|
||||
|
||||
factory BeneficiaryValidationVopModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$BeneficiaryValidationVopModelFromJson(json);
|
||||
}
|
||||
@@ -1,860 +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 'beneficiary_validation_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BeneficiaryValidationResponseModel {
|
||||
|
||||
bool get isCreated; BeneficiaryValidationItemModel get item;
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationResponseModelCopyWith<BeneficiaryValidationResponseModel> get copyWith => _$BeneficiaryValidationResponseModelCopyWithImpl<BeneficiaryValidationResponseModel>(this as BeneficiaryValidationResponseModel, _$identity);
|
||||
|
||||
/// Serializes this BeneficiaryValidationResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $BeneficiaryValidationResponseModelCopyWith<$Res> {
|
||||
factory $BeneficiaryValidationResponseModelCopyWith(BeneficiaryValidationResponseModel value, $Res Function(BeneficiaryValidationResponseModel) _then) = _$BeneficiaryValidationResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, BeneficiaryValidationItemModel item
|
||||
});
|
||||
|
||||
|
||||
$BeneficiaryValidationItemModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$BeneficiaryValidationResponseModelCopyWithImpl<$Res>
|
||||
implements $BeneficiaryValidationResponseModelCopyWith<$Res> {
|
||||
_$BeneficiaryValidationResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final BeneficiaryValidationResponseModel _self;
|
||||
final $Res Function(BeneficiaryValidationResponseModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as BeneficiaryValidationItemModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationItemModelCopyWith<$Res> get item {
|
||||
|
||||
return $BeneficiaryValidationItemModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [BeneficiaryValidationResponseModel].
|
||||
extension BeneficiaryValidationResponseModelPatterns on BeneficiaryValidationResponseModel {
|
||||
/// 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( _BeneficiaryValidationResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel() 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( _BeneficiaryValidationResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel():
|
||||
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( _BeneficiaryValidationResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, BeneficiaryValidationItemModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, BeneficiaryValidationItemModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel():
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, BeneficiaryValidationItemModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _BeneficiaryValidationResponseModel extends BeneficiaryValidationResponseModel {
|
||||
const _BeneficiaryValidationResponseModel({this.isCreated = false, required this.item}): super._();
|
||||
factory _BeneficiaryValidationResponseModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationResponseModelFromJson(json);
|
||||
|
||||
@override@JsonKey() final bool isCreated;
|
||||
@override final BeneficiaryValidationItemModel item;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$BeneficiaryValidationResponseModelCopyWith<_BeneficiaryValidationResponseModel> get copyWith => __$BeneficiaryValidationResponseModelCopyWithImpl<_BeneficiaryValidationResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$BeneficiaryValidationResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$BeneficiaryValidationResponseModelCopyWith<$Res> implements $BeneficiaryValidationResponseModelCopyWith<$Res> {
|
||||
factory _$BeneficiaryValidationResponseModelCopyWith(_BeneficiaryValidationResponseModel value, $Res Function(_BeneficiaryValidationResponseModel) _then) = __$BeneficiaryValidationResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, BeneficiaryValidationItemModel item
|
||||
});
|
||||
|
||||
|
||||
@override $BeneficiaryValidationItemModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$BeneficiaryValidationResponseModelCopyWithImpl<$Res>
|
||||
implements _$BeneficiaryValidationResponseModelCopyWith<$Res> {
|
||||
__$BeneficiaryValidationResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _BeneficiaryValidationResponseModel _self;
|
||||
final $Res Function(_BeneficiaryValidationResponseModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_BeneficiaryValidationResponseModel(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as BeneficiaryValidationItemModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of BeneficiaryValidationResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationItemModelCopyWith<$Res> get item {
|
||||
|
||||
return $BeneficiaryValidationItemModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BeneficiaryValidationItemModel {
|
||||
|
||||
String get beneficiaryValidationId; String get createdDate; BeneficiaryValidationVopModel? get vop;
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationItemModelCopyWith<BeneficiaryValidationItemModel> get copyWith => _$BeneficiaryValidationItemModelCopyWithImpl<BeneficiaryValidationItemModel>(this as BeneficiaryValidationItemModel, _$identity);
|
||||
|
||||
/// Serializes this BeneficiaryValidationItemModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationItemModel&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vop, vop) || other.vop == vop));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,beneficiaryValidationId,createdDate,vop);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationItemModel(beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vop: $vop)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $BeneficiaryValidationItemModelCopyWith<$Res> {
|
||||
factory $BeneficiaryValidationItemModelCopyWith(BeneficiaryValidationItemModel value, $Res Function(BeneficiaryValidationItemModel) _then) = _$BeneficiaryValidationItemModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop
|
||||
});
|
||||
|
||||
|
||||
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$BeneficiaryValidationItemModelCopyWithImpl<$Res>
|
||||
implements $BeneficiaryValidationItemModelCopyWith<$Res> {
|
||||
_$BeneficiaryValidationItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final BeneficiaryValidationItemModel _self;
|
||||
final $Res Function(BeneficiaryValidationItemModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vop = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,vop: freezed == vop ? _self.vop : vop // ignore: cast_nullable_to_non_nullable
|
||||
as BeneficiaryValidationVopModel?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop {
|
||||
if (_self.vop == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $BeneficiaryValidationVopModelCopyWith<$Res>(_self.vop!, (value) {
|
||||
return _then(_self.copyWith(vop: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [BeneficiaryValidationItemModel].
|
||||
extension BeneficiaryValidationItemModelPatterns on BeneficiaryValidationItemModel {
|
||||
/// 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( _BeneficiaryValidationItemModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel() 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( _BeneficiaryValidationItemModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel():
|
||||
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( _BeneficiaryValidationItemModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel() 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 beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel() when $default != null:
|
||||
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);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 beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel():
|
||||
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);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 beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationItemModel() when $default != null:
|
||||
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _BeneficiaryValidationItemModel implements BeneficiaryValidationItemModel {
|
||||
const _BeneficiaryValidationItemModel({required this.beneficiaryValidationId, this.createdDate = '', this.vop});
|
||||
factory _BeneficiaryValidationItemModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationItemModelFromJson(json);
|
||||
|
||||
@override final String beneficiaryValidationId;
|
||||
@override@JsonKey() final String createdDate;
|
||||
@override final BeneficiaryValidationVopModel? vop;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$BeneficiaryValidationItemModelCopyWith<_BeneficiaryValidationItemModel> get copyWith => __$BeneficiaryValidationItemModelCopyWithImpl<_BeneficiaryValidationItemModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$BeneficiaryValidationItemModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationItemModel&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vop, vop) || other.vop == vop));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,beneficiaryValidationId,createdDate,vop);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationItemModel(beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vop: $vop)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$BeneficiaryValidationItemModelCopyWith<$Res> implements $BeneficiaryValidationItemModelCopyWith<$Res> {
|
||||
factory _$BeneficiaryValidationItemModelCopyWith(_BeneficiaryValidationItemModel value, $Res Function(_BeneficiaryValidationItemModel) _then) = __$BeneficiaryValidationItemModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop
|
||||
});
|
||||
|
||||
|
||||
@override $BeneficiaryValidationVopModelCopyWith<$Res>? get vop;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$BeneficiaryValidationItemModelCopyWithImpl<$Res>
|
||||
implements _$BeneficiaryValidationItemModelCopyWith<$Res> {
|
||||
__$BeneficiaryValidationItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _BeneficiaryValidationItemModel _self;
|
||||
final $Res Function(_BeneficiaryValidationItemModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vop = freezed,}) {
|
||||
return _then(_BeneficiaryValidationItemModel(
|
||||
beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,vop: freezed == vop ? _self.vop : vop // ignore: cast_nullable_to_non_nullable
|
||||
as BeneficiaryValidationVopModel?,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of BeneficiaryValidationItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop {
|
||||
if (_self.vop == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $BeneficiaryValidationVopModelCopyWith<$Res>(_self.vop!, (value) {
|
||||
return _then(_self.copyWith(vop: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BeneficiaryValidationVopModel {
|
||||
|
||||
String get matchedName; String get recurrenceType; String get result;
|
||||
/// Create a copy of BeneficiaryValidationVopModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationVopModelCopyWith<BeneficiaryValidationVopModel> get copyWith => _$BeneficiaryValidationVopModelCopyWithImpl<BeneficiaryValidationVopModel>(this as BeneficiaryValidationVopModel, _$identity);
|
||||
|
||||
/// Serializes this BeneficiaryValidationVopModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationVopModel&&(identical(other.matchedName, matchedName) || other.matchedName == matchedName)&&(identical(other.recurrenceType, recurrenceType) || other.recurrenceType == recurrenceType)&&(identical(other.result, result) || other.result == result));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,matchedName,recurrenceType,result);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationVopModel(matchedName: $matchedName, recurrenceType: $recurrenceType, result: $result)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $BeneficiaryValidationVopModelCopyWith<$Res> {
|
||||
factory $BeneficiaryValidationVopModelCopyWith(BeneficiaryValidationVopModel value, $Res Function(BeneficiaryValidationVopModel) _then) = _$BeneficiaryValidationVopModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String matchedName, String recurrenceType, String result
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$BeneficiaryValidationVopModelCopyWithImpl<$Res>
|
||||
implements $BeneficiaryValidationVopModelCopyWith<$Res> {
|
||||
_$BeneficiaryValidationVopModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final BeneficiaryValidationVopModel _self;
|
||||
final $Res Function(BeneficiaryValidationVopModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationVopModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? matchedName = null,Object? recurrenceType = null,Object? result = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
matchedName: null == matchedName ? _self.matchedName : matchedName // ignore: cast_nullable_to_non_nullable
|
||||
as String,recurrenceType: null == recurrenceType ? _self.recurrenceType : recurrenceType // ignore: cast_nullable_to_non_nullable
|
||||
as String,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [BeneficiaryValidationVopModel].
|
||||
extension BeneficiaryValidationVopModelPatterns on BeneficiaryValidationVopModel {
|
||||
/// 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( _BeneficiaryValidationVopModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel() 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( _BeneficiaryValidationVopModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel():
|
||||
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( _BeneficiaryValidationVopModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel() 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 matchedName, String recurrenceType, String result)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel() when $default != null:
|
||||
return $default(_that.matchedName,_that.recurrenceType,_that.result);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 matchedName, String recurrenceType, String result) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel():
|
||||
return $default(_that.matchedName,_that.recurrenceType,_that.result);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 matchedName, String recurrenceType, String result)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationVopModel() when $default != null:
|
||||
return $default(_that.matchedName,_that.recurrenceType,_that.result);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _BeneficiaryValidationVopModel implements BeneficiaryValidationVopModel {
|
||||
const _BeneficiaryValidationVopModel({this.matchedName = '', this.recurrenceType = '', this.result = ''});
|
||||
factory _BeneficiaryValidationVopModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationVopModelFromJson(json);
|
||||
|
||||
@override@JsonKey() final String matchedName;
|
||||
@override@JsonKey() final String recurrenceType;
|
||||
@override@JsonKey() final String result;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationVopModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$BeneficiaryValidationVopModelCopyWith<_BeneficiaryValidationVopModel> get copyWith => __$BeneficiaryValidationVopModelCopyWithImpl<_BeneficiaryValidationVopModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$BeneficiaryValidationVopModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationVopModel&&(identical(other.matchedName, matchedName) || other.matchedName == matchedName)&&(identical(other.recurrenceType, recurrenceType) || other.recurrenceType == recurrenceType)&&(identical(other.result, result) || other.result == result));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,matchedName,recurrenceType,result);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationVopModel(matchedName: $matchedName, recurrenceType: $recurrenceType, result: $result)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$BeneficiaryValidationVopModelCopyWith<$Res> implements $BeneficiaryValidationVopModelCopyWith<$Res> {
|
||||
factory _$BeneficiaryValidationVopModelCopyWith(_BeneficiaryValidationVopModel value, $Res Function(_BeneficiaryValidationVopModel) _then) = __$BeneficiaryValidationVopModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String matchedName, String recurrenceType, String result
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$BeneficiaryValidationVopModelCopyWithImpl<$Res>
|
||||
implements _$BeneficiaryValidationVopModelCopyWith<$Res> {
|
||||
__$BeneficiaryValidationVopModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _BeneficiaryValidationVopModel _self;
|
||||
final $Res Function(_BeneficiaryValidationVopModel) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationVopModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? matchedName = null,Object? recurrenceType = null,Object? result = null,}) {
|
||||
return _then(_BeneficiaryValidationVopModel(
|
||||
matchedName: null == matchedName ? _self.matchedName : matchedName // ignore: cast_nullable_to_non_nullable
|
||||
as String,recurrenceType: null == recurrenceType ? _self.recurrenceType : recurrenceType // ignore: cast_nullable_to_non_nullable
|
||||
as String,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -1,56 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'beneficiary_validation_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_BeneficiaryValidationResponseModel
|
||||
_$BeneficiaryValidationResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_BeneficiaryValidationResponseModel(
|
||||
isCreated: json['isCreated'] as bool? ?? false,
|
||||
item: BeneficiaryValidationItemModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BeneficiaryValidationResponseModelToJson(
|
||||
_BeneficiaryValidationResponseModel instance,
|
||||
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
|
||||
|
||||
_BeneficiaryValidationItemModel _$BeneficiaryValidationItemModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _BeneficiaryValidationItemModel(
|
||||
beneficiaryValidationId: json['beneficiaryValidationId'] as String,
|
||||
createdDate: json['createdDate'] as String? ?? '',
|
||||
vop: json['vop'] == null
|
||||
? null
|
||||
: BeneficiaryValidationVopModel.fromJson(
|
||||
json['vop'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BeneficiaryValidationItemModelToJson(
|
||||
_BeneficiaryValidationItemModel instance,
|
||||
) => <String, dynamic>{
|
||||
'beneficiaryValidationId': instance.beneficiaryValidationId,
|
||||
'createdDate': instance.createdDate,
|
||||
'vop': instance.vop,
|
||||
};
|
||||
|
||||
_BeneficiaryValidationVopModel _$BeneficiaryValidationVopModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _BeneficiaryValidationVopModel(
|
||||
matchedName: json['matchedName'] as String? ?? '',
|
||||
recurrenceType: json['recurrenceType'] as String? ?? '',
|
||||
result: json['result'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BeneficiaryValidationVopModelToJson(
|
||||
_BeneficiaryValidationVopModel instance,
|
||||
) => <String, dynamic>{
|
||||
'matchedName': instance.matchedName,
|
||||
'recurrenceType': instance.recurrenceType,
|
||||
'result': instance.result,
|
||||
};
|
||||
@@ -14,7 +14,6 @@ import 'package:sf_shared/src/domain/entities/payment_profile_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/child_wallet_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/payout_beneficiary_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/sca_wallet_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/beneficiary_validation_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/transaction_beneficiary_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_balance_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_transaction_entity.dart';
|
||||
@@ -186,13 +185,12 @@ class TreezorRepositoryImpl implements TreezorRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({
|
||||
Future<String> validateTransactionBeneficiary({
|
||||
required int beneficiaryId,
|
||||
}) async {
|
||||
final model = await _remote.validateTransactionBeneficiary(
|
||||
return _remote.validateTransactionBeneficiary(
|
||||
beneficiaryId: beneficiaryId,
|
||||
);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'beneficiary_validation_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class BeneficiaryValidationEntity
|
||||
with _$BeneficiaryValidationEntity {
|
||||
const factory BeneficiaryValidationEntity({
|
||||
@Default(false) bool isCreated,
|
||||
required String beneficiaryValidationId,
|
||||
@Default('') String createdDate,
|
||||
@Default('') String vopResult,
|
||||
}) = _BeneficiaryValidationEntity;
|
||||
}
|
||||
@@ -1,280 +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 'beneficiary_validation_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$BeneficiaryValidationEntity {
|
||||
|
||||
bool get isCreated; String get beneficiaryValidationId; String get createdDate; String get vopResult;
|
||||
/// Create a copy of BeneficiaryValidationEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$BeneficiaryValidationEntityCopyWith<BeneficiaryValidationEntity> get copyWith => _$BeneficiaryValidationEntityCopyWithImpl<BeneficiaryValidationEntity>(this as BeneficiaryValidationEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vopResult, vopResult) || other.vopResult == vopResult));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,beneficiaryValidationId,createdDate,vopResult);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationEntity(isCreated: $isCreated, beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vopResult: $vopResult)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $BeneficiaryValidationEntityCopyWith<$Res> {
|
||||
factory $BeneficiaryValidationEntityCopyWith(BeneficiaryValidationEntity value, $Res Function(BeneficiaryValidationEntity) _then) = _$BeneficiaryValidationEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$BeneficiaryValidationEntityCopyWithImpl<$Res>
|
||||
implements $BeneficiaryValidationEntityCopyWith<$Res> {
|
||||
_$BeneficiaryValidationEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final BeneficiaryValidationEntity _self;
|
||||
final $Res Function(BeneficiaryValidationEntity) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vopResult = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,vopResult: null == vopResult ? _self.vopResult : vopResult // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [BeneficiaryValidationEntity].
|
||||
extension BeneficiaryValidationEntityPatterns on BeneficiaryValidationEntity {
|
||||
/// 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( _BeneficiaryValidationEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity() 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( _BeneficiaryValidationEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity():
|
||||
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( _BeneficiaryValidationEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity() when $default != null:
|
||||
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity():
|
||||
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BeneficiaryValidationEntity() when $default != null:
|
||||
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _BeneficiaryValidationEntity implements BeneficiaryValidationEntity {
|
||||
const _BeneficiaryValidationEntity({this.isCreated = false, required this.beneficiaryValidationId, this.createdDate = '', this.vopResult = ''});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isCreated;
|
||||
@override final String beneficiaryValidationId;
|
||||
@override@JsonKey() final String createdDate;
|
||||
@override@JsonKey() final String vopResult;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$BeneficiaryValidationEntityCopyWith<_BeneficiaryValidationEntity> get copyWith => __$BeneficiaryValidationEntityCopyWithImpl<_BeneficiaryValidationEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vopResult, vopResult) || other.vopResult == vopResult));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,beneficiaryValidationId,createdDate,vopResult);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeneficiaryValidationEntity(isCreated: $isCreated, beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vopResult: $vopResult)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$BeneficiaryValidationEntityCopyWith<$Res> implements $BeneficiaryValidationEntityCopyWith<$Res> {
|
||||
factory _$BeneficiaryValidationEntityCopyWith(_BeneficiaryValidationEntity value, $Res Function(_BeneficiaryValidationEntity) _then) = __$BeneficiaryValidationEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$BeneficiaryValidationEntityCopyWithImpl<$Res>
|
||||
implements _$BeneficiaryValidationEntityCopyWith<$Res> {
|
||||
__$BeneficiaryValidationEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _BeneficiaryValidationEntity _self;
|
||||
final $Res Function(_BeneficiaryValidationEntity) _then;
|
||||
|
||||
/// Create a copy of BeneficiaryValidationEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vopResult = null,}) {
|
||||
return _then(_BeneficiaryValidationEntity(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,vopResult: null == vopResult ? _self.vopResult : vopResult // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -3,7 +3,6 @@ import '../entities/mcc_group_entity.dart';
|
||||
import '../entities/payment_profile_entity.dart';
|
||||
import '../entities/payout_beneficiary_entity.dart';
|
||||
import '../entities/sca_wallet_entity.dart';
|
||||
import '../entities/beneficiary_validation_entity.dart';
|
||||
import '../entities/transaction_beneficiary_entity.dart';
|
||||
import '../entities/wallet_balance_entity.dart';
|
||||
import '../entities/wallet_card_entity.dart';
|
||||
@@ -48,7 +47,7 @@ abstract class TreezorRepository {
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
|
||||
Future<void> walletTransfer({
|
||||
required int beneficiaryId,
|
||||
|
||||
Reference in New Issue
Block a user