Compare commits
12 Commits
feature/fi
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
| ae4bc7824a | |||
| 01d9d4241b | |||
| 907eaf8d33 | |||
| 440bbcac66 | |||
| ec4e42b408 | |||
| 9bf06f2480 | |||
| 903e1991e1 | |||
| f9d8f59195 | |||
| ffc0a1f103 | |||
| 53cadd8499 | |||
| b4bb90d357 | |||
| 5ee7852ee7 |
1
.dart_tool/extension_discovery/devtools.json
Normal file
1
.dart_tool/extension_discovery/devtools.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version":2,"entries":[{"package":"sf_app_platform_mono_repo","rootUri":"../","packageUri":"lib/"}]}
|
||||
@@ -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}}
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>();
|
||||
@@ -25,7 +26,7 @@ late final GoRouter appRouter;
|
||||
void configureAppRouter() {
|
||||
appRouter = GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
initialLocation: AppRoutes.legacyOnboarding,
|
||||
initialLocation: AppRoutes.splash,
|
||||
debugLogDiagnostics: true,
|
||||
routes: [
|
||||
GoRoute(
|
||||
@@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -125,7 +158,7 @@ void configureAppRouter() {
|
||||
StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '${ AppRoutes.legacyDashboard}/chat',
|
||||
path: '${AppRoutes.legacyDashboard}/chat',
|
||||
name: 'legacy_chat',
|
||||
pageBuilder: (context, state) => MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
@@ -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',
|
||||
|
||||
42
apps/mobile_app/lib/providers/legacy_heartbeat_service.dart
Normal file
42
apps/mobile_app/lib/providers/legacy_heartbeat_service.dart
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
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();
|
||||
}
|
||||
@@ -50,9 +65,11 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
|
||||
ref.read(appLifecycleStateProvider.notifier).setState(state);
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
// walletHeartbeat.start();
|
||||
legacyHeartbeat.start();
|
||||
ref.read(permissionsProvider.notifier).checkPermissions();
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
// walletHeartbeat.stop();
|
||||
legacyHeartbeat.stop();
|
||||
}
|
||||
super.didChangeAppLifecycleState(state);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/path_provider_linux-2.2.1/
|
||||
@@ -1 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences_linux-2.4.1/
|
||||
@@ -1 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.2/
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/url_launcher_linux-3.2.2/
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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/"}]}
|
||||
@@ -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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.22\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.4.20\\\\","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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-09 10:57:00.990731","version":"3.35.6","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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.22\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.4.20\\\\","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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-16 09:33:25.098373","version":"3.35.6","swift_package_manager_enabled":{"ios":false,"macos":false}}
|
||||
3
modules/activity/devtools_options.yaml
Normal file
3
modules/activity/devtools_options.yaml
Normal 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:
|
||||
@@ -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(
|
||||
|
||||
3
modules/dashboard_shell/devtools_options.yaml
Normal file
3
modules/dashboard_shell/devtools_options.yaml
Normal 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:
|
||||
@@ -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';
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_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:sf_shared/sf_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});
|
||||
}
|
||||
@@ -1,193 +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/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: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:dio/dio.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../models/get_linked_devices_response_model.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);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) async {
|
||||
throw UnimplementedError();
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/users/$userId/devices/$deviceId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/users/$userId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to update user');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/$userId/devices',
|
||||
);
|
||||
final data = response.data!['items'];
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /:userId/devices');
|
||||
}
|
||||
|
||||
final model = GetAppUsersResponseModel.fromJson(data);
|
||||
/*final model = GetAppUsersResponseModel(items: [
|
||||
GetAppUsersItemResponseModel(
|
||||
id: 'id',
|
||||
delegationId: 'delegationId',
|
||||
email: 'carlos@test.com',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
status: 'status',
|
||||
role: 'role',
|
||||
lastLogin: 'lastLogin',
|
||||
currentLogin: 'currentLogin',
|
||||
language: 'language',
|
||||
firstName: 'Carlos',
|
||||
lastName: 'lastName',
|
||||
hasApiKey: 'hasApiKey',
|
||||
phone: 'phone',),
|
||||
GetAppUsersItemResponseModel(
|
||||
id: 'id',
|
||||
delegationId: 'delegationId',
|
||||
email: 'ana@test.com',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
status: 'status',
|
||||
role: 'role',
|
||||
lastLogin: 'lastLogin',
|
||||
currentLogin: 'currentLogin',
|
||||
language: 'language',
|
||||
firstName: 'Ana',
|
||||
lastName: 'lastName',
|
||||
hasApiKey: 'hasApiKey',
|
||||
phone: 'phone',),
|
||||
]);*/
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error getting devices',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAppUser({required String userId}) async {
|
||||
throw UnimplementedError();
|
||||
try {
|
||||
await _repository.delete<void>(
|
||||
'/users/$userId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/auth/change-password',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error to change password');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exception _mapDioError(DioException error, {required String defaultMessage}) {
|
||||
final apiMsg = _extractApiMessage(error.response?.data);
|
||||
final msg = apiMsg ?? error.message ?? defaultMessage;
|
||||
return Exception(msg);
|
||||
}
|
||||
|
||||
String? _extractApiMessage(Object? data) {
|
||||
if (data == null) return null;
|
||||
|
||||
if (data is Map) {
|
||||
final errorObj = data['error'];
|
||||
if (errorObj is Map && errorObj['message'] is String) {
|
||||
return (errorObj['message'] as String).trim();
|
||||
}
|
||||
if (data['message'] is String) {
|
||||
return (data['message'] as String).trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data is String) {
|
||||
final raw = data.trim();
|
||||
if (raw.isEmpty) return null;
|
||||
|
||||
try {
|
||||
final decoded = jsonDecode(raw);
|
||||
return _extractApiMessage(decoded);
|
||||
} catch (_) {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,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});
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class DevicesRemoteDatasource {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:account/src/core/data/models/update_device_request_model.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import 'devices_remote_datasource.dart';
|
||||
|
||||
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
|
||||
DevicesRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) async {
|
||||
try {
|
||||
await _repository.delete<void>(
|
||||
'/devices/$deviceId',
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to delete device');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) async {
|
||||
try {
|
||||
final body = request.toModel().toJson();
|
||||
await _repository.put<void>(
|
||||
'/devices',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to update device');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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});
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.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,
|
||||
@Default({}) Map<String, dynamic> settings,
|
||||
required String protocol,
|
||||
required String type,
|
||||
required String connectionServer,
|
||||
required String createdAt,
|
||||
@Default({}) Map<String, dynamic> 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,
|
||||
protocol: item.protocol,
|
||||
type: item.type,
|
||||
connectionServer: item.connectionServer,
|
||||
createdAt: item.createdAt,
|
||||
flags: item.flags,
|
||||
)).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);
|
||||
}
|
||||
@@ -1,869 +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_linked_devices_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesResponseModel {
|
||||
|
||||
List<GetLinkedDevicesItemResponseModel> get items;
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesResponseModelCopyWith<GetLinkedDevicesResponseModel> get copyWith => _$GetLinkedDevicesResponseModelCopyWithImpl<GetLinkedDevicesResponseModel>(this as GetLinkedDevicesResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesResponseModel&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesResponseModelCopyWith(GetLinkedDevicesResponseModel value, $Res Function(GetLinkedDevicesResponseModel) _then) = _$GetLinkedDevicesResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GetLinkedDevicesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetLinkedDevicesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesResponseModel].
|
||||
extension GetLinkedDevicesResponseModelPatterns on GetLinkedDevicesResponseModel {
|
||||
/// 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( _GetLinkedDevicesResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() 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( _GetLinkedDevicesResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel():
|
||||
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( _GetLinkedDevicesResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<GetLinkedDevicesItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<GetLinkedDevicesItemResponseModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel():
|
||||
return $default(_that.items);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<GetLinkedDevicesItemResponseModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesResponseModel implements GetLinkedDevicesResponseModel {
|
||||
const _GetLinkedDevicesResponseModel({required final List<GetLinkedDevicesItemResponseModel> items}): _items = items;
|
||||
factory _GetLinkedDevicesResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesResponseModelFromJson(json);
|
||||
|
||||
final List<GetLinkedDevicesItemResponseModel> _items;
|
||||
@override List<GetLinkedDevicesItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesResponseModelCopyWith<_GetLinkedDevicesResponseModel> get copyWith => __$GetLinkedDevicesResponseModelCopyWithImpl<_GetLinkedDevicesResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesResponseModel&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesResponseModelCopyWith<$Res> implements $GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesResponseModelCopyWith(_GetLinkedDevicesResponseModel value, $Res Function(_GetLinkedDevicesResponseModel) _then) = __$GetLinkedDevicesResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<GetLinkedDevicesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,}) {
|
||||
return _then(_GetLinkedDevicesResponseModel(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetLinkedDevicesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesItemResponseModel {
|
||||
|
||||
String get identificator; String get carrierName; String get phone; String get id; Map<String, dynamic> get settings; String get protocol; String get type; String get connectionServer; String get createdAt; Map<String, dynamic> get flags;
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesItemResponseModelCopyWith<GetLinkedDevicesItemResponseModel> get copyWith => _$GetLinkedDevicesItemResponseModelCopyWithImpl<GetLinkedDevicesItemResponseModel>(this as GetLinkedDevicesItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&const DeepCollectionEquality().equals(other.settings, settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&const DeepCollectionEquality().equals(other.flags, flags));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,const DeepCollectionEquality().hash(settings),protocol,type,connectionServer,createdAt,const DeepCollectionEquality().hash(flags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesItemResponseModelCopyWith(GetLinkedDevicesItemResponseModel value, $Res Function(GetLinkedDevicesItemResponseModel) _then) = _$GetLinkedDevicesItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesItemResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesItemResponseModel].
|
||||
extension GetLinkedDevicesItemResponseModelPatterns on GetLinkedDevicesItemResponseModel {
|
||||
/// 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( _GetLinkedDevicesItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() 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( _GetLinkedDevicesItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel():
|
||||
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( _GetLinkedDevicesItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() when $default != null:
|
||||
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel():
|
||||
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesItemResponseModel() when $default != null:
|
||||
return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesItemResponseModel implements GetLinkedDevicesItemResponseModel {
|
||||
const _GetLinkedDevicesItemResponseModel({required this.identificator, required this.carrierName, required this.phone, required this.id, final Map<String, dynamic> settings = const {}, required this.protocol, required this.type, required this.connectionServer, required this.createdAt, final Map<String, dynamic> flags = const {}}): _settings = settings,_flags = flags;
|
||||
factory _GetLinkedDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesItemResponseModelFromJson(json);
|
||||
|
||||
@override final String identificator;
|
||||
@override final String carrierName;
|
||||
@override final String phone;
|
||||
@override final String id;
|
||||
final Map<String, dynamic> _settings;
|
||||
@override@JsonKey() Map<String, dynamic> get settings {
|
||||
if (_settings is EqualUnmodifiableMapView) return _settings;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_settings);
|
||||
}
|
||||
|
||||
@override final String protocol;
|
||||
@override final String type;
|
||||
@override final String connectionServer;
|
||||
@override final String createdAt;
|
||||
final Map<String, dynamic> _flags;
|
||||
@override@JsonKey() Map<String, dynamic> get flags {
|
||||
if (_flags is EqualUnmodifiableMapView) return _flags;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_flags);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesItemResponseModelCopyWith<_GetLinkedDevicesItemResponseModel> get copyWith => __$GetLinkedDevicesItemResponseModelCopyWithImpl<_GetLinkedDevicesItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&const DeepCollectionEquality().equals(other._settings, _settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&const DeepCollectionEquality().equals(other._flags, _flags));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,const DeepCollectionEquality().hash(_settings),protocol,type,connectionServer,createdAt,const DeepCollectionEquality().hash(_flags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesItemResponseModelCopyWith<$Res> implements $GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesItemResponseModelCopyWith(_GetLinkedDevicesItemResponseModel value, $Res Function(_GetLinkedDevicesItemResponseModel) _then) = __$GetLinkedDevicesItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String identificator, String carrierName, String phone, String id, Map<String, dynamic> settings, String protocol, String type, String connectionServer, String createdAt, Map<String, dynamic> flags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesItemResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesItemResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) {
|
||||
return _then(_GetLinkedDevicesItemResponseModel(
|
||||
identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,settings: null == settings ? _self._settings : settings // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetLinkedDevicesSettingsResponseModel {
|
||||
|
||||
int get frequency; int get frequencyHeartRate; int get timezone; bool get pedometer; String get language; List<String> get alerts;
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetLinkedDevicesSettingsResponseModelCopyWith<GetLinkedDevicesSettingsResponseModel> get copyWith => _$GetLinkedDevicesSettingsResponseModelCopyWithImpl<GetLinkedDevicesSettingsResponseModel>(this as GetLinkedDevicesSettingsResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetLinkedDevicesSettingsResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLinkedDevicesSettingsResponseModel&&(identical(other.frequency, frequency) || other.frequency == frequency)&&(identical(other.frequencyHeartRate, frequencyHeartRate) || other.frequencyHeartRate == frequencyHeartRate)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.pedometer, pedometer) || other.pedometer == pedometer)&&(identical(other.language, language) || other.language == language)&&const DeepCollectionEquality().equals(other.alerts, alerts));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,frequency,frequencyHeartRate,timezone,pedometer,language,const DeepCollectionEquality().hash(alerts));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesSettingsResponseModel(frequency: $frequency, frequencyHeartRate: $frequencyHeartRate, timezone: $timezone, pedometer: $pedometer, language: $language, alerts: $alerts)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
factory $GetLinkedDevicesSettingsResponseModelCopyWith(GetLinkedDevicesSettingsResponseModel value, $Res Function(GetLinkedDevicesSettingsResponseModel) _then) = _$GetLinkedDevicesSettingsResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetLinkedDevicesSettingsResponseModelCopyWithImpl<$Res>
|
||||
implements $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
_$GetLinkedDevicesSettingsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetLinkedDevicesSettingsResponseModel _self;
|
||||
final $Res Function(GetLinkedDevicesSettingsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? frequency = null,Object? frequencyHeartRate = null,Object? timezone = null,Object? pedometer = null,Object? language = null,Object? alerts = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
frequency: null == frequency ? _self.frequency : frequency // ignore: cast_nullable_to_non_nullable
|
||||
as int,frequencyHeartRate: null == frequencyHeartRate ? _self.frequencyHeartRate : frequencyHeartRate // ignore: cast_nullable_to_non_nullable
|
||||
as int,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable
|
||||
as int,pedometer: null == pedometer ? _self.pedometer : pedometer // ignore: cast_nullable_to_non_nullable
|
||||
as bool,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,alerts: null == alerts ? _self.alerts : alerts // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetLinkedDevicesSettingsResponseModel].
|
||||
extension GetLinkedDevicesSettingsResponseModelPatterns on GetLinkedDevicesSettingsResponseModel {
|
||||
/// 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( _GetLinkedDevicesSettingsResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() 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( _GetLinkedDevicesSettingsResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel():
|
||||
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( _GetLinkedDevicesSettingsResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() 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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() when $default != null:
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel():
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);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( int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetLinkedDevicesSettingsResponseModel() when $default != null:
|
||||
return $default(_that.frequency,_that.frequencyHeartRate,_that.timezone,_that.pedometer,_that.language,_that.alerts);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetLinkedDevicesSettingsResponseModel implements GetLinkedDevicesSettingsResponseModel {
|
||||
const _GetLinkedDevicesSettingsResponseModel({required this.frequency, required this.frequencyHeartRate, required this.timezone, required this.pedometer, required this.language, required final List<String> alerts}): _alerts = alerts;
|
||||
factory _GetLinkedDevicesSettingsResponseModel.fromJson(Map<String, dynamic> json) => _$GetLinkedDevicesSettingsResponseModelFromJson(json);
|
||||
|
||||
@override final int frequency;
|
||||
@override final int frequencyHeartRate;
|
||||
@override final int timezone;
|
||||
@override final bool pedometer;
|
||||
@override final String language;
|
||||
final List<String> _alerts;
|
||||
@override List<String> get alerts {
|
||||
if (_alerts is EqualUnmodifiableListView) return _alerts;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_alerts);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetLinkedDevicesSettingsResponseModelCopyWith<_GetLinkedDevicesSettingsResponseModel> get copyWith => __$GetLinkedDevicesSettingsResponseModelCopyWithImpl<_GetLinkedDevicesSettingsResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetLinkedDevicesSettingsResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLinkedDevicesSettingsResponseModel&&(identical(other.frequency, frequency) || other.frequency == frequency)&&(identical(other.frequencyHeartRate, frequencyHeartRate) || other.frequencyHeartRate == frequencyHeartRate)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.pedometer, pedometer) || other.pedometer == pedometer)&&(identical(other.language, language) || other.language == language)&&const DeepCollectionEquality().equals(other._alerts, _alerts));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,frequency,frequencyHeartRate,timezone,pedometer,language,const DeepCollectionEquality().hash(_alerts));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetLinkedDevicesSettingsResponseModel(frequency: $frequency, frequencyHeartRate: $frequencyHeartRate, timezone: $timezone, pedometer: $pedometer, language: $language, alerts: $alerts)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetLinkedDevicesSettingsResponseModelCopyWith<$Res> implements $GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
factory _$GetLinkedDevicesSettingsResponseModelCopyWith(_GetLinkedDevicesSettingsResponseModel value, $Res Function(_GetLinkedDevicesSettingsResponseModel) _then) = __$GetLinkedDevicesSettingsResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int frequency, int frequencyHeartRate, int timezone, bool pedometer, String language, List<String> alerts
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetLinkedDevicesSettingsResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetLinkedDevicesSettingsResponseModelCopyWith<$Res> {
|
||||
__$GetLinkedDevicesSettingsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetLinkedDevicesSettingsResponseModel _self;
|
||||
final $Res Function(_GetLinkedDevicesSettingsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetLinkedDevicesSettingsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? frequency = null,Object? frequencyHeartRate = null,Object? timezone = null,Object? pedometer = null,Object? language = null,Object? alerts = null,}) {
|
||||
return _then(_GetLinkedDevicesSettingsResponseModel(
|
||||
frequency: null == frequency ? _self.frequency : frequency // ignore: cast_nullable_to_non_nullable
|
||||
as int,frequencyHeartRate: null == frequencyHeartRate ? _self.frequencyHeartRate : frequencyHeartRate // ignore: cast_nullable_to_non_nullable
|
||||
as int,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable
|
||||
as int,pedometer: null == pedometer ? _self.pedometer : pedometer // ignore: cast_nullable_to_non_nullable
|
||||
as bool,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,alerts: null == alerts ? _self._alerts : alerts // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -1,77 +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: json['settings'] as Map<String, dynamic>? ?? const {},
|
||||
protocol: json['protocol'] as String,
|
||||
type: json['type'] as String,
|
||||
connectionServer: json['connectionServer'] as String,
|
||||
createdAt: json['createdAt'] as String,
|
||||
flags: json['flags'] as Map<String, dynamic>? ?? const {},
|
||||
);
|
||||
|
||||
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,
|
||||
};
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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?,
|
||||
));
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -1,47 +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: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:sf_shared/sf_shared.dart';
|
||||
|
||||
class AccountRepositoryImpl implements AccountRepository {
|
||||
const AccountRepositoryImpl(this._remote);
|
||||
|
||||
final AccountRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _remote.getLinkedDevices(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) {
|
||||
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required String deviceId, required UpdateDeviceRequestEntity request}) {
|
||||
return _remote.updateDevice(userId: userId, deviceId: deviceId, request: request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
|
||||
return _remote.updateUser(userId: userId, request: request);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) {
|
||||
return _remote.getAppUsers(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAppUser({required String userId}) {
|
||||
return _remote.deleteAppUser(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changePassword({required String userId, required ChangePasswordRequestEntity request}) {
|
||||
return _remote.changePassword(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:account/src/core/data/datasource/devices_remote_datasource.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
import '../../domain/repositories/devices_repository.dart';
|
||||
|
||||
class DevicesRepositoryImpl implements DevicesRepository {
|
||||
const DevicesRepositoryImpl(this._remote);
|
||||
|
||||
final DevicesRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<void> deleteDevice({required String userId, required String deviceId}) {
|
||||
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) {
|
||||
return _remote.updateDevice(userId: userId, request: request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import 'package:account/src/features/change_password/domain/models/entities/change_password_request_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:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class AccountRepository {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({
|
||||
required String userId,
|
||||
required String deviceId,
|
||||
required UpdateDeviceRequestEntity request
|
||||
});
|
||||
|
||||
Future<void> updateUser({
|
||||
required String userId,
|
||||
required UpdateUserRequestEntity request
|
||||
});
|
||||
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
|
||||
Future<void> deleteAppUser({required String userId});
|
||||
|
||||
Future<void> changePassword({
|
||||
required String userId,
|
||||
required ChangePasswordRequestEntity request
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,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
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
|
||||
abstract class DevicesRepository {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
|
||||
Future<void> updateDevice({
|
||||
required String userId,
|
||||
required UpdateDeviceRequestEntity request
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,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});
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasource/devices_remote_datasource.dart';
|
||||
import '../data/datasource/devices_remote_datasource_impl.dart';
|
||||
|
||||
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return DevicesRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../data/repositories/devices_repository_impl.dart';
|
||||
import '../domain/repositories/devices_repository.dart';
|
||||
import 'devices_remote_datasource_provider.dart';
|
||||
|
||||
final devicesRepositoryProvider = Provider<DevicesRepository>((ref) {
|
||||
final remote = ref.read(devicesRemoteDatasourceProvider);
|
||||
return DevicesRepositoryImpl(remote);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
abstract class DeleteAppUserUseCase {
|
||||
Future<void> deleteAppUser({required String userId});
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class GetAppUsersUseCase {
|
||||
Future<List<UserEntity>> getAppUsers({required String userId});
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
class GetAppUsersUseCaseImpl implements GetAppUsersUseCase {
|
||||
GetAppUsersUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<UserEntity>> getAppUsers({required String userId}) {
|
||||
return _repository.getAppUsers(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -1,8 +1,5 @@
|
||||
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_shared/sf_shared.dart';
|
||||
@@ -13,13 +10,11 @@ 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);
|
||||
|
||||
_init();
|
||||
|
||||
@@ -30,7 +25,7 @@ class AppUsersViewModel extends Notifier<AppUsersViewState> {
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
|
||||
setUser(user);
|
||||
final appUsers = await _getAppUsersUseCase.getAppUsers(userId: user.id);
|
||||
final appUsers = await _usersRepository.getUsers(userId: user.id);
|
||||
setAppUsers(appUsers);
|
||||
}
|
||||
|
||||
@@ -49,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);
|
||||
}
|
||||
}
|
||||
@@ -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}) {
|
||||
|
||||
@@ -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)
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -4,11 +4,8 @@ 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_shared/sf_shared.dart';
|
||||
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final changePasswordViewModelProvider =
|
||||
NotifierProvider.autoDispose<ChangePasswordViewModel, ChangePasswordViewState>(
|
||||
ChangePasswordViewModel.new,
|
||||
@@ -26,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);
|
||||
|
||||
@@ -33,24 +37,27 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
newPasswordController.addListener(_onNewPasswordChanged);
|
||||
|
||||
repeatPasswordController = TextEditingController();
|
||||
repeatPasswordController.addListener(_onRepeatPasswordController);
|
||||
repeatPasswordController.addListener(_onRepeatPasswordChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
_init();
|
||||
|
||||
return const ChangePasswordViewState();
|
||||
}
|
||||
|
||||
Future<void> _init() async {
|
||||
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
setUser(user);
|
||||
|
||||
void toggleCurrentPasswordVisibility() {
|
||||
state = state.copyWith(
|
||||
showCurrentPassword: !state.showCurrentPassword
|
||||
);
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
void toggleNewPasswordVisibility() {
|
||||
state = state.copyWith(
|
||||
showNewPassword: !state.showNewPassword
|
||||
);
|
||||
}
|
||||
|
||||
void toggleRepeatedPasswordVisibility() {
|
||||
state = state.copyWith(
|
||||
showRepeatedPassword: !state.showRepeatedPassword
|
||||
);
|
||||
}
|
||||
|
||||
void _onCurrentPasswordChanged() {
|
||||
@@ -60,6 +67,7 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
|
||||
state = state.copyWith(
|
||||
currentPassword: value,
|
||||
errorMessage: ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,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: ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,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(userInfoProvider);
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
@@ -143,7 +161,7 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
|
||||
newPasswordController.removeListener(_onNewPasswordChanged);
|
||||
newPasswordController.dispose();
|
||||
|
||||
repeatPasswordController.removeListener(_onRepeatPasswordController);
|
||||
repeatPasswordController.removeListener(_onRepeatPasswordChanged);
|
||||
repeatPasswordController.dispose();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
abstract class DeleteAccountUseCase {
|
||||
Future<void> deleteAccount({
|
||||
required String userId,
|
||||
});
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
@@ -1,29 +1,25 @@
|
||||
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_shared/sf_shared.dart';
|
||||
|
||||
// import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
final deleteAccountViewModelProvider =
|
||||
NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
|
||||
DeleteAccountViewModel.new,
|
||||
);
|
||||
|
||||
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
late final DeleteAccountUseCase _deleteAccountUseCase;
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final 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);
|
||||
@@ -39,7 +35,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
setUser(user);
|
||||
|
||||
final devices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
final devices = await _devicesRepository.getDevices();
|
||||
setDevices(devices);
|
||||
}
|
||||
|
||||
@@ -97,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(userInfoProvider);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,6 +119,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
|
||||
void _finishWithError({required String message}) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
isComplete: false,
|
||||
errorMessage: message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
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';
|
||||
@@ -10,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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
abstract class DeleteDeviceUseCase {
|
||||
Future<void> deleteDevice({required String userId, required String deviceId});
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
abstract class GetLinkedDevicesUseCase {
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId});
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:account/src/core/domain/repositories/account_repository.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
class GetLinkedDevicesUseCaseImpl implements GetLinkedDevicesUseCase {
|
||||
GetLinkedDevicesUseCaseImpl(this._repository);
|
||||
|
||||
final AccountRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<DeviceEntity>> getLinkedDevices({required String userId}) {
|
||||
return _repository.getLinkedDevices(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -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});
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -3,54 +3,30 @@ 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:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.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(
|
||||
@@ -65,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,
|
||||
@@ -92,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)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
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';
|
||||
@@ -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),
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final getLinkedDevicesUseCaseProvider = Provider.autoDispose<GetLinkedDevicesUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return GetLinkedDevicesUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:account/src/core/providers/account_repository_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final updateDeviceUseCaseProvider = Provider.autoDispose<UpdateDeviceUseCase>((ref) {
|
||||
final accountRepository = ref.read(accountRepositoryProvider);
|
||||
return UpdateDeviceUseCaseImpl(accountRepository);
|
||||
});
|
||||
@@ -1,59 +1,51 @@
|
||||
import 'package:account/src/features/linked_devices/domain/delete_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/get_linked_devices_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/domain/update_device_use_case.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/delete_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/get_linked_devices_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/providers/update_device_use_case_provider.dart';
|
||||
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../../../core/domain/repositories/devices_repository.dart';
|
||||
import '../../../../core/providers/devices_repository_provider.dart';
|
||||
|
||||
final linkedDevicesViewModelProvider =
|
||||
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
|
||||
LinkedDevicesViewModel.new,
|
||||
);
|
||||
|
||||
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
late final GetLinkedDevicesUseCase _getLinkedDevicesUseCase;
|
||||
late final UpdateDeviceUseCase _updateDeviceUseCase;
|
||||
late final DeleteDeviceUseCase _deleteDeviceUseCase;
|
||||
late final SharedDevicesRepository _getDevicesRepository;
|
||||
late final DevicesRepository _devicesRepository;
|
||||
|
||||
late final TextEditingController deviceNameController;
|
||||
|
||||
@override
|
||||
LinkedDevicesViewState build() {
|
||||
_getLinkedDevicesUseCase = ref.read(getLinkedDevicesUseCaseProvider);
|
||||
_updateDeviceUseCase = ref.read(updateDeviceUseCaseProvider);
|
||||
_deleteDeviceUseCase = ref.read(deleteDeviceUseCaseProvider);
|
||||
|
||||
deviceNameController = TextEditingController();
|
||||
deviceNameController.addListener(_onDeviceNameChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
_getDevicesRepository = ref.read(sharedDevicesRepositoryProvider);
|
||||
_devicesRepository = ref.read(devicesRepositoryProvider);
|
||||
|
||||
_initControllers();
|
||||
_init();
|
||||
|
||||
return const LinkedDevicesViewState();
|
||||
}
|
||||
|
||||
void _initControllers() {
|
||||
deviceNameController = TextEditingController();
|
||||
deviceNameController.addListener(_onDeviceNameChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
}
|
||||
|
||||
Future<void> _init() async {
|
||||
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
setUser(user);
|
||||
final linkedDevices = await _getLinkedDevicesUseCase.getLinkedDevices(userId: user.id);
|
||||
setLinkedDevices(linkedDevices);
|
||||
|
||||
}
|
||||
|
||||
void setUser(UserEntity user) {
|
||||
state = state.copyWith(loggedUser: user);
|
||||
}
|
||||
|
||||
void setLinkedDevices(List<DeviceEntity> linkedDevices) {
|
||||
state = state.copyWith(linkedDevices: linkedDevices);
|
||||
final linkedDevices = await _getDevicesRepository.getDevices();
|
||||
state = state.copyWith(
|
||||
linkedDevices: linkedDevices,
|
||||
isLoading: false,
|
||||
);
|
||||
}
|
||||
|
||||
void toggleIsEditing() {
|
||||
@@ -70,9 +62,17 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
);
|
||||
}
|
||||
|
||||
void setSelectedDevice(DeviceEntity value) {
|
||||
if (value == state.selectedDevice) return;
|
||||
|
||||
state = state.copyWith(
|
||||
selectedDevice: value,
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> deleteDevice(DeviceEntity device) async {
|
||||
try {
|
||||
await _deleteDeviceUseCase.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
await _devicesRepository.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
|
||||
List<DeviceEntity> newList = state.linkedDevices;
|
||||
newList.remove(device);
|
||||
|
||||
@@ -90,26 +90,32 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
|
||||
|
||||
return UpdateDeviceRequestEntity(
|
||||
identificator: device.identificator,
|
||||
name: state.deviceName.trim(),
|
||||
carrierName: state.deviceName.trim(),
|
||||
// phone: /*state.dialCode.trim() + */state.phoneNumber.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
void updateDevice(DeviceEntity device) {
|
||||
Future<void> updateDevice() async {
|
||||
final deviceName = state.deviceName;
|
||||
final device = state.selectedDevice!;
|
||||
|
||||
if (deviceName.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: ''
|
||||
);
|
||||
return;
|
||||
}
|
||||
final userId = 'test';
|
||||
_updateDeviceUseCase.updateDevice(
|
||||
if (deviceName.isEmpty) return;
|
||||
|
||||
try {
|
||||
final userId = state.loggedUser!.id;
|
||||
_devicesRepository.updateDevice(
|
||||
userId: userId,
|
||||
deviceId: device.identificator,
|
||||
request: _toRequest(device));
|
||||
|
||||
} catch(e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
isComplete: false,
|
||||
errorMessage: e.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
|
||||
@@ -6,8 +6,10 @@ part 'linked_devices_view_state.freezed.dart';
|
||||
@freezed
|
||||
abstract class LinkedDevicesViewState with _$LinkedDevicesViewState {
|
||||
const factory LinkedDevicesViewState({
|
||||
@Default(false) bool isLoading,
|
||||
@Default(null) UserEntity? loggedUser,
|
||||
@Default(true) bool isLoading,
|
||||
@Default(true) bool isComplete,
|
||||
UserEntity? loggedUser,
|
||||
DeviceEntity? selectedDevice,
|
||||
@Default([]) List<DeviceEntity> linkedDevices,
|
||||
@Default(false) bool isEditing,
|
||||
@Default('') String deviceName,
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LinkedDevicesViewState {
|
||||
|
||||
bool get isLoading; UserEntity? get loggedUser; List<DeviceEntity> get linkedDevices; bool get isEditing; String get deviceName; String get errorMessage;
|
||||
bool get isLoading; bool get isComplete; UserEntity? get loggedUser; DeviceEntity? get selectedDevice; List<DeviceEntity> get linkedDevices; bool get isEditing; String get deviceName; String get errorMessage;
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LinkedDevicesViewStateCopyWith<LinkedDevicesViewState> get copyWith => _$Linked
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.linkedDevices, linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.linkedDevices, linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(linkedDevices),isEditing,deviceName,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,loggedUser,selectedDevice,const DeepCollectionEquality().hash(linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, isComplete: $isComplete, loggedUser: $loggedUser, selectedDevice: $selectedDevice, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ abstract mixin class $LinkedDevicesViewStateCopyWith<$Res> {
|
||||
factory $LinkedDevicesViewStateCopyWith(LinkedDevicesViewState value, $Res Function(LinkedDevicesViewState) _then) = _$LinkedDevicesViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;
|
||||
$UserEntityCopyWith<$Res>? get loggedUser;$DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -62,11 +62,13 @@ class _$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? loggedUser = freezed,Object? selectedDevice = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self.linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,linkedDevices: null == linkedDevices ? _self.linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
@@ -85,6 +87,18 @@ $UserEntityCopyWith<$Res>? get loggedUser {
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +181,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -188,10 +202,10 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState():
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -208,10 +222,10 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LinkedDevicesViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.loggedUser,_that.selectedDevice,_that.linkedDevices,_that.isEditing,_that.deviceName,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -223,11 +237,13 @@ return $default(_that.isLoading,_that.loggedUser,_that.linkedDevices,_that.isEdi
|
||||
|
||||
|
||||
class _LinkedDevicesViewState implements LinkedDevicesViewState {
|
||||
const _LinkedDevicesViewState({this.isLoading = false, this.loggedUser = null, final List<DeviceEntity> linkedDevices = const [], this.isEditing = false, this.deviceName = '', this.errorMessage = ''}): _linkedDevices = linkedDevices;
|
||||
const _LinkedDevicesViewState({this.isLoading = true, this.isComplete = true, this.loggedUser, this.selectedDevice, final List<DeviceEntity> linkedDevices = const [], this.isEditing = false, this.deviceName = '', this.errorMessage = ''}): _linkedDevices = linkedDevices;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final UserEntity? loggedUser;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override final UserEntity? loggedUser;
|
||||
@override final DeviceEntity? selectedDevice;
|
||||
final List<DeviceEntity> _linkedDevices;
|
||||
@override@JsonKey() List<DeviceEntity> get linkedDevices {
|
||||
if (_linkedDevices is EqualUnmodifiableListView) return _linkedDevices;
|
||||
@@ -249,16 +265,16 @@ _$LinkedDevicesViewStateCopyWith<_LinkedDevicesViewState> get copyWith => __$Lin
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._linkedDevices, _linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LinkedDevicesViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._linkedDevices, _linkedDevices)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,loggedUser,const DeepCollectionEquality().hash(_linkedDevices),isEditing,deviceName,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,loggedUser,selectedDevice,const DeepCollectionEquality().hash(_linkedDevices),isEditing,deviceName,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, loggedUser: $loggedUser, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
return 'LinkedDevicesViewState(isLoading: $isLoading, isComplete: $isComplete, loggedUser: $loggedUser, selectedDevice: $selectedDevice, linkedDevices: $linkedDevices, isEditing: $isEditing, deviceName: $deviceName, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -269,11 +285,11 @@ abstract mixin class _$LinkedDevicesViewStateCopyWith<$Res> implements $LinkedDe
|
||||
factory _$LinkedDevicesViewStateCopyWith(_LinkedDevicesViewState value, $Res Function(_LinkedDevicesViewState) _then) = __$LinkedDevicesViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, UserEntity? loggedUser, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
bool isLoading, bool isComplete, UserEntity? loggedUser, DeviceEntity? selectedDevice, List<DeviceEntity> linkedDevices, bool isEditing, String deviceName, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;
|
||||
@override $UserEntityCopyWith<$Res>? get loggedUser;@override $DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@@ -286,11 +302,13 @@ class __$LinkedDevicesViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? loggedUser = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? loggedUser = freezed,Object? selectedDevice = freezed,Object? linkedDevices = null,Object? isEditing = null,Object? deviceName = null,Object? errorMessage = null,}) {
|
||||
return _then(_LinkedDevicesViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,linkedDevices: null == linkedDevices ? _self._linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,linkedDevices: null == linkedDevices ? _self._linkedDevices : linkedDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<DeviceEntity>,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
@@ -310,6 +328,18 @@ $UserEntityCopyWith<$Res>? get loggedUser {
|
||||
return $UserEntityCopyWith<$Res>(_self.loggedUser!, (value) {
|
||||
return _then(_self.copyWith(loggedUser: value));
|
||||
});
|
||||
}/// Create a copy of LinkedDevicesViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class DeleteDeviceDialog extends ConsumerWidget {
|
||||
|
||||
final DeviceEntity device;
|
||||
|
||||
const DeleteDeviceDialog({required this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final vm = ref.read(linkedDevicesViewModelProvider.notifier);
|
||||
|
||||
return 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 vm.deleteDevice(device);
|
||||
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),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,8 @@ part 'update_user_request_entity.freezed.dart';
|
||||
@freezed
|
||||
abstract class UpdateUserRequestEntity with _$UpdateUserRequestEntity {
|
||||
const factory UpdateUserRequestEntity({
|
||||
required String id,
|
||||
String? delegationId,
|
||||
String? email,
|
||||
String? createdAt,
|
||||
String? updatedAt,
|
||||
String? status,
|
||||
String? role,
|
||||
String? lastLogin,
|
||||
String? currentLogin,
|
||||
String? language,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? hasApiKey,
|
||||
String? phone,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? phone,
|
||||
}) = _UpdateUserRequestEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UpdateUserRequestEntity {
|
||||
|
||||
String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone;
|
||||
String? get firstName; String? get lastName; String? get phone;
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $UpdateUserRequestEntityCopyWith<UpdateUserRequestEntity> get copyWith => _$Upda
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestEntity&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
return 'UpdateUserRequestEntity(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $UpdateUserRequestEntityCopyWith<$Res> {
|
||||
factory $UpdateUserRequestEntityCopyWith(UpdateUserRequestEntity value, $Res Function(UpdateUserRequestEntity) _then) = _$UpdateUserRequestEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
String? firstName, String? lastName, String? phone
|
||||
});
|
||||
|
||||
|
||||
@@ -62,21 +62,10 @@ class _$UpdateUserRequestEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
@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?,
|
||||
));
|
||||
@@ -163,10 +152,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 _UpdateUserRequestEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -184,10 +173,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 _UpdateUserRequestEntity():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -204,10 +193,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 _UpdateUserRequestEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -219,22 +208,11 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
|
||||
|
||||
|
||||
class _UpdateUserRequestEntity implements UpdateUserRequestEntity {
|
||||
const _UpdateUserRequestEntity({required this.id, this.delegationId, this.email, this.createdAt, this.updatedAt, this.status, this.role, this.lastLogin, this.currentLogin, this.language, this.firstName, this.lastName, this.hasApiKey, this.phone});
|
||||
const _UpdateUserRequestEntity({this.firstName, this.lastName, this.phone});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String? delegationId;
|
||||
@override final String? email;
|
||||
@override final String? createdAt;
|
||||
@override final String? updatedAt;
|
||||
@override final String? status;
|
||||
@override final String? role;
|
||||
@override final String? lastLogin;
|
||||
@override final String? currentLogin;
|
||||
@override final String? language;
|
||||
@override final String? firstName;
|
||||
@override final String? lastName;
|
||||
@override final String? hasApiKey;
|
||||
@override final String? phone;
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
@@ -247,16 +225,16 @@ _$UpdateUserRequestEntityCopyWith<_UpdateUserRequestEntity> get copyWith => __$U
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestEntity&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateUserRequestEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
return 'UpdateUserRequestEntity(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +245,7 @@ abstract mixin class _$UpdateUserRequestEntityCopyWith<$Res> implements $UpdateU
|
||||
factory _$UpdateUserRequestEntityCopyWith(_UpdateUserRequestEntity value, $Res Function(_UpdateUserRequestEntity) _then) = __$UpdateUserRequestEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
|
||||
String? firstName, String? lastName, String? phone
|
||||
});
|
||||
|
||||
|
||||
@@ -284,21 +262,10 @@ class __$UpdateUserRequestEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
|
||||
return _then(_UpdateUserRequestEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
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?,
|
||||
));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user