Merge commit '014ef1ad2615fe2981f18ed28adcde17edda4f1e' into fusion-app
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# melos_managed_dependency_overrides: design_system,flutter_treezor_entrust_sdk_bridge,fonts,sca_treezor,sf_infrastructure,sf_shared,utils,sf_localizations
|
||||
# melos_managed_dependency_overrides: design_system,flutter_treezor_entrust_sdk_bridge,fonts,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,utils
|
||||
dependency_overrides:
|
||||
design_system:
|
||||
path: ../../packages/design_system
|
||||
|
||||
@@ -14,17 +14,17 @@ class OnboardingPage {
|
||||
|
||||
const List<OnboardingPage> onboardingPages = <OnboardingPage>[
|
||||
OnboardingPage(
|
||||
image: 'assets/shared/images/bienvenida_paso1.svg',
|
||||
image: 'assets/shared/images/real_time_device_location.svg',
|
||||
title: I18n.onboardingTitle1,
|
||||
subtitle: I18n.onboardingSubtitle1,
|
||||
),
|
||||
OnboardingPage(
|
||||
image: 'assets/shared/images/bienvenida_paso2.svg',
|
||||
image: 'assets/shared/images/safety_zone.svg',
|
||||
title: I18n.onboardingTitle2,
|
||||
subtitle: I18n.onboardingSubtitle2,
|
||||
),
|
||||
OnboardingPage(
|
||||
image: 'assets/shared/images/bienvenida_paso3.svg',
|
||||
image: 'assets/shared/images/chat.svg',
|
||||
title: I18n.onboardingTitle3,
|
||||
subtitle: I18n.onboardingSubtitle3,
|
||||
),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:design_system/design_system.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fonts/fonts.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
@@ -41,7 +42,7 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Color.fromRGBO(247, 247, 247, 1),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
@@ -64,7 +65,7 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
StepIndicator(
|
||||
current: state.cardIndex + 1,
|
||||
total: onboardingPages.length,
|
||||
color: const Color(0xFF4A4A4A),
|
||||
color: Color.fromRGBO(88, 142, 165, 1),
|
||||
),
|
||||
const SizedBox(height: 38),
|
||||
Container(
|
||||
@@ -74,24 +75,30 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
onPressed: goToNext,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: isLast
|
||||
? const Color(0xFF329E95)
|
||||
: const Color(0xFF333333),
|
||||
foregroundColor: Colors.white,
|
||||
? const Color.fromRGBO(88, 142, 165, 1)
|
||||
: const Color.fromRGBO(255, 255, 255, 1),
|
||||
foregroundColor: isLast
|
||||
? const Color.fromRGBO(255, 255, 255, 1)
|
||||
: const Color.fromRGBO(88, 142, 165, 1),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 16,
|
||||
horizontal: 24,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
side: const BorderSide(
|
||||
color: Color.fromRGBO(88, 142, 165, 1),
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
isLast
|
||||
? context.translate(I18n.start)
|
||||
: context.translate(I18n.next),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
style: AppFonts.stolzlStyle(
|
||||
size: 18,
|
||||
weight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -107,11 +114,11 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
navigationContract.goTo(AppRoutes.login),
|
||||
child: Text(
|
||||
context.translate(I18n.skip),
|
||||
style: TextStyle(
|
||||
color: Color(0xFF333333),
|
||||
style: AppFonts.stolzlStyle(
|
||||
color: Color.fromRGBO(88, 142, 165, 1),
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
weight: FontWeight.w600,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:fonts/fonts.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class OnboardingContent extends StatelessWidget {
|
||||
@@ -21,28 +22,35 @@ class OnboardingContent extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(flex: 3, child: SvgPicture.asset(image)),
|
||||
SvgPicture.asset(image, height: 250),
|
||||
const SizedBox(height: 48),
|
||||
Text(
|
||||
context.translate(title),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 28,
|
||||
style: AppFonts.stolzlStyle(
|
||||
size: 28,
|
||||
weight: FontWeight.w700,
|
||||
color: const Color(0xFF4A4A4A),
|
||||
height: 1.4,
|
||||
letterSpacing: 0.3,
|
||||
color: Color(0xFF4A4A4A),
|
||||
),
|
||||
// style: const TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// fontSize: 28,
|
||||
// height: 1.4,
|
||||
// letterSpacing: 0.3,
|
||||
// color: Color(0xFF4A4A4A),
|
||||
// ),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
context.translate(subtitle),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
style: AppFonts.stolzlStyle(
|
||||
size: 18,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.3,
|
||||
color: Color(0xFF9B9B9B),
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -80,7 +80,7 @@ class AccountCreatedScreen extends ConsumerWidget {
|
||||
PrimaryButton(
|
||||
onPressed: () => navigationContract.goTo(AppRoutes.login),
|
||||
text: context.translate(I18n.accountCreatedContinue),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
color: Color.fromRGBO(88, 142, 165, 1),
|
||||
),
|
||||
const Spacer(flex: 8),
|
||||
],
|
||||
|
||||
@@ -90,7 +90,7 @@ class SignUpLayout extends StatelessWidget {
|
||||
onPressed: onNextPressed,
|
||||
text: "Siguiente",
|
||||
size: 16,
|
||||
color: theme.getColorFor(ThemeCode.buttonSecondary),
|
||||
color: Color.fromRGBO(88, 142, 165, 1),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -13,8 +13,8 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
#modules dependencies go here
|
||||
dashboard_shell:
|
||||
path: ../../modules/dashboard_shell
|
||||
home:
|
||||
path: ../../modules/home
|
||||
#packages dependencies go here
|
||||
design_system:
|
||||
path: ../../packages/design_system
|
||||
@@ -32,6 +32,8 @@ dependencies:
|
||||
path: ../../packages/sca_treezor
|
||||
payments:
|
||||
path: ../../packages/payments
|
||||
fonts:
|
||||
path: ../../packages/fonts
|
||||
#dependencies go here
|
||||
flutter_svg: ^2.2.1
|
||||
get_it: ^9.0.5
|
||||
@@ -51,6 +53,8 @@ dependencies:
|
||||
shared_preferences: ^2.5.4
|
||||
l10n_countries: ^1.3.1
|
||||
sealed_countries: ^2.8.0
|
||||
flutter_map: ^8.2.2
|
||||
latlong2: ^0.9.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# melos_managed_dependency_overrides: dashboard_shell,design_system,home,notifications,profile,sf_shared,navigation,utils,sf_localizations,fonts,sf_infrastructure,flutter_treezor_entrust_sdk_bridge,sca_treezor,payments,activity
|
||||
dependency_overrides:
|
||||
activity:
|
||||
path: ../activity
|
||||
dashboard_shell:
|
||||
path: ../dashboard_shell
|
||||
design_system:
|
||||
path: ../../packages/design_system
|
||||
flutter_treezor_entrust_sdk_bridge:
|
||||
path: ../../packages/flutter_treezor_entrust_sdk_bridge
|
||||
fonts:
|
||||
path: ../../packages/fonts
|
||||
home:
|
||||
path: ../home
|
||||
navigation:
|
||||
path: ../../packages/navigation
|
||||
notifications:
|
||||
path: ../notifications
|
||||
payments:
|
||||
path: ../../packages/payments
|
||||
profile:
|
||||
path: ../profile
|
||||
sca_treezor:
|
||||
path: ../../packages/sca_treezor
|
||||
sf_infrastructure:
|
||||
path: ../../packages/sf_infrastructure
|
||||
sf_localizations:
|
||||
path: ../../packages/sf_localizations
|
||||
sf_shared:
|
||||
path: ../../packages/sf_shared
|
||||
utils:
|
||||
path: ../../packages/utils
|
||||
@@ -1,32 +0,0 @@
|
||||
# melos_managed_dependency_overrides: auth,design_system,home,notifications,profile,sf_shared,navigation,utils,sf_localizations,fonts,sf_infrastructure,flutter_treezor_entrust_sdk_bridge,sca_treezor,payments,activity
|
||||
dependency_overrides:
|
||||
activity:
|
||||
path: ../activity
|
||||
auth:
|
||||
path: ../auth
|
||||
design_system:
|
||||
path: ../../packages/design_system
|
||||
flutter_treezor_entrust_sdk_bridge:
|
||||
path: ../../packages/flutter_treezor_entrust_sdk_bridge
|
||||
fonts:
|
||||
path: ../../packages/fonts
|
||||
home:
|
||||
path: ../home
|
||||
navigation:
|
||||
path: ../../packages/navigation
|
||||
notifications:
|
||||
path: ../notifications
|
||||
payments:
|
||||
path: ../../packages/payments
|
||||
profile:
|
||||
path: ../profile
|
||||
sca_treezor:
|
||||
path: ../../packages/sca_treezor
|
||||
sf_infrastructure:
|
||||
path: ../../packages/sf_infrastructure
|
||||
sf_localizations:
|
||||
path: ../../packages/sf_localizations
|
||||
sf_shared:
|
||||
path: ../../packages/sf_shared
|
||||
utils:
|
||||
path: ../../packages/utils
|
||||
@@ -1,11 +1,9 @@
|
||||
# melos_managed_dependency_overrides: auth,dashboard_shell,design_system,notifications,profile,sf_shared,navigation,utils,sf_localizations,fonts,sf_infrastructure,flutter_treezor_entrust_sdk_bridge,sca_treezor,payments,activity
|
||||
# melos_managed_dependency_overrides: activity,auth,design_system,flutter_treezor_entrust_sdk_bridge,fonts,navigation,notifications,payments,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,utils
|
||||
dependency_overrides:
|
||||
activity:
|
||||
path: ../activity
|
||||
auth:
|
||||
path: ../auth
|
||||
dashboard_shell:
|
||||
path: ../dashboard_shell
|
||||
design_system:
|
||||
path: ../../packages/design_system
|
||||
flutter_treezor_entrust_sdk_bridge:
|
||||
@@ -18,8 +16,6 @@ dependency_overrides:
|
||||
path: ../notifications
|
||||
payments:
|
||||
path: ../../packages/payments
|
||||
profile:
|
||||
path: ../profile
|
||||
sca_treezor:
|
||||
path: ../../packages/sca_treezor
|
||||
sf_infrastructure:
|
||||
|
||||
48
modules/legacy/.gitignore
vendored
Normal file
48
modules/legacy/.gitignore
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.pub/
|
||||
|
||||
.idea/
|
||||
.vagrant/
|
||||
.sconsign.dblite
|
||||
.svn/
|
||||
|
||||
migrate_working_dir/
|
||||
|
||||
*.swp
|
||||
profile
|
||||
|
||||
DerivedData/
|
||||
|
||||
.generated/
|
||||
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
|
||||
xcuserdata
|
||||
|
||||
*.moved-aside
|
||||
|
||||
*.pyc
|
||||
*sync/
|
||||
Icon?
|
||||
.tags*
|
||||
|
||||
build/
|
||||
.android/
|
||||
.ios/
|
||||
.flutter-plugins-dependencies
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
10
modules/legacy/.metadata
Normal file
10
modules/legacy/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "9f455d2486bcb28cad87b062475f42edc959f636"
|
||||
channel: "stable"
|
||||
|
||||
project_type: module
|
||||
11
modules/legacy/README.md
Normal file
11
modules/legacy/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# legacy
|
||||
|
||||
A new Flutter project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For help getting started with Flutter development, view the online
|
||||
[documentation](https://flutter.dev/).
|
||||
|
||||
For instructions integrating Flutter modules to your existing applications,
|
||||
see the [add-to-app documentation](https://flutter.dev/to/add-to-app).
|
||||
4
modules/legacy/analysis_options.yaml
Normal file
4
modules/legacy/analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
14
modules/legacy/legacy.iml
Normal file
14
modules/legacy/legacy.iml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
38
modules/legacy/melos_legacy.iml
Normal file
38
modules/legacy/melos_legacy.iml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/android/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/android/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/ios/Flutter" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/ios/Pods" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/ios/.symlinks" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/macos/Flutter" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/macos/Pods" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/macos/.symlinks" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/customer_service/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/customer_service/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/customer_service/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/account/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/account/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/account/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/functions/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/functions/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/functions/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_shared/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_shared/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_shared/build" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
<orderEntry type="library" name="Flutter Plugins" level="project" />
|
||||
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
8
modules/legacy/modules/account/lib/account.dart
Normal file
8
modules/legacy/modules/account/lib/account.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
library account;
|
||||
|
||||
export 'src/features/account_settings/account_settings_builder.dart';
|
||||
export 'src/features/personal_data/personal_data_builder.dart';
|
||||
export 'src/features/change_password/change_password_builder.dart';
|
||||
export 'src/features/linked_devices/linked_devices_builder.dart';
|
||||
export 'src/features/app_users/app_users_builder.dart';
|
||||
export 'src/features/delete_account/delete_account_builder.dart';
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
abstract class AccountRemoteDatasource {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request});
|
||||
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
|
||||
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
|
||||
Future<void> deleteAppUser({required String userId});
|
||||
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request});
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
|
||||
import 'package:account/src/core/data/models/change_password_request_model.dart';
|
||||
import 'package:account/src/core/data/models/get_app_users_response_model.dart';
|
||||
import 'package:account/src/core/data/models/get_linked_devices_response_model.dart';
|
||||
import 'package:account/src/core/data/models/update_device_request_model.dart';
|
||||
import 'package:account/src/core/data/models/update_user_request_model.dart';
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
|
||||
AccountRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) async {
|
||||
try {
|
||||
/*final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/$userId/devices',
|
||||
);
|
||||
final data = response.data!['items'];
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /:userId/devices');
|
||||
}
|
||||
|
||||
final model = GetLinkedDevicesResponseModel.fromJson(data);*/
|
||||
final model = GetLinkedDevicesResponseModel(items: [
|
||||
GetLinkedDevicesItemResponseModel(
|
||||
identificator: '1111',
|
||||
carrierName: 'Carlos',
|
||||
phone: '111111111',
|
||||
id: '',
|
||||
settings: GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: 0,
|
||||
frequencyHeartRate: 0,
|
||||
timezone: 0,
|
||||
pedometer: false,
|
||||
language: 'language',
|
||||
alerts: [],
|
||||
),
|
||||
protocol: '',
|
||||
type: '',
|
||||
connectionServer: '',
|
||||
createdAt: 0,
|
||||
flags: GetLinkedDevicesFlagsResponseModel(
|
||||
isInOrOut: 'isInOrOut',
|
||||
geofenceId: 'geofenceId',
|
||||
isBatteryLow: false,
|
||||
isDisconnect: false,
|
||||
)
|
||||
),
|
||||
GetLinkedDevicesItemResponseModel(
|
||||
identificator: '1112',
|
||||
carrierName: 'Ana',
|
||||
phone: '222222222',
|
||||
id: '',
|
||||
settings: GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: 0,
|
||||
frequencyHeartRate: 0,
|
||||
timezone: 0,
|
||||
pedometer: false,
|
||||
language: 'language',
|
||||
alerts: [],
|
||||
),
|
||||
protocol: '',
|
||||
type: '',
|
||||
connectionServer: '',
|
||||
createdAt: 0,
|
||||
flags: GetLinkedDevicesFlagsResponseModel(
|
||||
isInOrOut: 'isInOrOut',
|
||||
geofenceId: 'geofenceId',
|
||||
isBatteryLow: false,
|
||||
isDisconnect: false,
|
||||
)
|
||||
),
|
||||
]);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
|
||||
throw UnimplementedError();
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/users/$userId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update user');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/$userId/devices',
|
||||
);
|
||||
final data = response.data!['items'];
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /:userId/devices');
|
||||
}
|
||||
|
||||
final model = GetAppUsersResponseModel.fromJson(data);
|
||||
/*final model = GetAppUsersResponseModel(items: [
|
||||
GetAppUsersItemResponseModel(
|
||||
id: 'id',
|
||||
delegationId: 'delegationId',
|
||||
email: 'carlos@test.com',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
status: 'status',
|
||||
role: 'role',
|
||||
lastLogin: 'lastLogin',
|
||||
currentLogin: 'currentLogin',
|
||||
language: 'language',
|
||||
firstName: 'Carlos',
|
||||
lastName: 'lastName',
|
||||
hasApiKey: 'hasApiKey',
|
||||
phone: 'phone',),
|
||||
GetAppUsersItemResponseModel(
|
||||
id: 'id',
|
||||
delegationId: 'delegationId',
|
||||
email: 'ana@test.com',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
status: 'status',
|
||||
role: 'role',
|
||||
lastLogin: 'lastLogin',
|
||||
currentLogin: 'currentLogin',
|
||||
language: 'language',
|
||||
firstName: 'Ana',
|
||||
lastName: 'lastName',
|
||||
hasApiKey: 'hasApiKey',
|
||||
phone: 'phone',),
|
||||
]);*/
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAppUser({required String userId}) async {
|
||||
throw UnimplementedError();
|
||||
try {
|
||||
await _repository.delete<void>(
|
||||
'/users/$userId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/auth/change-password',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to change password');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exception _mapDioError(DioException error, {required String defaultMessage}) {
|
||||
final apiMsg = _extractApiMessage(error.response?.data);
|
||||
final msg = apiMsg ?? error.message ?? defaultMessage;
|
||||
return Exception(msg);
|
||||
}
|
||||
|
||||
String? _extractApiMessage(Object? data) {
|
||||
if (data == null) return null;
|
||||
|
||||
if (data is Map) {
|
||||
final errorObj = data['error'];
|
||||
if (errorObj is Map && errorObj['message'] is String) {
|
||||
return (errorObj['message'] as String).trim();
|
||||
}
|
||||
if (data['message'] is String) {
|
||||
return (data['message'] as String).trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data is String) {
|
||||
final raw = data.trim();
|
||||
if (raw.isEmpty) return null;
|
||||
|
||||
try {
|
||||
final decoded = jsonDecode(raw);
|
||||
return _extractApiMessage(decoded);
|
||||
} catch (_) {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'change_password_request_model.freezed.dart';
|
||||
part 'change_password_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ChangePasswordRequestModel with _$ChangePasswordRequestModel {
|
||||
const factory ChangePasswordRequestModel({
|
||||
required String password,
|
||||
}) = _ChangePasswordRequestModel;
|
||||
|
||||
factory ChangePasswordRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChangePasswordRequestModelFromJson(json);
|
||||
}
|
||||
|
||||
extension ChangePasswordRequestModelMapper on ChangePasswordRequestEntity {
|
||||
ChangePasswordRequestModel toModel() => ChangePasswordRequestModel(
|
||||
password: password,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
// 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 'change_password_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ChangePasswordRequestModel {
|
||||
|
||||
String get password;
|
||||
/// Create a copy of ChangePasswordRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChangePasswordRequestModelCopyWith<ChangePasswordRequestModel> get copyWith => _$ChangePasswordRequestModelCopyWithImpl<ChangePasswordRequestModel>(this as ChangePasswordRequestModel, _$identity);
|
||||
|
||||
/// Serializes this ChangePasswordRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordRequestModel&&(identical(other.password, password) || other.password == password));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,password);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordRequestModel(password: $password)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ChangePasswordRequestModelCopyWith<$Res> {
|
||||
factory $ChangePasswordRequestModelCopyWith(ChangePasswordRequestModel value, $Res Function(ChangePasswordRequestModel) _then) = _$ChangePasswordRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String password
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ChangePasswordRequestModelCopyWithImpl<$Res>
|
||||
implements $ChangePasswordRequestModelCopyWith<$Res> {
|
||||
_$ChangePasswordRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ChangePasswordRequestModel _self;
|
||||
final $Res Function(ChangePasswordRequestModel) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? password = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ChangePasswordRequestModel].
|
||||
extension ChangePasswordRequestModelPatterns on ChangePasswordRequestModel {
|
||||
/// 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( _ChangePasswordRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel() 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( _ChangePasswordRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel():
|
||||
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( _ChangePasswordRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel() 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 password)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel() when $default != null:
|
||||
return $default(_that.password);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 password) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel():
|
||||
return $default(_that.password);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 password)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestModel() when $default != null:
|
||||
return $default(_that.password);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _ChangePasswordRequestModel implements ChangePasswordRequestModel {
|
||||
const _ChangePasswordRequestModel({required this.password});
|
||||
factory _ChangePasswordRequestModel.fromJson(Map<String, dynamic> json) => _$ChangePasswordRequestModelFromJson(json);
|
||||
|
||||
@override final String password;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChangePasswordRequestModelCopyWith<_ChangePasswordRequestModel> get copyWith => __$ChangePasswordRequestModelCopyWithImpl<_ChangePasswordRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$ChangePasswordRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordRequestModel&&(identical(other.password, password) || other.password == password));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,password);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordRequestModel(password: $password)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChangePasswordRequestModelCopyWith<$Res> implements $ChangePasswordRequestModelCopyWith<$Res> {
|
||||
factory _$ChangePasswordRequestModelCopyWith(_ChangePasswordRequestModel value, $Res Function(_ChangePasswordRequestModel) _then) = __$ChangePasswordRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String password
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChangePasswordRequestModelCopyWithImpl<$Res>
|
||||
implements _$ChangePasswordRequestModelCopyWith<$Res> {
|
||||
__$ChangePasswordRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ChangePasswordRequestModel _self;
|
||||
final $Res Function(_ChangePasswordRequestModel) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? password = null,}) {
|
||||
return _then(_ChangePasswordRequestModel(
|
||||
password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'change_password_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_ChangePasswordRequestModel _$ChangePasswordRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ChangePasswordRequestModel(password: json['password'] as String);
|
||||
|
||||
Map<String, dynamic> _$ChangePasswordRequestModelToJson(
|
||||
_ChangePasswordRequestModel instance,
|
||||
) => <String, dynamic>{'password': instance.password};
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_app_users_response_model.freezed.dart';
|
||||
part 'get_app_users_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetAppUsersResponseModel with _$GetAppUsersResponseModel {
|
||||
const factory GetAppUsersResponseModel({
|
||||
required List<GetAppUsersItemResponseModel> items,
|
||||
}) = _GetAppUsersResponseModel;
|
||||
|
||||
factory GetAppUsersResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetAppUsersResponseModelFromJson(json);
|
||||
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetAppUsersItemResponseModel with _$GetAppUsersItemResponseModel {
|
||||
const factory GetAppUsersItemResponseModel({
|
||||
required String id,
|
||||
required String delegationId,
|
||||
required String email,
|
||||
required String createdAt,
|
||||
required String updatedAt,
|
||||
required String status,
|
||||
required String role,
|
||||
required String lastLogin,
|
||||
required String currentLogin,
|
||||
required String language,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required String hasApiKey,
|
||||
required String phone
|
||||
}) =
|
||||
_GetAppUsersItemResponseModel;
|
||||
|
||||
factory GetAppUsersItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetAppUsersItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetUsersResponseModelMapper on GetAppUsersResponseModel {
|
||||
List<UserEntity> toEntity() {
|
||||
return items.map((GetAppUsersItemResponseModel item) => UserEntity(
|
||||
id: item.id,
|
||||
delegationId: item.delegationId,
|
||||
email: item.email,
|
||||
createdAt: item.createdAt,
|
||||
updatedAt: item.updatedAt,
|
||||
status: item.status,
|
||||
role: item.role,
|
||||
lastLogin: item.lastLogin,
|
||||
currentLogin: item.currentLogin,
|
||||
language: item.language,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
hasApiKey: item.hasApiKey,
|
||||
phone: item.phone,
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,585 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_app_users_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetAppUsersResponseModel {
|
||||
|
||||
List<GetAppUsersItemResponseModel> get items;
|
||||
/// Create a copy of GetAppUsersResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetAppUsersResponseModelCopyWith<GetAppUsersResponseModel> get copyWith => _$GetAppUsersResponseModelCopyWithImpl<GetAppUsersResponseModel>(this as GetAppUsersResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetAppUsersResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetAppUsersResponseModel&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetAppUsersResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetAppUsersResponseModelCopyWith<$Res> {
|
||||
factory $GetAppUsersResponseModelCopyWith(GetAppUsersResponseModel value, $Res Function(GetAppUsersResponseModel) _then) = _$GetAppUsersResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GetAppUsersItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetAppUsersResponseModelCopyWithImpl<$Res>
|
||||
implements $GetAppUsersResponseModelCopyWith<$Res> {
|
||||
_$GetAppUsersResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetAppUsersResponseModel _self;
|
||||
final $Res Function(GetAppUsersResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetAppUsersResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetAppUsersItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetAppUsersResponseModel].
|
||||
extension GetAppUsersResponseModelPatterns on GetAppUsersResponseModel {
|
||||
/// 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( _GetAppUsersResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel() 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( _GetAppUsersResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel():
|
||||
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( _GetAppUsersResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<GetAppUsersItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<GetAppUsersItemResponseModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel():
|
||||
return $default(_that.items);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<GetAppUsersItemResponseModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetAppUsersResponseModel implements GetAppUsersResponseModel {
|
||||
const _GetAppUsersResponseModel({required final List<GetAppUsersItemResponseModel> items}): _items = items;
|
||||
factory _GetAppUsersResponseModel.fromJson(Map<String, dynamic> json) => _$GetAppUsersResponseModelFromJson(json);
|
||||
|
||||
final List<GetAppUsersItemResponseModel> _items;
|
||||
@override List<GetAppUsersItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetAppUsersResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetAppUsersResponseModelCopyWith<_GetAppUsersResponseModel> get copyWith => __$GetAppUsersResponseModelCopyWithImpl<_GetAppUsersResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetAppUsersResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetAppUsersResponseModel&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetAppUsersResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetAppUsersResponseModelCopyWith<$Res> implements $GetAppUsersResponseModelCopyWith<$Res> {
|
||||
factory _$GetAppUsersResponseModelCopyWith(_GetAppUsersResponseModel value, $Res Function(_GetAppUsersResponseModel) _then) = __$GetAppUsersResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<GetAppUsersItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetAppUsersResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetAppUsersResponseModelCopyWith<$Res> {
|
||||
__$GetAppUsersResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetAppUsersResponseModel _self;
|
||||
final $Res Function(_GetAppUsersResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetAppUsersResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,}) {
|
||||
return _then(_GetAppUsersResponseModel(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetAppUsersItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetAppUsersItemResponseModel {
|
||||
|
||||
String get id; String get delegationId; String get email; String get createdAt; String get updatedAt; String get status; String get role; String get lastLogin; String get currentLogin; String get language; String get firstName; String get lastName; String get hasApiKey; String get phone;
|
||||
/// Create a copy of GetAppUsersItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetAppUsersItemResponseModelCopyWith<GetAppUsersItemResponseModel> get copyWith => _$GetAppUsersItemResponseModelCopyWithImpl<GetAppUsersItemResponseModel>(this as GetAppUsersItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetAppUsersItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetAppUsersItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetAppUsersItemResponseModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetAppUsersItemResponseModelCopyWith<$Res> {
|
||||
factory $GetAppUsersItemResponseModelCopyWith(GetAppUsersItemResponseModel value, $Res Function(GetAppUsersItemResponseModel) _then) = _$GetAppUsersItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String delegationId, String email, String createdAt, String updatedAt, String status, String role, String lastLogin, String currentLogin, String language, String firstName, String lastName, String hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetAppUsersItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetAppUsersItemResponseModelCopyWith<$Res> {
|
||||
_$GetAppUsersItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetAppUsersItemResponseModel _self;
|
||||
final $Res Function(GetAppUsersItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetAppUsersItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = null,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: null == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,hasApiKey: null == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetAppUsersItemResponseModel].
|
||||
extension GetAppUsersItemResponseModelPatterns on GetAppUsersItemResponseModel {
|
||||
/// 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( _GetAppUsersItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel() 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( _GetAppUsersItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel():
|
||||
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( _GetAppUsersItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String delegationId, String email, String createdAt, String updatedAt, String status, String role, String lastLogin, String currentLogin, String language, String firstName, String lastName, String hasApiKey, String phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String delegationId, String email, String createdAt, String updatedAt, String status, String role, String lastLogin, String currentLogin, String language, String firstName, String lastName, String hasApiKey, String phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String delegationId, String email, String createdAt, String updatedAt, String status, String role, String lastLogin, String currentLogin, String language, String firstName, String lastName, String hasApiKey, String phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetAppUsersItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetAppUsersItemResponseModel implements GetAppUsersItemResponseModel {
|
||||
const _GetAppUsersItemResponseModel({required this.id, required this.delegationId, required this.email, required this.createdAt, required this.updatedAt, required this.status, required this.role, required this.lastLogin, required this.currentLogin, required this.language, required this.firstName, required this.lastName, required this.hasApiKey, required this.phone});
|
||||
factory _GetAppUsersItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetAppUsersItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String delegationId;
|
||||
@override final String email;
|
||||
@override final String createdAt;
|
||||
@override final String updatedAt;
|
||||
@override final String status;
|
||||
@override final String role;
|
||||
@override final String lastLogin;
|
||||
@override final String currentLogin;
|
||||
@override final String language;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final String hasApiKey;
|
||||
@override final String phone;
|
||||
|
||||
/// Create a copy of GetAppUsersItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetAppUsersItemResponseModelCopyWith<_GetAppUsersItemResponseModel> get copyWith => __$GetAppUsersItemResponseModelCopyWithImpl<_GetAppUsersItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetAppUsersItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetAppUsersItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetAppUsersItemResponseModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetAppUsersItemResponseModelCopyWith<$Res> implements $GetAppUsersItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetAppUsersItemResponseModelCopyWith(_GetAppUsersItemResponseModel value, $Res Function(_GetAppUsersItemResponseModel) _then) = __$GetAppUsersItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String delegationId, String email, String createdAt, String updatedAt, String status, String role, String lastLogin, String currentLogin, String language, String firstName, String lastName, String hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetAppUsersItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetAppUsersItemResponseModelCopyWith<$Res> {
|
||||
__$GetAppUsersItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetAppUsersItemResponseModel _self;
|
||||
final $Res Function(_GetAppUsersItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetAppUsersItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = null,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_GetAppUsersItemResponseModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: null == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,hasApiKey: null == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,59 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_app_users_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetAppUsersResponseModel _$GetAppUsersResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetAppUsersResponseModel(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetAppUsersItemResponseModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetAppUsersResponseModelToJson(
|
||||
_GetAppUsersResponseModel instance,
|
||||
) => <String, dynamic>{'items': instance.items};
|
||||
|
||||
_GetAppUsersItemResponseModel _$GetAppUsersItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetAppUsersItemResponseModel(
|
||||
id: json['id'] as String,
|
||||
delegationId: json['delegationId'] as String,
|
||||
email: json['email'] as String,
|
||||
createdAt: json['createdAt'] as String,
|
||||
updatedAt: json['updatedAt'] as String,
|
||||
status: json['status'] as String,
|
||||
role: json['role'] as String,
|
||||
lastLogin: json['lastLogin'] as String,
|
||||
currentLogin: json['currentLogin'] as String,
|
||||
language: json['language'] as String,
|
||||
firstName: json['firstName'] as String,
|
||||
lastName: json['lastName'] as String,
|
||||
hasApiKey: json['hasApiKey'] as String,
|
||||
phone: json['phone'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetAppUsersItemResponseModelToJson(
|
||||
_GetAppUsersItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'delegationId': instance.delegationId,
|
||||
'email': instance.email,
|
||||
'createdAt': instance.createdAt,
|
||||
'updatedAt': instance.updatedAt,
|
||||
'status': instance.status,
|
||||
'role': instance.role,
|
||||
'lastLogin': instance.lastLogin,
|
||||
'currentLogin': instance.currentLogin,
|
||||
'language': instance.language,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'hasApiKey': instance.hasApiKey,
|
||||
'phone': instance.phone,
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_linked_devices_response_model.freezed.dart';
|
||||
part 'get_linked_devices_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesResponseModel with _$GetLinkedDevicesResponseModel {
|
||||
const factory GetLinkedDevicesResponseModel({
|
||||
required List<GetLinkedDevicesItemResponseModel> items,
|
||||
}) = _GetLinkedDevicesResponseModel;
|
||||
|
||||
factory GetLinkedDevicesResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesItemResponseModel with _$GetLinkedDevicesItemResponseModel {
|
||||
const factory GetLinkedDevicesItemResponseModel({
|
||||
required String identificator,
|
||||
required String carrierName,
|
||||
required String phone,
|
||||
required String id,
|
||||
required GetLinkedDevicesSettingsResponseModel settings,
|
||||
required String protocol,
|
||||
required String type,
|
||||
required String connectionServer,
|
||||
required int createdAt,
|
||||
required GetLinkedDevicesFlagsResponseModel flags,
|
||||
}) =
|
||||
_GetLinkedDevicesItemResponseModel;
|
||||
|
||||
factory GetLinkedDevicesItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetDevicesResponseModelMapper on GetLinkedDevicesResponseModel {
|
||||
List<DeviceEntity> toEntity() {
|
||||
return items.map((GetLinkedDevicesItemResponseModel item) => DeviceEntity(
|
||||
identificator: item.identificator,
|
||||
carrierName: item.carrierName,
|
||||
phone: item.phone,
|
||||
id: item.id,
|
||||
settings: item.settings.toEntity(),
|
||||
protocol: item.protocol,
|
||||
type: item.type,
|
||||
connectionServer: item.connectionServer,
|
||||
createdAt: item.createdAt,
|
||||
flags: item.flags.toEntity(),
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesSettingsResponseModel with _$GetLinkedDevicesSettingsResponseModel {
|
||||
const factory GetLinkedDevicesSettingsResponseModel({
|
||||
required int frequency,
|
||||
required int frequencyHeartRate,
|
||||
required int timezone,
|
||||
required bool pedometer,
|
||||
required String language,
|
||||
required List<String> alerts,
|
||||
}) = _GetLinkedDevicesSettingsResponseModel;
|
||||
|
||||
factory GetLinkedDevicesSettingsResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesSettingsResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetLinkedDevicesSettingsResponseModelMapper on GetLinkedDevicesSettingsResponseModel {
|
||||
DeviceSettingsEntity toEntity() {
|
||||
return DeviceSettingsEntity(
|
||||
frequency: frequency,
|
||||
frequencyHeartRate: frequencyHeartRate,
|
||||
timezone: timezone,
|
||||
pedometer: pedometer,
|
||||
language: language,
|
||||
alerts: alerts,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLinkedDevicesFlagsResponseModel with _$GetLinkedDevicesFlagsResponseModel {
|
||||
const factory GetLinkedDevicesFlagsResponseModel({
|
||||
required String isInOrOut,
|
||||
required String geofenceId,
|
||||
required bool isBatteryLow,
|
||||
required bool isDisconnect,
|
||||
}) = _GetLinkedDevicesFlagsResponseModel;
|
||||
|
||||
factory GetLinkedDevicesFlagsResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLinkedDevicesFlagsResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetLinkedDevicesFlagsResponseModelMapper on GetLinkedDevicesFlagsResponseModel {
|
||||
DeviceFlagsEntity toEntity() {
|
||||
return DeviceFlagsEntity(
|
||||
isInOrOut: isInOrOut,
|
||||
geofenceId: geofenceId,
|
||||
isBatteryLow: isBatteryLow,
|
||||
isDisconnect: isDisconnect,
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_linked_devices_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetLinkedDevicesResponseModel _$GetLinkedDevicesResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLinkedDevicesResponseModel(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetLinkedDevicesItemResponseModel.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesResponseModelToJson(
|
||||
_GetLinkedDevicesResponseModel instance,
|
||||
) => <String, dynamic>{'items': instance.items};
|
||||
|
||||
_GetLinkedDevicesItemResponseModel _$GetLinkedDevicesItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLinkedDevicesItemResponseModel(
|
||||
identificator: json['identificator'] as String,
|
||||
carrierName: json['carrierName'] as String,
|
||||
phone: json['phone'] as String,
|
||||
id: json['id'] as String,
|
||||
settings: GetLinkedDevicesSettingsResponseModel.fromJson(
|
||||
json['settings'] as Map<String, dynamic>,
|
||||
),
|
||||
protocol: json['protocol'] as String,
|
||||
type: json['type'] as String,
|
||||
connectionServer: json['connectionServer'] as String,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
flags: GetLinkedDevicesFlagsResponseModel.fromJson(
|
||||
json['flags'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesItemResponseModelToJson(
|
||||
_GetLinkedDevicesItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'identificator': instance.identificator,
|
||||
'carrierName': instance.carrierName,
|
||||
'phone': instance.phone,
|
||||
'id': instance.id,
|
||||
'settings': instance.settings,
|
||||
'protocol': instance.protocol,
|
||||
'type': instance.type,
|
||||
'connectionServer': instance.connectionServer,
|
||||
'createdAt': instance.createdAt,
|
||||
'flags': instance.flags,
|
||||
};
|
||||
|
||||
_GetLinkedDevicesSettingsResponseModel
|
||||
_$GetLinkedDevicesSettingsResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: (json['frequency'] as num).toInt(),
|
||||
frequencyHeartRate: (json['frequencyHeartRate'] as num).toInt(),
|
||||
timezone: (json['timezone'] as num).toInt(),
|
||||
pedometer: json['pedometer'] as bool,
|
||||
language: json['language'] as String,
|
||||
alerts: (json['alerts'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesSettingsResponseModelToJson(
|
||||
_GetLinkedDevicesSettingsResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'frequency': instance.frequency,
|
||||
'frequencyHeartRate': instance.frequencyHeartRate,
|
||||
'timezone': instance.timezone,
|
||||
'pedometer': instance.pedometer,
|
||||
'language': instance.language,
|
||||
'alerts': instance.alerts,
|
||||
};
|
||||
|
||||
_GetLinkedDevicesFlagsResponseModel
|
||||
_$GetLinkedDevicesFlagsResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_GetLinkedDevicesFlagsResponseModel(
|
||||
isInOrOut: json['isInOrOut'] as String,
|
||||
geofenceId: json['geofenceId'] as String,
|
||||
isBatteryLow: json['isBatteryLow'] as bool,
|
||||
isDisconnect: json['isDisconnect'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLinkedDevicesFlagsResponseModelToJson(
|
||||
_GetLinkedDevicesFlagsResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'isInOrOut': instance.isInOrOut,
|
||||
'geofenceId': instance.geofenceId,
|
||||
'isBatteryLow': instance.isBatteryLow,
|
||||
'isDisconnect': instance.isDisconnect,
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_logged_user_response_model.freezed.dart';
|
||||
part 'get_logged_user_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetLoggedUserResponseModel with _$GetLoggedUserResponseModel {
|
||||
const factory GetLoggedUserResponseModel({
|
||||
required GetLoggedUserItemResponseModel item,
|
||||
}) = _GetLoggedUserResponseModel;
|
||||
|
||||
factory GetLoggedUserResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLoggedUserResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetLoggedUserItemResponseModel with _$GetLoggedUserItemResponseModel {
|
||||
const factory GetLoggedUserItemResponseModel({
|
||||
required String id,
|
||||
String? delegationId,
|
||||
String? email,
|
||||
String? createdAt,
|
||||
String? updatedAt,
|
||||
String? status,
|
||||
String? role,
|
||||
String? lastLogin,
|
||||
String? currentLogin,
|
||||
String? language,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? hasApiKey,
|
||||
String? phone,
|
||||
}) =
|
||||
_GetLoggedUserItemResponseModel;
|
||||
|
||||
factory GetLoggedUserItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetLoggedUserItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetLoggedUserResponseModelMapper on GetLoggedUserResponseModel {
|
||||
UserEntity toEntity() {
|
||||
return UserEntity(
|
||||
id: item.id,
|
||||
delegationId: item.delegationId ?? '',
|
||||
email: item.email ?? '',
|
||||
createdAt: item.createdAt ?? '',
|
||||
updatedAt: item.updatedAt ?? '',
|
||||
status: item.status ?? '',
|
||||
role: item.role ?? '',
|
||||
lastLogin: item.lastLogin ?? '',
|
||||
currentLogin: item.currentLogin ?? '',
|
||||
language: item.language ?? '',
|
||||
firstName: item.firstName ?? '',
|
||||
lastName: item.lastName ?? '',
|
||||
hasApiKey: item.hasApiKey ?? '',
|
||||
phone: item.phone ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,597 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_logged_user_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLoggedUserResponseModel {
|
||||
|
||||
GetLoggedUserItemResponseModel get item;
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLoggedUserResponseModelCopyWith<GetLoggedUserResponseModel> get copyWith => _$GetLoggedUserResponseModelCopyWithImpl<GetLoggedUserResponseModel>(this as GetLoggedUserResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLoggedUserResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLoggedUserResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLoggedUserResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLoggedUserResponseModelCopyWith<$Res> {
|
||||
factory $GetLoggedUserResponseModelCopyWith(GetLoggedUserResponseModel value, $Res Function(GetLoggedUserResponseModel) _then) = _$GetLoggedUserResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
GetLoggedUserItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
$GetLoggedUserItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLoggedUserResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLoggedUserResponseModelCopyWith<$Res> {
|
||||
_$GetLoggedUserResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLoggedUserResponseModel _self;
|
||||
final $Res Function(GetLoggedUserResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as GetLoggedUserItemResponseModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLoggedUserItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $GetLoggedUserItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLoggedUserResponseModel].
|
||||
extension GetLoggedUserResponseModelPatterns on GetLoggedUserResponseModel {
|
||||
/// 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( _GetLoggedUserResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel() 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( _GetLoggedUserResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel():
|
||||
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( _GetLoggedUserResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel() 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( GetLoggedUserItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel() when $default != null:
|
||||
return $default(_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( GetLoggedUserItemResponseModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel():
|
||||
return $default(_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( GetLoggedUserItemResponseModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserResponseModel() when $default != null:
|
||||
return $default(_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLoggedUserResponseModel implements GetLoggedUserResponseModel {
|
||||
const _GetLoggedUserResponseModel({required this.item});
|
||||
factory _GetLoggedUserResponseModel.fromJson(Map<String, dynamic> json) => _$GetLoggedUserResponseModelFromJson(json);
|
||||
|
||||
@override final GetLoggedUserItemResponseModel item;
|
||||
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLoggedUserResponseModelCopyWith<_GetLoggedUserResponseModel> get copyWith => __$GetLoggedUserResponseModelCopyWithImpl<_GetLoggedUserResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLoggedUserResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLoggedUserResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLoggedUserResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLoggedUserResponseModelCopyWith<$Res> implements $GetLoggedUserResponseModelCopyWith<$Res> {
|
||||
factory _$GetLoggedUserResponseModelCopyWith(_GetLoggedUserResponseModel value, $Res Function(_GetLoggedUserResponseModel) _then) = __$GetLoggedUserResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
GetLoggedUserItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
@override $GetLoggedUserItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLoggedUserResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLoggedUserResponseModelCopyWith<$Res> {
|
||||
__$GetLoggedUserResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLoggedUserResponseModel _self;
|
||||
final $Res Function(_GetLoggedUserResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? item = null,}) {
|
||||
return _then(_GetLoggedUserResponseModel(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as GetLoggedUserItemResponseModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of GetLoggedUserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLoggedUserItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $GetLoggedUserItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLoggedUserItemResponseModel {
|
||||
|
||||
String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone;
|
||||
/// Create a copy of GetLoggedUserItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLoggedUserItemResponseModelCopyWith<GetLoggedUserItemResponseModel> get copyWith => _$GetLoggedUserItemResponseModelCopyWithImpl<GetLoggedUserItemResponseModel>(this as GetLoggedUserItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLoggedUserItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLoggedUserItemResponseModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLoggedUserItemResponseModelCopyWith<$Res> {
|
||||
factory $GetLoggedUserItemResponseModelCopyWith(GetLoggedUserItemResponseModel value, $Res Function(GetLoggedUserItemResponseModel) _then) = _$GetLoggedUserItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLoggedUserItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLoggedUserItemResponseModelCopyWith<$Res> {
|
||||
_$GetLoggedUserItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLoggedUserItemResponseModel _self;
|
||||
final $Res Function(GetLoggedUserItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLoggedUserItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLoggedUserItemResponseModel].
|
||||
extension GetLoggedUserItemResponseModelPatterns on GetLoggedUserItemResponseModel {
|
||||
/// 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( _GetLoggedUserItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel() 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( _GetLoggedUserItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel():
|
||||
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( _GetLoggedUserItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLoggedUserItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLoggedUserItemResponseModel implements GetLoggedUserItemResponseModel {
|
||||
const _GetLoggedUserItemResponseModel({required this.id, this.delegationId, this.email, this.createdAt, this.updatedAt, this.status, this.role, this.lastLogin, this.currentLogin, this.language, this.firstName, this.lastName, this.hasApiKey, this.phone});
|
||||
factory _GetLoggedUserItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetLoggedUserItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String? delegationId;
|
||||
@override final String? email;
|
||||
@override final String? createdAt;
|
||||
@override final String? updatedAt;
|
||||
@override final String? status;
|
||||
@override final String? role;
|
||||
@override final String? lastLogin;
|
||||
@override final String? currentLogin;
|
||||
@override final String? language;
|
||||
@override final String? firstName;
|
||||
@override final String? lastName;
|
||||
@override final String? hasApiKey;
|
||||
@override final String? phone;
|
||||
|
||||
/// Create a copy of GetLoggedUserItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLoggedUserItemResponseModelCopyWith<_GetLoggedUserItemResponseModel> get copyWith => __$GetLoggedUserItemResponseModelCopyWithImpl<_GetLoggedUserItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLoggedUserItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLoggedUserItemResponseModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLoggedUserItemResponseModelCopyWith<$Res> implements $GetLoggedUserItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetLoggedUserItemResponseModelCopyWith(_GetLoggedUserItemResponseModel value, $Res Function(_GetLoggedUserItemResponseModel) _then) = __$GetLoggedUserItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLoggedUserItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLoggedUserItemResponseModelCopyWith<$Res> {
|
||||
__$GetLoggedUserItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLoggedUserItemResponseModel _self;
|
||||
final $Res Function(_GetLoggedUserItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLoggedUserItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_GetLoggedUserItemResponseModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,57 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_logged_user_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetLoggedUserResponseModel _$GetLoggedUserResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLoggedUserResponseModel(
|
||||
item: GetLoggedUserItemResponseModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLoggedUserResponseModelToJson(
|
||||
_GetLoggedUserResponseModel instance,
|
||||
) => <String, dynamic>{'item': instance.item};
|
||||
|
||||
_GetLoggedUserItemResponseModel _$GetLoggedUserItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetLoggedUserItemResponseModel(
|
||||
id: json['id'] as String,
|
||||
delegationId: json['delegationId'] as String?,
|
||||
email: json['email'] as String?,
|
||||
createdAt: json['createdAt'] as String?,
|
||||
updatedAt: json['updatedAt'] as String?,
|
||||
status: json['status'] as String?,
|
||||
role: json['role'] as String?,
|
||||
lastLogin: json['lastLogin'] as String?,
|
||||
currentLogin: json['currentLogin'] as String?,
|
||||
language: json['language'] as String?,
|
||||
firstName: json['firstName'] as String?,
|
||||
lastName: json['lastName'] as String?,
|
||||
hasApiKey: json['hasApiKey'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetLoggedUserItemResponseModelToJson(
|
||||
_GetLoggedUserItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'delegationId': instance.delegationId,
|
||||
'email': instance.email,
|
||||
'createdAt': instance.createdAt,
|
||||
'updatedAt': instance.updatedAt,
|
||||
'status': instance.status,
|
||||
'role': instance.role,
|
||||
'lastLogin': instance.lastLogin,
|
||||
'currentLogin': instance.currentLogin,
|
||||
'language': instance.language,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'hasApiKey': instance.hasApiKey,
|
||||
'phone': instance.phone,
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'update_device_request_model.freezed.dart';
|
||||
part 'update_device_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateDeviceRequestModel with _$UpdateDeviceRequestModel {
|
||||
const factory UpdateDeviceRequestModel({
|
||||
required String identificator,
|
||||
required String name,
|
||||
}) = _UpdateDeviceRequestModel;
|
||||
|
||||
factory UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateDeviceRequestModelFromJson(json);
|
||||
}
|
||||
|
||||
extension UpdateDeviceRequestModelMapper on UpdateDeviceRequestEntity {
|
||||
UpdateDeviceRequestModel toModel() => UpdateDeviceRequestModel(
|
||||
identificator: identificator,
|
||||
name: name,
|
||||
);
|
||||
}
|
||||
@@ -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 'update_device_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateDeviceRequestModel {
|
||||
|
||||
String get identificator; String get name;
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateDeviceRequestModelCopyWith<UpdateDeviceRequestModel> get copyWith => _$UpdateDeviceRequestModelCopyWithImpl<UpdateDeviceRequestModel>(this as UpdateDeviceRequestModel, _$identity);
|
||||
|
||||
/// Serializes this UpdateDeviceRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateDeviceRequestModelCopyWith<$Res> {
|
||||
factory $UpdateDeviceRequestModelCopyWith(UpdateDeviceRequestModel value, $Res Function(UpdateDeviceRequestModel) _then) = _$UpdateDeviceRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateDeviceRequestModelCopyWithImpl<$Res>
|
||||
implements $UpdateDeviceRequestModelCopyWith<$Res> {
|
||||
_$UpdateDeviceRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateDeviceRequestModel _self;
|
||||
final $Res Function(UpdateDeviceRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateDeviceRequestModel].
|
||||
extension UpdateDeviceRequestModelPatterns on UpdateDeviceRequestModel {
|
||||
/// 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( _UpdateDeviceRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() 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( _UpdateDeviceRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel():
|
||||
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( _UpdateDeviceRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel():
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestModel() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _UpdateDeviceRequestModel implements UpdateDeviceRequestModel {
|
||||
const _UpdateDeviceRequestModel({required this.identificator, required this.name});
|
||||
factory _UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateDeviceRequestModelFromJson(json);
|
||||
|
||||
@override final String identificator;
|
||||
@override final String name;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateDeviceRequestModelCopyWith<_UpdateDeviceRequestModel> get copyWith => __$UpdateDeviceRequestModelCopyWithImpl<_UpdateDeviceRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UpdateDeviceRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateDeviceRequestModelCopyWith<$Res> implements $UpdateDeviceRequestModelCopyWith<$Res> {
|
||||
factory _$UpdateDeviceRequestModelCopyWith(_UpdateDeviceRequestModel value, $Res Function(_UpdateDeviceRequestModel) _then) = __$UpdateDeviceRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateDeviceRequestModelCopyWithImpl<$Res>
|
||||
implements _$UpdateDeviceRequestModelCopyWith<$Res> {
|
||||
__$UpdateDeviceRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateDeviceRequestModel _self;
|
||||
final $Res Function(_UpdateDeviceRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
return _then(_UpdateDeviceRequestModel(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'update_device_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_UpdateDeviceRequestModel _$UpdateDeviceRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateDeviceRequestModel(
|
||||
identificator: json['identificator'] as String,
|
||||
name: json['name'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateDeviceRequestModelToJson(
|
||||
_UpdateDeviceRequestModel instance,
|
||||
) => <String, dynamic>{
|
||||
'identificator': instance.identificator,
|
||||
'name': instance.name,
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'update_user_request_model.freezed.dart';
|
||||
part 'update_user_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateUserRequestModel with _$UpdateUserRequestModel {
|
||||
const factory UpdateUserRequestModel({
|
||||
required String id,
|
||||
String? delegationId,
|
||||
String? email,
|
||||
String? createdAt,
|
||||
String? updatedAt,
|
||||
String? status,
|
||||
String? role,
|
||||
String? lastLogin,
|
||||
String? currentLogin,
|
||||
String? language,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? hasApiKey,
|
||||
String? phone,
|
||||
}) = _UpdateUserRequestModel;
|
||||
|
||||
factory UpdateUserRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateUserRequestModelFromJson(json);
|
||||
}
|
||||
|
||||
extension UpdateUserRequestModelMapper on UpdateUserRequestEntity {
|
||||
UpdateUserRequestModel toModel() => UpdateUserRequestModel(
|
||||
id: id,
|
||||
delegationId: delegationId,
|
||||
email: email,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
status: status,
|
||||
role: role,
|
||||
lastLogin: lastLogin,
|
||||
currentLogin: currentLogin,
|
||||
language: language,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
hasApiKey: hasApiKey,
|
||||
phone: phone,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
// 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 'update_user_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateUserRequestModel {
|
||||
|
||||
String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone;
|
||||
/// Create a copy of UpdateUserRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateUserRequestModelCopyWith<UpdateUserRequestModel> get copyWith => _$UpdateUserRequestModelCopyWithImpl<UpdateUserRequestModel>(this as UpdateUserRequestModel, _$identity);
|
||||
|
||||
/// Serializes this UpdateUserRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateUserRequestModelCopyWith<$Res> {
|
||||
factory $UpdateUserRequestModelCopyWith(UpdateUserRequestModel value, $Res Function(UpdateUserRequestModel) _then) = _$UpdateUserRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateUserRequestModelCopyWithImpl<$Res>
|
||||
implements $UpdateUserRequestModelCopyWith<$Res> {
|
||||
_$UpdateUserRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateUserRequestModel _self;
|
||||
final $Res Function(UpdateUserRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateUserRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateUserRequestModel].
|
||||
extension UpdateUserRequestModelPatterns on UpdateUserRequestModel {
|
||||
/// 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( _UpdateUserRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel() 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( _UpdateUserRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel():
|
||||
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( _UpdateUserRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _UpdateUserRequestModel implements UpdateUserRequestModel {
|
||||
const _UpdateUserRequestModel({required this.id, this.delegationId, this.email, this.createdAt, this.updatedAt, this.status, this.role, this.lastLogin, this.currentLogin, this.language, this.firstName, this.lastName, this.hasApiKey, this.phone});
|
||||
factory _UpdateUserRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateUserRequestModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String? delegationId;
|
||||
@override final String? email;
|
||||
@override final String? createdAt;
|
||||
@override final String? updatedAt;
|
||||
@override final String? status;
|
||||
@override final String? role;
|
||||
@override final String? lastLogin;
|
||||
@override final String? currentLogin;
|
||||
@override final String? language;
|
||||
@override final String? firstName;
|
||||
@override final String? lastName;
|
||||
@override final String? hasApiKey;
|
||||
@override final String? phone;
|
||||
|
||||
/// Create a copy of UpdateUserRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateUserRequestModelCopyWith<_UpdateUserRequestModel> get copyWith => __$UpdateUserRequestModelCopyWithImpl<_UpdateUserRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UpdateUserRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateUserRequestModelCopyWith<$Res> implements $UpdateUserRequestModelCopyWith<$Res> {
|
||||
factory _$UpdateUserRequestModelCopyWith(_UpdateUserRequestModel value, $Res Function(_UpdateUserRequestModel) _then) = __$UpdateUserRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateUserRequestModelCopyWithImpl<$Res>
|
||||
implements _$UpdateUserRequestModelCopyWith<$Res> {
|
||||
__$UpdateUserRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateUserRequestModel _self;
|
||||
final $Res Function(_UpdateUserRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateUserRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_UpdateUserRequestModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,45 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'update_user_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_UpdateUserRequestModel _$UpdateUserRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateUserRequestModel(
|
||||
id: json['id'] as String,
|
||||
delegationId: json['delegationId'] as String?,
|
||||
email: json['email'] as String?,
|
||||
createdAt: json['createdAt'] as String?,
|
||||
updatedAt: json['updatedAt'] as String?,
|
||||
status: json['status'] as String?,
|
||||
role: json['role'] as String?,
|
||||
lastLogin: json['lastLogin'] as String?,
|
||||
currentLogin: json['currentLogin'] as String?,
|
||||
language: json['language'] as String?,
|
||||
firstName: json['firstName'] as String?,
|
||||
lastName: json['lastName'] as String?,
|
||||
hasApiKey: json['hasApiKey'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateUserRequestModelToJson(
|
||||
_UpdateUserRequestModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'delegationId': instance.delegationId,
|
||||
'email': instance.email,
|
||||
'createdAt': instance.createdAt,
|
||||
'updatedAt': instance.updatedAt,
|
||||
'status': instance.status,
|
||||
'role': instance.role,
|
||||
'lastLogin': instance.lastLogin,
|
||||
'currentLogin': instance.currentLogin,
|
||||
'language': instance.language,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'hasApiKey': instance.hasApiKey,
|
||||
'phone': instance.phone,
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
class AccountRepositoryImpl implements AccountRepository {
|
||||
const AccountRepositoryImpl(this._remote);
|
||||
|
||||
final AccountRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _remote.getLinkedDevices(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) {
|
||||
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) {
|
||||
return _remote.updateDevice(userId: userId, deviceId: deviceId, request: request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
|
||||
return _remote.updateUser(userId: userId, request: request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) {
|
||||
return _remote.getAppUsers(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAppUser({required String userId}) {
|
||||
return _remote.deleteAppUser(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) {
|
||||
return _remote.changePassword(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
abstract class AccountRepository {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({
|
||||
required String userId,
|
||||
required String deviceId,
|
||||
required UpdateDeviceRequestEntity request
|
||||
});
|
||||
|
||||
Future<void> updateUser({
|
||||
required String userId,
|
||||
required UpdateUserRequestEntity request
|
||||
});
|
||||
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
|
||||
Future<void> deleteAppUser({required String userId});
|
||||
|
||||
Future<void> changePassword({
|
||||
required String userId,
|
||||
required ChangePasswordRequestEntity request
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
|
||||
import 'package:account/src/core/data/datasource/account_remote_datasource_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
final accountRemoteDatasourceProvider = Provider<AccountRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return AccountRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/data/repositories/account_repository_impl.dart';
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/core/providers/account_remote_datasource_provider.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
|
||||
final remote = ref.read(accountRemoteDatasourceProvider);
|
||||
return AccountRepositoryImpl(remote);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:account/src/features/account_settings/presentation/account_settings_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class AccountSettingsBuilder {
|
||||
const AccountSettingsBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: AccountSettingsScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class AccountSettingsScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const AccountSettingsScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final selectedDevice = ref.watch(selectedDeviceProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.accountSettings),
|
||||
body: SingleChildScrollView(child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppSectionButton(
|
||||
onPressed: (){navigationContract.pushTo(AppRoutes.personalData);},
|
||||
icon: SFIcons.account,
|
||||
text: I18n.personalData
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){navigationContract.pushTo(AppRoutes.changePassword);},
|
||||
icon: Icons.lock,
|
||||
text: I18n.changePassword
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){},
|
||||
icon: Icons.add_circle_outline,
|
||||
text: I18n.addNewSF
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){navigationContract.pushTo(AppRoutes.linkedDevices);},
|
||||
icon: Icons.account_circle_outlined,
|
||||
text: I18n.linkedDevices
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){navigationContract.pushTo(AppRoutes.appUsers);},
|
||||
icon: Icons.groups_outlined,
|
||||
text: I18n.appUsers
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: () async {
|
||||
final Uri url = Uri.parse('https://savefamilygps.com/pages/politica-de-privacidad-reloj-gps-infantil-localizador-savefamily');
|
||||
if (!await launchUrl(url)) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
},
|
||||
icon: SFIcons.privacy,
|
||||
text: I18n.privacyPolicy
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){
|
||||
showDialog(context: context, builder: (context)=>Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: RegCodeDialog(
|
||||
regCode: selectedDevice?.id ?? '',
|
||||
deviceId: selectedDevice?.identificator ?? '',
|
||||
name: selectedDevice?.carrierName ?? ''
|
||||
),
|
||||
));
|
||||
},
|
||||
icon: Icons.qr_code,
|
||||
text: I18n.regCode
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
AppSectionButton(
|
||||
onPressed: (){navigationContract.pushTo(AppRoutes.deleteAccount);},
|
||||
icon: Icons.no_accounts,
|
||||
text: I18n.deleteAccount
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
footer: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(vertical: 12, horizontal: 30),
|
||||
big: EdgeInsets.symmetric(vertical: 10, horizontal: 28)
|
||||
),
|
||||
child: PrimaryButton(text: context.translate(I18n.logOut), color: theme.getColorFor(ThemeCode.legacyPrimary)),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppSectionButton extends ConsumerWidget {
|
||||
|
||||
final GestureTapCallback onPressed;
|
||||
final IconData icon;
|
||||
final String text;
|
||||
|
||||
const AppSectionButton({
|
||||
required this.onPressed,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 20),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 18)
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(SizeUtils.getByScreen(small: 12, big: 18))),
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
|
||||
child: Icon(icon,
|
||||
size: SizeUtils.getByScreen(small: 40, big: 44),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
weight: 30,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
Expanded(
|
||||
child: Text(context.translate(text),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 18, big: 19),
|
||||
fontWeight: FontWeight.w500
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RegCodeDialog extends StatelessWidget {
|
||||
|
||||
final String regCode;
|
||||
final String deviceId;
|
||||
final String name;
|
||||
|
||||
const RegCodeDialog({
|
||||
super.key,
|
||||
required this.regCode,
|
||||
required this.deviceId,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: SizeUtils.getByScreen(small: 330, big: 328),
|
||||
color: Colors.transparent,
|
||||
child: Stack(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
height: SizeUtils.getByScreen(small: 300, big: 298),
|
||||
width: SizeUtils.getByScreen(small: 350, big: 348),
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(vertical: 14, horizontal: 18),
|
||||
big: EdgeInsets.symmetric(vertical: 12, horizontal: 16)
|
||||
),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
icon: Icon(Icons.close),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
Text(name, style: TextStyle()),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(context.translate(I18n.deviceIdLabel,
|
||||
args: {'deviceId': deviceId})),
|
||||
TextButton(
|
||||
onPressed: (){Clipboard.setData(ClipboardData(text: deviceId));},
|
||||
child: Text(context.translate(I18n.copy)),
|
||||
)
|
||||
],
|
||||
),
|
||||
QrImageView(
|
||||
data: regCode,
|
||||
version: QrVersions.auto,
|
||||
size: SizeUtils.getByScreen(small: 100, big: 98),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(context.translate(I18n.regCodeLabel,
|
||||
args: {'regCode': regCode})),
|
||||
TextButton(
|
||||
onPressed: (){Clipboard.setData(ClipboardData(text: regCode));},
|
||||
child: Text(context.translate(I18n.copy))
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color(0xFF00A1C6),
|
||||
),
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.all(12),
|
||||
big: EdgeInsets.all(12)
|
||||
),
|
||||
child: Icon(
|
||||
SFIcons.watch,
|
||||
size: SizeUtils.getByScreen(small: 68, big: 66),
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:account/src/features/app_users/presentation/app_users_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class AppUsersBuilder {
|
||||
const AppUsersBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: AppUsersScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
abstract class DeleteAppUserUseCase {
|
||||
Future<void> deleteAppUser({required String userId});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
|
||||
|
||||
class DeleteAppUserUseCaseImpl implements DeleteAppUserUseCase {
|
||||
DeleteAppUserUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteAppUser({required String userId}) {
|
||||
return _repository.deleteAppUser(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
abstract class GetAppUsersUseCase {
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
|
||||
|
||||
class GetAppUsersUseCaseImpl implements GetAppUsersUseCase {
|
||||
GetAppUsersUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) {
|
||||
return _repository.getAppUsers(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
import 'package:account/src/features/app_users/presentation/state/app_users_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class AppUsersScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const AppUsersScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(appUsersViewModelProvider.notifier);
|
||||
final state = ref.watch(appUsersViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
title: context.translate(I18n.appUsers),
|
||||
body: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>AppUserCard(
|
||||
user: state.appUsers[index],
|
||||
isEditing: state.isEditing,
|
||||
),
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.appUsers.length
|
||||
),
|
||||
),
|
||||
footer: state.isEditing ?
|
||||
PrimaryButton(
|
||||
onPressed: vm.toggleIsEditing,
|
||||
text: context.translate(I18n.save),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 44, big: 42),
|
||||
) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppUserCard extends ConsumerWidget {
|
||||
|
||||
final UserEntity user;
|
||||
final bool isEditing;
|
||||
|
||||
const AppUserCard({
|
||||
required this.user,
|
||||
required this.isEditing,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(SizeUtils.getByScreen(small: 12, big: 18))),
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
|
||||
child: Icon(SFIcons.account,
|
||||
size: SizeUtils.getByScreen(small: 40, big: 44),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
weight: 30,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(user.firstName,
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 18, big: 19),
|
||||
fontWeight: FontWeight.w500
|
||||
)
|
||||
),
|
||||
Text(context.translate(I18n.userAccount, args: {'email': user.email}),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 14, big: 13),
|
||||
)
|
||||
),
|
||||
Text(context.translate(I18n.userRole, args: {'role': user.role}),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 14, big: 13),
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
if (isEditing) ...[
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFFF5D52),
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.deleteUserDialog),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 4, big: 16)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: (){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
text: context.translate(I18n.delete),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
));},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
|
||||
import 'package:account/src/features/app_users/domain/delete_app_user_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final deleteAppUserUseCaseProvider = Provider.autoDispose<DeleteAppUserUseCase>((ref) {
|
||||
final authRepository = ref.read(accountRepositoryProvider);
|
||||
return DeleteAppUserUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
|
||||
import 'package:account/src/features/app_users/domain/get_app_users_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final getAppUsersUseCaseProvider = Provider.autoDispose<GetAppUsersUseCase>((ref) {
|
||||
final authRepository = ref.read(accountRepositoryProvider);
|
||||
return GetAppUsersUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
|
||||
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
|
||||
import 'package:account/src/features/app_users/presentation/providers/delete_app_user_use_case_provider.dart';
|
||||
import 'package:account/src/features/app_users/presentation/providers/get_app_users_use_case_provider.dart';
|
||||
import 'package:account/src/features/app_users/presentation/state/app_users_view_state.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final appUsersViewModelProvider =
|
||||
NotifierProvider.autoDispose<AppUsersViewModel, AppUsersViewState>(
|
||||
AppUsersViewModel.new,
|
||||
);
|
||||
|
||||
class AppUsersViewModel extends Notifier<AppUsersViewState> {
|
||||
late final GetAppUsersUseCase _getAppUsersUseCase;
|
||||
late final DeleteAppUserUseCase _deleteAppUserUseCase;
|
||||
|
||||
@override
|
||||
AppUsersViewState build() {
|
||||
_getAppUsersUseCase = ref.read(getAppUsersUseCaseProvider);
|
||||
_deleteAppUserUseCase = ref.read(deleteAppUserUseCaseProvider);
|
||||
|
||||
ref.read(loggedUserProvider.future)
|
||||
.then((user){
|
||||
setUser(user);
|
||||
return _getAppUsersUseCase.getAppUsers(userId: user.id);
|
||||
}).then(setAppUsers);
|
||||
|
||||
return const AppUsersViewState();
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void setAppUsers(List<UserEntity> appUsers) {
|
||||
state = state.copyWith(
|
||||
appUsers: appUsers,
|
||||
isLoading: false,
|
||||
);
|
||||
}
|
||||
|
||||
void toggleIsEditing() {
|
||||
state = state.copyWith(isEditing: !state.isEditing);
|
||||
}
|
||||
|
||||
void deleteAppUser() {
|
||||
_deleteAppUserUseCase.deleteAppUser(userId: state.loggedUser!.id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'app_users_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class AppUsersViewState with _$AppUsersViewState {
|
||||
const factory AppUsersViewState({
|
||||
@Default(false) bool isLoading,
|
||||
@Default(null) UserEntity? loggedUser,
|
||||
@Default([]) List<UserEntity> appUsers,
|
||||
@Default(false) bool isEditing,
|
||||
@Default('') String errorMessage
|
||||
}) = _AppUsersViewState;
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
// 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 'app_users_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$AppUsersViewState {
|
||||
|
||||
bool get isLoading; UserEntity? get loggedUser; List<UserEntity> get appUsers; bool get isEditing; String get errorMessage;
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AppUsersViewStateCopyWith<AppUsersViewState> get copyWith => _$AppUsersViewStateCopyWithImpl<AppUsersViewState>(this as AppUsersViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is AppUsersViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.appUsers, appUsers)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(appUsers),isEditing,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppUsersViewState(isLoading: $isLoading, loggedUser: $loggedUser, appUsers: $appUsers, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $AppUsersViewStateCopyWith<$Res> {
|
||||
factory $AppUsersViewStateCopyWith(AppUsersViewState value, $Res Function(AppUsersViewState) _then) = _$AppUsersViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<UserEntity> appUsers, bool isEditing, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$AppUsersViewStateCopyWithImpl<$Res>
|
||||
implements $AppUsersViewStateCopyWith<$Res> {
|
||||
_$AppUsersViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AppUsersViewState _self;
|
||||
final $Res Function(AppUsersViewState) _then;
|
||||
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? appUsers = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,appUsers: null == appUsers ? _self.appUsers : appUsers // ignore: cast_nullable_to_non_nullable
|
||||
as List<UserEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AppUsersViewState].
|
||||
extension AppUsersViewStatePatterns on AppUsersViewState {
|
||||
/// 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( _AppUsersViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState() 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( _AppUsersViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState():
|
||||
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( _AppUsersViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState() 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 isLoading, UserEntity? loggedUser, List<UserEntity> appUsers, bool isEditing, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.appUsers,_that.isEditing,_that.errorMessage);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 isLoading, UserEntity? loggedUser, List<UserEntity> appUsers, bool isEditing, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState():
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.appUsers,_that.isEditing,_that.errorMessage);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 isLoading, UserEntity? loggedUser, List<UserEntity> appUsers, bool isEditing, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppUsersViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.appUsers,_that.isEditing,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _AppUsersViewState implements AppUsersViewState {
|
||||
const _AppUsersViewState({this.isLoading = false, this.loggedUser = null, final List<UserEntity> appUsers = const [], this.isEditing = false, this.errorMessage = ''}): _appUsers = appUsers;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final UserEntity? loggedUser;
|
||||
final List<UserEntity> _appUsers;
|
||||
@override@JsonKey() List<UserEntity> get appUsers {
|
||||
if (_appUsers is EqualUnmodifiableListView) return _appUsers;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_appUsers);
|
||||
}
|
||||
|
||||
@override@JsonKey() final bool isEditing;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AppUsersViewStateCopyWith<_AppUsersViewState> get copyWith => __$AppUsersViewStateCopyWithImpl<_AppUsersViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AppUsersViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._appUsers, _appUsers)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(_appUsers),isEditing,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppUsersViewState(isLoading: $isLoading, loggedUser: $loggedUser, appUsers: $appUsers, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AppUsersViewStateCopyWith<$Res> implements $AppUsersViewStateCopyWith<$Res> {
|
||||
factory _$AppUsersViewStateCopyWith(_AppUsersViewState value, $Res Function(_AppUsersViewState) _then) = __$AppUsersViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<UserEntity> appUsers, bool isEditing, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AppUsersViewStateCopyWithImpl<$Res>
|
||||
implements _$AppUsersViewStateCopyWith<$Res> {
|
||||
__$AppUsersViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AppUsersViewState _self;
|
||||
final $Res Function(_AppUsersViewState) _then;
|
||||
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? appUsers = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
return _then(_AppUsersViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,appUsers: null == appUsers ? _self._appUsers : appUsers // ignore: cast_nullable_to_non_nullable
|
||||
as List<UserEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of AppUsersViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:account/src/features/change_password/presentation/change_password_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class ChangePasswordBuilder {
|
||||
const ChangePasswordBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: ChangePasswordScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
|
||||
abstract class ChangePasswordUseCase {
|
||||
Future<void> changePassword({
|
||||
required String userId,
|
||||
required ChangePasswordRequestEntity request,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:account/src/features/change_password/domain/change_password_use_case.dart';
|
||||
|
||||
class ChangePasswordUseCaseImpl implements ChangePasswordUseCase {
|
||||
ChangePasswordUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) {
|
||||
return _repository.changePassword(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'change_password_request_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ChangePasswordRequestEntity with _$ChangePasswordRequestEntity {
|
||||
const factory ChangePasswordRequestEntity({
|
||||
required String password,
|
||||
}) = _ChangePasswordRequestEntity;
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
// 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 'change_password_request_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChangePasswordRequestEntity {
|
||||
|
||||
String get password;
|
||||
/// Create a copy of ChangePasswordRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChangePasswordRequestEntityCopyWith<ChangePasswordRequestEntity> get copyWith => _$ChangePasswordRequestEntityCopyWithImpl<ChangePasswordRequestEntity>(this as ChangePasswordRequestEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordRequestEntity&&(identical(other.password, password) || other.password == password));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,password);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordRequestEntity(password: $password)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ChangePasswordRequestEntityCopyWith<$Res> {
|
||||
factory $ChangePasswordRequestEntityCopyWith(ChangePasswordRequestEntity value, $Res Function(ChangePasswordRequestEntity) _then) = _$ChangePasswordRequestEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String password
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ChangePasswordRequestEntityCopyWithImpl<$Res>
|
||||
implements $ChangePasswordRequestEntityCopyWith<$Res> {
|
||||
_$ChangePasswordRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ChangePasswordRequestEntity _self;
|
||||
final $Res Function(ChangePasswordRequestEntity) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? password = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ChangePasswordRequestEntity].
|
||||
extension ChangePasswordRequestEntityPatterns on ChangePasswordRequestEntity {
|
||||
/// 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( _ChangePasswordRequestEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity() 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( _ChangePasswordRequestEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity():
|
||||
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( _ChangePasswordRequestEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity() 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 password)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity() when $default != null:
|
||||
return $default(_that.password);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 password) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity():
|
||||
return $default(_that.password);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 password)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordRequestEntity() when $default != null:
|
||||
return $default(_that.password);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ChangePasswordRequestEntity implements ChangePasswordRequestEntity {
|
||||
const _ChangePasswordRequestEntity({required this.password});
|
||||
|
||||
|
||||
@override final String password;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChangePasswordRequestEntityCopyWith<_ChangePasswordRequestEntity> get copyWith => __$ChangePasswordRequestEntityCopyWithImpl<_ChangePasswordRequestEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordRequestEntity&&(identical(other.password, password) || other.password == password));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,password);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordRequestEntity(password: $password)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChangePasswordRequestEntityCopyWith<$Res> implements $ChangePasswordRequestEntityCopyWith<$Res> {
|
||||
factory _$ChangePasswordRequestEntityCopyWith(_ChangePasswordRequestEntity value, $Res Function(_ChangePasswordRequestEntity) _then) = __$ChangePasswordRequestEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String password
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChangePasswordRequestEntityCopyWithImpl<$Res>
|
||||
implements _$ChangePasswordRequestEntityCopyWith<$Res> {
|
||||
__$ChangePasswordRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ChangePasswordRequestEntity _self;
|
||||
final $Res Function(_ChangePasswordRequestEntity) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? password = null,}) {
|
||||
return _then(_ChangePasswordRequestEntity(
|
||||
password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1 @@
|
||||
part of 'change_password_request_entity.dart';
|
||||
@@ -0,0 +1,76 @@
|
||||
import 'package:account/src/features/change_password/presentation/state/change_password_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class ChangePasswordScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const ChangePasswordScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(changePasswordViewModelProvider.notifier);
|
||||
final state = ref.watch(changePasswordViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.changePassword),
|
||||
body: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 28, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 27, vertical: 8)
|
||||
),
|
||||
child: SingleChildScrollView(child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomTextField(
|
||||
controller: vm.currentPasswordController,
|
||||
hint: '********',
|
||||
label: context.translate(I18n.password),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.newPasswordController,
|
||||
hint: '********',
|
||||
label: context.translate(I18n.newPassword),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.repeatPasswordController,
|
||||
hint: '********',
|
||||
label: context.translate(I18n.repeatPassword),
|
||||
),
|
||||
if (state.errorMessage.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
state.errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color.fromRGBO(239, 17, 17, 1),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
))
|
||||
),
|
||||
footer: PrimaryButton(
|
||||
onPressed: () async {
|
||||
final bool res = await vm.changePassword();
|
||||
if (res){
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
text: context.translate('OK'),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/change_password/domain/change_password_use_case.dart';
|
||||
import 'package:account/src/features/change_password/domain/change_password_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final changePasswordUseCaseProvider = Provider.autoDispose<ChangePasswordUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return ChangePasswordUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -0,0 +1,143 @@
|
||||
import 'package:account/src/features/change_password/domain/change_password_use_case.dart';
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
|
||||
import 'package:account/src/features/change_password/presentation/providers/change_password_use_case_provider.dart';
|
||||
import 'package:account/src/features/change_password/presentation/state/change_password_view_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final changePasswordViewModelProvider =
|
||||
NotifierProvider.autoDispose<ChangePasswordViewModel, ChangePasswordViewState>(
|
||||
ChangePasswordViewModel.new,
|
||||
);
|
||||
|
||||
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;
|
||||
|
||||
@override
|
||||
ChangePasswordViewState build() {
|
||||
_changePasswordUseCase = ref.read(changePasswordUseCaseProvider);
|
||||
|
||||
currentPasswordController = TextEditingController();
|
||||
currentPasswordController.addListener(_onCurrentPasswordChanged);
|
||||
|
||||
newPasswordController = TextEditingController();
|
||||
newPasswordController.addListener(_onNewPasswordChanged);
|
||||
|
||||
repeatPasswordController = TextEditingController();
|
||||
repeatPasswordController.addListener(_onRepeatPasswordController);
|
||||
|
||||
ref.read(loggedUserProvider.future)
|
||||
.then(setUser);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
return const ChangePasswordViewState();
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void _onCurrentPasswordChanged() {
|
||||
final value = currentPasswordController.text;
|
||||
|
||||
if (value == state.currentPassword) return;
|
||||
|
||||
state = state.copyWith(
|
||||
currentPassword: value,
|
||||
);
|
||||
}
|
||||
|
||||
void _onNewPasswordChanged() {
|
||||
final value = newPasswordController.text;
|
||||
|
||||
if (value == state.newPassword) return;
|
||||
|
||||
state = state.copyWith(
|
||||
newPassword: value,
|
||||
);
|
||||
}
|
||||
|
||||
void _onRepeatPasswordController() {
|
||||
final value = repeatPasswordController.text;
|
||||
|
||||
if (value == state.repeatPassword) return;
|
||||
|
||||
state = state.copyWith(
|
||||
repeatPassword: value,
|
||||
);
|
||||
}
|
||||
|
||||
bool _validateForm() {
|
||||
if (state.currentPassword.trim().isEmpty){
|
||||
state = state.copyWith(errorMessage: 'errorMessageCurrentPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
if (state.newPassword.trim().isEmpty){
|
||||
state = state.copyWith(errorMessage: 'errorMessageNewPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
if (state.repeatPassword.trim().isEmpty){
|
||||
state = state.copyWith(errorMessage: 'errorMessageRepeatPasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
if (state.newPassword.trim() != state.repeatPassword.trim()){
|
||||
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ChangePasswordRequestEntity _toRequest() {
|
||||
|
||||
return ChangePasswordRequestEntity(
|
||||
password: state.newPassword.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> changePassword() async {
|
||||
if (state.isLoading) return false;
|
||||
if (!_validateForm()) return false;
|
||||
|
||||
try {
|
||||
final request = _toRequest();
|
||||
|
||||
await _changePasswordUseCase.changePassword(userId: state.loggedUser!.id, request: request);
|
||||
ref.invalidate(loggedUserProvider);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
_finishWithError(message: e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void _finishWithError({required String message}) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: message,
|
||||
);
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
currentPasswordController.removeListener(_onCurrentPasswordChanged);
|
||||
currentPasswordController.dispose();
|
||||
|
||||
newPasswordController.removeListener(_onNewPasswordChanged);
|
||||
newPasswordController.dispose();
|
||||
|
||||
repeatPasswordController.removeListener(_onRepeatPasswordController);
|
||||
repeatPasswordController.dispose();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
part 'change_password_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ChangePasswordViewState with _$ChangePasswordViewState {
|
||||
const factory ChangePasswordViewState({
|
||||
UserEntity? loggedUser,
|
||||
@Default(false) bool isLoading,
|
||||
@Default('') String currentPassword,
|
||||
@Default('') String newPassword,
|
||||
@Default('') String repeatPassword,
|
||||
@Default('') String errorMessage
|
||||
}) = _ChangePasswordViewState;
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
// 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 'change_password_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChangePasswordViewState {
|
||||
|
||||
UserEntity? get loggedUser; bool get isLoading; String get currentPassword; String get newPassword; String get repeatPassword; String get errorMessage;
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$ChangePasswordViewStateCopyWithImpl<ChangePasswordViewState>(this as ChangePasswordViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,isLoading,currentPassword,newPassword,repeatPassword,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordViewState(loggedUser: $loggedUser, isLoading: $isLoading, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ChangePasswordViewStateCopyWith<$Res> {
|
||||
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ChangePasswordViewStateCopyWithImpl<$Res>
|
||||
implements $ChangePasswordViewStateCopyWith<$Res> {
|
||||
_$ChangePasswordViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ChangePasswordViewState _self;
|
||||
final $Res Function(ChangePasswordViewState) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? isLoading = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ChangePasswordViewState].
|
||||
extension ChangePasswordViewStatePatterns on ChangePasswordViewState {
|
||||
/// 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( _ChangePasswordViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() 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( _ChangePasswordViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState():
|
||||
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( _ChangePasswordViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() 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( UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);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( UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState():
|
||||
return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);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( UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChangePasswordViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ChangePasswordViewState implements ChangePasswordViewState {
|
||||
const _ChangePasswordViewState({this.loggedUser, this.isLoading = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
|
||||
|
||||
|
||||
@override final UserEntity? loggedUser;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final String currentPassword;
|
||||
@override@JsonKey() final String newPassword;
|
||||
@override@JsonKey() final String repeatPassword;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$ChangePasswordViewStateCopyWithImpl<_ChangePasswordViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,isLoading,currentPassword,newPassword,repeatPassword,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangePasswordViewState(loggedUser: $loggedUser, isLoading: $isLoading, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangePasswordViewStateCopyWith<$Res> {
|
||||
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChangePasswordViewStateCopyWithImpl<$Res>
|
||||
implements _$ChangePasswordViewStateCopyWith<$Res> {
|
||||
__$ChangePasswordViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ChangePasswordViewState _self;
|
||||
final $Res Function(_ChangePasswordViewState) _then;
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? isLoading = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
|
||||
return _then(_ChangePasswordViewState(
|
||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of ChangePasswordViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:account/src/features/delete_account/presentation/delete_account_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class DeleteAccountBuilder {
|
||||
const DeleteAccountBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: DeleteAccountScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
abstract class DeleteAccountUseCase {
|
||||
Future<void> deleteAccount({
|
||||
required String userId,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
|
||||
|
||||
class DeleteAccountUseCaseImpl implements DeleteAccountUseCase {
|
||||
DeleteAccountUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteAccount({required String userId}) {
|
||||
return _repository.deleteAppUser(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_model.dart';
|
||||
import 'package:account/src/features/delete_account/presentation/widgets/confirm_dialog.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class DeleteAccountScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const DeleteAccountScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final state = ref.watch(deleteAccountViewModelProvider);
|
||||
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.deleteAccount),
|
||||
body: SingleChildScrollView(child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
width: double.infinity,
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(vertical: 20),
|
||||
big: EdgeInsets.symmetric(vertical: 19),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF00A1C6),
|
||||
borderRadius: BorderRadius.circular(12)
|
||||
),
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.all(7),
|
||||
big: EdgeInsets.all(6),
|
||||
),
|
||||
child: Icon(Icons.power_settings_new_outlined,
|
||||
size: SizeUtils.getByScreen(small: 48, big: 46),
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Text(context.translate(I18n.deleteAccount),
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 20, big: 19)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 6)),
|
||||
Text(context.translate(I18n.deleteAccountBody1),
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 38, big: 36)),
|
||||
Text(context.translate(I18n.deleteAccountBody2),
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary)
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
)),
|
||||
footer: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
),
|
||||
child: PrimaryButton(
|
||||
onPressed: (){
|
||||
if (state.loggedUser != null) {
|
||||
showDialog(context: context, builder: (context) =>
|
||||
Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: ConfirmDialog(navigationContract: navigationContract),
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
text: context.translate(I18n.requestCancelButton),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
|
||||
import 'package:account/src/features/delete_account/domain/delete_account_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final deleteAccountUseCaseProvider = Provider.autoDispose<DeleteAccountUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return DeleteAccountUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -0,0 +1,132 @@
|
||||
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
|
||||
import 'package:account/src/features/delete_account/presentation/providers/delete_account_use_case_provider.dart';
|
||||
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/get_linked_devices_use_case_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final deleteAccountViewModelProvider =
|
||||
NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
||||
DeleteAccountViewModel.new,
|
||||
);
|
||||
|
||||
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
late final DeleteAccountUseCase _deleteAccountUseCase;
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final TextEditingController passwordController;
|
||||
|
||||
@override
|
||||
DeleteAccountViewState build() {
|
||||
_deleteAccountUseCase = ref.read(deleteAccountUseCaseProvider);
|
||||
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
|
||||
|
||||
passwordController = TextEditingController();
|
||||
passwordController.addListener(_onPasswordChanged);
|
||||
|
||||
ref.onDispose(disposeListeners);
|
||||
|
||||
Future.microtask(() => load());
|
||||
|
||||
return const DeleteAccountViewState();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
final user = await ref.read(loggedUserProvider.future);
|
||||
setUser(user);
|
||||
|
||||
final devices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
setDevices(devices);
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void setDevices(List<DeviceEntity> devices) {
|
||||
state = state.copyWith(
|
||||
deviceNames: devices.map((device) => device.carrierName).toList(),
|
||||
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
|
||||
);
|
||||
}
|
||||
|
||||
void toggleDeleteDevice(int index) {
|
||||
List<bool> deleteDevices = state.deleteDevices;
|
||||
deleteDevices[index] = !deleteDevices[index];
|
||||
|
||||
state = state.copyWith(
|
||||
deleteDevices: deleteDevices,
|
||||
);
|
||||
}
|
||||
|
||||
void _onPasswordChanged() {
|
||||
final value = passwordController.text;
|
||||
if (value == state.password) return;
|
||||
|
||||
state = state.copyWith(
|
||||
password: value,
|
||||
errorMessage: ''
|
||||
);
|
||||
}
|
||||
|
||||
bool _validateForm() {
|
||||
if (state.password.trim().isEmpty) {
|
||||
state = state.copyWith(errorMessage: 'errorMessagePasswordIsEmpty');
|
||||
return false;
|
||||
}
|
||||
/*if (state.password.trim() != state.loggedUser.password.trim()) {
|
||||
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
|
||||
return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
void nextStep() {
|
||||
final step = state.confirmStep;
|
||||
|
||||
if (step == 0 && !_validateForm()) return;
|
||||
|
||||
state = state.copyWith(confirmStep: step + 1);
|
||||
}
|
||||
|
||||
void resetConfirmStep() {
|
||||
state = state.copyWith(confirmStep: 0);
|
||||
}
|
||||
|
||||
Future<bool> deleteAccount() async {
|
||||
if (state.isLoading) return false;
|
||||
|
||||
try {
|
||||
state = state.copyWith(isLoading: true);
|
||||
|
||||
await _deleteAccountUseCase.deleteAccount(userId: state.loggedUser!.id);
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
ref.invalidate(loggedUserProvider);
|
||||
|
||||
state = state.copyWith(isLoading: false, isDeleted: true);
|
||||
return true;
|
||||
} catch (e) {
|
||||
state = state.copyWith(isLoading: false);
|
||||
if (!ref.mounted) return false;
|
||||
_finishWithError(message: e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void _finishWithError({required String message}) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: message,
|
||||
);
|
||||
}
|
||||
|
||||
void disposeListeners() {
|
||||
passwordController.removeListener(_onPasswordChanged);
|
||||
passwordController.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
part 'delete_account_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class DeleteAccountViewState with _$DeleteAccountViewState {
|
||||
const factory DeleteAccountViewState({
|
||||
UserEntity? loggedUser,
|
||||
@Default('') String password,
|
||||
@Default(false) bool isLoading,
|
||||
@Default(false) bool isDeleted,
|
||||
@Default(0) int confirmStep,
|
||||
@Default([]) List<String> deviceNames,
|
||||
@Default([]) List<bool> deleteDevices,
|
||||
@Default('') String errorMessage,
|
||||
}) = _DeleteAccountViewState;
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
// 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 'delete_account_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$DeleteAccountViewState {
|
||||
|
||||
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isDeleted; int get confirmStep; List<String> get deviceNames; List<bool> get deleteDevices; String get errorMessage;
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeleteAccountViewStateCopyWith<DeleteAccountViewState> get copyWith => _$DeleteAccountViewStateCopyWithImpl<DeleteAccountViewState>(this as DeleteAccountViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isDeleted, isDeleted) || other.isDeleted == isDeleted)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.deviceNames, deviceNames)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isDeleted,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isDeleted: $isDeleted, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $DeleteAccountViewStateCopyWith<$Res> {
|
||||
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$DeleteAccountViewStateCopyWithImpl<$Res>
|
||||
implements $DeleteAccountViewStateCopyWith<$Res> {
|
||||
_$DeleteAccountViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final DeleteAccountViewState _self;
|
||||
final $Res Function(DeleteAccountViewState) _then;
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isDeleted = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isDeleted: null == isDeleted ? _self.isDeleted : isDeleted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||
as int,deviceNames: null == deviceNames ? _self.deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [DeleteAccountViewState].
|
||||
extension DeleteAccountViewStatePatterns on DeleteAccountViewState {
|
||||
/// 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( _DeleteAccountViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() 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( _DeleteAccountViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState():
|
||||
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( _DeleteAccountViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() 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( UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);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( UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState():
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);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( UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _DeleteAccountViewState() when $default != null:
|
||||
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _DeleteAccountViewState implements DeleteAccountViewState {
|
||||
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isDeleted = false, this.confirmStep = 0, final List<String> deviceNames = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _deviceNames = deviceNames,_deleteDevices = deleteDevices;
|
||||
|
||||
|
||||
@override final UserEntity? loggedUser;
|
||||
@override@JsonKey() final String password;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isDeleted;
|
||||
@override@JsonKey() final int confirmStep;
|
||||
final List<String> _deviceNames;
|
||||
@override@JsonKey() List<String> get deviceNames {
|
||||
if (_deviceNames is EqualUnmodifiableListView) return _deviceNames;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_deviceNames);
|
||||
}
|
||||
|
||||
final List<bool> _deleteDevices;
|
||||
@override@JsonKey() List<bool> get deleteDevices {
|
||||
if (_deleteDevices is EqualUnmodifiableListView) return _deleteDevices;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_deleteDevices);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$DeleteAccountViewStateCopyWith<_DeleteAccountViewState> get copyWith => __$DeleteAccountViewStateCopyWithImpl<_DeleteAccountViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isDeleted, isDeleted) || other.isDeleted == isDeleted)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._deviceNames, _deviceNames)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isDeleted,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isDeleted: $isDeleted, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$DeleteAccountViewStateCopyWith<$Res> implements $DeleteAccountViewStateCopyWith<$Res> {
|
||||
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$DeleteAccountViewStateCopyWithImpl<$Res>
|
||||
implements _$DeleteAccountViewStateCopyWith<$Res> {
|
||||
__$DeleteAccountViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _DeleteAccountViewState _self;
|
||||
final $Res Function(_DeleteAccountViewState) _then;
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isDeleted = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
|
||||
return _then(_DeleteAccountViewState(
|
||||
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isDeleted: null == isDeleted ? _self.isDeleted : isDeleted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
|
||||
as int,deviceNames: null == deviceNames ? _self._deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of DeleteAccountViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,229 @@
|
||||
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/app_routes.dart';
|
||||
import 'package:navigation/navigation_contract.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class ConfirmDialog extends ConsumerWidget{
|
||||
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const ConfirmDialog({
|
||||
super.key,
|
||||
required this.navigationContract,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final state = ref.watch(deleteAccountViewModelProvider);
|
||||
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
|
||||
|
||||
final steps = [
|
||||
VerifyAccountStep(
|
||||
theme: theme,
|
||||
email: state.loggedUser!.email,
|
||||
passwordController: viewModel.passwordController,
|
||||
errorMessage: state.errorMessage,
|
||||
nextStep: viewModel.nextStep,
|
||||
),
|
||||
ConfirmRequestStep(
|
||||
theme: theme,
|
||||
toggleDeleteDevice: viewModel.toggleDeleteDevice,
|
||||
deviceNames: state.deviceNames,
|
||||
onCancel: (){
|
||||
viewModel.resetConfirmStep();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onSubmit: () async {
|
||||
viewModel.deleteAccount();
|
||||
if (!context.mounted) return;
|
||||
|
||||
navigationContract.goTo(AppRoutes.login);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
return steps[state.confirmStep];
|
||||
}
|
||||
}
|
||||
|
||||
class VerifyAccountStep extends StatelessWidget {
|
||||
|
||||
final String email;
|
||||
final TextEditingController passwordController;
|
||||
final String errorMessage;
|
||||
final VoidCallback nextStep;
|
||||
final ThemePort theme;
|
||||
|
||||
const VerifyAccountStep({
|
||||
required this.email,
|
||||
required this.passwordController,
|
||||
required this.errorMessage,
|
||||
required this.nextStep,
|
||||
required this.theme,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 210,
|
||||
width: 500,
|
||||
color: Colors.white,
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 11),
|
||||
big: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(context.translate(I18n.verifyAccount),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
|
||||
Text('${context.translate(I18n.email)}: ${email}'),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 6)),
|
||||
Row(
|
||||
children: [
|
||||
Text('${context.translate(I18n.password)}: '),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(child: TextField(
|
||||
controller: passwordController,
|
||||
style: TextStyle(fontSize: 12),
|
||||
decoration: InputDecoration(hintText: context.translate(I18n.password)),
|
||||
obscureText: true,
|
||||
enableSuggestions: false,
|
||||
autocorrect: true,
|
||||
))
|
||||
],
|
||||
),
|
||||
if (errorMessage.isNotEmpty)
|
||||
Text(
|
||||
errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: SecondaryButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: 40,
|
||||
radius: 20,
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: nextStep,
|
||||
text: context.translate(I18n.accept),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: 40,
|
||||
radius: 20,
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ConfirmRequestStep extends StatelessWidget {
|
||||
|
||||
final ThemePort theme;
|
||||
final Function toggleDeleteDevice;
|
||||
final List<String> deviceNames;
|
||||
final VoidCallback onCancel;
|
||||
final VoidCallback onSubmit;
|
||||
|
||||
const ConfirmRequestStep({
|
||||
required this.theme,
|
||||
required this.toggleDeleteDevice,
|
||||
required this.deviceNames,
|
||||
required this.onCancel,
|
||||
required this.onSubmit,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 400,
|
||||
width: 500,
|
||||
color: Colors.white,
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 11),
|
||||
big: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 14, big: 12)),
|
||||
Text(context.translate(I18n.requestCancelTitle),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 14, big: 12)),
|
||||
Expanded(child: SingleChildScrollView(child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.requestCancelBody),
|
||||
style: TextStyle(height: 1.5),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
...List<Widget>.generate(deviceNames.length, (int index) =>
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(context.translate(I18n.deleteDeviceData,
|
||||
args: {'name': deviceNames[index]}
|
||||
),
|
||||
style: TextStyle(height: 0),
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: false,
|
||||
onChanged: (_){
|
||||
toggleDeleteDevice(index);
|
||||
}
|
||||
)
|
||||
),
|
||||
]
|
||||
))),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: SecondaryButton(
|
||||
onPressed: onCancel,
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: 50,
|
||||
radius: 25,
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: onSubmit,
|
||||
text: context.translate(I18n.confirm),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: 50,
|
||||
radius: 25,
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
abstract class DeleteDeviceUseCase {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
|
||||
class DeleteDeviceUseCaseImpl implements DeleteDeviceUseCase {
|
||||
DeleteDeviceUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
return _repository.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'update_device_request_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateDeviceRequestEntity with _$UpdateDeviceRequestEntity {
|
||||
const factory UpdateDeviceRequestEntity({
|
||||
required String identificator,
|
||||
required String name,
|
||||
}) = _UpdateDeviceRequestEntity;
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
// 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 'update_device_request_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UpdateDeviceRequestEntity {
|
||||
|
||||
String get identificator; String get name;
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateDeviceRequestEntityCopyWith<UpdateDeviceRequestEntity> get copyWith => _$UpdateDeviceRequestEntityCopyWithImpl<UpdateDeviceRequestEntity>(this as UpdateDeviceRequestEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateDeviceRequestEntityCopyWith<$Res> {
|
||||
factory $UpdateDeviceRequestEntityCopyWith(UpdateDeviceRequestEntity value, $Res Function(UpdateDeviceRequestEntity) _then) = _$UpdateDeviceRequestEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateDeviceRequestEntityCopyWithImpl<$Res>
|
||||
implements $UpdateDeviceRequestEntityCopyWith<$Res> {
|
||||
_$UpdateDeviceRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateDeviceRequestEntity _self;
|
||||
final $Res Function(UpdateDeviceRequestEntity) _then;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateDeviceRequestEntity].
|
||||
extension UpdateDeviceRequestEntityPatterns on UpdateDeviceRequestEntity {
|
||||
/// 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( _UpdateDeviceRequestEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() 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( _UpdateDeviceRequestEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity():
|
||||
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( _UpdateDeviceRequestEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity():
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateDeviceRequestEntity() when $default != null:
|
||||
return $default(_that.identificator,_that.name);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _UpdateDeviceRequestEntity implements UpdateDeviceRequestEntity {
|
||||
const _UpdateDeviceRequestEntity({required this.identificator, required this.name});
|
||||
|
||||
|
||||
@override final String identificator;
|
||||
@override final String name;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateDeviceRequestEntityCopyWith<_UpdateDeviceRequestEntity> get copyWith => __$UpdateDeviceRequestEntityCopyWithImpl<_UpdateDeviceRequestEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,name);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateDeviceRequestEntityCopyWith<$Res> implements $UpdateDeviceRequestEntityCopyWith<$Res> {
|
||||
factory _$UpdateDeviceRequestEntityCopyWith(_UpdateDeviceRequestEntity value, $Res Function(_UpdateDeviceRequestEntity) _then) = __$UpdateDeviceRequestEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String name
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateDeviceRequestEntityCopyWithImpl<$Res>
|
||||
implements _$UpdateDeviceRequestEntityCopyWith<$Res> {
|
||||
__$UpdateDeviceRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateDeviceRequestEntity _self;
|
||||
final $Res Function(_UpdateDeviceRequestEntity) _then;
|
||||
|
||||
/// Create a copy of UpdateDeviceRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
|
||||
return _then(_UpdateDeviceRequestEntity(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1 @@
|
||||
part of 'update_device_request_entity.dart';
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
|
||||
abstract class GetLinkedDevicesUseCase {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
|
||||
class GetLinkedDevicesUseCaseImpl implements GetLinkedDevicesUseCase {
|
||||
GetLinkedDevicesUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _repository.getLinkedDevices(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class UpdateDeviceUseCase {
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
// import 'package:account/src/features/linked_devices/domain/entities/device_entity.dart';
|
||||
// import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
|
||||
class UpdateDeviceUseCaseImpl implements UpdateDeviceUseCase {
|
||||
UpdateDeviceUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
|
||||
return _repository.updateDevice(userId: userId, deviceId: deviceId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// import 'package:account/src/features/account_settings/presentation/account_settings_screen.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/linked_devices_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class LinkedDevicesBuilder {
|
||||
const LinkedDevicesBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: LinkedDevicesScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
// import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class EditLinkedDeviceScreen extends ConsumerWidget {
|
||||
//final NavigationContract navigationContract;
|
||||
final DeviceEntity device;
|
||||
|
||||
const EditLinkedDeviceScreen({super.key, required this.device /*required this.navigationContract*/});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
// final state = ref.watch(linkedDevicesViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return /*LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.editDeviceTitle),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: body
|
||||
);*/
|
||||
Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
IconButton(onPressed: () {Navigator.pop(context);},
|
||||
icon: Icon(Icons.arrow_back)),
|
||||
Center(
|
||||
child: Text(context.translate(I18n.editDeviceTitle),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 28, big: 27)
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
Expanded(child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 48, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 47, vertical: 8)
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Center(child: SvgPicture.asset('assets/images/ui/profile.svg')),
|
||||
Center(child: SizedBox(
|
||||
width: 160,
|
||||
height: 160,
|
||||
child: Align(alignment: Alignment.bottomRight,
|
||||
child: IconButton(
|
||||
onPressed: (){},
|
||||
icon: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color(0xFFCAC9C9)
|
||||
),
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Icon(
|
||||
Icons.edit_outlined,
|
||||
color: Colors.white,
|
||||
size: SizeUtils.getByScreen(small: 32, big: 30),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.deviceNameController,
|
||||
hint: device.carrierName,
|
||||
label: context.translate(I18n.name),
|
||||
)
|
||||
],
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: (){vm.updateDevice(device);},
|
||||
text: context.translate(I18n.save),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
)
|
||||
],
|
||||
))
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/edit_linked_device_screen.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class LinkedDevicesScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const LinkedDevicesScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
final state = ref.watch(linkedDevicesViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.linkedDevices),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>LinkedDeviceCard(
|
||||
device: state.linkedDevices[index],
|
||||
isEditing: state.isEditing,
|
||||
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
|
||||
),
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.linkedDevices.length
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LinkedDeviceCard extends ConsumerWidget {
|
||||
|
||||
final DeviceEntity device;
|
||||
final bool isEditing;
|
||||
final Function onDelete;
|
||||
|
||||
const LinkedDeviceCard({
|
||||
required this.device,
|
||||
required this.isEditing,
|
||||
required this.onDelete,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(SizeUtils.getByScreen(small: 12, big: 18))),
|
||||
color: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
|
||||
child: Icon(SFIcons.watch,
|
||||
size: SizeUtils.getByScreen(small: 40, big: 44),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
weight: 30,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(device.carrierName,
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 18, big: 19),
|
||||
fontWeight: FontWeight.w500
|
||||
)
|
||||
),
|
||||
Text(device.phone ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 14, big: 13),
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
if (isEditing) ...[
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFFF5D52),
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||
),
|
||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.deleteDeviceDialog),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: (){Navigator.pop(context);},
|
||||
text: context.translate(I18n.cancel),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 4, big: 16)),
|
||||
Expanded(child: PrimaryButton(
|
||||
onPressed: () async {
|
||||
await onDelete();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
text: context.translate(I18n.delete),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
height: SizeUtils.getByScreen(small: 38, big: 36),
|
||||
radius: SizeUtils.getByScreen(small: 32, big: 34),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
));},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 16, big: 14)),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
child:
|
||||
IconButton(
|
||||
onPressed: (){Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => EditLinkedDeviceScreen(
|
||||
device: device,
|
||||
/*navigationContract: navigationContract*/
|
||||
)),
|
||||
);},
|
||||
icon: Icon(
|
||||
Icons.edit_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final deleteDeviceUseCaseProvider = Provider.autoDispose<DeleteDeviceUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return DeleteDeviceUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final getLinkedDevicesUseCaseProvider = Provider.autoDispose<GetLinkedDevicesUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return GetLinkedDevicesUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final updateDeviceUseCaseProvider = Provider.autoDispose<UpdateDeviceUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return UpdateDeviceUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/delete_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/get_linked_devices_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/update_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final linkedDevicesViewModelProvider =
|
||||
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
|
||||
LinkedDevicesViewModel.new,
|
||||
);
|
||||
|
||||
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final UpdateDeviceUseCase _updateDeviceUseCase;
|
||||
late final DeleteDeviceUseCase _deleteDeviceUseCase;
|
||||
|
||||
late final TextEditingController deviceNameController;
|
||||
|
||||
@override
|
||||
LinkedDevicesViewState build() {
|
||||
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
|
||||
_updateDeviceUseCase = ref.read(updateDeviceUseCaseProvider);
|
||||
_deleteDeviceUseCase = ref.read(deleteDeviceUseCaseProvider);
|
||||
|
||||
deviceNameController = TextEditingController();
|
||||
deviceNameController.addListener(_onDeviceNameChanged);
|
||||
|
||||
ref.read(loggedUserProvider.future)
|
||||
.then((user){
|
||||
setUser(user);
|
||||
return _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
}).then(setLinkedDevices);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
return const LinkedDevicesViewState();
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void setLinkedDevices(List<DeviceEntity> linkedDevices) {
|
||||
state = state.copyWith(linkedDevices: linkedDevices);
|
||||
}
|
||||
|
||||
void toggleIsEditing() {
|
||||
state = state.copyWith(isEditing: !state.isEditing);
|
||||
}
|
||||
|
||||
void _onDeviceNameChanged() {
|
||||
final value = deviceNameController.text;
|
||||
|
||||
if (value == state.deviceName) return;
|
||||
|
||||
state = state.copyWith(
|
||||
deviceName: value,
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> deleteDevice(DeviceEntity device) async {
|
||||
try {
|
||||
await _deleteDeviceUseCase.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
List<DeviceEntity> newList = state.linkedDevices;
|
||||
newList.remove(device);
|
||||
|
||||
state = state.copyWith(
|
||||
linkedDevices: newList
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateDeviceRequestEntity _toRequest(DeviceEntity device) {
|
||||
|
||||
return UpdateDeviceRequestEntity(
|
||||
identificator: device.identificator,
|
||||
name: state.deviceName.trim(),
|
||||
// phone: /*state.dialCode.trim() + */state.phoneNumber.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
void updateDevice(DeviceEntity device) {
|
||||
final deviceName = state.deviceName;
|
||||
|
||||
if (deviceName.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: ''
|
||||
);
|
||||
return;
|
||||
}
|
||||
final userId = 'test';
|
||||
_updateDeviceUseCase.updateDevice(
|
||||
userId: userId,
|
||||
deviceId: device.identificator,
|
||||
request: _toRequest(device));
|
||||
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
deviceNameController.removeListener(_onDeviceNameChanged);
|
||||
deviceNameController.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
part 'linked_devices_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LinkedDevicesViewState with _$LinkedDevicesViewState {
|
||||
const factory LinkedDevicesViewState({
|
||||
@Default(false) bool isLoading,
|
||||
@Default(null) UserEntity? loggedUser,
|
||||
@Default([]) List<DeviceEntity> linkedDevices,
|
||||
@Default(false) bool isEditing,
|
||||
@Default('') String deviceName,
|
||||
@Default('') String errorMessage
|
||||
}) = _LinkedDevicesViewState;
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
// 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 'linked_devices_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LinkedDevicesViewState {
|
||||
|
||||
bool get isLoading; UserEntity? get loggedUser; List<DeviceEntity> get linkedDevices; bool get isEditing; String get deviceName; String get errorMessage;
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LinkedDevicesViewStateCopyWith<LinkedDevicesViewState> get copyWith => _$LinkedDevicesViewStateCopyWithImpl<LinkedDevicesViewState>(this as LinkedDevicesViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.linkedDevices, linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LinkedDevicesViewStateCopyWith<$Res> {
|
||||
factory $LinkedDevicesViewStateCopyWith(LinkedDevicesViewState value, $Res Function(LinkedDevicesViewState) _then) = _$LinkedDevicesViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
implements $LinkedDevicesViewStateCopyWith<$Res> {
|
||||
_$LinkedDevicesViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LinkedDevicesViewState _self;
|
||||
final $Res Function(LinkedDevicesViewState) _then;
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self.linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LinkedDevicesViewState].
|
||||
extension LinkedDevicesViewStatePatterns on LinkedDevicesViewState {
|
||||
/// 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( _LinkedDevicesViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() 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( _LinkedDevicesViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState():
|
||||
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( _LinkedDevicesViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() 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 isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return 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 isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState():
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
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 isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LinkedDevicesViewState implements LinkedDevicesViewState {
|
||||
const _LinkedDevicesViewState({this.isLoading = false, this.loggedUser = null, final List<DeviceEntity> linkedDevices = const [], this.isEditing = false, this.deviceName = '', this.errorMessage = ''}): _linkedDevices = linkedDevices;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final UserEntity? loggedUser;
|
||||
final List<DeviceEntity> _linkedDevices;
|
||||
@override@JsonKey() List<DeviceEntity> get linkedDevices {
|
||||
if (_linkedDevices is EqualUnmodifiableListView) return _linkedDevices;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_linkedDevices);
|
||||
}
|
||||
|
||||
@override@JsonKey() final bool isEditing;
|
||||
@override@JsonKey() final String deviceName;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LinkedDevicesViewStateCopyWith<_LinkedDevicesViewState> get copyWith => __$LinkedDevicesViewStateCopyWithImpl<_LinkedDevicesViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._linkedDevices, _linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(_linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LinkedDevicesViewStateCopyWith<$Res> implements $LinkedDevicesViewStateCopyWith<$Res> {
|
||||
factory _$LinkedDevicesViewStateCopyWith(_LinkedDevicesViewState value, $Res Function(_LinkedDevicesViewState) _then) = __$LinkedDevicesViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
implements _$LinkedDevicesViewStateCopyWith<$Res> {
|
||||
__$LinkedDevicesViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LinkedDevicesViewState _self;
|
||||
final $Res Function(_LinkedDevicesViewState) _then;
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_LinkedDevicesViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self._linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<$Res>? get loggedUser {
|
||||
if (_self.loggedUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'update_user_request_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateUserRequestEntity with _$UpdateUserRequestEntity {
|
||||
const factory UpdateUserRequestEntity({
|
||||
required String id,
|
||||
String? delegationId,
|
||||
String? email,
|
||||
String? createdAt,
|
||||
String? updatedAt,
|
||||
String? status,
|
||||
String? role,
|
||||
String? lastLogin,
|
||||
String? currentLogin,
|
||||
String? language,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? hasApiKey,
|
||||
String? phone,
|
||||
}) = _UpdateUserRequestEntity;
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
// 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 'update_user_request_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UpdateUserRequestEntity {
|
||||
|
||||
String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone;
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateUserRequestEntityCopyWith<UpdateUserRequestEntity> get copyWith => _$UpdateUserRequestEntityCopyWithImpl<UpdateUserRequestEntity>(this as UpdateUserRequestEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateUserRequestEntityCopyWith<$Res> {
|
||||
factory $UpdateUserRequestEntityCopyWith(UpdateUserRequestEntity value, $Res Function(UpdateUserRequestEntity) _then) = _$UpdateUserRequestEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateUserRequestEntityCopyWithImpl<$Res>
|
||||
implements $UpdateUserRequestEntityCopyWith<$Res> {
|
||||
_$UpdateUserRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateUserRequestEntity _self;
|
||||
final $Res Function(UpdateUserRequestEntity) _then;
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateUserRequestEntity].
|
||||
extension UpdateUserRequestEntityPatterns on UpdateUserRequestEntity {
|
||||
/// 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( _UpdateUserRequestEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity() 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( _UpdateUserRequestEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity():
|
||||
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( _UpdateUserRequestEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateUserRequestEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _UpdateUserRequestEntity implements UpdateUserRequestEntity {
|
||||
const _UpdateUserRequestEntity({required this.id, this.delegationId, this.email, this.createdAt, this.updatedAt, this.status, this.role, this.lastLogin, this.currentLogin, this.language, this.firstName, this.lastName, this.hasApiKey, this.phone});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String? delegationId;
|
||||
@override final String? email;
|
||||
@override final String? createdAt;
|
||||
@override final String? updatedAt;
|
||||
@override final String? status;
|
||||
@override final String? role;
|
||||
@override final String? lastLogin;
|
||||
@override final String? currentLogin;
|
||||
@override final String? language;
|
||||
@override final String? firstName;
|
||||
@override final String? lastName;
|
||||
@override final String? hasApiKey;
|
||||
@override final String? phone;
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateUserRequestEntityCopyWith<_UpdateUserRequestEntity> get copyWith => __$UpdateUserRequestEntityCopyWithImpl<_UpdateUserRequestEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateUserRequestEntityCopyWith<$Res> implements $UpdateUserRequestEntityCopyWith<$Res> {
|
||||
factory _$UpdateUserRequestEntityCopyWith(_UpdateUserRequestEntity value, $Res Function(_UpdateUserRequestEntity) _then) = __$UpdateUserRequestEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateUserRequestEntityCopyWithImpl<$Res>
|
||||
implements _$UpdateUserRequestEntityCopyWith<$Res> {
|
||||
__$UpdateUserRequestEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateUserRequestEntity _self;
|
||||
final $Res Function(_UpdateUserRequestEntity) _then;
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
return _then(_UpdateUserRequestEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
|
||||
abstract class UpdateUserUseCase {
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
|
||||
import 'package:account/src/features/personal_data/domain/update_user_use_case.dart';
|
||||
|
||||
class UpdateUserUseCaseImpl implements UpdateUserUseCase {
|
||||
UpdateUserUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
|
||||
return _repository.updateUser(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// import 'package:account/src/features/account_settings/presentation/account_settings_screen.dart';
|
||||
import 'package:account/src/features/personal_data/presentation/personal_data_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class PersonalDataBuilder {
|
||||
const PersonalDataBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: PersonalDataScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import 'package:account/src/features/personal_data/presentation/state/personal_data_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class PersonalDataScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const PersonalDataScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(personalDataViewModelProvider.notifier);
|
||||
final state = ref.watch(personalDataViewModelProvider);
|
||||
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.personalData),
|
||||
body: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 48, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 47, vertical: 8)
|
||||
),
|
||||
child: SingleChildScrollView(child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Center(child: SvgPicture.asset('assets/images/ui/profile.svg')),
|
||||
Center(child: SizedBox(
|
||||
width: 160,
|
||||
height: 160,
|
||||
child: Align(alignment: Alignment.bottomRight,
|
||||
child: IconButton(
|
||||
onPressed: (){},
|
||||
icon: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color(0xFFCAC9C9)
|
||||
),
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Icon(
|
||||
Icons.edit_outlined,
|
||||
color: Colors.white,
|
||||
size: SizeUtils.getByScreen(small: 32, big: 30),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
|
||||
Text(context.translate(I18n.emailLabel),
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 14, big: 13))
|
||||
),
|
||||
Text(state.user?.email ?? '',
|
||||
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 18, big: 17))
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.nameController,
|
||||
hint: state.user?.firstName ?? '',
|
||||
label: context.translate(I18n.firstNameLabel),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.phoneController,
|
||||
hint: state.user?.phone ?? '',
|
||||
label: context.translate(I18n.phoneLabel),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
CustomTextField(
|
||||
controller: vm.emailController,
|
||||
hint: state.user?.email ?? '',
|
||||
label: context.translate(I18n.emailLabel),
|
||||
),
|
||||
],
|
||||
))
|
||||
),
|
||||
footer: PrimaryButton(
|
||||
onPressed: vm.updateUser,
|
||||
text: context.translate(I18n.submit),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/personal_data/domain/update_user_use_case.dart';
|
||||
import 'package:account/src/features/personal_data/domain/update_user_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final updateUserUseCaseProvider = Provider.autoDispose<UpdateUserUseCase>((ref) {
|
||||
final authRepository = ref.read(accountRepositoryProvider);
|
||||
return UpdateUserUseCaseImpl(authRepository);
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user