From ffc0a1f103f89c90dfaa0b8541443aa6589e379f Mon Sep 17 00:00:00 2001 From: aitorarana Date: Wed, 11 Mar 2026 13:11:11 +0100 Subject: [PATCH] legacy device setup screen flow from account settings --- .../presentation/account_settings_screen.dart | 120 +++--------------- .../presentation/widgets/reg_code_dialog.dart | 104 +++++++++++++++ modules/legacy/modules/account/pubspec.lock | 7 + modules/legacy/modules/account/pubspec.yaml | 3 +- .../modules/account/pubspec_overrides.yaml | 3 + .../modules/legacy_auth/lib/legacy_auth.dart | 1 + .../presentation/device_setup_screen.dart | 23 +++- .../presentation/steps/profile_step.dart | 2 +- 8 files changed, 150 insertions(+), 113 deletions(-) create mode 100644 modules/legacy/modules/account/lib/src/features/account_settings/presentation/widgets/reg_code_dialog.dart diff --git a/modules/legacy/modules/account/lib/src/features/account_settings/presentation/account_settings_screen.dart b/modules/legacy/modules/account/lib/src/features/account_settings/presentation/account_settings_screen.dart index 7f83e2c8..e5011837 100644 --- a/modules/legacy/modules/account/lib/src/features/account_settings/presentation/account_settings_screen.dart +++ b/modules/legacy/modules/account/lib/src/features/account_settings/presentation/account_settings_screen.dart @@ -1,16 +1,18 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:legacy_auth/legacy_auth.dart'; import 'package:legacy_shared/legacy_shared.dart'; import 'package:navigation/navigation.dart'; import 'package:sf_localizations/sf_localizations.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:utils/utils.dart'; -import 'package:flutter/services.dart'; -import 'package:qr_flutter/qr_flutter.dart'; + +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}); @@ -21,7 +23,7 @@ class AccountSettingsScreen extends ConsumerWidget { final selectedDevice = ref.watch(selectedDeviceProvider); return LegacyPageLayout( -theme: theme, + theme: theme, title: context.translate(I18n.accountSettings), body: SingleChildScrollView(child: Container( padding: SizeUtils.getByScreen( @@ -43,7 +45,16 @@ theme: theme, ), SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), AppSectionButton( - onPressed: (){}, + onPressed: (){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => LegacyDeviceSetupScreen( + navigationContract: navigationContract, + isFirstDevice: false + ), + ), + ); + }, icon: Icons.add_circle_outline, text: I18n.addNewSF ), @@ -62,7 +73,7 @@ theme: theme, 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'); + final Uri url = Uri.parse(_privacyUrl); if (!await launchUrl(url)) { throw Exception('Could not launch $url'); } @@ -160,103 +171,4 @@ class AppSectionButton extends ConsumerWidget { ) ); } -} - -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, - ), - ) - ), - ], - ), - ); - } - } \ No newline at end of file diff --git a/modules/legacy/modules/account/lib/src/features/account_settings/presentation/widgets/reg_code_dialog.dart b/modules/legacy/modules/account/lib/src/features/account_settings/presentation/widgets/reg_code_dialog.dart new file mode 100644 index 00000000..7be1f29e --- /dev/null +++ b/modules/legacy/modules/account/lib/src/features/account_settings/presentation/widgets/reg_code_dialog.dart @@ -0,0 +1,104 @@ +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, + }); + + @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, + ), + ) + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/modules/legacy/modules/account/pubspec.lock b/modules/legacy/modules/account/pubspec.lock index 7c1df684..1d2b4b2b 100644 --- a/modules/legacy/modules/account/pubspec.lock +++ b/modules/legacy/modules/account/pubspec.lock @@ -586,6 +586,13 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + legacy_auth: + dependency: "direct main" + description: + path: "../legacy_auth" + relative: true + source: path + version: "0.0.1" legacy_shared: dependency: "direct main" description: diff --git a/modules/legacy/modules/account/pubspec.yaml b/modules/legacy/modules/account/pubspec.yaml index aa4e3835..4d1ffcc4 100644 --- a/modules/legacy/modules/account/pubspec.yaml +++ b/modules/legacy/modules/account/pubspec.yaml @@ -24,7 +24,8 @@ dependencies: flutter: sdk: flutter #modules dependencies go here - + legacy_auth: + path: ../../modules/legacy_auth #packages dependencies go here design_system: path: ../../../../packages/design_system diff --git a/modules/legacy/modules/account/pubspec_overrides.yaml b/modules/legacy/modules/account/pubspec_overrides.yaml index d10e1fe1..498ed0b7 100644 --- a/modules/legacy/modules/account/pubspec_overrides.yaml +++ b/modules/legacy/modules/account/pubspec_overrides.yaml @@ -1,3 +1,4 @@ +# melos_managed_dependency_overrides: legacy_auth # melos_managed_dependency_overrides: activity,auth,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_shared,navigation,notifications,payments,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,utils dependency_overrides: activity: @@ -12,6 +13,8 @@ dependency_overrides: path: ../../../../packages/fonts home: path: ../../../home + legacy_auth: + path: ..\\legacy_auth legacy_shared: path: ../../packages/legacy_shared navigation: diff --git a/modules/legacy/modules/legacy_auth/lib/legacy_auth.dart b/modules/legacy/modules/legacy_auth/lib/legacy_auth.dart index 81bd4f3b..45f8014a 100644 --- a/modules/legacy/modules/legacy_auth/lib/legacy_auth.dart +++ b/modules/legacy/modules/legacy_auth/lib/legacy_auth.dart @@ -4,6 +4,7 @@ export 'src/features/link_phone/presentation/verify_code/verify_link_phone_code_ export 'src/features/login/login_builder.dart'; export 'src/features/recover_password/presentation/request_recovery/request_recovery_builder.dart'; export 'src/features/device_setup/device_setup_builder.dart'; +export 'src/features/device_setup/presentation/device_setup_screen.dart'; export 'src/features/sign_up/sign_up_builder.dart'; export 'src/core/data/datasource/session_local_datasource.dart'; export 'src/core/providers/auth_repository_provider.dart'; diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart index 1c80dfe8..5a7235b0 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart @@ -11,8 +11,13 @@ import 'package:sf_localizations/sf_localizations.dart'; class LegacyDeviceSetupScreen extends ConsumerWidget { final NavigationContract navigationContract; + final bool isFirstDevice; - const LegacyDeviceSetupScreen({super.key, required this.navigationContract}); + const LegacyDeviceSetupScreen({ + super.key, + required this.navigationContract, + this.isFirstDevice = true, + }); @override Widget build(BuildContext context, WidgetRef ref) { @@ -95,13 +100,17 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { final ok = await vm.createDevice(); if (!context.mounted) return; if (ok) { - Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => LegacySuccessScreen( - navigationContract: navigationContract, + if (isFirstDevice){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => LegacySuccessScreen( + navigationContract: navigationContract, + ), ), - ), - ); + ); + } else { + Navigator.pop(context); + } } return; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart index 007406d5..726dfa5c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart @@ -12,7 +12,7 @@ Future _pickBornAt( FocusManager.instance.primaryFocus?.unfocus(); final now = DateTime.now(); - final initial = currentBornAt ?? DateTime(now.year - 18, now.month, now.day); + final initial = currentBornAt ?? DateTime(now.year - 4, now.month, now.day); final safeInitial = initial.isAfter(now) ? now : initial; final picked = await showDatePicker(