Merge origin/feature/remote-management

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 12:46:58 +01:00
519 changed files with 33839 additions and 8047 deletions

View File

@@ -0,0 +1 @@
{"version":2,"entries":[{"package":"sf_app_platform_mono_repo","rootUri":"../","packageUri":"lib/"}]}

View File

@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.2.4/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.3/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_secure_storage","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.2.4/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"flutter_secure_storage_macos","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_macos-3.1.3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.3/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"flutter_secure_storage_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_linux-1.2.3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"flutter_secure_storage_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.1.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false}],"web":[{"name":"flutter_secure_storage_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_web-1.2.1/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":["flutter_secure_storage_linux","flutter_secure_storage_macos","flutter_secure_storage_web","flutter_secure_storage_windows"]},{"name":"flutter_secure_storage_linux","dependencies":[]},{"name":"flutter_secure_storage_macos","dependencies":[]},{"name":"flutter_secure_storage_web","dependencies":[]},{"name":"flutter_secure_storage_windows","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2026-02-27 12:35:56.235180","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.2.4/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.3/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_secure_storage","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.2.4/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"flutter_secure_storage_macos","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_macos-3.1.3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.3/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"flutter_secure_storage_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_linux-1.2.3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"flutter_secure_storage_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.1.2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false}],"web":[{"name":"flutter_secure_storage_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/flutter_secure_storage_web-1.2.1/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":["flutter_secure_storage_linux","flutter_secure_storage_macos","flutter_secure_storage_web","flutter_secure_storage_windows"]},{"name":"flutter_secure_storage_linux","dependencies":[]},{"name":"flutter_secure_storage_macos","dependencies":[]},{"name":"flutter_secure_storage_web","dependencies":[]},{"name":"flutter_secure_storage_windows","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2026-03-13 09:52:54.635963","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}

1
.idea/modules.xml generated
View File

@@ -24,6 +24,7 @@
<module fileurl="file://$PROJECT_DIR$/packages/payments/melos_payments.iml" filepath="$PROJECT_DIR$/packages/payments/melos_payments.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/profile/melos_profile.iml" filepath="$PROJECT_DIR$/modules/profile/melos_profile.iml" />
<module fileurl="file://$PROJECT_DIR$/packages/sca_treezor/melos_sca_treezor.iml" filepath="$PROJECT_DIR$/packages/sca_treezor/melos_sca_treezor.iml" />
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/settings/melos_settings.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/settings/melos_settings.iml" />
<module fileurl="file://$PROJECT_DIR$/apps/mobile_app/melos_sf_app_platform.iml" filepath="$PROJECT_DIR$/apps/mobile_app/melos_sf_app_platform.iml" />
<module fileurl="file://$PROJECT_DIR$/packages/sf_infrastructure/melos_sf_infrastructure.iml" filepath="$PROJECT_DIR$/packages/sf_infrastructure/melos_sf_infrastructure.iml" />
<module fileurl="file://$PROJECT_DIR$/packages/sf_localizations/melos_sf_localizations.iml" filepath="$PROJECT_DIR$/packages/sf_localizations/melos_sf_localizations.iml" />

View File

@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:label="@string/app_name"

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
# permission_handler: enable contacts permission
PERMISSION_CONTACTS=1

View File

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

View File

@@ -47,6 +47,8 @@
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>NSContactsUsageDescription</key>
<string>Necesitamos acceso a tus contactos para seleccionar números de teléfono.</string>
<key>NSCameraUsageDescription</key>
<string>Necesitamos la cámara para escanear códigos QR</string>
<key>NSLocationWhenInUseUsageDescription</key>

View File

@@ -16,6 +16,7 @@ import 'package:navigation/navigation.dart';
import 'package:notifications/notifications.dart';
import 'package:payments/payments.dart';
import 'package:profile/profile.dart';
import 'package:settings/settings.dart';
import 'package:splash/splash.dart';
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
@@ -93,10 +94,27 @@ void configureAppRouter() {
name: 'device_management',
pageBuilder: DeviceManagementBuilder().buildPage,
routes: [
GoRoute(
path: 'scheduled_activities',
name: 'scheduled_activities',
pageBuilder: const ScheduledActivitiesBuilder().buildPage,
),
GoRoute(
path: 'contacts',
name: 'contacts',
pageBuilder: ContactsBuilder().buildPage,
pageBuilder: const ContactsBuilder().buildPage,
routes: [
GoRoute(
path: 'edit/:contactId',
name: 'edit_contact',
pageBuilder: const EditContactBuilder().buildPage,
),
],
),
GoRoute(
path: 'health',
name: 'health',
pageBuilder: const HealthBuilder().buildPage,
),
GoRoute(
path: 'remote_connection',
@@ -108,6 +126,21 @@ void configureAppRouter() {
name: 'locate_device',
pageBuilder: LocateDeviceBuilder().buildPage,
),
GoRoute(
path: 'rewards',
name: 'rewards',
pageBuilder: RewardsBuilder().buildPage,
),
GoRoute(
path: 'activity_meter',
name: 'activity_meter',
pageBuilder: const ActivityMeterBuilder().buildPage,
),
GoRoute(
path: 'apps_use',
name: 'apps_use',
pageBuilder: const AppsUseBuilder().buildPage,
),
],
),
],
@@ -136,8 +169,95 @@ void configureAppRouter() {
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.settings,
name: 'settings',
pageBuilder: SettingsBuilder().buildPage,
routes: [
GoRoute(
path: 'alarm',
name: 'alarm',
pageBuilder: AlarmBuilder().buildPage,
),
GoRoute(
path: 'remote_management',
name: 'remote_management',
pageBuilder: RemoteManagementBuilder().buildPage,
),
GoRoute(
path: 'sos_agenda',
name: 'sos_agenda',
pageBuilder: SosContactsBuilder().buildPage,
),
GoRoute(
path: 'sound',
name: 'sound',
pageBuilder: SoundBuilder().buildPage,
),
GoRoute(
path: 'sync_clock',
name: 'sync_clock',
pageBuilder: SyncClockBuilder().buildPage,
),
GoRoute(
path: 'app_store',
name: 'app_store',
pageBuilder: AppStoreBuilder().buildPage,
),
GoRoute(
path: 'battery',
name: 'battery',
pageBuilder: BatteryBuilder().buildPage,
),
GoRoute(
path: 'block_phone',
name: 'block_phone',
pageBuilder: BlockPhoneBuilder().buildPage,
),
GoRoute(
path: 'disable_functions',
name: 'disable_functions',
pageBuilder: DisableFunctionsBuilder().buildPage,
),
GoRoute(
path: 'language',
name: 'language',
pageBuilder: LanguageBuilder().buildPage,
),
GoRoute(
path: 'legacy_notifications',
name: 'legacy_notifications',
pageBuilder: LegacyNotificationsBuilder().buildPage,
),
GoRoute(
path: 'remote_on_off',
name: 'remote_on_off',
pageBuilder: RemoteOnOffBuilder().buildPage,
),
GoRoute(
path: 'sms_alert',
name: 'sms_alert',
pageBuilder: SmsAlertBuilder().buildPage,
),
GoRoute(
path: 'timezone',
name: 'timezone',
pageBuilder: TimezoneBuilder().buildPage,
),
GoRoute(
path: 'wifi_settings',
name: 'wifi_settings',
pageBuilder: WifiSettingsBuilder().buildPage,
),
],
),
],
),
],
),
GoRoute(
path: AppRoutes.login,
name: 'login',

View File

@@ -0,0 +1,42 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
class LegacyHeartbeatService {
LegacyHeartbeatService({
required QuestiaRepository repository,
required void Function() onUnauthorized,
}) : _repository = repository,
_onUnauthorized = onUnauthorized;
final QuestiaRepository _repository;
final void Function() _onUnauthorized;
Timer? _timer;
static const _interval = Duration(minutes: 3);
void start() {
if (_timer != null) return;
_beat();
_timer = Timer.periodic(_interval, (_) => _beat());
debugPrint('[LegacyHeartbeat] started');
}
void stop() {
_timer?.cancel();
_timer = null;
debugPrint('[LegacyHeartbeat] stopped');
}
Future<void> _beat() async {
try {
await _repository.get<dynamic>('/auth/me');
debugPrint('[LegacyHeartbeat] /auth/me => OK');
} catch (e) {
debugPrint('[LegacyHeartbeat] error: $e');
stop();
_onUnauthorized();
}
}
}

View File

@@ -6,7 +6,9 @@ import 'package:sf_app_platform/navigation/app_router.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_app_platform/providers/app_state_provider.dart';
import 'package:sf_app_platform/providers/permissions/permissions_provider.dart';
import 'package:sf_app_platform/providers/legacy_heartbeat_service.dart';
import 'package:sf_app_platform/providers/wallet_heartbeat_service.dart';
import 'package:get_it/get_it.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:sf_localizations/sf_localizations.dart';
@@ -23,6 +25,7 @@ class SaveFamilyApp extends ConsumerStatefulWidget {
class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
with WidgetsBindingObserver {
late final WalletHeartbeatService walletHeartbeat;
late final LegacyHeartbeatService legacyHeartbeat;
@override
void initState() {
@@ -33,13 +36,25 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
sessionLocal: SessionLocalDatasourceImpl(),
onError: () => appRouter.go(AppRoutes.scaTreezor),
);
onBeforeSessionCleared = walletHeartbeat.stop;
walletHeartbeat.start();
legacyHeartbeat = LegacyHeartbeatService(
repository: GetIt.I<QuestiaRepository>(),
onUnauthorized: () {
clearSessionData();
appRouter.go(AppRoutes.legacyLogin);
},
);
onBeforeSessionCleared = () {
walletHeartbeat.stop();
legacyHeartbeat.stop();
};
// walletHeartbeat.start();
legacyHeartbeat.start();
}
@override
void dispose() {
walletHeartbeat.stop();
legacyHeartbeat.stop();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@@ -49,10 +64,12 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
debugPrint('State: $state');
ref.read(appLifecycleStateProvider.notifier).setState(state);
if (state == AppLifecycleState.resumed) {
walletHeartbeat.start();
// walletHeartbeat.start();
legacyHeartbeat.start();
ref.read(permissionsProvider.notifier).checkPermissions();
} else if (state == AppLifecycleState.paused) {
walletHeartbeat.stop();
// walletHeartbeat.stop();
legacyHeartbeat.stop();
}
super.didChangeAppLifecycleState(state);
}

View File

@@ -406,6 +406,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_contacts:
dependency: transitive
description:
name: flutter_contacts
sha256: "388d32cd33f16640ee169570128c933b45f3259bddbfae7a100bb49e5ffea9ae"
url: "https://pub.dev"
source: hosted
version: "1.1.9+2"
flutter_launcher_icons:
dependency: "direct dev"
description:
@@ -1081,6 +1089,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.5.0"
settings:
dependency: "direct main"
description:
path: "../../modules/legacy/modules/settings"
relative: true
source: path
version: "1.0.0+1"
sf_infrastructure:
dependency: "direct main"
description:

View File

@@ -65,6 +65,8 @@ dependencies:
path: ../../modules/legacy/modules/location
legacy_auth:
path: ../../modules/legacy/modules/legacy_auth
settings:
path: ../../modules/legacy/modules/settings
#packages dependencies go here
navigation:
path: ../../packages/navigation

View File

@@ -1,4 +1,6 @@
# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management,legacy_auth,location
# melos_managed_dependency_overrides: settings
# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management
dependency_overrides:
account:
path: ../../modules/legacy/modules/account
@@ -40,6 +42,8 @@ dependency_overrides:
path: ../../modules/profile
sca_treezor:
path: ../../packages/sca_treezor
settings:
path: ../../modules/legacy/modules/settings
sf_infrastructure:
path: ../../packages/sf_infrastructure
sf_localizations:

View File

@@ -22,6 +22,15 @@
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/.pub" />
<excludeFolder url="file://$MODULE_DIR$/modules/legacy/build" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/.pub" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/build" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/.pub" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/build" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux/example/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />

View File

@@ -0,0 +1 @@
{"version":2,"entries":[{"package":"design_system","rootUri":"../../../packages/design_system/","packageUri":"lib/"},{"package":"flutter_treezor_entrust_sdk_bridge","rootUri":"../../../packages/flutter_treezor_entrust_sdk_bridge/","packageUri":"lib/"},{"package":"fonts","rootUri":"../../../packages/fonts/","packageUri":"lib/"},{"package":"get_it","rootUri":"file:///Users/juliandalcalaf/.pub-cache/hosted/pub.dev/get_it-9.2.0/","packageUri":"lib/","config":{"name":"get_it","issueTracker":"https://github.com/fluttercommunity/get_it/issues","version":"0.0.1","materialIconCodePoint":"0xe189"}},{"package":"sca_treezor","rootUri":"../../../packages/sca_treezor/","packageUri":"lib/"},{"package":"sf_infrastructure","rootUri":"../../../packages/sf_infrastructure/","packageUri":"lib/"},{"package":"sf_localizations","rootUri":"../../../packages/sf_localizations/","packageUri":"lib/"},{"package":"sf_shared","rootUri":"../../../packages/sf_shared/","packageUri":"lib/"},{"package":"shared_preferences","rootUri":"file:///Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences-2.5.4/","packageUri":"lib/","config":{"name":"shared_preferences","issueTracker":"https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22","version":"1.0.0","materialIconCodePoint":"0xe683"}},{"package":"utils","rootUri":"../../../packages/utils/","packageUri":"lib/"},{"package":"activity","rootUri":"../","packageUri":"lib/"}]}

View File

@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/apps/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/apps/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"],"dev_dependency":false}],"web":[{"name":"shared_preferences_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_treezor_entrust_sdk_bridge","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2026-02-28 20:18:36.684471","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/apps/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/apps/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"],"dev_dependency":false}],"web":[{"name":"shared_preferences_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_treezor_entrust_sdk_bridge","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2026-03-13 09:49:15.619720","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}

View File

@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:

View File

@@ -32,7 +32,7 @@ class OnboardingScreen extends ConsumerWidget {
void goToNext() {
if (isLast) {
navigationContract.goTo(AppRoutes.login);
navigationContract.goTo(AppRoutes.legacyLogin);
} else {
pageController.nextPage(
duration: const Duration(milliseconds: 400),
@@ -111,7 +111,7 @@ class OnboardingScreen extends ConsumerWidget {
? const SizedBox.shrink()
: TextButton(
onPressed: () =>
navigationContract.goTo(AppRoutes.login),
navigationContract.goTo(AppRoutes.legacyLogin),
child: Text(
context.translate(I18n.skip),
style: AppFonts.stolzlStyle(

View File

@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:

View File

@@ -29,10 +29,13 @@
<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" />
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/.pub" />
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/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>
</module>

View File

@@ -5,4 +5,4 @@ export 'src/features/personal_data/personal_data_builder.dart';
export 'src/features/change_password/change_password_builder.dart';
export 'src/features/linked_devices/linked_devices_builder.dart';
export 'src/features/app_users/app_users_builder.dart';
export 'src/features/delete_account/delete_account_builder.dart';
export 'src/features/delete_account/delete_account_builder.dart';

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
abstract class ChangePasswordRemoteDatasource {
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request});
}

View File

@@ -0,0 +1,27 @@
import 'package:account/src/core/data/models/change_password_request_model.dart';
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../../../features/change_password/domain/models/entities/change_password_request_entity.dart';
import 'change_password_remote_datasource.dart';
class ChangePasswordRemoteDatasourceImpl implements ChangePasswordRemoteDatasource {
ChangePasswordRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@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');
}
}
}

View File

@@ -0,0 +1,7 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
abstract class DevicesRemoteDatasource {
Future<void> deleteDevice({required String userId, required String deviceId});
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request});
}

View File

@@ -0,0 +1,37 @@
import 'package:account/src/core/data/models/update_device_request_model.dart';
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'devices_remote_datasource.dart';
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
DevicesRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) async {
try {
await _repository.delete<void>(
'/devices/$deviceId',
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to delete device');
}
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) async {
try {
final body = request.toModel().toJson();
await _repository.put<void>(
'/devices',
body: body,
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to update device');
}
}
}

View File

@@ -0,0 +1,10 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
abstract class UsersRemoteDatasource {
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
Future<List<UserEntity>> getUsers({required String userId});
Future<void> deleteUser({required String userId});
}

View File

@@ -0,0 +1,59 @@
import 'package:account/src/core/data/datasource/users_remote_datasource.dart';
import 'package:account/src/core/data/models/get_app_users_response_model.dart';
import 'package:account/src/core/data/models/update_user_request_model.dart';
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/sf_shared.dart';
class UsersRemoteDatasourceImpl implements UsersRemoteDatasource {
UsersRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<List<UserEntity>> getUsers({required String userId}) async {
try {
final response = await _repository.get<Map<String, dynamic>>(
'/users/$userId/user-devices',
);
final data = response.data!['items'];
if (data == null || data.isEmpty) {
throw Exception('Empty response from /users/$userId/user-devices');
}
final model = GetAppUsersResponseModel.fromJson(data);
return model.toEntity();
} on DioException catch (error) {
throw mapDioError(
error,
defaultMessage: error.message ?? 'Error getting devices',
);
}
}
@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<void> deleteUser({required String userId}) async {
try {
await _repository.delete<void>(
'/users/$userId',
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to delete device');
}
}
}

View File

@@ -1,5 +1,6 @@
import 'package:legacy_shared/legacy_shared.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:sf_shared/sf_shared.dart';
part 'get_app_users_response_model.freezed.dart';
part 'get_app_users_response_model.g.dart';
@@ -21,16 +22,16 @@ abstract class GetAppUsersItemResponseModel with _$GetAppUsersItemResponseModel
required String id,
required String delegationId,
required String email,
required String createdAt,
required String updatedAt,
required int createdAt,
required int? updatedAt,
required String status,
required String role,
required String lastLogin,
required String currentLogin,
required int lastLogin,
required int currentLogin,
required String language,
required String firstName,
required String lastName,
required String hasApiKey,
required bool hasApiKey,
required String phone
}) =
_GetAppUsersItemResponseModel;

View File

@@ -284,7 +284,7 @@ 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;
String get id; String get delegationId; String get email; int get createdAt; int? get updatedAt; String get status; String get role; int get lastLogin; int get currentLogin; String get language; String get firstName; String get lastName; bool 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)
@@ -317,7 +317,7 @@ 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
String id, String delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
});
@@ -334,22 +334,22 @@ class _$GetAppUsersItemResponseModelCopyWithImpl<$Res>
/// 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,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,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 int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,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 int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
as int,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 bool,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,
));
}
@@ -435,7 +435,7 @@ return $default(_that);case _:
/// }
/// ```
@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;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool 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 _:
@@ -456,7 +456,7 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@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;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool 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 _:
@@ -476,7 +476,7 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@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;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool 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 _:
@@ -497,16 +497,16 @@ class _GetAppUsersItemResponseModel implements GetAppUsersItemResponseModel {
@override final String id;
@override final String delegationId;
@override final String email;
@override final String createdAt;
@override final String updatedAt;
@override final int createdAt;
@override final int? updatedAt;
@override final String status;
@override final String role;
@override final String lastLogin;
@override final String currentLogin;
@override final int lastLogin;
@override final int currentLogin;
@override final String language;
@override final String firstName;
@override final String lastName;
@override final String hasApiKey;
@override final bool hasApiKey;
@override final String phone;
/// Create a copy of GetAppUsersItemResponseModel
@@ -542,7 +542,7 @@ abstract mixin class _$GetAppUsersItemResponseModelCopyWith<$Res> implements $Ge
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
String id, String delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
});
@@ -559,22 +559,22 @@ class __$GetAppUsersItemResponseModelCopyWithImpl<$Res>
/// 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,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,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 int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,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 int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
as int,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 bool,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,
));
}

View File

@@ -26,16 +26,16 @@ _GetAppUsersItemResponseModel _$GetAppUsersItemResponseModelFromJson(
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,
createdAt: (json['createdAt'] as num).toInt(),
updatedAt: (json['updatedAt'] as num?)?.toInt(),
status: json['status'] as String,
role: json['role'] as String,
lastLogin: json['lastLogin'] as String,
currentLogin: json['currentLogin'] as String,
lastLogin: (json['lastLogin'] as num).toInt(),
currentLogin: (json['currentLogin'] as num).toInt(),
language: json['language'] as String,
firstName: json['firstName'] as String,
lastName: json['lastName'] as String,
hasApiKey: json['hasApiKey'] as String,
hasApiKey: json['hasApiKey'] as bool,
phone: json['phone'] as String,
);

View File

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

View File

@@ -1,99 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'get_linked_devices_response_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_GetLinkedDevicesResponseModel _$GetLinkedDevicesResponseModelFromJson(
Map<String, dynamic> json,
) => _GetLinkedDevicesResponseModel(
items: (json['items'] as List<dynamic>)
.map(
(e) => GetLinkedDevicesItemResponseModel.fromJson(
e as Map<String, dynamic>,
),
)
.toList(),
);
Map<String, dynamic> _$GetLinkedDevicesResponseModelToJson(
_GetLinkedDevicesResponseModel instance,
) => <String, dynamic>{'items': instance.items};
_GetLinkedDevicesItemResponseModel _$GetLinkedDevicesItemResponseModelFromJson(
Map<String, dynamic> json,
) => _GetLinkedDevicesItemResponseModel(
identificator: json['identificator'] as String,
carrierName: json['carrierName'] as String,
phone: json['phone'] as String,
id: json['id'] as String,
settings: 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,
};

View File

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

View File

@@ -1,597 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'get_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

View File

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

View File

@@ -8,7 +8,7 @@ part 'update_device_request_model.g.dart';
abstract class UpdateDeviceRequestModel with _$UpdateDeviceRequestModel {
const factory UpdateDeviceRequestModel({
required String identificator,
required String name,
required String carrierName,
}) = _UpdateDeviceRequestModel;
factory UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) =>
@@ -18,6 +18,6 @@ abstract class UpdateDeviceRequestModel with _$UpdateDeviceRequestModel {
extension UpdateDeviceRequestModelMapper on UpdateDeviceRequestEntity {
UpdateDeviceRequestModel toModel() => UpdateDeviceRequestModel(
identificator: identificator,
name: name,
carrierName: carrierName,
);
}

View File

@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$UpdateDeviceRequestModel {
String get identificator; String get name;
String get identificator; String get carrierName;
/// Create a copy of UpdateDeviceRequestModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $UpdateDeviceRequestModelCopyWith<UpdateDeviceRequestModel> get copyWith => _$Up
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,identificator,name);
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
@override
String toString() {
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
return 'UpdateDeviceRequestModel(identificator: $identificator, carrierName: $carrierName)';
}
@@ -48,7 +48,7 @@ abstract mixin class $UpdateDeviceRequestModelCopyWith<$Res> {
factory $UpdateDeviceRequestModelCopyWith(UpdateDeviceRequestModel value, $Res Function(UpdateDeviceRequestModel) _then) = _$UpdateDeviceRequestModelCopyWithImpl;
@useResult
$Res call({
String identificator, String name
String identificator, String carrierName
});
@@ -65,10 +65,10 @@ class _$UpdateDeviceRequestModelCopyWithImpl<$Res>
/// Create a copy of UpdateDeviceRequestModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,}) {
return _then(_self.copyWith(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,
));
}
@@ -154,10 +154,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestModel() when $default != null:
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
return orElse();
}
@@ -175,10 +175,10 @@ return $default(_that.identificator,_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName) $default,) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestModel():
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
throw StateError('Unexpected subclass');
}
@@ -195,10 +195,10 @@ return $default(_that.identificator,_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName)? $default,) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestModel() when $default != null:
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
return null;
}
@@ -210,11 +210,11 @@ return $default(_that.identificator,_that.name);case _:
@JsonSerializable()
class _UpdateDeviceRequestModel implements UpdateDeviceRequestModel {
const _UpdateDeviceRequestModel({required this.identificator, required this.name});
const _UpdateDeviceRequestModel({required this.identificator, required this.carrierName});
factory _UpdateDeviceRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateDeviceRequestModelFromJson(json);
@override final String identificator;
@override final String name;
@override final String carrierName;
/// Create a copy of UpdateDeviceRequestModel
/// with the given fields replaced by the non-null parameter values.
@@ -229,16 +229,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,identificator,name);
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
@override
String toString() {
return 'UpdateDeviceRequestModel(identificator: $identificator, name: $name)';
return 'UpdateDeviceRequestModel(identificator: $identificator, carrierName: $carrierName)';
}
@@ -249,7 +249,7 @@ abstract mixin class _$UpdateDeviceRequestModelCopyWith<$Res> implements $Update
factory _$UpdateDeviceRequestModelCopyWith(_UpdateDeviceRequestModel value, $Res Function(_UpdateDeviceRequestModel) _then) = __$UpdateDeviceRequestModelCopyWithImpl;
@override @useResult
$Res call({
String identificator, String name
String identificator, String carrierName
});
@@ -266,10 +266,10 @@ class __$UpdateDeviceRequestModelCopyWithImpl<$Res>
/// Create a copy of UpdateDeviceRequestModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,}) {
return _then(_UpdateDeviceRequestModel(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,
));
}

View File

@@ -10,12 +10,12 @@ _UpdateDeviceRequestModel _$UpdateDeviceRequestModelFromJson(
Map<String, dynamic> json,
) => _UpdateDeviceRequestModel(
identificator: json['identificator'] as String,
name: json['name'] as String,
carrierName: json['carrierName'] as String,
);
Map<String, dynamic> _$UpdateDeviceRequestModelToJson(
_UpdateDeviceRequestModel instance,
) => <String, dynamic>{
'identificator': instance.identificator,
'name': instance.name,
'carrierName': instance.carrierName,
};

View File

@@ -7,19 +7,8 @@ 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;
@@ -29,19 +18,8 @@ abstract class UpdateUserRequestModel with _$UpdateUserRequestModel {
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,
);
}

View File

@@ -15,7 +15,7 @@ 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;
String? get firstName; String? get lastName; String? get phone;
/// Create a copy of UpdateUserRequestModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $UpdateUserRequestModelCopyWith<UpdateUserRequestModel> get copyWith => _$Update
@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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestModel&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(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);
int get hashCode => Object.hash(runtimeType,firstName,lastName,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)';
return 'UpdateUserRequestModel(firstName: $firstName, lastName: $lastName, phone: $phone)';
}
@@ -48,7 +48,7 @@ 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
String? firstName, String? lastName, String? phone
});
@@ -65,21 +65,10 @@ class _$UpdateUserRequestModelCopyWithImpl<$Res>
/// 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,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? firstName = freezed,Object? lastName = 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
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?,
));
@@ -166,10 +155,10 @@ return $default(_that);case _:
/// }
/// ```
@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;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? firstName, String? lastName, 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 $default(_that.firstName,_that.lastName,_that.phone);case _:
return orElse();
}
@@ -187,10 +176,10 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@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;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? firstName, String? lastName, 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 _:
return $default(_that.firstName,_that.lastName,_that.phone);case _:
throw StateError('Unexpected subclass');
}
@@ -207,10 +196,10 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@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;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? firstName, String? lastName, 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 $default(_that.firstName,_that.lastName,_that.phone);case _:
return null;
}
@@ -222,22 +211,11 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
@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});
const _UpdateUserRequestModel({this.firstName, this.lastName, 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
@@ -253,16 +231,16 @@ 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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestModel&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(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);
int get hashCode => Object.hash(runtimeType,firstName,lastName,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)';
return 'UpdateUserRequestModel(firstName: $firstName, lastName: $lastName, phone: $phone)';
}
@@ -273,7 +251,7 @@ abstract mixin class _$UpdateUserRequestModelCopyWith<$Res> implements $UpdateUs
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
String? firstName, String? lastName, String? phone
});
@@ -290,21 +268,10 @@ class __$UpdateUserRequestModelCopyWithImpl<$Res>
/// 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,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? firstName = freezed,Object? lastName = 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
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?,
));

View File

@@ -9,37 +9,15 @@ part of 'update_user_request_model.dart';
_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,
};

View File

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

View File

@@ -0,0 +1,15 @@
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
import '../../domain/repositories/change_password_repository.dart';
import '../datasource/change_password_remote_datasource.dart';
class ChangePasswordRepositoryImpl implements ChangePasswordRepository {
const ChangePasswordRepositoryImpl(this._remote);
final ChangePasswordRemoteDatasource _remote;
@override
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) {
return _remote.changePassword(userId: userId, request: request);
}
}

View File

@@ -0,0 +1,20 @@
import 'package:account/src/core/data/datasource/devices_remote_datasource.dart';
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import '../../domain/repositories/devices_repository.dart';
class DevicesRepositoryImpl implements DevicesRepository {
const DevicesRepositoryImpl(this._remote);
final DevicesRemoteDatasource _remote;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) {
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) {
return _remote.updateDevice(userId: userId, request: request);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
import '../../domain/repositories/users_repository.dart';
import '../datasource/users_remote_datasource.dart';
class UsersRepositoryImpl implements UsersRepository {
const UsersRepositoryImpl(this._remote);
final UsersRemoteDatasource _remote;
@override
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
return _remote.updateUser(userId: userId, request: request);
}
@override
Future<List<UserEntity>> getUsers({required String userId}) {
return _remote.getUsers(userId: userId);
}
@override
Future<void> deleteUser({required String userId}) {
return _remote.deleteUser(userId: userId);
}
}

View File

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

View File

@@ -0,0 +1,8 @@
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_entity.dart';
abstract class ChangePasswordRepository {
Future<void> changePassword({
required String userId,
required ChangePasswordRequestEntity request
});
}

View File

@@ -0,0 +1,10 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
abstract class DevicesRepository {
Future<void> deleteDevice({required String userId, required String deviceId});
Future<void> updateDevice({
required String userId,
required UpdateDeviceRequestEntity request
});
}

View File

@@ -0,0 +1,13 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
abstract class UsersRepository {
Future<void> updateUser({
required String userId,
required UpdateUserRequestEntity request
});
Future<List<UserEntity>> getUsers({required String userId});
Future<void> deleteUser({required String userId});
}

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/change_password_remote_datasource.dart';
import '../data/datasource/change_password_remote_datasource_impl.dart';
final changePasswordRemoteDatasourceProvider = Provider<ChangePasswordRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return ChangePasswordRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/change_password_repository_impl.dart';
import '../domain/repositories/change_password_repository.dart';
import 'change_password_remote_datasource_provider.dart';
final changePasswordRepositoryProvider = Provider<ChangePasswordRepository>((ref) {
final remote = ref.read(changePasswordRemoteDatasourceProvider);
return ChangePasswordRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/devices_remote_datasource.dart';
import '../data/datasource/devices_remote_datasource_impl.dart';
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return DevicesRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/devices_repository_impl.dart';
import '../domain/repositories/devices_repository.dart';
import 'devices_remote_datasource_provider.dart';
final devicesRepositoryProvider = Provider<DevicesRepository>((ref) {
final remote = ref.read(devicesRemoteDatasourceProvider);
return DevicesRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/users_remote_datasource.dart';
import '../data/datasource/users_remote_datasource_impl.dart';
final usersRemoteDatasourceProvider = Provider<UsersRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return UsersRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/users_repository_impl.dart';
import '../domain/repositories/users_repository.dart';
import 'users_remote_datasource_provider.dart';
final usersRepositoryProvider = Provider<UsersRepository>((ref) {
final remote = ref.read(usersRemoteDatasourceProvider);
return UsersRepositoryImpl(remote);
});

View File

@@ -1,3 +1,4 @@
import 'package:account/src/features/account_settings/presentation/state/account_settings_view_model.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -6,257 +7,173 @@ 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';
import 'widgets/reg_code_dialog.dart';
class AccountSettingsScreen extends ConsumerWidget {
final NavigationContract navigationContract;
static final _privacyUrl =
'https://savefamilygps.com/pages/politica-de-privacidad-reloj-gps-infantil-localizador-savefamily';
const AccountSettingsScreen({super.key, required this.navigationContract});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final color = theme.getColorFor(ThemeCode.legacyPrimary);
final selectedDevice = ref.watch(selectedDeviceProvider);
final isLoggingOut = ref.watch(
accountSettingsViewModelProvider.select((s) => s.isLoggingOut),
);
ref.listen(accountSettingsViewModelProvider.select((s) => s.isLoggingOut), (
prev,
isLoggingOut,
) {
if (prev == true && !isLoggingOut) {
navigationContract.goTo(AppRoutes.legacyLogin);
}
});
return LegacyPageLayout(
theme: theme,
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)
body: SingleChildScrollView(
child: Padding(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8),
),
child: Column(
children: [
_item(
context,
onPressed: () =>
navigationContract.pushTo(AppRoutes.personalData),
icon: SFIcons.account,
text: I18n.personalData,
color: color,
),
_item(
context,
onPressed: () =>
navigationContract.pushTo(AppRoutes.changePassword),
icon: Icons.lock,
text: I18n.changePassword,
color: color,
),
_item(
context,
onPressed: () =>
navigationContract.pushTo(AppRoutes.legacyDeviceSetup),
icon: Icons.add_circle_outline,
text: I18n.addNewSF,
color: color,
),
_item(
context,
onPressed: () =>
navigationContract.pushTo(AppRoutes.linkedDevices),
icon: Icons.account_circle_outlined,
text: I18n.linkedDevices,
color: color,
),
// _item(context, onPressed: () => navigationContract.pushTo(AppRoutes.appUsers), icon: Icons.groups_outlined, text: I18n.appUsers, color: color),
_item(
context,
onPressed: () async {
final Uri url = Uri.parse(_privacyUrl);
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
},
icon: SFIcons.privacy,
text: I18n.privacyPolicy,
color: color,
),
_item(
context,
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,
color: color,
),
_item(
context,
onPressed: () =>
navigationContract.pushTo(AppRoutes.deleteAccount),
icon: Icons.no_accounts,
text: I18n.deleteAccount,
color: color,
),
],
),
),
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)
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
child: PrimaryButton(
text: context.translate(I18n.logOut),
color: theme.getColorFor(ThemeCode.legacyPrimary),
leading: isLoggingOut
? const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
)
)
],
: null,
onPressed: isLoggingOut
? () {}
: ref.read(accountSettingsViewModelProvider.notifier).logout,
),
)
);
}
}
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,
),
)
),
],
),
);
}
}
Widget _item(
BuildContext context, {
required VoidCallback onPressed,
required IconData icon,
required String text,
required Color color,
}) {
return Padding(
padding: EdgeInsets.only(
bottom: SizeUtils.getByScreen(small: 16, big: 15),
),
child: SectionButton(
onPressed: onPressed,
icon: Icon(
icon,
size: SizeUtils.getByScreen(small: 28, big: 26),
color: color,
),
body: Text(
context.translate(text),
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 18, big: 19),
fontWeight: FontWeight.w500,
),
),
),
);
}
}

View File

@@ -0,0 +1,30 @@
import 'package:account/src/features/account_settings/presentation/state/account_settings_view_state.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/legacy_auth.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
final accountSettingsViewModelProvider =
NotifierProvider.autoDispose<AccountSettingsViewModel, AccountSettingsViewState>(
AccountSettingsViewModel.new,
);
class AccountSettingsViewModel extends Notifier<AccountSettingsViewState> {
@override
AccountSettingsViewState build() {
return const AccountSettingsViewState();
}
Future<void> logout() async {
if (state.isLoggingOut) return;
state = state.copyWith(isLoggingOut: true, errorMessage: '');
try {
await ref.read(legacyAuthRepositoryProvider).logout();
} catch (_) {}
await clearSessionData();
state = state.copyWith(isLoggingOut: false);
}
}

View File

@@ -0,0 +1,11 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'account_settings_view_state.freezed.dart';
@freezed
abstract class AccountSettingsViewState with _$AccountSettingsViewState {
const factory AccountSettingsViewState({
@Default(false) bool isLoggingOut,
@Default('') String errorMessage,
}) = _AccountSettingsViewState;
}

View File

@@ -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 'account_settings_view_state.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$AccountSettingsViewState {
bool get isLoggingOut; String get errorMessage;
/// Create a copy of AccountSettingsViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$AccountSettingsViewStateCopyWith<AccountSettingsViewState> get copyWith => _$AccountSettingsViewStateCopyWithImpl<AccountSettingsViewState>(this as AccountSettingsViewState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AccountSettingsViewState&&(identical(other.isLoggingOut, isLoggingOut) || other.isLoggingOut == isLoggingOut)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoggingOut,errorMessage);
@override
String toString() {
return 'AccountSettingsViewState(isLoggingOut: $isLoggingOut, errorMessage: $errorMessage)';
}
}
/// @nodoc
abstract mixin class $AccountSettingsViewStateCopyWith<$Res> {
factory $AccountSettingsViewStateCopyWith(AccountSettingsViewState value, $Res Function(AccountSettingsViewState) _then) = _$AccountSettingsViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoggingOut, String errorMessage
});
}
/// @nodoc
class _$AccountSettingsViewStateCopyWithImpl<$Res>
implements $AccountSettingsViewStateCopyWith<$Res> {
_$AccountSettingsViewStateCopyWithImpl(this._self, this._then);
final AccountSettingsViewState _self;
final $Res Function(AccountSettingsViewState) _then;
/// Create a copy of AccountSettingsViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoggingOut = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoggingOut: null == isLoggingOut ? _self.isLoggingOut : isLoggingOut // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [AccountSettingsViewState].
extension AccountSettingsViewStatePatterns on AccountSettingsViewState {
/// 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( _AccountSettingsViewState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _AccountSettingsViewState() 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( _AccountSettingsViewState value) $default,){
final _that = this;
switch (_that) {
case _AccountSettingsViewState():
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( _AccountSettingsViewState value)? $default,){
final _that = this;
switch (_that) {
case _AccountSettingsViewState() 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 isLoggingOut, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _AccountSettingsViewState() when $default != null:
return $default(_that.isLoggingOut,_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 isLoggingOut, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _AccountSettingsViewState():
return $default(_that.isLoggingOut,_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 isLoggingOut, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _AccountSettingsViewState() when $default != null:
return $default(_that.isLoggingOut,_that.errorMessage);case _:
return null;
}
}
}
/// @nodoc
class _AccountSettingsViewState implements AccountSettingsViewState {
const _AccountSettingsViewState({this.isLoggingOut = false, this.errorMessage = ''});
@override@JsonKey() final bool isLoggingOut;
@override@JsonKey() final String errorMessage;
/// Create a copy of AccountSettingsViewState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$AccountSettingsViewStateCopyWith<_AccountSettingsViewState> get copyWith => __$AccountSettingsViewStateCopyWithImpl<_AccountSettingsViewState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AccountSettingsViewState&&(identical(other.isLoggingOut, isLoggingOut) || other.isLoggingOut == isLoggingOut)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoggingOut,errorMessage);
@override
String toString() {
return 'AccountSettingsViewState(isLoggingOut: $isLoggingOut, errorMessage: $errorMessage)';
}
}
/// @nodoc
abstract mixin class _$AccountSettingsViewStateCopyWith<$Res> implements $AccountSettingsViewStateCopyWith<$Res> {
factory _$AccountSettingsViewStateCopyWith(_AccountSettingsViewState value, $Res Function(_AccountSettingsViewState) _then) = __$AccountSettingsViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoggingOut, String errorMessage
});
}
/// @nodoc
class __$AccountSettingsViewStateCopyWithImpl<$Res>
implements _$AccountSettingsViewStateCopyWith<$Res> {
__$AccountSettingsViewStateCopyWithImpl(this._self, this._then);
final _AccountSettingsViewState _self;
final $Res Function(_AccountSettingsViewState) _then;
/// Create a copy of AccountSettingsViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoggingOut = null,Object? errorMessage = null,}) {
return _then(_AccountSettingsViewState(
isLoggingOut: null == isLoggingOut ? _self.isLoggingOut : isLoggingOut // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -0,0 +1,134 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart';
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,
});
static const _iconRadius = 40.0;
@override
Widget build(BuildContext context) {
return Stack(
clipBehavior: Clip.none,
alignment: Alignment.topCenter,
children: [
Container(
width: SizeUtils.getByScreen(small: 320, big: 340),
margin: const EdgeInsets.only(top: _iconRadius),
padding: EdgeInsets.only(
top: _iconRadius + SizeUtils.getByScreen(small: 12, big: 10),
bottom: SizeUtils.getByScreen(small: 20, big: 18),
left: SizeUtils.getByScreen(small: 20, big: 18),
right: SizeUtils.getByScreen(small: 20, big: 18),
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () => Navigator.pop(context),
child: const Icon(Icons.close, size: 22, color: Colors.grey),
),
),
Text(
name,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 16),
_CopyableField(
label: context.translate(
I18n.deviceIdLabel,
args: {'deviceId': deviceId},
),
value: deviceId,
),
const SizedBox(height: 20),
QrImageView(
data: regCode,
version: QrVersions.auto,
size: SizeUtils.getByScreen(small: 120, big: 120),
padding: EdgeInsets.zero,
),
const SizedBox(height: 16),
_CopyableField(
label: context.translate(
I18n.regCodeLabel,
args: {'regCode': regCode},
),
value: regCode,
),
],
),
),
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFF00A1C6),
),
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 16, big: 16)),
child: Icon(
SFIcons.watch,
size: SizeUtils.getByScreen(small: 68, big: 66),
color: Colors.white,
),
),
],
);
}
}
class _CopyableField extends StatelessWidget {
final String label;
final String value;
const _CopyableField({required this.label, required this.value});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Clipboard.setData(ClipboardData(text: value)),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
label,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 13),
),
),
const SizedBox(width: 6),
const Icon(Icons.copy, size: 14, color: Colors.grey),
],
),
),
);
}
}

View File

@@ -1,4 +0,0 @@
abstract class DeleteAppUserUseCase {
Future<void> deleteAppUser({required String userId});
}

View File

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

View File

@@ -1,5 +0,0 @@
import 'package:legacy_shared/legacy_shared.dart';
abstract class GetAppUsersUseCase {
Future<List<UserEntity>> getAppUsers({required String userId});
}

View File

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

View File

@@ -5,6 +5,7 @@ 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:sf_shared/sf_shared.dart';
import 'package:utils/utils.dart';
class AppUsersScreen extends ConsumerWidget {

View File

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

View File

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

View File

@@ -1,11 +1,8 @@
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/core/domain/repositories/users_repository.dart';
import 'package:account/src/core/providers/users_repository_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';
import 'package:sf_shared/sf_shared.dart';
final appUsersViewModelProvider =
NotifierProvider.autoDispose<AppUsersViewModel, AppUsersViewState>(
@@ -13,23 +10,25 @@ NotifierProvider.autoDispose<AppUsersViewModel, AppUsersViewState>(
);
class AppUsersViewModel extends Notifier<AppUsersViewState> {
late final GetAppUsersUseCase _getAppUsersUseCase;
late final DeleteAppUserUseCase _deleteAppUserUseCase;
late final UsersRepository _usersRepository;
@override
AppUsersViewState build() {
_getAppUsersUseCase = ref.read(getAppUsersUseCaseProvider);
_deleteAppUserUseCase = ref.read(deleteAppUserUseCaseProvider);
_usersRepository = ref.read(usersRepositoryProvider);
ref.read(loggedUserProvider.future)
.then((user){
setUser(user);
return _getAppUsersUseCase.getAppUsers(userId: user.id);
}).then(setAppUsers);
_init();
return const AppUsersViewState();
}
Future<void> _init() async {
final user = await ref.read(userInfoProvider.future);
setUser(user);
final appUsers = await _usersRepository.getUsers(userId: user.id);
setAppUsers(appUsers);
}
void setUser(UserEntity user) {
state = state.copyWith(loggedUser: user);
}
@@ -45,7 +44,7 @@ class AppUsersViewModel extends Notifier<AppUsersViewState> {
state = state.copyWith(isEditing: !state.isEditing);
}
void deleteAppUser() {
_deleteAppUserUseCase.deleteAppUser(userId: state.loggedUser!.id);
void deleteUser() {
_usersRepository.deleteUser(userId: state.loggedUser!.id);
}
}

View File

@@ -1,5 +1,5 @@
import 'package:legacy_shared/legacy_shared.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:sf_shared/sf_shared.dart';
part 'app_users_view_state.freezed.dart';

View File

@@ -1,11 +1,11 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/core/domain/repositories/change_password_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;
final ChangePasswordRepository _repository;
@override
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) {

View File

@@ -14,13 +14,11 @@ class ChangePasswordScreen extends ConsumerWidget {
@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,
theme: theme,
title: context.translate(I18n.changePassword),
body: Container(
padding: SizeUtils.getByScreen(
@@ -30,45 +28,156 @@ theme: theme,
child: SingleChildScrollView(child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CustomTextField(
controller: vm.currentPasswordController,
hint: '********',
label: context.translate(I18n.password),
),
const _PasswordSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
CustomTextField(
controller: vm.newPasswordController,
hint: '********',
label: context.translate(I18n.newPassword),
),
const _NewPasswordSection(),
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,
),
),
],
const _RepeatPasswordSection(),
const _ErrorMessageSection()
],
))
),
footer: PrimaryButton(
footer: _SaveSection(navigationContract: navigationContract),
);
}
}
class _PasswordSection extends ConsumerWidget {
const _PasswordSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
);
return CustomTextField(
controller: vm.currentPasswordController,
hint: '********',
label: context.translate(I18n.password),
showPassword: showPassword,
onVisibilityChanged: vm.toggleCurrentPasswordVisibility,
);
}
}
class _NewPasswordSection extends ConsumerWidget {
const _NewPasswordSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
);
return CustomTextField(
controller: vm.newPasswordController,
hint: '********',
label: context.translate(I18n.newPassword),
showPassword: showPassword,
onVisibilityChanged: vm.toggleNewPasswordVisibility,
);
}
}
class _RepeatPasswordSection extends ConsumerWidget {
const _RepeatPasswordSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
);
return CustomTextField(
controller: vm.repeatPasswordController,
hint: '********',
label: context.translate(I18n.repeatPassword),
showPassword: showPassword,
onVisibilityChanged: vm.toggleRepeatedPasswordVisibility,
);
}
}
class _ErrorMessageSection extends ConsumerWidget {
const _ErrorMessageSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final errorMessage = ref.watch(
changePasswordViewModelProvider.select((s)=>s.errorMessage)
);
if (errorMessage.isNotEmpty) {
return Column(
children: [
const SizedBox(height: 8),
Text(
errorMessage,
textAlign: TextAlign.center,
style: const TextStyle(
color: Color.fromRGBO(239, 17, 17, 1),
fontSize: 12,
),
),
],
);
} else return SizedBox.shrink();
}
}
class _SaveSection extends ConsumerWidget {
final NavigationContract navigationContract;
const _SaveSection({required this.navigationContract});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final vm = ref.read(changePasswordViewModelProvider.notifier);
return Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10),
child: PrimaryButton(
onPressed: () async {
final bool res = await vm.changePassword();
if (res){
navigationContract.goBack();
await vm.submit();
final errorMessage = ref.read(
changePasswordViewModelProvider.select((s)=>s.errorMessage)
);
if (errorMessage.isNotEmpty) {
showTopSnackbar(
context,
message: errorMessage,
type: MessageType.error
);
return;
}
final isComplete = ref.read(
changePasswordViewModelProvider.select((s)=>s.isComplete)
);
if (isComplete){
navigationContract.goTo(AppRoutes.legacyLogin);
}
},
text: context.translate('OK'),
text: context.translate(I18n.save),
color: theme.getColorFor(ThemeCode.legacyPrimary)
),
);

View File

@@ -1,9 +1,10 @@
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';
import '../../../../core/providers/change_password_repository_provider.dart';
final changePasswordUseCaseProvider = Provider.autoDispose<ChangePasswordUseCase>((ref) {
final accountRepository = ref.read(accountRepositoryProvider);
return ChangePasswordUseCaseImpl(accountRepository);
final changePassword = ref.read(changePasswordRepositoryProvider);
return ChangePasswordUseCaseImpl(changePassword);
});

View File

@@ -4,9 +4,7 @@ import 'package:account/src/features/change_password/presentation/providers/chan
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';
import 'package:sf_shared/sf_shared.dart';
final changePasswordViewModelProvider =
NotifierProvider.autoDispose<ChangePasswordViewModel, ChangePasswordViewState>(
@@ -25,6 +23,13 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
ChangePasswordViewState build() {
_changePasswordUseCase = ref.read(changePasswordUseCaseProvider);
_initControllers();
return const ChangePasswordViewState();
}
void _initControllers() {
currentPasswordController = TextEditingController();
currentPasswordController.addListener(_onCurrentPasswordChanged);
@@ -32,18 +37,27 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
newPasswordController.addListener(_onNewPasswordChanged);
repeatPasswordController = TextEditingController();
repeatPasswordController.addListener(_onRepeatPasswordController);
ref.read(loggedUserProvider.future)
.then(setUser);
repeatPasswordController.addListener(_onRepeatPasswordChanged);
ref.onDispose(disposeControllers);
return const ChangePasswordViewState();
}
void setUser(UserEntity user) {
state = state.copyWith(loggedUser: user);
void toggleCurrentPasswordVisibility() {
state = state.copyWith(
showCurrentPassword: !state.showCurrentPassword
);
}
void toggleNewPasswordVisibility() {
state = state.copyWith(
showNewPassword: !state.showNewPassword
);
}
void toggleRepeatedPasswordVisibility() {
state = state.copyWith(
showRepeatedPassword: !state.showRepeatedPassword
);
}
void _onCurrentPasswordChanged() {
@@ -53,6 +67,7 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
state = state.copyWith(
currentPassword: value,
errorMessage: ''
);
}
@@ -63,16 +78,18 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
state = state.copyWith(
newPassword: value,
errorMessage: ''
);
}
void _onRepeatPasswordController() {
void _onRepeatPasswordChanged() {
final value = repeatPasswordController.text;
if (value == state.repeatPassword) return;
state = state.copyWith(
repeatPassword: value,
errorMessage: ''
);
}
@@ -103,28 +120,36 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
);
}
Future<bool> changePassword() async {
if (state.isLoading) return false;
if (!_validateForm()) return false;
Future<void> submit() async {
if (state.isLoading) return;
if (!_validateForm()) return;
try {
state = state.copyWith(
isLoading: true,
isComplete: false
);
final user = await ref.read(userInfoProvider.future);
final request = _toRequest();
await _changePasswordUseCase.changePassword(userId: state.loggedUser!.id, request: request);
ref.invalidate(loggedUserProvider);
return true;
await _changePasswordUseCase.changePassword(userId: user.id, request: request);
state = state.copyWith(
isLoading: false,
isComplete: true
);
} catch (e) {
if (!ref.mounted) return false;
if (!ref.mounted) return;
_finishWithError(message: e.toString());
return false;
return;
}
}
void _finishWithError({required String message}) {
state = state.copyWith(
isLoading: false,
isComplete: false,
errorMessage: message,
);
}
@@ -136,7 +161,7 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
newPasswordController.removeListener(_onNewPasswordChanged);
newPasswordController.dispose();
repeatPasswordController.removeListener(_onRepeatPasswordController);
repeatPasswordController.removeListener(_onRepeatPasswordChanged);
repeatPasswordController.dispose();
}

View File

@@ -1,13 +1,15 @@
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(false) bool isComplete,
@Default(false) bool showCurrentPassword,
@Default(false) bool showNewPassword,
@Default(false) bool showRepeatedPassword,
@Default('') String currentPassword,
@Default('') String newPassword,
@Default('') String repeatPassword,

View File

@@ -14,7 +14,7 @@ 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;
bool get isLoading; bool get isComplete; bool get showCurrentPassword; bool get showNewPassword; bool get showRepeatedPassword; String get currentPassword; String get newPassword; String get repeatPassword; String get errorMessage;
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$Chan
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,isLoading,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(loggedUser: $loggedUser, isLoading: $isLoading, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -45,11 +45,11 @@ 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
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
});
$UserEntityCopyWith<$Res>? get loggedUser;
}
/// @nodoc
@@ -62,10 +62,13 @@ class _$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? isLoading = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = 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
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,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
@@ -73,19 +76,7 @@ as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage
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));
});
}
}
@@ -167,10 +158,10 @@ return $default(_that);case _:
/// }
/// ```
@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;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return orElse();
}
@@ -188,10 +179,10 @@ return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.new
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, 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 _:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -208,10 +199,10 @@ return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.new
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, bool isLoading, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return null;
}
@@ -223,11 +214,14 @@ return $default(_that.loggedUser,_that.isLoading,_that.currentPassword,_that.new
class _ChangePasswordViewState implements ChangePasswordViewState {
const _ChangePasswordViewState({this.loggedUser, this.isLoading = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showCurrentPassword = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
@override final UserEntity? loggedUser;
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final bool showCurrentPassword;
@override@JsonKey() final bool showNewPassword;
@override@JsonKey() final bool showRepeatedPassword;
@override@JsonKey() final String currentPassword;
@override@JsonKey() final String newPassword;
@override@JsonKey() final String repeatPassword;
@@ -243,16 +237,16 @@ _$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$C
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,isLoading,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(loggedUser: $loggedUser, isLoading: $isLoading, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -263,11 +257,11 @@ abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangeP
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
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
});
@override $UserEntityCopyWith<$Res>? get loggedUser;
}
/// @nodoc
@@ -280,10 +274,13 @@ class __$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? isLoading = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = 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
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,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
@@ -292,19 +289,7 @@ 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

View File

@@ -1,6 +0,0 @@
abstract class DeleteAccountUseCase {
Future<void> deleteAccount({
required String userId,
});
}

View File

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

View File

@@ -17,9 +17,6 @@ class DeleteAccountScreen extends ConsumerWidget {
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),
@@ -27,72 +24,126 @@ class DeleteAccountScreen extends ConsumerWidget {
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)),
)
],
),
),
const _Header(),
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)
),
),
const _BodySection(),
],
)
)),
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)
),
),
footer: _RequestCancelSection(navigationContract: navigationContract),
);
}
}
class _Header extends ConsumerWidget {
const _Header();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
return 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)),
)
],
),
);
}
}
class _BodySection extends ConsumerWidget {
const _BodySection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
return Column(
children: [
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)
),
)
],
);
}
}
class _RequestCancelSection extends ConsumerWidget {
final NavigationContract navigationContract;
const _RequestCancelSection({required this.navigationContract});
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final isLoading = ref.watch(
deleteAccountViewModelProvider.select((s)=>s.isLoading)
);
final user = ref.watch(
deleteAccountViewModelProvider.select((s)=>s.loggedUser)
);
return Padding(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 14, vertical: 10),
big: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
),
child: PrimaryButton(
onPressed: (){
if (isLoading) return;
if (user == null) {
navigationContract.goTo(AppRoutes.login);
return;
}
showDialog(context: context, builder: (context) =>
Dialog(
backgroundColor: Colors.transparent,
child: ConfirmDialog(navigationContract: navigationContract),
)
);
},
text: context.translate(I18n.requestCancelButton),
color: theme.getColorFor(ThemeCode.legacyPrimary)
),
);
}
}

View File

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

View File

@@ -1,13 +1,10 @@
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/core/domain/repositories/users_repository.dart';
import 'package:account/src/core/providers/users_repository_provider.dart';
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
import 'package: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';
import 'package:sf_shared/sf_shared.dart';
final deleteAccountViewModelProvider =
NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
@@ -15,14 +12,14 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
);
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
late final DeleteAccountUseCase _deleteAccountUseCase;
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
late final UsersRepository _usersRepository;
late final SharedDevicesRepository _devicesRepository;
late final TextEditingController passwordController;
@override
DeleteAccountViewState build() {
_deleteAccountUseCase = ref.read(deleteAccountUseCaseProvider);
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
_usersRepository = ref.read(usersRepositoryProvider);
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
passwordController = TextEditingController();
passwordController.addListener(_onPasswordChanged);
@@ -35,10 +32,10 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
}
Future<void> load() async {
final user = await ref.read(loggedUserProvider.future);
final user = await ref.read(userInfoProvider.future);
setUser(user);
final devices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
final devices = await _devicesRepository.getDevices();
setDevices(devices);
}
@@ -48,7 +45,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
void setDevices(List<DeviceEntity> devices) {
state = state.copyWith(
deviceNames: devices.map((device) => device.carrierName).toList(),
deviceNames: devices.map((device) => device.carrierName!).toList(),
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
);
}
@@ -96,24 +93,25 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
state = state.copyWith(confirmStep: 0);
}
Future<bool> deleteAccount() async {
if (state.isLoading) return false;
Future<void> deleteAccount() async {
if (state.isLoading) return;
try {
state = state.copyWith(isLoading: true);
state = state.copyWith(
isLoading: true,
isComplete: false,
);
await _deleteAccountUseCase.deleteAccount(userId: state.loggedUser!.id);
if (!ref.mounted) return false;
await _usersRepository.deleteUser(userId: state.loggedUser!.id);
if (!ref.mounted) return;
ref.invalidate(loggedUserProvider);
state = state.copyWith(isLoading: false, isDeleted: true);
return true;
state = state.copyWith(
isLoading: false,
isComplete: true
);
} catch (e) {
state = state.copyWith(isLoading: false);
if (!ref.mounted) return false;
if (!ref.mounted) return;
_finishWithError(message: e.toString());
return false;
}
}
@@ -121,6 +119,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
void _finishWithError({required String message}) {
state = state.copyWith(
isLoading: false,
isComplete: false,
errorMessage: message,
);
}

View File

@@ -1,5 +1,5 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart';
part 'delete_account_view_state.freezed.dart';
@@ -9,7 +9,7 @@ abstract class DeleteAccountViewState with _$DeleteAccountViewState {
UserEntity? loggedUser,
@Default('') String password,
@Default(false) bool isLoading,
@Default(false) bool isDeleted,
@Default(false) bool isComplete,
@Default(0) int confirmStep,
@Default([]) List<String> deviceNames,
@Default([]) List<bool> deleteDevices,

View File

@@ -14,7 +14,7 @@ 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;
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isComplete; int get confirmStep; List<String> get deviceNames; List<bool> get deleteDevices; String get errorMessage;
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $DeleteAccountViewStateCopyWith<DeleteAccountViewState> get copyWith => _$Delete
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.deviceNames, deviceNames)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isDeleted,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
@override
String toString() {
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isDeleted: $isDeleted, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $DeleteAccountViewStateCopyWith<$Res> {
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
@useResult
$Res call({
UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
});
@@ -62,12 +62,12 @@ class _$DeleteAccountViewStateCopyWithImpl<$Res>
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isDeleted = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? 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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
as int,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
@@ -169,10 +169,10 @@ return $default(_that);case _:
/// }
/// ```
@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;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _DeleteAccountViewState() when $default != null:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return orElse();
}
@@ -190,10 +190,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,
/// }
/// ```
@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;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _DeleteAccountViewState():
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -210,10 +210,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,
/// }
/// ```
@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;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _DeleteAccountViewState() when $default != null:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return null;
}
@@ -225,13 +225,13 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isDeleted,
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;
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isComplete = false, this.confirmStep = 0, final List<String> deviceNames = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _deviceNames = deviceNames,_deleteDevices = deleteDevices;
@override final UserEntity? loggedUser;
@override@JsonKey() final String password;
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isDeleted;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final int confirmStep;
final List<String> _deviceNames;
@override@JsonKey() List<String> get deviceNames {
@@ -259,16 +259,16 @@ _$DeleteAccountViewStateCopyWith<_DeleteAccountViewState> get copyWith => __$Del
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.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));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._deviceNames, _deviceNames)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isDeleted,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
@override
String toString() {
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isDeleted: $isDeleted, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
}
@@ -279,7 +279,7 @@ abstract mixin class _$DeleteAccountViewStateCopyWith<$Res> implements $DeleteAc
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
@override @useResult
$Res call({
UserEntity? loggedUser, String password, bool isLoading, bool isDeleted, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
});
@@ -296,12 +296,12 @@ class __$DeleteAccountViewStateCopyWithImpl<$Res>
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isDeleted = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? 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,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
as int,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

View File

@@ -25,14 +25,14 @@ class ConfirmDialog extends ConsumerWidget{
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
final steps = [
VerifyAccountStep(
_VerifyAccountStep(
theme: theme,
email: state.loggedUser!.email,
passwordController: viewModel.passwordController,
errorMessage: state.errorMessage,
nextStep: viewModel.nextStep,
),
ConfirmRequestStep(
_ConfirmRequestStep(
theme: theme,
toggleDeleteDevice: viewModel.toggleDeleteDevice,
deviceNames: state.deviceNames,
@@ -43,8 +43,13 @@ class ConfirmDialog extends ConsumerWidget{
onSubmit: () async {
viewModel.deleteAccount();
if (!context.mounted) return;
navigationContract.goTo(AppRoutes.login);
final isComplete = ref.read(
deleteAccountViewModelProvider.select((s)=>s.isComplete)
);
if (isComplete) {
navigationContract.goTo(AppRoutes.login);
}
},
),
];
@@ -53,7 +58,7 @@ class ConfirmDialog extends ConsumerWidget{
}
}
class VerifyAccountStep extends StatelessWidget {
class _VerifyAccountStep extends StatelessWidget {
final String email;
final TextEditingController passwordController;
@@ -61,7 +66,7 @@ class VerifyAccountStep extends StatelessWidget {
final VoidCallback nextStep;
final ThemePort theme;
const VerifyAccountStep({
const _VerifyAccountStep({
required this.email,
required this.passwordController,
required this.errorMessage,
@@ -141,7 +146,7 @@ class VerifyAccountStep extends StatelessWidget {
}
class ConfirmRequestStep extends StatelessWidget {
class _ConfirmRequestStep extends StatelessWidget {
final ThemePort theme;
final Function toggleDeleteDevice;
@@ -149,7 +154,7 @@ class ConfirmRequestStep extends StatelessWidget {
final VoidCallback onCancel;
final VoidCallback onSubmit;
const ConfirmRequestStep({
const _ConfirmRequestStep({
required this.theme,
required this.toggleDeleteDevice,
required this.deviceNames,
@@ -160,7 +165,7 @@ class ConfirmRequestStep extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 400,
height: 300,
width: 500,
color: Colors.white,
padding: SizeUtils.getByScreen(

View File

@@ -1,4 +0,0 @@
abstract class DeleteDeviceUseCase {
Future<void> deleteDevice({required String userId, required String deviceId});
}

View File

@@ -1,13 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
class DeleteDeviceUseCaseImpl implements DeleteDeviceUseCase {
DeleteDeviceUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) async {
return _repository.deleteDevice(userId: userId, deviceId: deviceId);
}
}

View File

@@ -6,6 +6,6 @@ part 'update_device_request_entity.freezed.dart';
abstract class UpdateDeviceRequestEntity with _$UpdateDeviceRequestEntity {
const factory UpdateDeviceRequestEntity({
required String identificator,
required String name,
required String carrierName,
}) = _UpdateDeviceRequestEntity;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$UpdateDeviceRequestEntity {
String get identificator; String get name;
String get identificator; String get carrierName;
/// Create a copy of UpdateDeviceRequestEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $UpdateDeviceRequestEntityCopyWith<UpdateDeviceRequestEntity> get copyWith => _$
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
}
@override
int get hashCode => Object.hash(runtimeType,identificator,name);
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
@override
String toString() {
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
return 'UpdateDeviceRequestEntity(identificator: $identificator, carrierName: $carrierName)';
}
@@ -45,7 +45,7 @@ abstract mixin class $UpdateDeviceRequestEntityCopyWith<$Res> {
factory $UpdateDeviceRequestEntityCopyWith(UpdateDeviceRequestEntity value, $Res Function(UpdateDeviceRequestEntity) _then) = _$UpdateDeviceRequestEntityCopyWithImpl;
@useResult
$Res call({
String identificator, String name
String identificator, String carrierName
});
@@ -62,10 +62,10 @@ class _$UpdateDeviceRequestEntityCopyWithImpl<$Res>
/// Create a copy of UpdateDeviceRequestEntity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? name = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,}) {
return _then(_self.copyWith(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,
));
}
@@ -151,10 +151,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String name)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestEntity() when $default != null:
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
return orElse();
}
@@ -172,10 +172,10 @@ return $default(_that.identificator,_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String name) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName) $default,) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestEntity():
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
throw StateError('Unexpected subclass');
}
@@ -192,10 +192,10 @@ return $default(_that.identificator,_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String name)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName)? $default,) {final _that = this;
switch (_that) {
case _UpdateDeviceRequestEntity() when $default != null:
return $default(_that.identificator,_that.name);case _:
return $default(_that.identificator,_that.carrierName);case _:
return null;
}
@@ -207,11 +207,11 @@ return $default(_that.identificator,_that.name);case _:
class _UpdateDeviceRequestEntity implements UpdateDeviceRequestEntity {
const _UpdateDeviceRequestEntity({required this.identificator, required this.name});
const _UpdateDeviceRequestEntity({required this.identificator, required this.carrierName});
@override final String identificator;
@override final String name;
@override final String carrierName;
/// Create a copy of UpdateDeviceRequestEntity
/// with the given fields replaced by the non-null parameter values.
@@ -223,16 +223,16 @@ _$UpdateDeviceRequestEntityCopyWith<_UpdateDeviceRequestEntity> get copyWith =>
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateDeviceRequestEntity&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName));
}
@override
int get hashCode => Object.hash(runtimeType,identificator,name);
int get hashCode => Object.hash(runtimeType,identificator,carrierName);
@override
String toString() {
return 'UpdateDeviceRequestEntity(identificator: $identificator, name: $name)';
return 'UpdateDeviceRequestEntity(identificator: $identificator, carrierName: $carrierName)';
}
@@ -243,7 +243,7 @@ abstract mixin class _$UpdateDeviceRequestEntityCopyWith<$Res> implements $Updat
factory _$UpdateDeviceRequestEntityCopyWith(_UpdateDeviceRequestEntity value, $Res Function(_UpdateDeviceRequestEntity) _then) = __$UpdateDeviceRequestEntityCopyWithImpl;
@override @useResult
$Res call({
String identificator, String name
String identificator, String carrierName
});
@@ -260,10 +260,10 @@ class __$UpdateDeviceRequestEntityCopyWithImpl<$Res>
/// Create a copy of UpdateDeviceRequestEntity
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? name = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,}) {
return _then(_UpdateDeviceRequestEntity(
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,
));
}

View File

@@ -1,5 +0,0 @@
import 'package:legacy_shared/src/data/models/entities/device_entity.dart';
abstract class GetLinkedDevicesUseCase {
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
}

View File

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

View File

@@ -1,6 +0,0 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
abstract class UpdateDeviceUseCase {
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request});
}

View File

@@ -1,16 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
// import 'package:account/src/features/linked_devices/domain/entities/device_entity.dart';
// import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
class UpdateDeviceUseCaseImpl implements UpdateDeviceUseCase {
UpdateDeviceUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
return _repository.updateDevice(userId: userId, deviceId: deviceId, request: request);
}
}

View File

@@ -1,58 +1,32 @@
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*/});
const EditLinkedDeviceScreen();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
// final state = ref.watch(linkedDevicesViewModelProvider);
final theme = ref.watch(themePortProvider);
return /*LegacyPageLayout(
theme: theme,
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
final device = ref.watch(
linkedDevicesViewModelProvider.select((s)=>s.selectedDevice)
);
return LegacyPageLayout(
theme: theme,
title: context.translate(I18n.editDeviceTitle),
showEdit: true,
onEditChange: vm.toggleIsEditing,
body: body
);*/
Scaffold(
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
body: SafeArea(
child: Column(
body: Column(
children: [
Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
),
child: Stack(
children: [
IconButton(onPressed: () {Navigator.pop(context);},
icon: Icon(Icons.arrow_back)),
Center(
child: Text(context.translate(I18n.editDeviceTitle),
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 28, big: 27)
),
)
)
],
),
),
SizedBox(height: SizeUtils.getByScreen(small: 20, big: 18)),
Expanded(child: Container(
padding: SizeUtils.getByScreen(
@@ -67,7 +41,8 @@ theme: theme,
children: [
Stack(
children: [
Center(child: SvgPicture.asset('assets/images/ui/profile.svg')),
DecoratedBox(decoration: BoxDecoration(color: Colors.blueAccent)),
Center(child: SvgPicture.asset('assets/shared/images/profile.svg')),
Center(child: SizedBox(
width: 160,
height: 160,
@@ -94,22 +69,53 @@ theme: theme,
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
CustomTextField(
controller: vm.deviceNameController,
hint: device.carrierName,
hint: device!.carrierName!,
label: context.translate(I18n.name),
)
],
),
PrimaryButton(
onPressed: (){vm.updateDevice(device);},
text: context.translate(I18n.save),
color: theme.getColorFor(ThemeCode.legacyPrimary)
)
],
))
),
],
),
footer: _SaveSection(),
);
}
}
class _SaveSection extends ConsumerWidget{
const _SaveSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
return Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10),
child:
PrimaryButton(
onPressed: () async {
await vm.updateDevice();
final errorMessage = ref.read(
linkedDevicesViewModelProvider.select((s) => s.errorMessage)
);
if (errorMessage.isNotEmpty) {
showTopSnackbar(
context,
message: errorMessage,
type: MessageType.error,
);
}
},
text: context.translate(I18n.save),
color: theme.getColorFor(ThemeCode.legacyPrimary)
)
),
);
}
}

View File

@@ -1,12 +1,13 @@
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:account/src/features/linked_devices/presentation/widgets/delete_device_dialog.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:utils/utils.dart';
class LinkedDevicesScreen extends ConsumerWidget {
@@ -22,38 +23,32 @@ class LinkedDevicesScreen extends ConsumerWidget {
final theme = ref.watch(themePortProvider);
return LegacyPageLayout(
theme: theme,
theme: theme,
title: context.translate(I18n.linkedDevices),
showEdit: true,
onEditChange: vm.toggleIsEditing,
body: Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
big: EdgeInsets.symmetric(horizontal: 21, vertical: 8)
body: ListView.separated(
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
device: state.linkedDevices[index],
isEditing: state.isEditing,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
),
child: ListView.separated(
itemBuilder: (BuildContext context, int index)=>LinkedDeviceCard(
device: state.linkedDevices[index],
isEditing: state.isEditing,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
),
separatorBuilder: (BuildContext context, int index)=>SizedBox(
height: SizeUtils.getByScreen(small: 18, big: 17)
),
itemCount: state.linkedDevices.length
separatorBuilder: (BuildContext context, int index)=>SizedBox(
height: SizeUtils.getByScreen(small: 18, big: 17)
),
itemCount: state.linkedDevices.length
),
);
}
}
class LinkedDeviceCard extends ConsumerWidget {
class _LinkedDeviceCard extends ConsumerWidget {
final DeviceEntity device;
final bool isEditing;
final Function onDelete;
const LinkedDeviceCard({
const _LinkedDeviceCard({
required this.device,
required this.isEditing,
required this.onDelete,
@@ -63,6 +58,8 @@ class LinkedDeviceCard extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
return Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 22, vertical: 10),
@@ -91,7 +88,7 @@ class LinkedDeviceCard extends ConsumerWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(device.carrierName,
Text(device.carrierName!,
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 18, big: 19),
fontWeight: FontWeight.w500
@@ -113,46 +110,7 @@ class LinkedDeviceCard extends ConsumerWidget {
),
child: IconButton(
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
child: Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
),
width: SizeUtils.getByScreen(small: 360, big: 350),
height: SizeUtils.getByScreen(small: 195, big: 185),
child: Column(
children: [
Text(context.translate(I18n.deleteDeviceDialog),
textAlign: TextAlign.center,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
),
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: PrimaryButton(
onPressed: (){Navigator.pop(context);},
text: context.translate(I18n.cancel),
color: theme.getColorFor(ThemeCode.legacyPrimary),
height: SizeUtils.getByScreen(small: 38, big: 36),
radius: SizeUtils.getByScreen(small: 32, big: 34),
)),
SizedBox(width: SizeUtils.getByScreen(small: 4, big: 16)),
Expanded(child: PrimaryButton(
onPressed: () async {
await onDelete();
Navigator.pop(context);
},
text: context.translate(I18n.delete),
color: theme.getColorFor(ThemeCode.legacyPrimary),
height: SizeUtils.getByScreen(small: 38, big: 36),
radius: SizeUtils.getByScreen(small: 32, big: 34),
))
],
)
],
),
),
child: DeleteDeviceDialog(device: device),
));},
icon: Icon(
Icons.close,
@@ -168,13 +126,13 @@ class LinkedDeviceCard extends ConsumerWidget {
),
child:
IconButton(
onPressed: (){Navigator.push(
context,
MaterialPageRoute(builder: (_) => EditLinkedDeviceScreen(
device: device,
/*navigationContract: navigationContract*/
)),
);},
onPressed: (){
vm.setSelectedDevice(device);
Navigator.push(
context,
MaterialPageRoute(builder: (_) => EditLinkedDeviceScreen()),
);
},
icon: Icon(
Icons.edit_outlined,
color: Colors.white,

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/providers/account_repository_provider.dart';
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
import 'package:account/src/features/linked_devices/domain/delete_device_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final deleteDeviceUseCaseProvider = Provider.autoDispose<DeleteDeviceUseCase>((ref) {
final accountRepository = ref.read(accountRepositoryProvider);
return DeleteDeviceUseCaseImpl(accountRepository);
});

Some files were not shown because too many files have changed in this diff Show More