From e4000d57fcc3ef935b705f3e8ba9077e47af616c Mon Sep 17 00:00:00 2001 From: JulianAlcala Date: Mon, 9 Mar 2026 15:32:53 +0100 Subject: [PATCH] activation key in legacy device setup --- .../device_setup_remote_datasource.dart | 2 + .../device_setup_remote_datasource_impl.dart | 10 +++++ .../device_setup_repository_impl.dart | 5 +++ .../repositories/device_setup_repository.dart | 2 + .../presentation/device_setup_screen.dart | 14 ++++-- .../state/device_setup_view_model.dart | 44 ++++++++++++++++--- .../state/device_setup_view_state.dart | 1 + .../device_setup_view_state.freezed.dart | 39 ++++++++-------- .../presentation/steps/profile_step.dart | 8 ++++ .../presentation/success_screen.dart | 7 ++- packages/sf_localizations/assets/l10n/de.json | 3 +- packages/sf_localizations/assets/l10n/en.json | 3 +- packages/sf_localizations/assets/l10n/es.json | 3 +- packages/sf_localizations/assets/l10n/fr.json | 3 +- packages/sf_localizations/assets/l10n/it.json | 3 +- packages/sf_localizations/assets/l10n/pt.json | 3 +- .../lib/src/generated/i18n.dart | 1 + 17 files changed, 114 insertions(+), 37 deletions(-) diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart index ca1f0b96..92c71b28 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart @@ -1,6 +1,8 @@ import 'package:legacy_auth/src/core/data/models/device_response_model.dart'; abstract class LegacyDeviceSetupRemoteDatasource { + Future generateActivationKey({required String identificator}); + Future createDevice({ required String name, required String genrer, diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart index a853b57e..6cc18fd4 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart @@ -9,6 +9,16 @@ class LegacyDeviceSetupRemoteDatasourceImpl final QuestiaRepository _repository; + @override + Future generateActivationKey({required String identificator}) async { + await safeCall( + () => _repository.post( + '/recorded-devices/$identificator/activation-key', + ), + 'Error generating activation key', + ); + } + @override Future createDevice({ required String name, diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart index a964ccde..9efe5cff 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart @@ -6,6 +6,11 @@ class LegacyDeviceSetupRepositoryImpl implements LegacyDeviceSetupRepository { final LegacyDeviceSetupRemoteDatasource _remote; + @override + Future generateActivationKey({required String identificator}) { + return _remote.generateActivationKey(identificator: identificator); + } + @override Future createDevice({ required String name, diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart index e79372b8..3c81baf6 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart @@ -1,4 +1,6 @@ abstract class LegacyDeviceSetupRepository { + Future generateActivationKey({required String identificator}); + Future createDevice({ required String name, required String genrer, 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 975797dd..1c80dfe8 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 @@ -6,7 +6,6 @@ import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:navigation/app_routes.dart'; import 'package:navigation/navigation_contract.dart'; import 'package:sf_localizations/sf_localizations.dart'; @@ -81,7 +80,10 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { Expanded( child: AnimatedSwitcher( duration: const Duration(milliseconds: 250), - child: LegacyStepBody(key: ValueKey(state.step), state: state), + child: LegacyStepBody( + key: ValueKey(state.step), + state: state, + ), ), ), @@ -94,12 +96,16 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { if (!context.mounted) return; if (ok) { Navigator.of(context).push( - MaterialPageRoute(builder: (_) => LegacySuccessScreen()), + MaterialPageRoute( + builder: (_) => LegacySuccessScreen( + navigationContract: navigationContract, + ), + ), ); } return; } - vm.next(); + await vm.next(); }, theme: theme, ), diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart index 45a5d1f4..b035ae39 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart @@ -22,6 +22,7 @@ class LegacyDeviceSetupViewModel extends Notifier { late final TextEditingController weightController; late final TextEditingController heightController; late final TextEditingController watchCodeController; + late final TextEditingController activationKeyController; @override LegacyDeviceSetupViewState build() { @@ -45,6 +46,7 @@ class LegacyDeviceSetupViewModel extends Notifier { weightController = TextEditingController(text: s.weight); heightController = TextEditingController(text: s.height); watchCodeController = TextEditingController(text: s.watchCode); + activationKeyController = TextEditingController(text: s.activationKey); } void _addListeners() { @@ -54,9 +56,10 @@ class LegacyDeviceSetupViewModel extends Notifier { weightController.addListener(_onWeightChanged); heightController.addListener(_onHeightChanged); watchCodeController.addListener(_onWatchCodeChanged); + activationKeyController.addListener(_onActivationKeyChanged); } - void next() { + Future next() async { switch (state.step) { case LegacyAddKidStep.intro: state = state.copyWith(step: LegacyAddKidStep.linkInfo); @@ -65,19 +68,37 @@ class LegacyDeviceSetupViewModel extends Notifier { state = state.copyWith(step: LegacyAddKidStep.scanWatch); return; case LegacyAddKidStep.scanWatch: - final hasWatch = state.watchQr.isNotEmpty || state.watchCode.isNotEmpty; - if (!hasWatch) { + final identificator = state.watchCode.isNotEmpty ? state.watchCode : state.watchQr; + if (identificator.isEmpty) { state = state.copyWith(errorMessage: ''); state = state.copyWith(errorMessage: I18n.errorScanWatchRequired); return; } - state = state.copyWith(step: LegacyAddKidStep.profile, errorMessage: ''); + await _generateActivationKey(identificator); return; case LegacyAddKidStep.profile: return; } } + Future _generateActivationKey(String identificator) async { + state = state.copyWith(isLoading: true, errorMessage: ''); + try { + await _deviceSetupRepository.generateActivationKey(identificator: identificator); + if (!ref.mounted) return; + state = state.copyWith( + isLoading: false, + step: LegacyAddKidStep.profile, + ); + } catch (e) { + if (!ref.mounted) return; + state = state.copyWith( + isLoading: false, + errorMessage: e.toString(), + ); + } + } + void back() { switch (state.step) { case LegacyAddKidStep.intro: @@ -114,8 +135,7 @@ class LegacyDeviceSetupViewModel extends Notifier { final stepLength = (heightCm * 0.40).round(); final genrer = state.genrer.trim(); final relationType = state.relationType.trim(); - final activationKey = - state.watchCode.isNotEmpty ? state.watchCode : state.watchQr; + final activationKey = state.activationKey.trim(); state = state.copyWith(isLoading: true); @@ -155,7 +175,8 @@ class LegacyDeviceSetupViewModel extends Notifier { state.weight.trim().isEmpty || int.tryParse(state.weight.trim()) == null || state.height.trim().isEmpty || - double.tryParse(state.height.trim()) == null; + double.tryParse(state.height.trim()) == null || + state.activationKey.trim().isEmpty; if (isInvalid) { state = state.copyWith(errorMessage: ''); @@ -213,6 +234,13 @@ class LegacyDeviceSetupViewModel extends Notifier { state = state.copyWith(watchCode: text, errorMessage: ''); } + void _onActivationKeyChanged() { + toUpperCaseController(activationKeyController); + final text = activationKeyController.text; + if (text == state.activationKey) return; + state = state.copyWith(activationKey: text, errorMessage: ''); + } + void setError(String message) { state = state.copyWith(errorMessage: message); } @@ -236,6 +264,7 @@ class LegacyDeviceSetupViewModel extends Notifier { weightController.clear(); heightController.clear(); watchCodeController.clear(); + activationKeyController.clear(); state = const LegacyDeviceSetupViewState(); } @@ -247,5 +276,6 @@ class LegacyDeviceSetupViewModel extends Notifier { weightController.dispose(); heightController.dispose(); watchCodeController.dispose(); + activationKeyController.dispose(); } } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart index 4f34465c..42c87f6b 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart @@ -17,6 +17,7 @@ abstract class LegacyDeviceSetupViewState with _$LegacyDeviceSetupViewState { @Default('') String watchQr, @Default('') String watchCode, + @Default('') String activationKey, @Default(false) bool isLoading, @Default('') String errorMessage, diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart index 93886a6d..80d339d0 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacyDeviceSetupViewState { - LegacyAddKidStep get step; String get firstName; String get lastName; DateTime? get bornAt; String get genrer; String get relationType; String get weight; String get height; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess; + LegacyAddKidStep get step; String get firstName; String get lastName; DateTime? get bornAt; String get genrer; String get relationType; String get weight; String get height; String get watchQr; String get watchCode; String get activationKey; bool get isLoading; String get errorMessage; bool get isSuccess; /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $LegacyDeviceSetupViewStateCopyWith get copyWith => @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.activationKey, activationKey) || other.activationKey == activationKey)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); } @override -int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess); +int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,activationKey,isLoading,errorMessage,isSuccess); @override String toString() { - return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; + return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, activationKey: $activationKey, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; } @@ -45,7 +45,7 @@ abstract mixin class $LegacyDeviceSetupViewStateCopyWith<$Res> { factory $LegacyDeviceSetupViewStateCopyWith(LegacyDeviceSetupViewState value, $Res Function(LegacyDeviceSetupViewState) _then) = _$LegacyDeviceSetupViewStateCopyWithImpl; @useResult $Res call({ - LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess + LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, String activationKey, bool isLoading, String errorMessage, bool isSuccess }); @@ -62,7 +62,7 @@ class _$LegacyDeviceSetupViewStateCopyWithImpl<$Res> /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? activationKey = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { return _then(_self.copyWith( step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -74,6 +74,7 @@ as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullabl as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable +as String,activationKey: null == activationKey ? _self.activationKey : activationKey // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable @@ -162,10 +163,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, String activationKey, bool isLoading, String errorMessage, bool isSuccess)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _AddKidFlowState() when $default != null: -return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.activationKey,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: return orElse(); } @@ -183,10 +184,10 @@ return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.gen /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, String activationKey, bool isLoading, String errorMessage, bool isSuccess) $default,) {final _that = this; switch (_that) { case _AddKidFlowState(): -return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.activationKey,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: throw StateError('Unexpected subclass'); } @@ -203,10 +204,10 @@ return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.gen /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, String activationKey, bool isLoading, String errorMessage, bool isSuccess)? $default,) {final _that = this; switch (_that) { case _AddKidFlowState() when $default != null: -return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.activationKey,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: return null; } @@ -218,7 +219,7 @@ return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.gen class _AddKidFlowState implements LegacyDeviceSetupViewState { - const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.firstName = '', this.lastName = '', this.bornAt, this.genrer = '', this.relationType = '', this.weight = '', this.height = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false}); + const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.firstName = '', this.lastName = '', this.bornAt, this.genrer = '', this.relationType = '', this.weight = '', this.height = '', this.watchQr = '', this.watchCode = '', this.activationKey = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false}); @override@JsonKey() final LegacyAddKidStep step; @@ -231,6 +232,7 @@ class _AddKidFlowState implements LegacyDeviceSetupViewState { @override@JsonKey() final String height; @override@JsonKey() final String watchQr; @override@JsonKey() final String watchCode; +@override@JsonKey() final String activationKey; @override@JsonKey() final bool isLoading; @override@JsonKey() final String errorMessage; @override@JsonKey() final bool isSuccess; @@ -245,16 +247,16 @@ _$AddKidFlowStateCopyWith<_AddKidFlowState> get copyWith => __$AddKidFlowStateCo @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.activationKey, activationKey) || other.activationKey == activationKey)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); } @override -int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess); +int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,activationKey,isLoading,errorMessage,isSuccess); @override String toString() { - return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; + return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, activationKey: $activationKey, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; } @@ -265,7 +267,7 @@ abstract mixin class _$AddKidFlowStateCopyWith<$Res> implements $LegacyDeviceSet factory _$AddKidFlowStateCopyWith(_AddKidFlowState value, $Res Function(_AddKidFlowState) _then) = __$AddKidFlowStateCopyWithImpl; @override @useResult $Res call({ - LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess + LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, String activationKey, bool isLoading, String errorMessage, bool isSuccess }); @@ -282,7 +284,7 @@ class __$AddKidFlowStateCopyWithImpl<$Res> /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? activationKey = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { return _then(_AddKidFlowState( step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -294,6 +296,7 @@ as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullabl as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable +as String,activationKey: null == activationKey ? _self.activationKey : activationKey // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable 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 8fcf6c70..007406d5 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 @@ -144,6 +144,14 @@ class LegacyProfileStepScreen extends ConsumerWidget { ), const SizedBox(height: 8), + + CustomTextField( + label: context.translate(I18n.activationKeyLabel), + hint: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', + controller: vm.activationKeyController, + ), + + const SizedBox(height: 8), ], ), ), diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart index 7ece3b99..bc0b3b0a 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart @@ -3,10 +3,13 @@ import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:navigation/navigation.dart'; import 'package:sf_localizations/sf_localizations.dart'; class LegacySuccessScreen extends ConsumerWidget { - const LegacySuccessScreen({super.key}); + final NavigationContract navigationContract; + + const LegacySuccessScreen({super.key, required this.navigationContract}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -58,7 +61,7 @@ class LegacySuccessScreen extends ConsumerWidget { LegacyFlowFooter( primaryText: context.translate(I18n.continueKey), onPrimary: () { - Navigator.of(context).pop(); + navigationContract.goTo(AppRoutes.controlPanel); }, secondaryText: context.translate(I18n.deviceSetup_addAnotherKid), onSecondary: () { diff --git a/packages/sf_localizations/assets/l10n/de.json b/packages/sf_localizations/assets/l10n/de.json index fea9ccc0..ef7963b2 100644 --- a/packages/sf_localizations/assets/l10n/de.json +++ b/packages/sf_localizations/assets/l10n/de.json @@ -487,5 +487,6 @@ "deviceSetup_weightLabel": "Gewicht (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Größe (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Aktivierungsschlüssel" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/en.json b/packages/sf_localizations/assets/l10n/en.json index 9fb43baa..019d19c0 100755 --- a/packages/sf_localizations/assets/l10n/en.json +++ b/packages/sf_localizations/assets/l10n/en.json @@ -543,5 +543,6 @@ "deviceSetup_weightLabel": "Weight (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Height (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Activation key" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/es.json b/packages/sf_localizations/assets/l10n/es.json index bccacf24..de986f81 100644 --- a/packages/sf_localizations/assets/l10n/es.json +++ b/packages/sf_localizations/assets/l10n/es.json @@ -539,5 +539,6 @@ "deviceSetup_weightLabel": "Peso (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Altura (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Clave de activación" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/fr.json b/packages/sf_localizations/assets/l10n/fr.json index b66986a5..d031dd92 100644 --- a/packages/sf_localizations/assets/l10n/fr.json +++ b/packages/sf_localizations/assets/l10n/fr.json @@ -487,5 +487,6 @@ "deviceSetup_weightLabel": "Poids (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Taille (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Clé d'activation" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/it.json b/packages/sf_localizations/assets/l10n/it.json index ee82a8df..e9690358 100644 --- a/packages/sf_localizations/assets/l10n/it.json +++ b/packages/sf_localizations/assets/l10n/it.json @@ -487,5 +487,6 @@ "deviceSetup_weightLabel": "Peso (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Altezza (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Chiave di attivazione" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/pt.json b/packages/sf_localizations/assets/l10n/pt.json index 2554978c..f9ca20ce 100644 --- a/packages/sf_localizations/assets/l10n/pt.json +++ b/packages/sf_localizations/assets/l10n/pt.json @@ -487,5 +487,6 @@ "deviceSetup_weightLabel": "Peso (kg)", "deviceSetup_weightHint": "30", "deviceSetup_heightLabel": "Altura (cm)", - "deviceSetup_heightHint": "120" + "deviceSetup_heightHint": "120", + "activationKeyLabel": "Chave de ativação" } \ No newline at end of file diff --git a/packages/sf_localizations/lib/src/generated/i18n.dart b/packages/sf_localizations/lib/src/generated/i18n.dart index 21516df0..44a53793 100755 --- a/packages/sf_localizations/lib/src/generated/i18n.dart +++ b/packages/sf_localizations/lib/src/generated/i18n.dart @@ -660,4 +660,5 @@ class I18n { static const String deviceSetup_weightHint = 'deviceSetup_weightHint'; static const String deviceSetup_heightLabel = 'deviceSetup_heightLabel'; static const String deviceSetup_heightHint = 'deviceSetup_heightHint'; + static const String activationKeyLabel = 'activationKeyLabel'; }