Compare commits

...

11 Commits

60 changed files with 1757 additions and 361 deletions

View File

@@ -1,5 +1,5 @@
{
"env": "development",
"apiBaseUrl": "https://api-neki-b2b.neki.es/gateway/api/",
"apiOrigin": "bde6ea73-d09c-475f-aabf-1d11137e4d0d"
}
"apiOrigin": "https://neki-b2b.neki.es"
}

View File

@@ -1,7 +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> deleteDevice({required String deviceId});
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request});
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
}

View File

@@ -12,7 +12,7 @@ class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
final QuestiaRepository _repository;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) async {
Future<void> deleteDevice({required String deviceId}) async {
try {
await _repository.delete<void>(
'/devices/$deviceId',
@@ -23,7 +23,7 @@ class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) async {
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) async {
try {
final body = request.toModel().toJson();
await _repository.put<void>(

View File

@@ -9,12 +9,12 @@ class DevicesRepositoryImpl implements DevicesRepository {
final DevicesRemoteDatasource _remote;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) {
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
Future<void> deleteDevice({required String deviceId}) {
return _remote.deleteDevice(deviceId: deviceId);
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) {
return _remote.updateDevice(userId: userId, request: request);
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) {
return _remote.updateDevice(request: request);
}
}

View File

@@ -1,10 +1,9 @@
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> deleteDevice({required String deviceId});
Future<void> updateDevice({
required String userId,
required UpdateDeviceRequestEntity request
});
}

View File

@@ -16,6 +16,9 @@ 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,
@@ -28,11 +31,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()
],
))
@@ -42,29 +45,6 @@ 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();
@@ -111,6 +91,89 @@ 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();
@@ -136,7 +199,9 @@ class _ErrorMessageSection extends ConsumerWidget {
),
],
);
} else return SizedBox.shrink();
} else {
return SizedBox.shrink();
}
}
}

View File

@@ -14,7 +14,6 @@ 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;
@@ -29,10 +28,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
void _initControllers() {
currentPasswordController = TextEditingController();
currentPasswordController.addListener(_onCurrentPasswordChanged);
newPasswordController = TextEditingController();
newPasswordController.addListener(_onNewPasswordChanged);
@@ -60,17 +55,6 @@ 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;
@@ -94,11 +78,14 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
bool _validateForm() {
if (state.currentPassword.trim().isEmpty){
state = state.copyWith(errorMessage: 'errorMessageCurrentPasswordIsEmpty');
return false;
}
if (state.newPassword.trim().isEmpty){
final _upperRegex = RegExp(r'[A-Z]');
final _digitRegex = RegExp(r'[0-9]');
final _specialRegex =
RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]');
final password = state.newPassword.trim();
if (password.isEmpty){
state = state.copyWith(errorMessage: 'errorMessageNewPasswordIsEmpty');
return false;
}
@@ -106,10 +93,26 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
state = state.copyWith(errorMessage: 'errorMessageRepeatPasswordIsEmpty');
return false;
}
if (state.newPassword.trim() != state.repeatPassword.trim()){
if (password != 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;
}
@@ -155,9 +158,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
void disposeControllers() {
currentPasswordController.removeListener(_onCurrentPasswordChanged);
currentPasswordController.dispose();
newPasswordController.removeListener(_onNewPasswordChanged);
newPasswordController.dispose();

View File

@@ -7,10 +7,8 @@ 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

View File

@@ -27,16 +27,20 @@ class LinkedDevicesScreen extends ConsumerWidget {
title: context.translate(I18n.linkedDevices),
showEdit: true,
onEditChange: vm.toggleIsEditing,
body: ListView.separated(
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
device: state.linkedDevices[index],
isEditing: state.isEditing,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
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
),
separatorBuilder: (BuildContext context, int index)=>SizedBox(
height: SizeUtils.getByScreen(small: 18, big: 17)
),
itemCount: state.linkedDevices.length
),
);
}
@@ -44,11 +48,13 @@ 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,
@@ -76,7 +82,7 @@ class _LinkedDeviceCard extends ConsumerWidget {
shape: BoxShape.circle,
color: theme.getColorFor(ThemeCode.backgroundPrimary),
),
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 8, big: 12)),
child: Icon(SFIcons.watch,
size: SizeUtils.getByScreen(small: 40, big: 44),
color: theme.getColorFor(ThemeCode.legacyPrimary),
@@ -110,7 +116,10 @@ class _LinkedDeviceCard extends ConsumerWidget {
),
child: IconButton(
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
child: DeleteDeviceDialog(device: device),
child: DeleteDeviceDialog(
navigationContract: navigationContract,
device: device,
),
));},
icon: Icon(
Icons.close,

View File

@@ -70,19 +70,32 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
);
}
Future<bool> deleteDevice(DeviceEntity device) async {
Future<void> deleteDevice(DeviceEntity device) async {
try {
await _devicesRepository.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
List<DeviceEntity> newList = state.linkedDevices;
newList.remove(device);
state = state.copyWith(
linkedDevices: newList
isLoading: true,
isComplete: false,
);
return true;
await _devicesRepository.deleteDevice(deviceId: device.id);
List<DeviceEntity> newList = state.linkedDevices.toList();
newList.remove(device);
if (device == state.selectedDevice) {
ref.invalidate(selectedDeviceProvider);
}
state = state.copyWith(
linkedDevices: newList,
isLoading: false,
isComplete: true,
);
} catch (e) {
return false;
state = state.copyWith(
isLoading: false,
errorMessage: e.toString(),
);
return;
}
}
@@ -102,9 +115,7 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
if (deviceName.isEmpty) return;
try {
final userId = state.loggedUser!.id;
_devicesRepository.updateDevice(
userId: userId,
request: _toRequest(device));
} catch(e) {
@@ -114,8 +125,6 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
errorMessage: e.toString()
);
}
}
void disposeControllers() {

View File

@@ -2,15 +2,20 @@ 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.device});
const DeleteDeviceDialog({
required this.navigationContract,
required this.device
});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -21,15 +26,15 @@ class DeleteDeviceDialog extends ConsumerWidget {
return Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
big: EdgeInsets.symmetric(horizontal: 24, vertical: 18)
),
width: SizeUtils.getByScreen(small: 360, big: 350),
height: SizeUtils.getByScreen(small: 195, big: 185),
height: SizeUtils.getByScreen(small: 184, big: 160),
child: Column(
children: [
Text(context.translate(I18n.deleteDeviceDialog),
textAlign: TextAlign.center,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 17, big: 16)),
),
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
Row(
@@ -46,7 +51,20 @@ class DeleteDeviceDialog extends ConsumerWidget {
Expanded(child: PrimaryButton(
onPressed: () async {
await vm.deleteDevice(device);
Navigator.pop(context);
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);
}
},
text: context.translate(I18n.delete),
color: theme.getColorFor(ThemeCode.legacyPrimary),

View File

@@ -1,7 +0,0 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class FunctionsRemoteDatasource {
Future<List<PictureEntity>> getPictures({required String userId});
Future<PictureEntity> takePicture({required String userId});
}

View File

@@ -0,0 +1,7 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class PicturesRemoteDatasource {
Future<List<PictureEntity>> getPictures({required String deviceId});
Future<PictureEntity> takePicture({required String deviceId});
}

View File

@@ -1,17 +1,19 @@
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
import 'package:device_management/src/core/data/datasources/pictures_remote_datasource.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
class FunctionsRemoteDatasourceImpl implements FunctionsRemoteDatasource {
FunctionsRemoteDatasourceImpl(this._repository);
class PicturesRemoteDatasourceImpl implements PicturesRemoteDatasource {
PicturesRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<List<PictureEntity>> getPictures({required String userId}) async {
Future<List<PictureEntity>> getPictures({required String deviceId}) async {
/*try {
final response = await _repository.get<Map<String, dynamic>>(
'',
'/devices/identificator/$deviceId/photos',
);
final data = response.data;
@@ -28,7 +30,7 @@ class FunctionsRemoteDatasourceImpl implements FunctionsRemoteDatasource {
}
@override
Future<PictureEntity> takePicture({required String userId}) async {
Future<PictureEntity> takePicture({required String deviceId}) async {
/*try {
final response = await _repository.get<Map<String, dynamic>>(
'',

View File

@@ -1,21 +0,0 @@
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
class FunctionsRepositoryImpl implements FunctionsRepository {
const FunctionsRepositoryImpl(this._remote);
final FunctionsRemoteDatasource _remote;
@override
Future<List<PictureEntity>> getPictures({required String userId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.getPictures(userId: userId);
}
@override
Future<PictureEntity> takePicture({required String userId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.takePicture(userId: userId);
}
}

View File

@@ -0,0 +1,22 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import '../../domain/repositories/pictures_repository.dart';
import '../datasources/pictures_remote_datasource.dart';
class PicturesRepositoryImpl implements PicturesRepository {
const PicturesRepositoryImpl(this._remote);
final PicturesRemoteDatasource _remote;
@override
Future<List<PictureEntity>> getPictures({required String deviceId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.getPictures(deviceId: deviceId);
}
@override
Future<PictureEntity> takePicture({required String deviceId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.takePicture(deviceId: deviceId);
}
}

View File

@@ -1,7 +0,0 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class FunctionsRepository {
Future<List<PictureEntity>> getPictures({required String userId});
Future<PictureEntity> takePicture({required String userId});
}

View File

@@ -0,0 +1,7 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class PicturesRepository {
Future<List<PictureEntity>> getPictures({required String deviceId});
Future<PictureEntity> takePicture({required String deviceId});
}

View File

@@ -1,9 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
import 'package:device_management/src/core/data/datasources/functions_remote_datasource_impl.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
final functionsRemoteDatasourceProvider = Provider<FunctionsRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return FunctionsRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -1,9 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/core/providers/functions_remote_datasource_provider.dart';
import 'package:device_management/src/core/data/repositories/functions_repository_impl.dart';
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
final functionsRepositoryProvider = Provider<FunctionsRepository>((ref) {
final remote = ref.read(functionsRemoteDatasourceProvider);
return FunctionsRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasources/pictures_remote_datasource.dart';
import '../data/datasources/pictures_remote_datasource_impl.dart';
final picturesRemoteDatasourceProvider = Provider<PicturesRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return PicturesRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/pictures_repository_impl.dart';
import '../domain/repositories/pictures_repository.dart';
import 'pictures_remote_datasource_provider.dart';
final picturesRepositoryProvider = Provider<PicturesRepository>((ref) {
final remote = ref.read(picturesRemoteDatasourceProvider);
return PicturesRepositoryImpl(remote);
});

View File

@@ -27,14 +27,14 @@ class DeviceManagementScreen extends ConsumerWidget {
),
child: Column(
children: [
// AppMenuButton(
// color: theme.getColorFor(ThemeCode.legacyPrimary),
// onPressed: () =>
// navigationContract.pushTo(AppRoutes.remoteConnection),
// icon: SFIcons.connection,
// text: context.translate(I18n.remoteConnection),
// ),
// SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () =>
navigationContract.pushTo(AppRoutes.remoteConnection),
icon: SFIcons.connection,
text: context.translate(I18n.remoteConnection),
),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () =>

View File

@@ -1,5 +0,0 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class GetPicturesUseCase {
Future<List<PictureEntity>> getPictures({required String userId});
}

View File

@@ -1,44 +0,0 @@
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:device_management/src/features/remote_connection/domain/get_pictures_use_case.dart';
class GetPicturesUseCaseImpl implements GetPicturesUseCase {
GetPicturesUseCaseImpl(this._repository);
final FunctionsRepository _repository;
@override
Future<List<PictureEntity>> getPictures({required String userId}) async {
// return _repository.getPictures(userId: userId);
return [
PictureEntity(
id: '1',
deviceId: '1111',
createdAt: DateTime.now(),
asset: 'assets/shared/images/iso_sf.png',
takenAt: DateTime.now(),
),
PictureEntity(
id: '2',
deviceId: '1111',
createdAt: DateTime.now(),
asset: 'assets/shared/images/iso_sf.png',
takenAt: DateTime.now(),
),
PictureEntity(
id: '3',
deviceId: '1111',
createdAt: DateTime.now(),
asset: 'assets/shared/images/iso_sf.png',
takenAt: DateTime.now(),
),
PictureEntity(
id: '4',
deviceId: '1111',
createdAt: DateTime.now(),
asset: 'assets/shared/images/iso_sf.png',
takenAt: DateTime.now(),
),
];
}
}

View File

@@ -1,5 +0,0 @@
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
abstract class TakePictureUseCase {
Future<PictureEntity> takePicture({required String userId});
}

View File

@@ -1,14 +0,0 @@
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:device_management/src/features/remote_connection/domain/take_picture_use_case.dart';
class TakePictureUseCaseImpl implements TakePictureUseCase {
TakePictureUseCaseImpl(this._repository);
final FunctionsRepository _repository;
@override
Future<PictureEntity> takePicture({required String userId}) {
return _repository.takePicture(userId: userId);
}
}

View File

@@ -1,9 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/core/providers/functions_repository_provider.dart';
import 'package:device_management/src/features/remote_connection/domain/get_pictures_use_case.dart';
import 'package:device_management/src/features/remote_connection/domain/get_pictures_use_case_impl.dart';
final getPicturesUseCaseProvider = Provider.autoDispose<GetPicturesUseCase>((ref) {
final functionsRepository = ref.read(functionsRepositoryProvider);
return GetPicturesUseCaseImpl(functionsRepository);
});

View File

@@ -1,9 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/core/providers/functions_repository_provider.dart';
import 'package:device_management/src/features/remote_connection/domain/take_picture_use_case.dart';
import 'package:device_management/src/features/remote_connection/domain/take_picture_use_case_impl.dart';
final takePictureUseCaseProvider = Provider.autoDispose<TakePictureUseCase>((ref) {
final functionsRepository = ref.read(functionsRepositoryProvider);
return TakePictureUseCaseImpl(functionsRepository);
});

View File

@@ -15,16 +15,30 @@ class RemoteCameraScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
ref.listen(
remoteConnectionViewModelProvider.select((s) => s.successMessage),
(_, successMessage) {
if (successMessage.isNotEmpty) {
showTopSnackbar(context, message: context.translate(successMessage), type: MessageType.success);
ref.read(remoteConnectionViewModelProvider.notifier).clearSuccess();
}
},
);
final theme = ref.watch(themePortProvider);
final isLoadingPictures = ref.watch(
remoteConnectionViewModelProvider.select((s)=>s.isLoadingPictures)
remoteConnectionViewModelProvider.select((s)=>s.isLoadingPictures)
);
final isTakingPicture = ref.watch(
remoteConnectionViewModelProvider.select((s)=>s.isTakingPicture)
);
return LegacyPageLayout(
theme: theme,
title: context.translate(I18n.remoteCamera),
body: Expanded(child: isLoadingPictures
body: Expanded(child: isLoadingPictures || isTakingPicture
? const Center(child: CircularProgressIndicator())
: const _GallerySection()
),
@@ -103,24 +117,7 @@ class _TakePictureSection extends ConsumerWidget {
big: EdgeInsets.symmetric(vertical: 10, horizontal: 25)
),
child: PrimaryButton(
onPressed: () async {
showDialog(context: context, builder: (context)=>Dialog(
child: Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
),
width: SizeUtils.getByScreen(small: 360, big: 350),
height: SizeUtils.getByScreen(small: 195, big: 185),
child: Center(child: Text(context.translate(I18n.loadingPhoto),
textAlign: TextAlign.center,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 26, big: 25)),
)),
),
));
await vm.takePicture();
Navigator.pop(context);
},
onPressed: vm.takePicture,
text: context.translate(I18n.takePicture),
color: theme.getColorFor(ThemeCode.legacyPrimary),
height: SizeUtils.getByScreen(small: 36, big: 35),

View File

@@ -1,13 +1,12 @@
import 'package:device_management/src/core/providers/pictures_repository_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:device_management/src/features/remote_connection/domain/get_pictures_use_case.dart';
import 'package:device_management/src/features/remote_connection/domain/take_picture_use_case.dart';
import 'package:device_management/src/features/remote_connection/presentation/providers/get_pictures_use_case_provider.dart';
import 'package:device_management/src/features/remote_connection/presentation/providers/take_picture_use_case_provider.dart';
import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_state.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:sf_localizations/sf_localizations.dart';
import '../../../../core/domain/repositories/pictures_repository.dart';
final remoteConnectionViewModelProvider =
NotifierProvider.autoDispose<RemoteConnectionViewModel, RemoteConnectionViewState>(
@@ -15,17 +14,17 @@ NotifierProvider.autoDispose<RemoteConnectionViewModel, RemoteConnectionViewStat
);
class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
late final GetPicturesUseCase _getPicturesUseCase;
late final TakePictureUseCase _takePictureUseCase;
late final TextEditingController phoneController;
late final CommandsRepository _commandsRepository;
late final PicturesRepository _picturesRepository;
static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$');
@override
RemoteConnectionViewState build() {
_getPicturesUseCase = ref.read(getPicturesUseCaseProvider);
_takePictureUseCase = ref.read(takePictureUseCaseProvider);
_commandsRepository = ref.read(commandsRepositoryProvider);
_picturesRepository = ref.read(picturesRepositoryProvider);
phoneController = TextEditingController();
phoneController.addListener(_onPhoneChanged);
@@ -38,13 +37,11 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
}
Future<void> load() async {
final user = await ref.read(userInfoProvider.future);
final device = ref.read(selectedDeviceProvider);
if (device == null) return;
final pictures = await _getPicturesUseCase.getPictures(userId: user.id);
setImages(pictures);
}
final pictures = await _picturesRepository.getPictures(deviceId: device.identificator);
void setImages(List<PictureEntity> pictures) {
state = state.copyWith(
pictures: pictures,
isLoadingPictures: false,
@@ -84,18 +81,30 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
);
}
void clearSuccess() {
state = state.copyWith(
successMessage: '',
);
}
Future<void> takePicture() async {
try {
state = state.copyWith(isTakingPicture: true);
state = state.copyWith(
isTakingPicture: true,
successMessage: '',
);
final request = SendCommandRequestModel(
device: state.deviceId,
command: DeviceCommand.requestPhoto,
);
await _takePictureUseCase.takePicture(userId: '')
.then((picture) {
List<PictureEntity> pictures = state.pictures;
pictures.add(picture);
state = state.copyWith(
isTakingPicture: true,
);
});
await _commandsRepository.send(request: request);
state = state.copyWith(
isTakingPicture: false,
successMessage: I18n.photoTaken
);
} catch (e){
state = state.copyWith(
isTakingPicture: false,
@@ -106,6 +115,7 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
Future<void> call() async {
final phone = phoneController.text;
final dialCode = state.dialCode;
if (phone.isEmpty){
state = state.copyWith(errorMessage: 'errorMessagePhoneIsEmpty');
return;
@@ -114,6 +124,29 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
state = state.copyWith(errorMessage: 'errorMessagePhoneIsInvalid');
return;
}
try {
state = state.copyWith(
isCalling: true,
);
final fullPhone = dialCode + phone;
final request = SendCommandRequestModel(
device: state.deviceId,
command: DeviceCommand.callCenter,
data: {
'phone_number': fullPhone,
}
);
_commandsRepository.send(request: request);
} catch (e) {
state = state.copyWith(
isCalling: false,
errorMessage: e.toString(),
);
}
}
void disposeControllers() {

View File

@@ -6,12 +6,15 @@ part 'remote_connection_view_state.freezed.dart';
@freezed
abstract class RemoteConnectionViewState with _$RemoteConnectionViewState {
const factory RemoteConnectionViewState({
@Default('') String deviceId,
@Default('+34') String dialCode,
@Default('') String phone,
@Default([]) List<PictureEntity> pictures,
@Default(0) int pictureIndex,
@Default(true) bool isLoadingPictures,
@Default(false) bool isTakingPicture,
@Default(false) bool isCalling,
@Default('') String errorMessage
@Default('') String errorMessage,
@Default('') String successMessage
}) = _RemoteConnectionViewState;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$RemoteConnectionViewState {
String get phone; List<PictureEntity> get pictures; int get pictureIndex; bool get isLoadingPictures; bool get isTakingPicture; bool get isCalling; String get errorMessage;
String get deviceId; String get dialCode; String get phone; List<PictureEntity> get pictures; int get pictureIndex; bool get isLoadingPictures; bool get isTakingPicture; bool get isCalling; String get errorMessage; String get successMessage;
/// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $RemoteConnectionViewStateCopyWith<RemoteConnectionViewState> get copyWith => _$
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RemoteConnectionViewState&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other.pictures, pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other.pictures, pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage));
}
@override
int get hashCode => Object.hash(runtimeType,phone,const DeepCollectionEquality().hash(pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage);
int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage,successMessage);
@override
String toString() {
return 'RemoteConnectionViewState(phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage)';
return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage, successMessage: $successMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $RemoteConnectionViewStateCopyWith<$Res> {
factory $RemoteConnectionViewStateCopyWith(RemoteConnectionViewState value, $Res Function(RemoteConnectionViewState) _then) = _$RemoteConnectionViewStateCopyWithImpl;
@useResult
$Res call({
String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage
String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage
});
@@ -62,15 +62,18 @@ class _$RemoteConnectionViewStateCopyWithImpl<$Res>
/// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,Object? successMessage = null,}) {
return _then(_self.copyWith(
phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,pictures: null == pictures ? _self.pictures : pictures // ignore: cast_nullable_to_non_nullable
as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable
as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable
as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable
as bool,isCalling: null == isCalling ? _self.isCalling : isCalling // 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,
));
}
@@ -156,10 +159,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _RemoteConnectionViewState() when $default != null:
return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage);case _:
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _:
return orElse();
}
@@ -177,10 +180,10 @@ return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPic
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage) $default,) {final _that = this;
switch (_that) {
case _RemoteConnectionViewState():
return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage);case _:
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -197,10 +200,10 @@ return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPic
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage)? $default,) {final _that = this;
switch (_that) {
case _RemoteConnectionViewState() when $default != null:
return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage);case _:
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _:
return null;
}
@@ -212,9 +215,11 @@ return $default(_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPic
class _RemoteConnectionViewState implements RemoteConnectionViewState {
const _RemoteConnectionViewState({this.phone = '', final List<PictureEntity> pictures = const [], this.pictureIndex = 0, this.isLoadingPictures = true, this.isTakingPicture = false, this.isCalling = false, this.errorMessage = ''}): _pictures = pictures;
const _RemoteConnectionViewState({this.deviceId = '', this.dialCode = '+34', this.phone = '', final List<PictureEntity> pictures = const [], this.pictureIndex = 0, this.isLoadingPictures = true, this.isTakingPicture = false, this.isCalling = false, this.errorMessage = '', this.successMessage = ''}): _pictures = pictures;
@override@JsonKey() final String deviceId;
@override@JsonKey() final String dialCode;
@override@JsonKey() final String phone;
final List<PictureEntity> _pictures;
@override@JsonKey() List<PictureEntity> get pictures {
@@ -228,6 +233,7 @@ class _RemoteConnectionViewState implements RemoteConnectionViewState {
@override@JsonKey() final bool isTakingPicture;
@override@JsonKey() final bool isCalling;
@override@JsonKey() final String errorMessage;
@override@JsonKey() final String successMessage;
/// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values.
@@ -239,16 +245,16 @@ _$RemoteConnectionViewStateCopyWith<_RemoteConnectionViewState> get copyWith =>
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RemoteConnectionViewState&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other._pictures, _pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other._pictures, _pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage));
}
@override
int get hashCode => Object.hash(runtimeType,phone,const DeepCollectionEquality().hash(_pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage);
int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(_pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage,successMessage);
@override
String toString() {
return 'RemoteConnectionViewState(phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage)';
return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage, successMessage: $successMessage)';
}
@@ -259,7 +265,7 @@ abstract mixin class _$RemoteConnectionViewStateCopyWith<$Res> implements $Remot
factory _$RemoteConnectionViewStateCopyWith(_RemoteConnectionViewState value, $Res Function(_RemoteConnectionViewState) _then) = __$RemoteConnectionViewStateCopyWithImpl;
@override @useResult
$Res call({
String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage
String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage
});
@@ -276,15 +282,18 @@ class __$RemoteConnectionViewStateCopyWithImpl<$Res>
/// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,Object? successMessage = null,}) {
return _then(_RemoteConnectionViewState(
phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,pictures: null == pictures ? _self._pictures : pictures // ignore: cast_nullable_to_non_nullable
as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable
as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable
as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable
as bool,isCalling: null == isCalling ? _self.isCalling : isCalling // 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,
));
}

View File

@@ -8,6 +8,9 @@ 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;
@@ -54,7 +57,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 12, left: 8, right: 8),
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 4, big: 12), left: 8, right: 8),
child: Row(
children: [
if (isIntro)
@@ -114,6 +117,9 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
}
return;
}
if (state.step == LegacyAddKidStep.scanWatch) {
showActivationCodeDialog(context);
}
await vm.next();
},
theme: theme,

View File

@@ -3,6 +3,7 @@ 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});
@@ -11,29 +12,34 @@ class LegacyIntroStepScreen extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
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),
),
],
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),
),
],
),
);
}
}

View File

@@ -3,6 +3,7 @@ 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});
@@ -13,7 +14,7 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 30)),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 65),
child: Text(

View File

@@ -147,7 +147,7 @@ class LegacyProfileStepScreen extends ConsumerWidget {
CustomTextField(
label: context.translate(I18n.activationKeyLabel),
hint: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
hint: 'XXXXXXXX',
controller: vm.activationKeyController,
),

View File

@@ -0,0 +1,33 @@
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)),
),
);
}
}

View File

@@ -3,6 +3,7 @@ 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({
@@ -88,6 +89,7 @@ class LegacyTwoFactorBottomSheetView extends StatelessWidget {
if (isOtpLoading || !_isValidOtp) return;
unawaited(onVerify());
},
gap: SizeUtils.getByScreen(small: 10, big: 8),
),
const SizedBox(height: 20),

View File

@@ -4,10 +4,14 @@ part 'send_command_request_model.freezed.dart';
part 'send_command_request_model.g.dart';
enum DeviceCommand {
@JsonValue('CALL_CENTER')
callCenter,
@JsonValue('FACTORY')
factory,
@JsonValue('FIND_DEVICE')
findDevice,
@JsonValue('REQUEST_PHOTO')
requestPhoto,
@JsonValue('RESTART')
restart,
@JsonValue('REWARDS')

View File

@@ -23,8 +23,10 @@ Map<String, dynamic> _$SendCommandRequestModelToJson(
};
const _$DeviceCommandEnumMap = {
DeviceCommand.callCenter: 'CALL_CENTER',
DeviceCommand.factory: 'FACTORY',
DeviceCommand.findDevice: 'FIND_DEVICE',
DeviceCommand.requestPhoto: 'REQUEST_PHOTO',
DeviceCommand.restart: 'RESTART',
DeviceCommand.rewards: 'REWARDS',
DeviceCommand.shutdown: 'SHUTDOWN',

View File

@@ -298,11 +298,13 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
try {
final treezorRepo = ref.read(treezorRepositoryProvider);
final beneficiaryValidationId = await treezorRepo
final validation = 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,

View File

@@ -70,7 +70,7 @@ class _SplashScreenState extends State<SplashScreen>
controller: _controller,
onLoaded: (composition) {
_controller
..duration = composition.duration
..duration = composition.duration * 0.8
..forward();
},
),

View File

@@ -7,6 +7,6 @@
<versions>
<version>2.6.4</version>
</versions>
<lastUpdated>20260316000000</lastUpdated>
<lastUpdated>20260320000000</lastUpdated>
</versioning>
</metadata>

View File

@@ -1 +1 @@
a0ed8b315dd3aaa92839422686f00f9d
20c099fa5d73eb3667d91872fabb23b6

View File

@@ -1 +1 @@
4888c373e3701bd965ce8ff0daaa19071f7d9a9e
67c2ba6eea196d22403b194e8407fcca966416f6

View File

@@ -16,16 +16,19 @@ 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);

View File

@@ -582,7 +582,7 @@
"deviceSetup_weightHint": "30",
"deviceSetup_heightLabel": "Height (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Activation key",
"activationKeyLabel": "Activation key (check your email)",
"rewardsMessage": "*Using this feature you can reward your child for goals achieved or good actions.",
"sendRewards": "Send rewards!",
"rewardsSent": "Rewards sent!",
@@ -705,5 +705,7 @@
"wifiBssidHint": "e.g. 0c:80:63:e4:cb:e1",
"editChildProfile": "Edit profile",
"editChildProfileSaveSuccess": "Child profile updated successfully",
"editChildProfileTitle": "Edit child profile"
"editChildProfileTitle": "Edit child profile",
"activationCodeMessage": "An activation key has been sent to your email",
"photoTaken": "Photo taken successfully"
}

View File

@@ -580,7 +580,7 @@
"deviceSetup_weightHint": "30",
"deviceSetup_heightLabel": "Altura (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Clave de activación",
"activationKeyLabel": "Clave de activación (consulta tu correo electrónico)",
"rewardsMessage": "*Usando esta función puedes recompensar a tu hijo por metas alcanzadas o buenas acciones.",
"sendRewards": "¡Enviar recompensas!",
"rewardsSent": "¡Recompensas enviadas!",
@@ -703,5 +703,7 @@
"wifiBssidHint": "ej. 0c:80:63:e4:cb:e1",
"editChildProfile": "Editar perfil",
"editChildProfileTitle": "Editar perfil del niño",
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente"
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente",
"activationCodeMessage": "Se ha enviado un código de activación a tu correo electrónico",
"photoTaken": "Foto tomada exitosamente"
}

View File

@@ -829,4 +829,6 @@ 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 photoTaken = 'photoTaken';
}

View File

@@ -29,6 +29,7 @@ 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';

View File

@@ -3,6 +3,7 @@ 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';
@@ -41,7 +42,7 @@ abstract class TreezorRemoteDatasource {
required String scaProof,
});
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({required int beneficiaryId});
Future<void> walletTransfer({
required int beneficiaryId,

View File

@@ -7,6 +7,7 @@ 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';
@@ -241,7 +242,7 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
}
@override
Future<String> validateTransactionBeneficiary({
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({
required int beneficiaryId,
}) async {
try {
@@ -254,7 +255,9 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
'Invalid response from /transaction-beneficiaries/$beneficiaryId/validation',
);
}
return data['item'] as String;
return BeneficiaryValidationResponseModel.fromJson(
Map<String, dynamic>.from(data),
);
} on DioException catch (error) {
throw _mapDioError(
error,

View File

@@ -0,0 +1,54 @@
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);
}

View File

@@ -0,0 +1,860 @@
// 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

View File

@@ -0,0 +1,56 @@
// 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,
};

View File

@@ -14,6 +14,7 @@ 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';
@@ -185,12 +186,13 @@ class TreezorRepositoryImpl implements TreezorRepository {
}
@override
Future<String> validateTransactionBeneficiary({
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({
required int beneficiaryId,
}) async {
return _remote.validateTransactionBeneficiary(
final model = await _remote.validateTransactionBeneficiary(
beneficiaryId: beneficiaryId,
);
return model.toEntity();
}
@override

View File

@@ -0,0 +1,14 @@
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;
}

View File

@@ -0,0 +1,280 @@
// 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

View File

@@ -3,6 +3,7 @@ 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';
@@ -47,7 +48,7 @@ abstract class TreezorRepository {
required String scaProof,
});
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({required int beneficiaryId});
Future<void> walletTransfer({
required int beneficiaryId,