legacy login refactor
This commit is contained in:
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -15,6 +15,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/packages/fonts/melos_fonts.iml" filepath="$PROJECT_DIR$/packages/fonts/melos_fonts.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/modules/home/melos_home.iml" filepath="$PROJECT_DIR$/modules/home/melos_home.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/modules/legacy/melos_legacy.iml" filepath="$PROJECT_DIR$/modules/legacy/melos_legacy.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/legacy_auth/melos_legacy_auth.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/legacy_auth/melos_legacy_auth.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/modules/legacy/modules/legacy_dashboard_shell/melos_legacy_dashboard_shell.iml" filepath="$PROJECT_DIR$/modules/legacy/modules/legacy_dashboard_shell/melos_legacy_dashboard_shell.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/modules/legacy/packages/legacy_shared/melos_legacy_shared.iml" filepath="$PROJECT_DIR$/modules/legacy/packages/legacy_shared/melos_legacy_shared.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/packages/navigation/melos_navigation.iml" filepath="$PROJECT_DIR$/packages/navigation/melos_navigation.iml" />
|
||||
|
||||
7
.idea/runConfigurations/melos_flutter_test_legacy_auth.xml
generated
Normal file
7
.idea/runConfigurations/melos_flutter_test_legacy_auth.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<!-- Generated by Melos -->
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Flutter Test -> 'legacy_auth'" type="FlutterTestConfigType" factoryName="Flutter Test">
|
||||
<option name="testDir" value="$PROJECT_DIR$/modules/legacy/modules/legacy_auth/test" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:account/account.dart';
|
||||
import 'package:activity/activity.dart';
|
||||
import 'package:auth/auth.dart';
|
||||
import 'package:legacy_auth/legacy_auth.dart';
|
||||
import 'package:customer_service/customer_service.dart';
|
||||
import 'package:dashboard_shell/dashboard_builder.dart';
|
||||
import 'package:device_management/device_management.dart';
|
||||
@@ -23,7 +24,7 @@ late final GoRouter appRouter;
|
||||
void configureAppRouter() {
|
||||
appRouter = GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
initialLocation: AppRoutes.splash,
|
||||
initialLocation: AppRoutes.legacyLogin,
|
||||
debugLogDiagnostics: true,
|
||||
routes: [
|
||||
GoRoute(
|
||||
@@ -153,6 +154,41 @@ void configureAppRouter() {
|
||||
name: 'device_setup',
|
||||
pageBuilder: DeviceSetupBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyLogin,
|
||||
name: 'legacy_login',
|
||||
pageBuilder: LegacyLoginBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacySignup,
|
||||
name: 'legacy_signup',
|
||||
pageBuilder: LegacySignupBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyOnboarding,
|
||||
name: 'legacy_onboarding',
|
||||
pageBuilder: LegacyOnboardingBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyLinkPhone,
|
||||
name: 'legacy_request_link_phone',
|
||||
pageBuilder: LegacyRequestLinkPhoneBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyPhoneCode,
|
||||
name: 'legacy_verify_link_phone_code',
|
||||
pageBuilder: LegacyVerifyLinkPhoneCodeBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyRecoverPassword,
|
||||
name: 'legacy_recover_password',
|
||||
pageBuilder: LegacyRequestRecoveryBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyDeviceSetup,
|
||||
name: 'legacy_device_setup',
|
||||
pageBuilder: LegacyDeviceSetupBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.hipayWebView,
|
||||
name: 'hipay_webview',
|
||||
|
||||
@@ -690,6 +690,13 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
legacy_auth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../../modules/legacy/modules/legacy_auth"
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
legacy_dashboard_shell:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -61,6 +61,8 @@ dependencies:
|
||||
path: ../../modules/legacy/modules/account
|
||||
device_management:
|
||||
path: ../../modules/legacy/modules/device_management
|
||||
legacy_auth:
|
||||
path: ../../modules/legacy/modules/legacy_auth
|
||||
#packages dependencies go here
|
||||
navigation:
|
||||
path: ../../packages/navigation
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 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
|
||||
# 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
|
||||
dependency_overrides:
|
||||
account:
|
||||
path: ../../modules/legacy/modules/account
|
||||
@@ -22,6 +22,8 @@ dependency_overrides:
|
||||
path: ../../packages/fonts
|
||||
home:
|
||||
path: ../../modules/home
|
||||
legacy_auth:
|
||||
path: ../../modules/legacy/modules/legacy_auth
|
||||
legacy_dashboard_shell:
|
||||
path: ../../modules/legacy/modules/legacy_dashboard_shell
|
||||
legacy_shared:
|
||||
|
||||
31
modules/legacy/modules/legacy_auth/.gitignore
vendored
Normal file
31
modules/legacy/modules/legacy_auth/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins-dependencies
|
||||
/build/
|
||||
/coverage/
|
||||
10
modules/legacy/modules/legacy_auth/.metadata
Normal file
10
modules/legacy/modules/legacy_auth/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
|
||||
channel: "stable"
|
||||
|
||||
project_type: package
|
||||
3
modules/legacy/modules/legacy_auth/CHANGELOG.md
Normal file
3
modules/legacy/modules/legacy_auth/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
1
modules/legacy/modules/legacy_auth/LICENSE
Normal file
1
modules/legacy/modules/legacy_auth/LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
TODO: Add your license here.
|
||||
39
modules/legacy/modules/legacy_auth/README.md
Normal file
39
modules/legacy/modules/legacy_auth/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||
-->
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
4
modules/legacy/modules/legacy_auth/analysis_options.yaml
Normal file
4
modules/legacy/modules/legacy_auth/analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
10
modules/legacy/modules/legacy_auth/lib/legacy_auth.dart
Normal file
10
modules/legacy/modules/legacy_auth/lib/legacy_auth.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
export 'src/features/onboarding/onboarding_builder.dart';
|
||||
export 'src/features/link_phone/presentation/request_phone/request_link_phone_builder.dart';
|
||||
export 'src/features/link_phone/presentation/verify_code/verify_link_phone_code_builder.dart';
|
||||
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/sign_up/sign_up_builder.dart';
|
||||
export 'src/core/data/datasource/session_local_datasource.dart';
|
||||
export 'src/core/providers/auth_repository_provider.dart';
|
||||
export 'src/core/data/datasource/session_local_datasource_impl.dart';
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
abstract class LegacyAuthRemoteDatasource {
|
||||
Future<void> requestPhoneCode({required String phone});
|
||||
|
||||
Future<void> verifyPhoneCode({required String phone, required String code});
|
||||
|
||||
Future<LegacyLoginResponseModel> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
|
||||
// Future<String> totpLogin({required String token, required String code});
|
||||
|
||||
Future<LegacySignUpResponseModel> signUp({required LegacySignUpRequestModel request});
|
||||
|
||||
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({required String token});
|
||||
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
});
|
||||
|
||||
Future<String> requestPasswordReset({required String email});
|
||||
|
||||
Future<void> recoverPassword({required newPassword, required token});
|
||||
|
||||
Future<void> logout();
|
||||
|
||||
Future<LegacyChildProfileResponseModel> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
import 'auth_remote_datasource.dart';
|
||||
|
||||
class LegacyAuthRemoteDatasourceImpl implements LegacyAuthRemoteDatasource {
|
||||
LegacyAuthRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> requestPhoneCode({required String phone}) async {
|
||||
try {
|
||||
await _repository.post<void>(
|
||||
'/auth/link-phone/request-code',
|
||||
body: <String, dynamic>{'phone': phone},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.response?.data ?? 'Error to request phone code',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> verifyPhoneCode({
|
||||
required String phone,
|
||||
required String code,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.post<void>(
|
||||
'/auth/link-phone/verify-code',
|
||||
body: <String, dynamic>{'phone': phone, 'code': code},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in verification code');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyLoginResponseModel> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.post<Map<String, dynamic>>(
|
||||
'/auth/login',
|
||||
body: <String, dynamic>{'email': email, 'password': password},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/login');
|
||||
}
|
||||
|
||||
final parsed = LegacyLoginResponseModel.fromJson(data);
|
||||
|
||||
return parsed;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: error.message ?? 'Error in login',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFARequestCode({
|
||||
//this gonna send a request to the backend to send email code to the user for default
|
||||
required String token,
|
||||
required String methodType,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.post<void>(
|
||||
'/auth/2fa/request-code',
|
||||
body: <String, dynamic>{'token': token, 'methodType': methodType},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFARequestCode');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.post<void>(
|
||||
'/auth/twofa/login',
|
||||
body: <String, dynamic>{
|
||||
'token': token,
|
||||
'code': code,
|
||||
'methodType': methodType,
|
||||
'rememberMe': true,
|
||||
},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFASendCode');
|
||||
}
|
||||
}
|
||||
|
||||
// @override
|
||||
// Future<String> totpLogin({
|
||||
// required String token,
|
||||
// required String code,
|
||||
// }) async {
|
||||
// try {
|
||||
// final response = await _repository.post<String>(
|
||||
// '/auth/totp/login',
|
||||
// body: <String, dynamic>{
|
||||
// 'token': token,
|
||||
// 'code': code,
|
||||
// 'rememberMe': true,
|
||||
// },
|
||||
// );
|
||||
|
||||
// final data = response.data;
|
||||
// if (data == null || data.isEmpty) {
|
||||
// throw Exception('Empty response from /auth/totp/login');
|
||||
// }
|
||||
|
||||
// return data;
|
||||
// } on DioException catch (error) {
|
||||
// throw _mapDioError(error, defaultMessage: 'Error in totpLogin');
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Future<LegacySignUpResponseModel> signUp({
|
||||
required LegacySignUpRequestModel request,
|
||||
}) async {
|
||||
try {
|
||||
final body = request.toJson();
|
||||
debugPrint(const JsonEncoder.withIndent(' ').convert(body));
|
||||
|
||||
final response = await _repository.post<Map<String, dynamic>>(
|
||||
'/auth/signup',
|
||||
body: body,
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/signup');
|
||||
}
|
||||
|
||||
final parsed = LegacySignUpResponseModel.fromJson(data);
|
||||
|
||||
if (!parsed.isCreated) {
|
||||
throw Exception('Sign up failed: isCreated=false');
|
||||
}
|
||||
|
||||
final userId = parsed.item.userId.trim();
|
||||
if (userId.isEmpty) {
|
||||
throw Exception('Sign up response has empty userId');
|
||||
}
|
||||
|
||||
return parsed;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in signUp');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({
|
||||
required String token,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.post<Map<String, dynamic>>(
|
||||
'/auth/totp/secret',
|
||||
body: <String, dynamic>{'token': token},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/totp/secret');
|
||||
}
|
||||
|
||||
final model = LegacyTwoFASecretResponseModel.fromJson(data);
|
||||
return model;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFASignUp');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.post<String>(
|
||||
'/auth/totp/code',
|
||||
body: <String, dynamic>{'token': token, 'code': code},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/totp/code');
|
||||
}
|
||||
|
||||
return data;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFaCodeSignUp');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> requestPasswordReset({required String email}) async {
|
||||
try {
|
||||
late final Map<String, dynamic> body;
|
||||
body = {'email': email};
|
||||
|
||||
final response = await _repository.put<String>(
|
||||
'/auth/reset-password',
|
||||
body: body,
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/totp/code');
|
||||
}
|
||||
|
||||
return data;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error to request password reset',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> recoverPassword({required newPassword, required token}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/auth/recovery-password',
|
||||
body: <String, dynamic>{'newPassword': newPassword, 'token': token},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error to request password recovery',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> logout() async {
|
||||
try {
|
||||
await _repository.post<void>('/auth/logout');
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in logout');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyChildProfileResponseModel> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.post<Map<String, dynamic>>(
|
||||
'/child-profiles',
|
||||
body: <String, dynamic>{
|
||||
'address': address,
|
||||
'bornAt': bornAt,
|
||||
'cardPublicKey': cardPublicKey,
|
||||
'deviceActivationCode': deviceActivationCode,
|
||||
'firstName': firstName,
|
||||
'genre': genrer,
|
||||
'id': id,
|
||||
'lastName': lastName,
|
||||
'parentId': parentId,
|
||||
'relationType': relationType,
|
||||
'scaProof': scaProof,
|
||||
},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/child-profiles');
|
||||
}
|
||||
|
||||
return LegacyChildProfileResponseModel.fromJson(data);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in createChildProfile');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,6 @@
|
||||
abstract class LegacySessionLocalDatasource {
|
||||
Future<void> savePaymentProfileId(String id);
|
||||
Future<String?> getPaymentProfileId();
|
||||
|
||||
Future<void> clearSession();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'session_local_datasource.dart';
|
||||
|
||||
class LegacySessionLocalDatasourceImpl implements LegacySessionLocalDatasource {
|
||||
static const _paymentProfileIdKey = 'session_payment_profile_id';
|
||||
|
||||
@override
|
||||
Future<void> savePaymentProfileId(String id) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_paymentProfileIdKey, id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getPaymentProfileId() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString(_paymentProfileIdKey);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearSession() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(_paymentProfileIdKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/address_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'address_model.freezed.dart';
|
||||
part 'address_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyAddressModel with _$LegacyAddressModel {
|
||||
const factory LegacyAddressModel({
|
||||
required String street,
|
||||
required String city,
|
||||
required String province,
|
||||
required String state,
|
||||
required String country,
|
||||
required int postCode,
|
||||
}) = _LegacyAddressModel;
|
||||
|
||||
factory LegacyAddressModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyAddressModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacyAddressModelMapper on LegacyAddressEntity {
|
||||
LegacyAddressModel toModel() => LegacyAddressModel(
|
||||
street: street,
|
||||
city: city,
|
||||
province: province,
|
||||
state: state,
|
||||
country: country,
|
||||
postCode: postCode,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
// 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 'address_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyAddressModel {
|
||||
|
||||
String get street; String get city; String get province; String get state; String get country; int get postCode;
|
||||
/// Create a copy of LegacyAddressModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyAddressModelCopyWith<LegacyAddressModel> get copyWith => _$LegacyAddressModelCopyWithImpl<LegacyAddressModel>(this as LegacyAddressModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyAddressModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyAddressModel&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.province, province) || other.province == province)&&(identical(other.state, state) || other.state == state)&&(identical(other.country, country) || other.country == country)&&(identical(other.postCode, postCode) || other.postCode == postCode));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,street,city,province,state,country,postCode);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAddressModel(street: $street, city: $city, province: $province, state: $state, country: $country, postCode: $postCode)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyAddressModelCopyWith<$Res> {
|
||||
factory $LegacyAddressModelCopyWith(LegacyAddressModel value, $Res Function(LegacyAddressModel) _then) = _$LegacyAddressModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country, int postCode
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyAddressModelCopyWithImpl<$Res>
|
||||
implements $LegacyAddressModelCopyWith<$Res> {
|
||||
_$LegacyAddressModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyAddressModel _self;
|
||||
final $Res Function(LegacyAddressModel) _then;
|
||||
|
||||
/// Create a copy of LegacyAddressModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,Object? postCode = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,postCode: null == postCode ? _self.postCode : postCode // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyAddressModel].
|
||||
extension LegacyAddressModelPatterns on LegacyAddressModel {
|
||||
/// 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( _LegacyAddressModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel() 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( _LegacyAddressModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel():
|
||||
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( _LegacyAddressModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel() 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 street, String city, String province, String state, String country, int postCode)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.postCode);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 street, String city, String province, String state, String country, int postCode) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel():
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.postCode);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 street, String city, String province, String state, String country, int postCode)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAddressModel() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.postCode);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyAddressModel implements LegacyAddressModel {
|
||||
const _LegacyAddressModel({required this.street, required this.city, required this.province, required this.state, required this.country, required this.postCode});
|
||||
factory _LegacyAddressModel.fromJson(Map<String, dynamic> json) => _$LegacyAddressModelFromJson(json);
|
||||
|
||||
@override final String street;
|
||||
@override final String city;
|
||||
@override final String province;
|
||||
@override final String state;
|
||||
@override final String country;
|
||||
@override final int postCode;
|
||||
|
||||
/// Create a copy of LegacyAddressModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyAddressModelCopyWith<_LegacyAddressModel> get copyWith => __$LegacyAddressModelCopyWithImpl<_LegacyAddressModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyAddressModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyAddressModel&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.province, province) || other.province == province)&&(identical(other.state, state) || other.state == state)&&(identical(other.country, country) || other.country == country)&&(identical(other.postCode, postCode) || other.postCode == postCode));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,street,city,province,state,country,postCode);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAddressModel(street: $street, city: $city, province: $province, state: $state, country: $country, postCode: $postCode)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyAddressModelCopyWith<$Res> implements $LegacyAddressModelCopyWith<$Res> {
|
||||
factory _$LegacyAddressModelCopyWith(_LegacyAddressModel value, $Res Function(_LegacyAddressModel) _then) = __$LegacyAddressModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country, int postCode
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyAddressModelCopyWithImpl<$Res>
|
||||
implements _$LegacyAddressModelCopyWith<$Res> {
|
||||
__$LegacyAddressModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyAddressModel _self;
|
||||
final $Res Function(_LegacyAddressModel) _then;
|
||||
|
||||
/// Create a copy of LegacyAddressModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,Object? postCode = null,}) {
|
||||
return _then(_LegacyAddressModel(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,postCode: null == postCode ? _self.postCode : postCode // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'address_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacyAddressModel _$LegacyAddressModelFromJson(Map<String, dynamic> json) =>
|
||||
_LegacyAddressModel(
|
||||
street: json['street'] as String,
|
||||
city: json['city'] as String,
|
||||
province: json['province'] as String,
|
||||
state: json['state'] as String,
|
||||
country: json['country'] as String,
|
||||
postCode: (json['postCode'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyAddressModelToJson(_LegacyAddressModel instance) =>
|
||||
<String, dynamic>{
|
||||
'street': instance.street,
|
||||
'city': instance.city,
|
||||
'province': instance.province,
|
||||
'state': instance.state,
|
||||
'country': instance.country,
|
||||
'postCode': instance.postCode,
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'child_profile_response_model.freezed.dart';
|
||||
part 'child_profile_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyChildProfileResponseModel with _$LegacyChildProfileResponseModel {
|
||||
const factory LegacyChildProfileResponseModel({
|
||||
required bool isCreated,
|
||||
required LegacyChildProfileItemResponseModel item,
|
||||
}) = _LegacyChildProfileResponseModel;
|
||||
|
||||
factory LegacyChildProfileResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyChildProfileResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacyChildProfileItemResponseModel
|
||||
with _$LegacyChildProfileItemResponseModel {
|
||||
const factory LegacyChildProfileItemResponseModel({
|
||||
required String id,
|
||||
required String deviceIdentificator,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String address,
|
||||
required int createdAt,
|
||||
int? updatedAt,
|
||||
String? profileImageId,
|
||||
}) = _LegacyChildProfileItemResponseModel;
|
||||
|
||||
factory LegacyChildProfileItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyChildProfileItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacyChildProfileResponseModelMapper on LegacyChildProfileResponseModel {
|
||||
LegacyChildProfileEntity toEntity() {
|
||||
return LegacyChildProfileEntity(
|
||||
isCreated: isCreated,
|
||||
item: LegacyChildProfileItemEntity(
|
||||
id: item.id,
|
||||
deviceIdentificator: item.deviceIdentificator,
|
||||
parentId: item.parentId,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
bornAt: item.bornAt,
|
||||
address: item.address,
|
||||
createdAt: item.createdAt,
|
||||
updatedAt: item.updatedAt,
|
||||
profileImageId: item.profileImageId,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,588 @@
|
||||
// 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 'child_profile_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyChildProfileResponseModel {
|
||||
|
||||
bool get isCreated; LegacyChildProfileItemResponseModel get item;
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileResponseModelCopyWith<LegacyChildProfileResponseModel> get copyWith => _$LegacyChildProfileResponseModelCopyWithImpl<LegacyChildProfileResponseModel>(this as LegacyChildProfileResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyChildProfileResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyChildProfileResponseModelCopyWith<$Res> {
|
||||
factory $LegacyChildProfileResponseModelCopyWith(LegacyChildProfileResponseModel value, $Res Function(LegacyChildProfileResponseModel) _then) = _$LegacyChildProfileResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyChildProfileItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyChildProfileResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacyChildProfileResponseModelCopyWith<$Res> {
|
||||
_$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyChildProfileResponseModel _self;
|
||||
final $Res Function(LegacyChildProfileResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyChildProfileItemResponseModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyChildProfileResponseModel].
|
||||
extension LegacyChildProfileResponseModelPatterns on LegacyChildProfileResponseModel {
|
||||
/// 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( _LegacyChildProfileResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel() 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( _LegacyChildProfileResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel():
|
||||
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( _LegacyChildProfileResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel() 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 isCreated, LegacyChildProfileItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemResponseModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel():
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyChildProfileItemResponseModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyChildProfileResponseModel implements LegacyChildProfileResponseModel {
|
||||
const _LegacyChildProfileResponseModel({required this.isCreated, required this.item});
|
||||
factory _LegacyChildProfileResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyChildProfileResponseModelFromJson(json);
|
||||
|
||||
@override final bool isCreated;
|
||||
@override final LegacyChildProfileItemResponseModel item;
|
||||
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyChildProfileResponseModelCopyWith<_LegacyChildProfileResponseModel> get copyWith => __$LegacyChildProfileResponseModelCopyWithImpl<_LegacyChildProfileResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyChildProfileResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyChildProfileResponseModelCopyWith<$Res> implements $LegacyChildProfileResponseModelCopyWith<$Res> {
|
||||
factory _$LegacyChildProfileResponseModelCopyWith(_LegacyChildProfileResponseModel value, $Res Function(_LegacyChildProfileResponseModel) _then) = __$LegacyChildProfileResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyChildProfileItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
@override $LegacyChildProfileItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyChildProfileResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacyChildProfileResponseModelCopyWith<$Res> {
|
||||
__$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyChildProfileResponseModel _self;
|
||||
final $Res Function(_LegacyChildProfileResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_LegacyChildProfileResponseModel(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyChildProfileItemResponseModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LegacyChildProfileResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyChildProfileItemResponseModel {
|
||||
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId;
|
||||
/// Create a copy of LegacyChildProfileItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemResponseModelCopyWith<LegacyChildProfileItemResponseModel> get copyWith => _$LegacyChildProfileItemResponseModelCopyWithImpl<LegacyChildProfileItemResponseModel>(this as LegacyChildProfileItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyChildProfileItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyChildProfileItemResponseModelCopyWith<$Res> {
|
||||
factory $LegacyChildProfileItemResponseModelCopyWith(LegacyChildProfileItemResponseModel value, $Res Function(LegacyChildProfileItemResponseModel) _then) = _$LegacyChildProfileItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyChildProfileItemResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacyChildProfileItemResponseModelCopyWith<$Res> {
|
||||
_$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyChildProfileItemResponseModel _self;
|
||||
final $Res Function(LegacyChildProfileItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyChildProfileItemResponseModel].
|
||||
extension LegacyChildProfileItemResponseModelPatterns on LegacyChildProfileItemResponseModel {
|
||||
/// 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( _LegacyChildProfileItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel() 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( _LegacyChildProfileItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel():
|
||||
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( _LegacyChildProfileItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyChildProfileItemResponseModel implements LegacyChildProfileItemResponseModel {
|
||||
const _LegacyChildProfileItemResponseModel({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId});
|
||||
factory _LegacyChildProfileItemResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyChildProfileItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String deviceIdentificator;
|
||||
@override final String parentId;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final int bornAt;
|
||||
@override final String address;
|
||||
@override final int createdAt;
|
||||
@override final int? updatedAt;
|
||||
@override final String? profileImageId;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyChildProfileItemResponseModelCopyWith<_LegacyChildProfileItemResponseModel> get copyWith => __$LegacyChildProfileItemResponseModelCopyWithImpl<_LegacyChildProfileItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyChildProfileItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyChildProfileItemResponseModelCopyWith<$Res> implements $LegacyChildProfileItemResponseModelCopyWith<$Res> {
|
||||
factory _$LegacyChildProfileItemResponseModelCopyWith(_LegacyChildProfileItemResponseModel value, $Res Function(_LegacyChildProfileItemResponseModel) _then) = __$LegacyChildProfileItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyChildProfileItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacyChildProfileItemResponseModelCopyWith<$Res> {
|
||||
__$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyChildProfileItemResponseModel _self;
|
||||
final $Res Function(_LegacyChildProfileItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
|
||||
return _then(_LegacyChildProfileItemResponseModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,50 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'child_profile_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacyChildProfileResponseModel _$LegacyChildProfileResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacyChildProfileResponseModel(
|
||||
isCreated: json['isCreated'] as bool,
|
||||
item: LegacyChildProfileItemResponseModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyChildProfileResponseModelToJson(
|
||||
_LegacyChildProfileResponseModel instance,
|
||||
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
|
||||
|
||||
_LegacyChildProfileItemResponseModel
|
||||
_$LegacyChildProfileItemResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_LegacyChildProfileItemResponseModel(
|
||||
id: json['id'] as String,
|
||||
deviceIdentificator: json['deviceIdentificator'] as String,
|
||||
parentId: json['parentId'] as String,
|
||||
firstName: json['firstName'] as String,
|
||||
lastName: json['lastName'] as String,
|
||||
bornAt: (json['bornAt'] as num).toInt(),
|
||||
address: json['address'] as String,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
updatedAt: (json['updatedAt'] as num?)?.toInt(),
|
||||
profileImageId: json['profileImageId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyChildProfileItemResponseModelToJson(
|
||||
_LegacyChildProfileItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'deviceIdentificator': instance.deviceIdentificator,
|
||||
'parentId': instance.parentId,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'bornAt': instance.bornAt,
|
||||
'address': instance.address,
|
||||
'createdAt': instance.createdAt,
|
||||
'updatedAt': instance.updatedAt,
|
||||
'profileImageId': instance.profileImageId,
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_response_model.freezed.dart';
|
||||
part 'login_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyLoginResponseModel with _$LegacyLoginResponseModel {
|
||||
const factory LegacyLoginResponseModel({
|
||||
required String token,
|
||||
@Default(<LegacyAvailableMethodModel>[])
|
||||
List<LegacyAvailableMethodModel> availableMethods,
|
||||
}) = _LegacyLoginResponseModel;
|
||||
|
||||
factory LegacyLoginResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyLoginResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacyAvailableMethodModel with _$LegacyAvailableMethodModel {
|
||||
const factory LegacyAvailableMethodModel({
|
||||
required String id,
|
||||
required String userId,
|
||||
required String methodType,
|
||||
required String status,
|
||||
required bool isDefault,
|
||||
required int createdAt,
|
||||
}) = _LegacyAvailableMethodModel;
|
||||
|
||||
factory LegacyAvailableMethodModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyAvailableMethodModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacyLoginResponseModelMapper on LegacyLoginResponseModel {
|
||||
LegacyLoginResponseEntity toEntity() {
|
||||
return LegacyLoginResponseEntity(
|
||||
token: token,
|
||||
availableMethods: availableMethods
|
||||
.map(
|
||||
(m) => LegacyAvailableMethodEntity(
|
||||
id: m.id,
|
||||
userId: m.userId,
|
||||
methodType: m.methodType,
|
||||
status: m.status,
|
||||
isDefault: m.isDefault,
|
||||
createdAt: m.createdAt,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
// 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 'login_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyLoginResponseModel {
|
||||
|
||||
String get token; List<LegacyAvailableMethodModel> get availableMethods;
|
||||
/// Create a copy of LegacyLoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyLoginResponseModelCopyWith<LegacyLoginResponseModel> get copyWith => _$LegacyLoginResponseModelCopyWithImpl<LegacyLoginResponseModel>(this as LegacyLoginResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyLoginResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLoginResponseModel&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginResponseModel(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyLoginResponseModelCopyWith<$Res> {
|
||||
factory $LegacyLoginResponseModelCopyWith(LegacyLoginResponseModel value, $Res Function(LegacyLoginResponseModel) _then) = _$LegacyLoginResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String token, List<LegacyAvailableMethodModel> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyLoginResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacyLoginResponseModelCopyWith<$Res> {
|
||||
_$LegacyLoginResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyLoginResponseModel _self;
|
||||
final $Res Function(LegacyLoginResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyLoginResponseModel].
|
||||
extension LegacyLoginResponseModelPatterns on LegacyLoginResponseModel {
|
||||
/// 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( _LegacyLoginResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel() 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( _LegacyLoginResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel():
|
||||
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( _LegacyLoginResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel() 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 token, List<LegacyAvailableMethodModel> availableMethods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<LegacyAvailableMethodModel> availableMethods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel():
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<LegacyAvailableMethodModel> availableMethods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseModel() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyLoginResponseModel implements LegacyLoginResponseModel {
|
||||
const _LegacyLoginResponseModel({required this.token, final List<LegacyAvailableMethodModel> availableMethods = const <LegacyAvailableMethodModel>[]}): _availableMethods = availableMethods;
|
||||
factory _LegacyLoginResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyLoginResponseModelFromJson(json);
|
||||
|
||||
@override final String token;
|
||||
final List<LegacyAvailableMethodModel> _availableMethods;
|
||||
@override@JsonKey() List<LegacyAvailableMethodModel> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of LegacyLoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyLoginResponseModelCopyWith<_LegacyLoginResponseModel> get copyWith => __$LegacyLoginResponseModelCopyWithImpl<_LegacyLoginResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyLoginResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLoginResponseModel&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(_availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginResponseModel(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyLoginResponseModelCopyWith<$Res> implements $LegacyLoginResponseModelCopyWith<$Res> {
|
||||
factory _$LegacyLoginResponseModelCopyWith(_LegacyLoginResponseModel value, $Res Function(_LegacyLoginResponseModel) _then) = __$LegacyLoginResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String token, List<LegacyAvailableMethodModel> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyLoginResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacyLoginResponseModelCopyWith<$Res> {
|
||||
__$LegacyLoginResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyLoginResponseModel _self;
|
||||
final $Res Function(_LegacyLoginResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_LegacyLoginResponseModel(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyAvailableMethodModel {
|
||||
|
||||
String get id; String get userId; String get methodType; String get status; bool get isDefault; int get createdAt;
|
||||
/// Create a copy of LegacyAvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyAvailableMethodModelCopyWith<LegacyAvailableMethodModel> get copyWith => _$LegacyAvailableMethodModelCopyWithImpl<LegacyAvailableMethodModel>(this as LegacyAvailableMethodModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyAvailableMethodModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyAvailableMethodModel&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAvailableMethodModel(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyAvailableMethodModelCopyWith<$Res> {
|
||||
factory $LegacyAvailableMethodModelCopyWith(LegacyAvailableMethodModel value, $Res Function(LegacyAvailableMethodModel) _then) = _$LegacyAvailableMethodModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyAvailableMethodModelCopyWithImpl<$Res>
|
||||
implements $LegacyAvailableMethodModelCopyWith<$Res> {
|
||||
_$LegacyAvailableMethodModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyAvailableMethodModel _self;
|
||||
final $Res Function(LegacyAvailableMethodModel) _then;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyAvailableMethodModel].
|
||||
extension LegacyAvailableMethodModelPatterns on LegacyAvailableMethodModel {
|
||||
/// 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( _LegacyAvailableMethodModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel() 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( _LegacyAvailableMethodModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel():
|
||||
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( _LegacyAvailableMethodModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel():
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodModel() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyAvailableMethodModel implements LegacyAvailableMethodModel {
|
||||
const _LegacyAvailableMethodModel({required this.id, required this.userId, required this.methodType, required this.status, required this.isDefault, required this.createdAt});
|
||||
factory _LegacyAvailableMethodModel.fromJson(Map<String, dynamic> json) => _$LegacyAvailableMethodModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String userId;
|
||||
@override final String methodType;
|
||||
@override final String status;
|
||||
@override final bool isDefault;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyAvailableMethodModelCopyWith<_LegacyAvailableMethodModel> get copyWith => __$LegacyAvailableMethodModelCopyWithImpl<_LegacyAvailableMethodModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyAvailableMethodModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyAvailableMethodModel&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAvailableMethodModel(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyAvailableMethodModelCopyWith<$Res> implements $LegacyAvailableMethodModelCopyWith<$Res> {
|
||||
factory _$LegacyAvailableMethodModelCopyWith(_LegacyAvailableMethodModel value, $Res Function(_LegacyAvailableMethodModel) _then) = __$LegacyAvailableMethodModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyAvailableMethodModelCopyWithImpl<$Res>
|
||||
implements _$LegacyAvailableMethodModelCopyWith<$Res> {
|
||||
__$LegacyAvailableMethodModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyAvailableMethodModel _self;
|
||||
final $Res Function(_LegacyAvailableMethodModel) _then;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_LegacyAvailableMethodModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,50 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'login_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacyLoginResponseModel _$LegacyLoginResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacyLoginResponseModel(
|
||||
token: json['token'] as String,
|
||||
availableMethods:
|
||||
(json['availableMethods'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) =>
|
||||
LegacyAvailableMethodModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList() ??
|
||||
const <LegacyAvailableMethodModel>[],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyLoginResponseModelToJson(
|
||||
_LegacyLoginResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'token': instance.token,
|
||||
'availableMethods': instance.availableMethods,
|
||||
};
|
||||
|
||||
_LegacyAvailableMethodModel _$LegacyAvailableMethodModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacyAvailableMethodModel(
|
||||
id: json['id'] as String,
|
||||
userId: json['userId'] as String,
|
||||
methodType: json['methodType'] as String,
|
||||
status: json['status'] as String,
|
||||
isDefault: json['isDefault'] as bool,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyAvailableMethodModelToJson(
|
||||
_LegacyAvailableMethodModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'userId': instance.userId,
|
||||
'methodType': instance.methodType,
|
||||
'status': instance.status,
|
||||
'isDefault': instance.isDefault,
|
||||
'createdAt': instance.createdAt,
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'address_model.dart';
|
||||
|
||||
part 'sign_up_request_model.freezed.dart';
|
||||
part 'sign_up_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacySignUpRequestModel with _$LegacySignUpRequestModel {
|
||||
const factory LegacySignUpRequestModel({
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required String email,
|
||||
required String phone,
|
||||
required String language,
|
||||
required String password,
|
||||
required List<LegacyAddressModel> taxResidences,
|
||||
required List<LegacyAddressModel> addresses,
|
||||
required int bornAt,
|
||||
required String placeOfBirth,
|
||||
required String birthCountry,
|
||||
required String document,
|
||||
required String documentType,
|
||||
required String relationType,
|
||||
}) = _LegacySignUpRequestModel;
|
||||
|
||||
factory LegacySignUpRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacySignUpRequestModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacySignUpRequestModelMapper on LegacySignUpRequestEntity {
|
||||
LegacySignUpRequestModel toModel() => LegacySignUpRequestModel(
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
email: email,
|
||||
phone: phone,
|
||||
language: language,
|
||||
password: password,
|
||||
taxResidences: taxResidences
|
||||
.map((e) => e.toModel())
|
||||
.toList(growable: false),
|
||||
addresses: addresses.map((e) => e.toModel()).toList(growable: false),
|
||||
bornAt: bornAt,
|
||||
placeOfBirth: placeOfBirth,
|
||||
birthCountry: birthCountry,
|
||||
document: document,
|
||||
documentType: documentType,
|
||||
relationType: relationType,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'sign_up_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacySignUpRequestModel {
|
||||
|
||||
String get firstName; String get lastName; String get email; String get phone; String get language; String get password; List<LegacyAddressModel> get taxResidences; List<LegacyAddressModel> get addresses; int get bornAt; String get placeOfBirth; String get birthCountry; String get document; String get documentType; String get relationType;
|
||||
/// Create a copy of LegacySignUpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacySignUpRequestModelCopyWith<LegacySignUpRequestModel> get copyWith => _$LegacySignUpRequestModelCopyWithImpl<LegacySignUpRequestModel>(this as LegacySignUpRequestModel, _$identity);
|
||||
|
||||
/// Serializes this LegacySignUpRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacySignUpRequestModel&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language)&&(identical(other.password, password) || other.password == password)&&const DeepCollectionEquality().equals(other.taxResidences, taxResidences)&&const DeepCollectionEquality().equals(other.addresses, addresses)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.placeOfBirth, placeOfBirth) || other.placeOfBirth == placeOfBirth)&&(identical(other.birthCountry, birthCountry) || other.birthCountry == birthCountry)&&(identical(other.document, document) || other.document == document)&&(identical(other.documentType, documentType) || other.documentType == documentType)&&(identical(other.relationType, relationType) || other.relationType == relationType));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,email,phone,language,password,const DeepCollectionEquality().hash(taxResidences),const DeepCollectionEquality().hash(addresses),bornAt,placeOfBirth,birthCountry,document,documentType,relationType);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpRequestModel(firstName: $firstName, lastName: $lastName, email: $email, phone: $phone, language: $language, password: $password, taxResidences: $taxResidences, addresses: $addresses, bornAt: $bornAt, placeOfBirth: $placeOfBirth, birthCountry: $birthCountry, document: $document, documentType: $documentType, relationType: $relationType)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacySignUpRequestModelCopyWith<$Res> {
|
||||
factory $LegacySignUpRequestModelCopyWith(LegacySignUpRequestModel value, $Res Function(LegacySignUpRequestModel) _then) = _$LegacySignUpRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String firstName, String lastName, String email, String phone, String language, String password, List<LegacyAddressModel> taxResidences, List<LegacyAddressModel> addresses, int bornAt, String placeOfBirth, String birthCountry, String document, String documentType, String relationType
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacySignUpRequestModelCopyWithImpl<$Res>
|
||||
implements $LegacySignUpRequestModelCopyWith<$Res> {
|
||||
_$LegacySignUpRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacySignUpRequestModel _self;
|
||||
final $Res Function(LegacySignUpRequestModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? email = null,Object? phone = null,Object? language = null,Object? password = null,Object? taxResidences = null,Object? addresses = null,Object? bornAt = null,Object? placeOfBirth = null,Object? birthCountry = null,Object? document = null,Object? documentType = null,Object? relationType = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,taxResidences: null == taxResidences ? _self.taxResidences : taxResidences // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAddressModel>,addresses: null == addresses ? _self.addresses : addresses // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAddressModel>,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,placeOfBirth: null == placeOfBirth ? _self.placeOfBirth : placeOfBirth // ignore: cast_nullable_to_non_nullable
|
||||
as String,birthCountry: null == birthCountry ? _self.birthCountry : birthCountry // ignore: cast_nullable_to_non_nullable
|
||||
as String,document: null == document ? _self.document : document // ignore: cast_nullable_to_non_nullable
|
||||
as String,documentType: null == documentType ? _self.documentType : documentType // ignore: cast_nullable_to_non_nullable
|
||||
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacySignUpRequestModel].
|
||||
extension LegacySignUpRequestModelPatterns on LegacySignUpRequestModel {
|
||||
/// 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( _LegacySignUpRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel() 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( _LegacySignUpRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel():
|
||||
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( _LegacySignUpRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel() 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 firstName, String lastName, String email, String phone, String language, String password, List<LegacyAddressModel> taxResidences, List<LegacyAddressModel> addresses, int bornAt, String placeOfBirth, String birthCountry, String document, String documentType, String relationType)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel() when $default != null:
|
||||
return $default(_that.firstName,_that.lastName,_that.email,_that.phone,_that.language,_that.password,_that.taxResidences,_that.addresses,_that.bornAt,_that.placeOfBirth,_that.birthCountry,_that.document,_that.documentType,_that.relationType);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 firstName, String lastName, String email, String phone, String language, String password, List<LegacyAddressModel> taxResidences, List<LegacyAddressModel> addresses, int bornAt, String placeOfBirth, String birthCountry, String document, String documentType, String relationType) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel():
|
||||
return $default(_that.firstName,_that.lastName,_that.email,_that.phone,_that.language,_that.password,_that.taxResidences,_that.addresses,_that.bornAt,_that.placeOfBirth,_that.birthCountry,_that.document,_that.documentType,_that.relationType);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 firstName, String lastName, String email, String phone, String language, String password, List<LegacyAddressModel> taxResidences, List<LegacyAddressModel> addresses, int bornAt, String placeOfBirth, String birthCountry, String document, String documentType, String relationType)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpRequestModel() when $default != null:
|
||||
return $default(_that.firstName,_that.lastName,_that.email,_that.phone,_that.language,_that.password,_that.taxResidences,_that.addresses,_that.bornAt,_that.placeOfBirth,_that.birthCountry,_that.document,_that.documentType,_that.relationType);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacySignUpRequestModel implements LegacySignUpRequestModel {
|
||||
const _LegacySignUpRequestModel({required this.firstName, required this.lastName, required this.email, required this.phone, required this.language, required this.password, required final List<LegacyAddressModel> taxResidences, required final List<LegacyAddressModel> addresses, required this.bornAt, required this.placeOfBirth, required this.birthCountry, required this.document, required this.documentType, required this.relationType}): _taxResidences = taxResidences,_addresses = addresses;
|
||||
factory _LegacySignUpRequestModel.fromJson(Map<String, dynamic> json) => _$LegacySignUpRequestModelFromJson(json);
|
||||
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final String email;
|
||||
@override final String phone;
|
||||
@override final String language;
|
||||
@override final String password;
|
||||
final List<LegacyAddressModel> _taxResidences;
|
||||
@override List<LegacyAddressModel> get taxResidences {
|
||||
if (_taxResidences is EqualUnmodifiableListView) return _taxResidences;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_taxResidences);
|
||||
}
|
||||
|
||||
final List<LegacyAddressModel> _addresses;
|
||||
@override List<LegacyAddressModel> get addresses {
|
||||
if (_addresses is EqualUnmodifiableListView) return _addresses;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_addresses);
|
||||
}
|
||||
|
||||
@override final int bornAt;
|
||||
@override final String placeOfBirth;
|
||||
@override final String birthCountry;
|
||||
@override final String document;
|
||||
@override final String documentType;
|
||||
@override final String relationType;
|
||||
|
||||
/// Create a copy of LegacySignUpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacySignUpRequestModelCopyWith<_LegacySignUpRequestModel> get copyWith => __$LegacySignUpRequestModelCopyWithImpl<_LegacySignUpRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacySignUpRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacySignUpRequestModel&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language)&&(identical(other.password, password) || other.password == password)&&const DeepCollectionEquality().equals(other._taxResidences, _taxResidences)&&const DeepCollectionEquality().equals(other._addresses, _addresses)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.placeOfBirth, placeOfBirth) || other.placeOfBirth == placeOfBirth)&&(identical(other.birthCountry, birthCountry) || other.birthCountry == birthCountry)&&(identical(other.document, document) || other.document == document)&&(identical(other.documentType, documentType) || other.documentType == documentType)&&(identical(other.relationType, relationType) || other.relationType == relationType));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,email,phone,language,password,const DeepCollectionEquality().hash(_taxResidences),const DeepCollectionEquality().hash(_addresses),bornAt,placeOfBirth,birthCountry,document,documentType,relationType);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpRequestModel(firstName: $firstName, lastName: $lastName, email: $email, phone: $phone, language: $language, password: $password, taxResidences: $taxResidences, addresses: $addresses, bornAt: $bornAt, placeOfBirth: $placeOfBirth, birthCountry: $birthCountry, document: $document, documentType: $documentType, relationType: $relationType)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacySignUpRequestModelCopyWith<$Res> implements $LegacySignUpRequestModelCopyWith<$Res> {
|
||||
factory _$LegacySignUpRequestModelCopyWith(_LegacySignUpRequestModel value, $Res Function(_LegacySignUpRequestModel) _then) = __$LegacySignUpRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String firstName, String lastName, String email, String phone, String language, String password, List<LegacyAddressModel> taxResidences, List<LegacyAddressModel> addresses, int bornAt, String placeOfBirth, String birthCountry, String document, String documentType, String relationType
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacySignUpRequestModelCopyWithImpl<$Res>
|
||||
implements _$LegacySignUpRequestModelCopyWith<$Res> {
|
||||
__$LegacySignUpRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacySignUpRequestModel _self;
|
||||
final $Res Function(_LegacySignUpRequestModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? email = null,Object? phone = null,Object? language = null,Object? password = null,Object? taxResidences = null,Object? addresses = null,Object? bornAt = null,Object? placeOfBirth = null,Object? birthCountry = null,Object? document = null,Object? documentType = null,Object? relationType = null,}) {
|
||||
return _then(_LegacySignUpRequestModel(
|
||||
firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,taxResidences: null == taxResidences ? _self._taxResidences : taxResidences // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAddressModel>,addresses: null == addresses ? _self._addresses : addresses // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAddressModel>,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,placeOfBirth: null == placeOfBirth ? _self.placeOfBirth : placeOfBirth // ignore: cast_nullable_to_non_nullable
|
||||
as String,birthCountry: null == birthCountry ? _self.birthCountry : birthCountry // ignore: cast_nullable_to_non_nullable
|
||||
as String,document: null == document ? _self.document : document // ignore: cast_nullable_to_non_nullable
|
||||
as String,documentType: null == documentType ? _self.documentType : documentType // ignore: cast_nullable_to_non_nullable
|
||||
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,49 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sign_up_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacySignUpRequestModel _$LegacySignUpRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacySignUpRequestModel(
|
||||
firstName: json['firstName'] as String,
|
||||
lastName: json['lastName'] as String,
|
||||
email: json['email'] as String,
|
||||
phone: json['phone'] as String,
|
||||
language: json['language'] as String,
|
||||
password: json['password'] as String,
|
||||
taxResidences: (json['taxResidences'] as List<dynamic>)
|
||||
.map((e) => LegacyAddressModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
addresses: (json['addresses'] as List<dynamic>)
|
||||
.map((e) => LegacyAddressModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
bornAt: (json['bornAt'] as num).toInt(),
|
||||
placeOfBirth: json['placeOfBirth'] as String,
|
||||
birthCountry: json['birthCountry'] as String,
|
||||
document: json['document'] as String,
|
||||
documentType: json['documentType'] as String,
|
||||
relationType: json['relationType'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacySignUpRequestModelToJson(
|
||||
_LegacySignUpRequestModel instance,
|
||||
) => <String, dynamic>{
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'email': instance.email,
|
||||
'phone': instance.phone,
|
||||
'language': instance.language,
|
||||
'password': instance.password,
|
||||
'taxResidences': instance.taxResidences,
|
||||
'addresses': instance.addresses,
|
||||
'bornAt': instance.bornAt,
|
||||
'placeOfBirth': instance.placeOfBirth,
|
||||
'birthCountry': instance.birthCountry,
|
||||
'document': instance.document,
|
||||
'documentType': instance.documentType,
|
||||
'relationType': instance.relationType,
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'sign_up_response_model.freezed.dart';
|
||||
part 'sign_up_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacySignUpResponseModel with _$LegacySignUpResponseModel {
|
||||
const factory LegacySignUpResponseModel({
|
||||
required bool isCreated,
|
||||
required LegacySignUpResponseItemModel item,
|
||||
}) = _LegacySignUpResponseModel;
|
||||
|
||||
factory LegacySignUpResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacySignUpResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacySignUpResponseItemModel with _$LegacySignUpResponseItemModel {
|
||||
const factory LegacySignUpResponseItemModel({required String userId}) =
|
||||
_LegacySignUpResponseItemModel;
|
||||
|
||||
factory LegacySignUpResponseItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacySignUpResponseItemModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacySignUpResponseModelMapper on LegacySignUpResponseModel {
|
||||
LegacySignUpResponseEntity toEntity() =>
|
||||
LegacySignUpResponseEntity(isCreated: isCreated, userId: item.userId);
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
// 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 'sign_up_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacySignUpResponseModel {
|
||||
|
||||
bool get isCreated; LegacySignUpResponseItemModel get item;
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacySignUpResponseModelCopyWith<LegacySignUpResponseModel> get copyWith => _$LegacySignUpResponseModelCopyWithImpl<LegacySignUpResponseModel>(this as LegacySignUpResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacySignUpResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacySignUpResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacySignUpResponseModelCopyWith<$Res> {
|
||||
factory $LegacySignUpResponseModelCopyWith(LegacySignUpResponseModel value, $Res Function(LegacySignUpResponseModel) _then) = _$LegacySignUpResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacySignUpResponseItemModel item
|
||||
});
|
||||
|
||||
|
||||
$LegacySignUpResponseItemModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacySignUpResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacySignUpResponseModelCopyWith<$Res> {
|
||||
_$LegacySignUpResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacySignUpResponseModel _self;
|
||||
final $Res Function(LegacySignUpResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacySignUpResponseItemModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacySignUpResponseItemModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacySignUpResponseModel].
|
||||
extension LegacySignUpResponseModelPatterns on LegacySignUpResponseModel {
|
||||
/// 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( _LegacySignUpResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel() 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( _LegacySignUpResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel():
|
||||
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( _LegacySignUpResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel() 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 isCreated, LegacySignUpResponseItemModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacySignUpResponseItemModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel():
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacySignUpResponseItemModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacySignUpResponseModel implements LegacySignUpResponseModel {
|
||||
const _LegacySignUpResponseModel({required this.isCreated, required this.item});
|
||||
factory _LegacySignUpResponseModel.fromJson(Map<String, dynamic> json) => _$LegacySignUpResponseModelFromJson(json);
|
||||
|
||||
@override final bool isCreated;
|
||||
@override final LegacySignUpResponseItemModel item;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacySignUpResponseModelCopyWith<_LegacySignUpResponseModel> get copyWith => __$LegacySignUpResponseModelCopyWithImpl<_LegacySignUpResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacySignUpResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacySignUpResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacySignUpResponseModelCopyWith<$Res> implements $LegacySignUpResponseModelCopyWith<$Res> {
|
||||
factory _$LegacySignUpResponseModelCopyWith(_LegacySignUpResponseModel value, $Res Function(_LegacySignUpResponseModel) _then) = __$LegacySignUpResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacySignUpResponseItemModel item
|
||||
});
|
||||
|
||||
|
||||
@override $LegacySignUpResponseItemModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacySignUpResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacySignUpResponseModelCopyWith<$Res> {
|
||||
__$LegacySignUpResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacySignUpResponseModel _self;
|
||||
final $Res Function(_LegacySignUpResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_LegacySignUpResponseModel(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacySignUpResponseItemModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LegacySignUpResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacySignUpResponseItemModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacySignUpResponseItemModel {
|
||||
|
||||
String get userId;
|
||||
/// Create a copy of LegacySignUpResponseItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacySignUpResponseItemModelCopyWith<LegacySignUpResponseItemModel> get copyWith => _$LegacySignUpResponseItemModelCopyWithImpl<LegacySignUpResponseItemModel>(this as LegacySignUpResponseItemModel, _$identity);
|
||||
|
||||
/// Serializes this LegacySignUpResponseItemModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,userId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpResponseItemModel(userId: $userId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacySignUpResponseItemModelCopyWith<$Res> {
|
||||
factory $LegacySignUpResponseItemModelCopyWith(LegacySignUpResponseItemModel value, $Res Function(LegacySignUpResponseItemModel) _then) = _$LegacySignUpResponseItemModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String userId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacySignUpResponseItemModelCopyWithImpl<$Res>
|
||||
implements $LegacySignUpResponseItemModelCopyWith<$Res> {
|
||||
_$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacySignUpResponseItemModel _self;
|
||||
final $Res Function(LegacySignUpResponseItemModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? userId = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacySignUpResponseItemModel].
|
||||
extension LegacySignUpResponseItemModelPatterns on LegacySignUpResponseItemModel {
|
||||
/// 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( _LegacySignUpResponseItemModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel() 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( _LegacySignUpResponseItemModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel():
|
||||
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( _LegacySignUpResponseItemModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel() 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 userId)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel() when $default != null:
|
||||
return $default(_that.userId);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 userId) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel():
|
||||
return $default(_that.userId);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 userId)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacySignUpResponseItemModel() when $default != null:
|
||||
return $default(_that.userId);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacySignUpResponseItemModel implements LegacySignUpResponseItemModel {
|
||||
const _LegacySignUpResponseItemModel({required this.userId});
|
||||
factory _LegacySignUpResponseItemModel.fromJson(Map<String, dynamic> json) => _$LegacySignUpResponseItemModelFromJson(json);
|
||||
|
||||
@override final String userId;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacySignUpResponseItemModelCopyWith<_LegacySignUpResponseItemModel> get copyWith => __$LegacySignUpResponseItemModelCopyWithImpl<_LegacySignUpResponseItemModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacySignUpResponseItemModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,userId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacySignUpResponseItemModel(userId: $userId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacySignUpResponseItemModelCopyWith<$Res> implements $LegacySignUpResponseItemModelCopyWith<$Res> {
|
||||
factory _$LegacySignUpResponseItemModelCopyWith(_LegacySignUpResponseItemModel value, $Res Function(_LegacySignUpResponseItemModel) _then) = __$LegacySignUpResponseItemModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String userId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacySignUpResponseItemModelCopyWithImpl<$Res>
|
||||
implements _$LegacySignUpResponseItemModelCopyWith<$Res> {
|
||||
__$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacySignUpResponseItemModel _self;
|
||||
final $Res Function(_LegacySignUpResponseItemModel) _then;
|
||||
|
||||
/// Create a copy of LegacySignUpResponseItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? userId = null,}) {
|
||||
return _then(_LegacySignUpResponseItemModel(
|
||||
userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,28 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sign_up_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacySignUpResponseModel _$LegacySignUpResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacySignUpResponseModel(
|
||||
isCreated: json['isCreated'] as bool,
|
||||
item: LegacySignUpResponseItemModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacySignUpResponseModelToJson(
|
||||
_LegacySignUpResponseModel instance,
|
||||
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
|
||||
|
||||
_LegacySignUpResponseItemModel _$LegacySignUpResponseItemModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacySignUpResponseItemModel(userId: json['userId'] as String);
|
||||
|
||||
Map<String, dynamic> _$LegacySignUpResponseItemModelToJson(
|
||||
_LegacySignUpResponseItemModel instance,
|
||||
) => <String, dynamic>{'userId': instance.userId};
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/two_fa_secret_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'two_fa_secret_response_model.freezed.dart';
|
||||
part 'two_fa_secret_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyTwoFASecretResponseModel with _$LegacyTwoFASecretResponseModel {
|
||||
const factory LegacyTwoFASecretResponseModel({
|
||||
required bool isCreated,
|
||||
required LegacyTwoFASecretItemResponseModel item,
|
||||
}) = _LegacyTwoFASecretResponseModel;
|
||||
|
||||
factory LegacyTwoFASecretResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyTwoFASecretResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacyTwoFASecretItemResponseModel
|
||||
with _$LegacyTwoFASecretItemResponseModel {
|
||||
const factory LegacyTwoFASecretItemResponseModel({
|
||||
required String secret,
|
||||
required String qr,
|
||||
}) = _LegacyTwoFASecretItemResponseModel;
|
||||
|
||||
factory LegacyTwoFASecretItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LegacyTwoFASecretItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LegacyTwoFASecretResponseModelMapper on LegacyTwoFASecretResponseModel {
|
||||
LegacyTwoFASecretEntity toEntity() {
|
||||
return LegacyTwoFASecretEntity(
|
||||
isCreated: isCreated,
|
||||
item: LegacyTwoFASecretItemEntity(secret: item.secret, qr: item.qr),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
// 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 'two_fa_secret_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyTwoFASecretResponseModel {
|
||||
|
||||
bool get isCreated; LegacyTwoFASecretItemResponseModel get item;
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyTwoFASecretResponseModelCopyWith<LegacyTwoFASecretResponseModel> get copyWith => _$LegacyTwoFASecretResponseModelCopyWithImpl<LegacyTwoFASecretResponseModel>(this as LegacyTwoFASecretResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyTwoFASecretResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyTwoFASecretResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyTwoFASecretResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyTwoFASecretResponseModelCopyWith<$Res> {
|
||||
factory $LegacyTwoFASecretResponseModelCopyWith(LegacyTwoFASecretResponseModel value, $Res Function(LegacyTwoFASecretResponseModel) _then) = _$LegacyTwoFASecretResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyTwoFASecretItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
$LegacyTwoFASecretItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyTwoFASecretResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacyTwoFASecretResponseModelCopyWith<$Res> {
|
||||
_$LegacyTwoFASecretResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyTwoFASecretResponseModel _self;
|
||||
final $Res Function(LegacyTwoFASecretResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyTwoFASecretItemResponseModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyTwoFASecretItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyTwoFASecretItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyTwoFASecretResponseModel].
|
||||
extension LegacyTwoFASecretResponseModelPatterns on LegacyTwoFASecretResponseModel {
|
||||
/// 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( _LegacyTwoFASecretResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel() 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( _LegacyTwoFASecretResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel():
|
||||
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( _LegacyTwoFASecretResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel() 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 isCreated, LegacyTwoFASecretItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyTwoFASecretItemResponseModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel():
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyTwoFASecretItemResponseModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretResponseModel() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyTwoFASecretResponseModel implements LegacyTwoFASecretResponseModel {
|
||||
const _LegacyTwoFASecretResponseModel({required this.isCreated, required this.item});
|
||||
factory _LegacyTwoFASecretResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyTwoFASecretResponseModelFromJson(json);
|
||||
|
||||
@override final bool isCreated;
|
||||
@override final LegacyTwoFASecretItemResponseModel item;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyTwoFASecretResponseModelCopyWith<_LegacyTwoFASecretResponseModel> get copyWith => __$LegacyTwoFASecretResponseModelCopyWithImpl<_LegacyTwoFASecretResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyTwoFASecretResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyTwoFASecretResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyTwoFASecretResponseModel(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyTwoFASecretResponseModelCopyWith<$Res> implements $LegacyTwoFASecretResponseModelCopyWith<$Res> {
|
||||
factory _$LegacyTwoFASecretResponseModelCopyWith(_LegacyTwoFASecretResponseModel value, $Res Function(_LegacyTwoFASecretResponseModel) _then) = __$LegacyTwoFASecretResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyTwoFASecretItemResponseModel item
|
||||
});
|
||||
|
||||
|
||||
@override $LegacyTwoFASecretItemResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyTwoFASecretResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacyTwoFASecretResponseModelCopyWith<$Res> {
|
||||
__$LegacyTwoFASecretResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyTwoFASecretResponseModel _self;
|
||||
final $Res Function(_LegacyTwoFASecretResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_LegacyTwoFASecretResponseModel(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyTwoFASecretItemResponseModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyTwoFASecretItemResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyTwoFASecretItemResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyTwoFASecretItemResponseModel {
|
||||
|
||||
String get secret; String get qr;
|
||||
/// Create a copy of LegacyTwoFASecretItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyTwoFASecretItemResponseModelCopyWith<LegacyTwoFASecretItemResponseModel> get copyWith => _$LegacyTwoFASecretItemResponseModelCopyWithImpl<LegacyTwoFASecretItemResponseModel>(this as LegacyTwoFASecretItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LegacyTwoFASecretItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyTwoFASecretItemResponseModel&&(identical(other.secret, secret) || other.secret == secret)&&(identical(other.qr, qr) || other.qr == qr));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,secret,qr);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyTwoFASecretItemResponseModel(secret: $secret, qr: $qr)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyTwoFASecretItemResponseModelCopyWith<$Res> {
|
||||
factory $LegacyTwoFASecretItemResponseModelCopyWith(LegacyTwoFASecretItemResponseModel value, $Res Function(LegacyTwoFASecretItemResponseModel) _then) = _$LegacyTwoFASecretItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String secret, String qr
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyTwoFASecretItemResponseModelCopyWithImpl<$Res>
|
||||
implements $LegacyTwoFASecretItemResponseModelCopyWith<$Res> {
|
||||
_$LegacyTwoFASecretItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyTwoFASecretItemResponseModel _self;
|
||||
final $Res Function(LegacyTwoFASecretItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? secret = null,Object? qr = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
secret: null == secret ? _self.secret : secret // ignore: cast_nullable_to_non_nullable
|
||||
as String,qr: null == qr ? _self.qr : qr // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyTwoFASecretItemResponseModel].
|
||||
extension LegacyTwoFASecretItemResponseModelPatterns on LegacyTwoFASecretItemResponseModel {
|
||||
/// 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( _LegacyTwoFASecretItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel() 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( _LegacyTwoFASecretItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel():
|
||||
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( _LegacyTwoFASecretItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel() 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 secret, String qr)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel() when $default != null:
|
||||
return $default(_that.secret,_that.qr);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 secret, String qr) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel():
|
||||
return $default(_that.secret,_that.qr);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 secret, String qr)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyTwoFASecretItemResponseModel() when $default != null:
|
||||
return $default(_that.secret,_that.qr);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LegacyTwoFASecretItemResponseModel implements LegacyTwoFASecretItemResponseModel {
|
||||
const _LegacyTwoFASecretItemResponseModel({required this.secret, required this.qr});
|
||||
factory _LegacyTwoFASecretItemResponseModel.fromJson(Map<String, dynamic> json) => _$LegacyTwoFASecretItemResponseModelFromJson(json);
|
||||
|
||||
@override final String secret;
|
||||
@override final String qr;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyTwoFASecretItemResponseModelCopyWith<_LegacyTwoFASecretItemResponseModel> get copyWith => __$LegacyTwoFASecretItemResponseModelCopyWithImpl<_LegacyTwoFASecretItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LegacyTwoFASecretItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyTwoFASecretItemResponseModel&&(identical(other.secret, secret) || other.secret == secret)&&(identical(other.qr, qr) || other.qr == qr));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,secret,qr);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyTwoFASecretItemResponseModel(secret: $secret, qr: $qr)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyTwoFASecretItemResponseModelCopyWith<$Res> implements $LegacyTwoFASecretItemResponseModelCopyWith<$Res> {
|
||||
factory _$LegacyTwoFASecretItemResponseModelCopyWith(_LegacyTwoFASecretItemResponseModel value, $Res Function(_LegacyTwoFASecretItemResponseModel) _then) = __$LegacyTwoFASecretItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String secret, String qr
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyTwoFASecretItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$LegacyTwoFASecretItemResponseModelCopyWith<$Res> {
|
||||
__$LegacyTwoFASecretItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyTwoFASecretItemResponseModel _self;
|
||||
final $Res Function(_LegacyTwoFASecretItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of LegacyTwoFASecretItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? secret = null,Object? qr = null,}) {
|
||||
return _then(_LegacyTwoFASecretItemResponseModel(
|
||||
secret: null == secret ? _self.secret : secret // ignore: cast_nullable_to_non_nullable
|
||||
as String,qr: null == qr ? _self.qr : qr // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,31 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'two_fa_secret_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LegacyTwoFASecretResponseModel _$LegacyTwoFASecretResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _LegacyTwoFASecretResponseModel(
|
||||
isCreated: json['isCreated'] as bool,
|
||||
item: LegacyTwoFASecretItemResponseModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyTwoFASecretResponseModelToJson(
|
||||
_LegacyTwoFASecretResponseModel instance,
|
||||
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
|
||||
|
||||
_LegacyTwoFASecretItemResponseModel
|
||||
_$LegacyTwoFASecretItemResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_LegacyTwoFASecretItemResponseModel(
|
||||
secret: json['secret'] as String,
|
||||
qr: json['qr'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LegacyTwoFASecretItemResponseModelToJson(
|
||||
_LegacyTwoFASecretItemResponseModel instance,
|
||||
) => <String, dynamic>{'secret': instance.secret, 'qr': instance.qr};
|
||||
@@ -0,0 +1,160 @@
|
||||
import 'package:legacy_auth/src/core/data/datasource/auth_remote_datasource.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
|
||||
import 'package:legacy_auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
class LegacyAuthRepositoryImpl implements LegacyAuthRepository {
|
||||
const LegacyAuthRepositoryImpl(this._remote);
|
||||
|
||||
final LegacyAuthRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<void> requestPhoneCode({required String phone}) {
|
||||
return _remote.requestPhoneCode(phone: phone);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> verifyPhoneCode({required String phone, required String code}) {
|
||||
return _remote.verifyPhoneCode(phone: phone, code: code);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyLoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
final responseModel = await _remote.login(email: email, password: password);
|
||||
|
||||
return LegacyLoginResponseModelMapper(responseModel).toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _remote.twoFARequestCode(token: token, methodType: methodType);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _remote.twoFASendCode(
|
||||
token: token,
|
||||
code: code,
|
||||
methodType: methodType,
|
||||
);
|
||||
}
|
||||
|
||||
// @override
|
||||
// Future<String> totpLogin({required String token, required String code}) {
|
||||
// return _remote.totpLogin(token: token, code: code);
|
||||
// }
|
||||
|
||||
@override
|
||||
Future<LegacySignUpResponseEntity> signUp({
|
||||
required LegacySignUpRequestEntity request,
|
||||
}) async {
|
||||
final model = request.toModel();
|
||||
final responseModel = await _remote.signUp(request: model);
|
||||
return responseModel.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({
|
||||
required String token,
|
||||
}) {
|
||||
return _remote.generateTwoFASignUp(token: token);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
}) {
|
||||
return _remote.verifyTwoFACodeSignUp(token: token, code: code);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> requestPasswordReset({required String email}) {
|
||||
return _remote.requestPasswordReset(email: email);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> recoverPassword({
|
||||
required String newPassword,
|
||||
required String token,
|
||||
}) {
|
||||
return _remote.recoverPassword(newPassword: newPassword, token: token);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> logout() {
|
||||
return _remote.logout();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LegacyChildProfileEntity> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
final model = await _remote.createChildProfile(
|
||||
id: id,
|
||||
parentId: parentId,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
bornAt: bornAt,
|
||||
genrer: genrer,
|
||||
relationType: relationType,
|
||||
address: address,
|
||||
cardPublicKey: cardPublicKey,
|
||||
deviceActivationCode: deviceActivationCode,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
|
||||
if (!model.isCreated) {
|
||||
throw Exception('Child profile creation failed: isCreated=false');
|
||||
}
|
||||
|
||||
return model.toEntity();
|
||||
}
|
||||
}
|
||||
|
||||
extension LegacyLoginResponseModelMapper on LegacyLoginResponseModel {
|
||||
LegacyLoginResponseEntity toEntity() {
|
||||
return LegacyLoginResponseEntity(
|
||||
token: token,
|
||||
availableMethods: availableMethods
|
||||
.map(
|
||||
(m) => LegacyAvailableMethodEntity(
|
||||
id: m.id,
|
||||
userId: m.userId,
|
||||
methodType: m.methodType,
|
||||
status: m.status,
|
||||
isDefault: m.isDefault,
|
||||
createdAt: m.createdAt,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
|
||||
|
||||
abstract class LegacyAuthRepository {
|
||||
Future<void> requestPhoneCode({required String phone});
|
||||
|
||||
Future<void> verifyPhoneCode({required String phone, required String code});
|
||||
|
||||
Future<LegacyLoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
|
||||
Future<LegacySignUpResponseEntity> signUp({required LegacySignUpRequestEntity request});
|
||||
|
||||
Future<LegacyTwoFASecretResponseModel> generateTwoFASignUp({required String token});
|
||||
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
});
|
||||
|
||||
Future<String> requestPasswordReset({required String email});
|
||||
|
||||
Future<void> recoverPassword({
|
||||
required String newPassword,
|
||||
required String token,
|
||||
});
|
||||
|
||||
Future<void> logout();
|
||||
|
||||
Future<LegacyChildProfileEntity> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:legacy_auth/src/core/data/datasource/auth_remote_datasource.dart';
|
||||
import 'package:legacy_auth/src/core/data/datasource/auth_remote_datasource_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
final legacyAuthRemoteDatasourceProvider = Provider<LegacyAuthRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return LegacyAuthRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:legacy_auth/src/core/data/repositories/auth_repository_impl.dart';
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/core/providers/auth_remote_datasource_provider.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyAuthRepositoryProvider = Provider<LegacyAuthRepository>((ref) {
|
||||
final remote = ref.read(legacyAuthRemoteDatasourceProvider);
|
||||
return LegacyAuthRepositoryImpl(remote);
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:legacy_auth/src/core/data/datasource/session_local_datasource.dart';
|
||||
import 'package:legacy_auth/src/core/data/datasource/session_local_datasource_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacySessionLocalDatasourceProvider = Provider<LegacySessionLocalDatasource>((ref) {
|
||||
return LegacySessionLocalDatasourceImpl();
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/device_setup_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class LegacyDeviceSetupBuilder {
|
||||
const LegacyDeviceSetupBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: LegacyDeviceSetupScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
|
||||
|
||||
abstract class LegacyCreateChildProfileUseCase {
|
||||
Future<LegacyChildProfileEntity> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart';
|
||||
|
||||
class LegacyCreateChildProfileUseCaseImpl implements LegacyCreateChildProfileUseCase {
|
||||
LegacyCreateChildProfileUseCaseImpl(this._repository);
|
||||
|
||||
final LegacyAuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<LegacyChildProfileEntity> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String genrer,
|
||||
required String relationType,
|
||||
required String address,
|
||||
required String cardPublicKey,
|
||||
required String deviceActivationCode,
|
||||
required String scaProof,
|
||||
}) {
|
||||
return _repository.createChildProfile(
|
||||
id: id,
|
||||
parentId: parentId,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
bornAt: bornAt,
|
||||
genrer: genrer,
|
||||
relationType: relationType,
|
||||
address: address,
|
||||
cardPublicKey: cardPublicKey,
|
||||
deviceActivationCode: deviceActivationCode,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'child_profile_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyChildProfileEntity with _$LegacyChildProfileEntity {
|
||||
const factory LegacyChildProfileEntity({
|
||||
required bool isCreated,
|
||||
required LegacyChildProfileItemEntity item,
|
||||
}) = _LegacyChildProfileEntity;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacyChildProfileItemEntity with _$LegacyChildProfileItemEntity {
|
||||
const factory LegacyChildProfileItemEntity({
|
||||
required String id,
|
||||
required String deviceIdentificator,
|
||||
required String parentId,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required int bornAt,
|
||||
required String address,
|
||||
required int createdAt,
|
||||
int? updatedAt,
|
||||
String? profileImageId,
|
||||
}) = _LegacyChildProfileItemEntity;
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
// 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 'child_profile_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyChildProfileEntity {
|
||||
|
||||
bool get isCreated; LegacyChildProfileItemEntity get item;
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileEntityCopyWith<LegacyChildProfileEntity> get copyWith => _$LegacyChildProfileEntityCopyWithImpl<LegacyChildProfileEntity>(this as LegacyChildProfileEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyChildProfileEntityCopyWith<$Res> {
|
||||
factory $LegacyChildProfileEntityCopyWith(LegacyChildProfileEntity value, $Res Function(LegacyChildProfileEntity) _then) = _$LegacyChildProfileEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyChildProfileItemEntity item
|
||||
});
|
||||
|
||||
|
||||
$LegacyChildProfileItemEntityCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyChildProfileEntityCopyWithImpl<$Res>
|
||||
implements $LegacyChildProfileEntityCopyWith<$Res> {
|
||||
_$LegacyChildProfileEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyChildProfileEntity _self;
|
||||
final $Res Function(LegacyChildProfileEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyChildProfileItemEntity,
|
||||
));
|
||||
}
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemEntityCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyChildProfileEntity].
|
||||
extension LegacyChildProfileEntityPatterns on LegacyChildProfileEntity {
|
||||
/// 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( _LegacyChildProfileEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity() 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( _LegacyChildProfileEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity():
|
||||
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( _LegacyChildProfileEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity() 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 isCreated, LegacyChildProfileItemEntity item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, LegacyChildProfileItemEntity item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity():
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, LegacyChildProfileItemEntity item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileEntity() when $default != null:
|
||||
return $default(_that.isCreated,_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyChildProfileEntity implements LegacyChildProfileEntity {
|
||||
const _LegacyChildProfileEntity({required this.isCreated, required this.item});
|
||||
|
||||
|
||||
@override final bool isCreated;
|
||||
@override final LegacyChildProfileItemEntity item;
|
||||
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyChildProfileEntityCopyWith<_LegacyChildProfileEntity> get copyWith => __$LegacyChildProfileEntityCopyWithImpl<_LegacyChildProfileEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isCreated,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyChildProfileEntityCopyWith<$Res> implements $LegacyChildProfileEntityCopyWith<$Res> {
|
||||
factory _$LegacyChildProfileEntityCopyWith(_LegacyChildProfileEntity value, $Res Function(_LegacyChildProfileEntity) _then) = __$LegacyChildProfileEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isCreated, LegacyChildProfileItemEntity item
|
||||
});
|
||||
|
||||
|
||||
@override $LegacyChildProfileItemEntityCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyChildProfileEntityCopyWithImpl<$Res>
|
||||
implements _$LegacyChildProfileEntityCopyWith<$Res> {
|
||||
__$LegacyChildProfileEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyChildProfileEntity _self;
|
||||
final $Res Function(_LegacyChildProfileEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
|
||||
return _then(_LegacyChildProfileEntity(
|
||||
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
|
||||
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyChildProfileItemEntity,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of LegacyChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemEntityCopyWith<$Res> get item {
|
||||
|
||||
return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyChildProfileItemEntity {
|
||||
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId;
|
||||
/// Create a copy of LegacyChildProfileItemEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyChildProfileItemEntityCopyWith<LegacyChildProfileItemEntity> get copyWith => _$LegacyChildProfileItemEntityCopyWithImpl<LegacyChildProfileItemEntity>(this as LegacyChildProfileItemEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyChildProfileItemEntityCopyWith<$Res> {
|
||||
factory $LegacyChildProfileItemEntityCopyWith(LegacyChildProfileItemEntity value, $Res Function(LegacyChildProfileItemEntity) _then) = _$LegacyChildProfileItemEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyChildProfileItemEntityCopyWithImpl<$Res>
|
||||
implements $LegacyChildProfileItemEntityCopyWith<$Res> {
|
||||
_$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyChildProfileItemEntity _self;
|
||||
final $Res Function(LegacyChildProfileItemEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyChildProfileItemEntity].
|
||||
extension LegacyChildProfileItemEntityPatterns on LegacyChildProfileItemEntity {
|
||||
/// 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( _LegacyChildProfileItemEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity() 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( _LegacyChildProfileItemEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity():
|
||||
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( _LegacyChildProfileItemEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyChildProfileItemEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyChildProfileItemEntity implements LegacyChildProfileItemEntity {
|
||||
const _LegacyChildProfileItemEntity({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String deviceIdentificator;
|
||||
@override final String parentId;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final int bornAt;
|
||||
@override final String address;
|
||||
@override final int createdAt;
|
||||
@override final int? updatedAt;
|
||||
@override final String? profileImageId;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyChildProfileItemEntityCopyWith<_LegacyChildProfileItemEntity> get copyWith => __$LegacyChildProfileItemEntityCopyWithImpl<_LegacyChildProfileItemEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyChildProfileItemEntityCopyWith<$Res> implements $LegacyChildProfileItemEntityCopyWith<$Res> {
|
||||
factory _$LegacyChildProfileItemEntityCopyWith(_LegacyChildProfileItemEntity value, $Res Function(_LegacyChildProfileItemEntity) _then) = __$LegacyChildProfileItemEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyChildProfileItemEntityCopyWithImpl<$Res>
|
||||
implements _$LegacyChildProfileItemEntityCopyWith<$Res> {
|
||||
__$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyChildProfileItemEntity _self;
|
||||
final $Res Function(_LegacyChildProfileItemEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyChildProfileItemEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) {
|
||||
return _then(_LegacyChildProfileItemEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
|
||||
|
||||
extension LegacyAddKidStepMapper on LegacyAddKidStep {
|
||||
LegacyAddKidMainStep get mainStep {
|
||||
switch (this) {
|
||||
case LegacyAddKidStep.linkInfo:
|
||||
case LegacyAddKidStep.scanStrap:
|
||||
case LegacyAddKidStep.scanWatch:
|
||||
return LegacyAddKidMainStep.linkDevice;
|
||||
case LegacyAddKidStep.profile:
|
||||
return LegacyAddKidMainStep.profile;
|
||||
case LegacyAddKidStep.allowance:
|
||||
return LegacyAddKidMainStep.allowance;
|
||||
case LegacyAddKidStep.intro:
|
||||
return LegacyAddKidMainStep.linkDevice;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class LegacyContactScreen extends ConsumerWidget {
|
||||
const LegacyContactScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: Container(
|
||||
margin: EdgeInsets.all(30),
|
||||
child: Center(
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text(
|
||||
"Contáctanos",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30),
|
||||
),
|
||||
Text(
|
||||
"Trasládanos tus dudas e intentaremos responderte lo antes posible",
|
||||
),
|
||||
DropdownMenu(
|
||||
initialSelection: "es",
|
||||
label: Text("País"),
|
||||
dropdownMenuEntries: [
|
||||
DropdownMenuEntry(value: "es", label: "España"),
|
||||
DropdownMenuEntry(value: "fr", label: "Francia"),
|
||||
DropdownMenuEntry(value: "pt", label: "Portugal"),
|
||||
],
|
||||
),
|
||||
DropdownMenu(
|
||||
initialSelection: "online",
|
||||
label: Text("Canal de compra"),
|
||||
dropdownMenuEntries: [
|
||||
DropdownMenuEntry(value: "online", label: "SF online shop"),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
label: "Nombre",
|
||||
hint: "Nombre y apellidos",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
label: "Correo electrónico",
|
||||
hint: "Correo electrónico",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
lines: 3,
|
||||
label: "Asunto del mensaje",
|
||||
hint: "Escribe tu mensaje",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text("Enviar"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/add_kid_step_mapper.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/step_body.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/success_screen.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_footer.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/app_routes.dart';
|
||||
import 'package:navigation/navigation_contract.dart';
|
||||
import 'package:payments/payments.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyDeviceSetupScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const LegacyDeviceSetupScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final state = ref.watch(legacyDeviceSetupViewModelProvider);
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final mainStep = state.step.mainStep;
|
||||
|
||||
final isIntro = state.step == LegacyAddKidStep.intro;
|
||||
final isAllowance = state.step == LegacyAddKidStep.allowance;
|
||||
|
||||
final canPopRoute = state.step == LegacyAddKidStep.intro;
|
||||
|
||||
return PopScope(
|
||||
canPop: canPopRoute,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop || isAllowance) return;
|
||||
vm.back();
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12, left: 8, right: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (isIntro || isAllowance)
|
||||
const SizedBox(width: 48)
|
||||
else
|
||||
IconButton(
|
||||
onPressed: vm.back,
|
||||
icon: const Icon(Icons.arrow_back_ios_new_rounded),
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
tooltip: MaterialLocalizations.of(
|
||||
context,
|
||||
).backButtonTooltip,
|
||||
),
|
||||
Expanded(
|
||||
child: isIntro
|
||||
? const SizedBox.shrink()
|
||||
: StepIndicator(
|
||||
total: LegacyAddKidMainStep.values.length,
|
||||
current: mainStep.index + 1,
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () =>
|
||||
navigationContract.goTo(AppRoutes.dashboardHome),
|
||||
icon: const Icon(Icons.close),
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
child: LegacyStepBody(key: ValueKey(state.step), state: state),
|
||||
),
|
||||
),
|
||||
|
||||
LegacyFlowFooter(
|
||||
primaryText: context.translate(primaryButtonText(state.step)),
|
||||
onPrimary: () async {
|
||||
if (state.step == LegacyAddKidStep.profile) {
|
||||
if (!vm.validateProfile()) return;
|
||||
final ok = await vm.createChildProfile();
|
||||
if (!context.mounted) return;
|
||||
if (ok) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => LegacySuccessScreen()),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state.step == LegacyAddKidStep.allowance) {
|
||||
_pushHiPayScreen(context, ref);
|
||||
return;
|
||||
}
|
||||
vm.next();
|
||||
},
|
||||
secondaryText: isAllowance
|
||||
? context.translate(I18n.deviceSetup_skipAndConfigureLater)
|
||||
: null,
|
||||
onSecondary: isAllowance
|
||||
? () => navigationContract.pushTo(AppRoutes.dashboardHome)
|
||||
: null,
|
||||
theme: theme,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pushHiPayScreen(BuildContext context, WidgetRef ref) async {
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
final result = await Navigator.of(context).push<HiPayResult>(
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
HiPayWebViewScreen(navigationContract: navigationContract),
|
||||
),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
if (result == HiPayResult.success) {
|
||||
vm.setError('');
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.deviceSetup_cardRegistered),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigationContract.pushTo(AppRoutes.dashboardHome);
|
||||
} else {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.deviceSetup_paymentCancelled),
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String primaryButtonText(LegacyAddKidStep step) {
|
||||
switch (step) {
|
||||
case LegacyAddKidStep.intro:
|
||||
return I18n.deviceSetup_start;
|
||||
case LegacyAddKidStep.allowance:
|
||||
return I18n.deviceSetup_addCreditCard;
|
||||
default:
|
||||
return I18n.continueKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
enum LegacyAddKidMainStep { linkDevice, profile, allowance }
|
||||
@@ -0,0 +1 @@
|
||||
enum LegacyAddKidStep { intro, linkInfo, scanStrap, scanWatch, profile, allowance }
|
||||
@@ -0,0 +1 @@
|
||||
enum LegacyScanLinkStep { strap, watch }
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyCreateChildProfileUseCaseProvider =
|
||||
Provider.autoDispose<LegacyCreateChildProfileUseCase>((ref) {
|
||||
final authRepository = ref.read(legacyAuthRepositoryProvider);
|
||||
return LegacyCreateChildProfileUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,182 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyQrScannerScreen extends StatefulWidget {
|
||||
const LegacyQrScannerScreen({super.key});
|
||||
|
||||
@override
|
||||
State<LegacyQrScannerScreen> createState() => _LegacyQrScannerScreenState();
|
||||
}
|
||||
|
||||
class _LegacyQrScannerScreenState extends State<LegacyQrScannerScreen> {
|
||||
late final MobileScannerController _controller;
|
||||
|
||||
bool _alreadyReturned = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = MobileScannerController(
|
||||
detectionSpeed: DetectionSpeed.noDuplicates,
|
||||
formats: const [BarcodeFormat.qrCode],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _returnResult(String value) {
|
||||
if (_alreadyReturned) return;
|
||||
_alreadyReturned = true;
|
||||
Navigator.of(context).pop(value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
foregroundColor: Colors.white,
|
||||
title: Text(context.translate(I18n.deviceSetup_scanQr)),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.flash_on),
|
||||
onPressed: () => _controller.toggleTorch(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
MobileScanner(
|
||||
controller: _controller,
|
||||
onDetect: (capture) {
|
||||
if (capture.barcodes.isEmpty) return;
|
||||
|
||||
final rawValue = capture.barcodes.first.rawValue;
|
||||
if (rawValue == null || rawValue.isEmpty) return;
|
||||
|
||||
_returnResult(rawValue);
|
||||
},
|
||||
),
|
||||
|
||||
const Positioned.fill(
|
||||
child: LegacyQrScannerOverlay(
|
||||
cutOutSize: 260,
|
||||
borderRadius: 18,
|
||||
borderWidth: 3,
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 50,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Text(
|
||||
context.translate(I18n.deviceSetup_scanQr_hint),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white, fontSize: 15),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LegacyQrScannerOverlay extends StatelessWidget {
|
||||
const LegacyQrScannerOverlay({
|
||||
super.key,
|
||||
required this.cutOutSize,
|
||||
required this.borderRadius,
|
||||
required this.borderWidth,
|
||||
});
|
||||
|
||||
final double cutOutSize;
|
||||
final double borderRadius;
|
||||
final double borderWidth;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IgnorePointer(
|
||||
child: CustomPaint(
|
||||
painter: _LegacyQrScannerOverlayPainter(
|
||||
cutOutSize: cutOutSize,
|
||||
borderRadius: borderRadius,
|
||||
borderWidth: borderWidth,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LegacyQrScannerOverlayPainter extends CustomPainter {
|
||||
_LegacyQrScannerOverlayPainter({
|
||||
required this.cutOutSize,
|
||||
required this.borderRadius,
|
||||
required this.borderWidth,
|
||||
});
|
||||
|
||||
final double cutOutSize;
|
||||
final double borderRadius;
|
||||
final double borderWidth;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final screenRect = Rect.fromLTWH(0, 0, size.width, size.height);
|
||||
|
||||
final cutOutRect = Rect.fromCenter(
|
||||
center: screenRect.center,
|
||||
width: cutOutSize,
|
||||
height: cutOutSize,
|
||||
);
|
||||
|
||||
final cutOutRRect = RRect.fromRectXY(
|
||||
cutOutRect,
|
||||
borderRadius,
|
||||
borderRadius,
|
||||
);
|
||||
|
||||
final backgroundPath = Path()..addRect(screenRect);
|
||||
final cutOutPath = Path()..addRRect(cutOutRRect);
|
||||
|
||||
final overlayPath = Path.combine(
|
||||
PathOperation.difference,
|
||||
backgroundPath,
|
||||
cutOutPath,
|
||||
);
|
||||
|
||||
final overlayPaint = Paint()
|
||||
..color = Colors.black.withValues(alpha: 0.55)
|
||||
..style = PaintingStyle.fill;
|
||||
|
||||
canvas.drawPath(overlayPath, overlayPaint);
|
||||
|
||||
final borderPaint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = borderWidth
|
||||
..color = Colors.white;
|
||||
|
||||
canvas.drawRRect(cutOutRRect, borderPaint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.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:uuid/uuid.dart';
|
||||
|
||||
final legacyDeviceSetupViewModelProvider =
|
||||
NotifierProvider<LegacyDeviceSetupViewModel, LegacyDeviceSetupViewState>(
|
||||
LegacyDeviceSetupViewModel.new,
|
||||
);
|
||||
|
||||
class LegacyDeviceSetupViewModel extends Notifier<LegacyDeviceSetupViewState> {
|
||||
late final LegacyCreateChildProfileUseCase _createChildProfileUseCase;
|
||||
late final GetUserInfoUseCase _getUserInfoUseCase;
|
||||
|
||||
late final TextEditingController bornAtController;
|
||||
late final TextEditingController firstNameController;
|
||||
late final TextEditingController lastNameController;
|
||||
late final TextEditingController addressController;
|
||||
late final TextEditingController strapCodeController;
|
||||
late final TextEditingController watchCodeController;
|
||||
late final TextEditingController allowanceAmountController;
|
||||
|
||||
@override
|
||||
LegacyDeviceSetupViewState build() {
|
||||
final initial = LegacyDeviceSetupViewState(id: const Uuid().v4());
|
||||
_initControllers(initial);
|
||||
_addListeners();
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
return initial;
|
||||
}
|
||||
|
||||
void _initControllers(LegacyDeviceSetupViewState s) {
|
||||
_createChildProfileUseCase = ref.read(legacyCreateChildProfileUseCaseProvider);
|
||||
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
|
||||
|
||||
firstNameController = TextEditingController(text: s.firstName);
|
||||
lastNameController = TextEditingController(text: s.lastName);
|
||||
bornAtController = TextEditingController(
|
||||
text: s.bornAt == null ? '' : _formatDate(s.bornAt!),
|
||||
);
|
||||
|
||||
addressController = TextEditingController(text: s.address);
|
||||
strapCodeController = TextEditingController(text: s.strapCode);
|
||||
watchCodeController = TextEditingController(text: s.watchCode);
|
||||
allowanceAmountController = TextEditingController(text: s.allowanceAmount);
|
||||
}
|
||||
|
||||
void _addListeners() {
|
||||
firstNameController.addListener(_onFirstNameChanged);
|
||||
lastNameController.addListener(_onLastNameChanged);
|
||||
bornAtController.addListener(_onBornAtTextChanged);
|
||||
addressController.addListener(_onAddressChanged);
|
||||
|
||||
strapCodeController.addListener(_onStrapCodeChanged);
|
||||
watchCodeController.addListener(_onWatchCodeChanged);
|
||||
allowanceAmountController.addListener(_onAllowanceAmountChanged);
|
||||
}
|
||||
|
||||
void next() {
|
||||
switch (state.step) {
|
||||
case LegacyAddKidStep.intro:
|
||||
state = state.copyWith(step: LegacyAddKidStep.linkInfo);
|
||||
return;
|
||||
case LegacyAddKidStep.linkInfo:
|
||||
state = state.copyWith(step: LegacyAddKidStep.scanStrap);
|
||||
return;
|
||||
case LegacyAddKidStep.scanStrap:
|
||||
final hasStrap = state.strapQr.isNotEmpty || state.strapCode.isNotEmpty;
|
||||
if (!hasStrap) {
|
||||
state = state.copyWith(errorMessage: I18n.errorScanStrapRequired);
|
||||
return;
|
||||
}
|
||||
state = state.copyWith(step: LegacyAddKidStep.scanWatch, errorMessage: '');
|
||||
return;
|
||||
case LegacyAddKidStep.scanWatch:
|
||||
final hasWatch = state.watchQr.isNotEmpty || state.watchCode.isNotEmpty;
|
||||
if (!hasWatch) {
|
||||
state = state.copyWith(errorMessage: I18n.errorScanWatchRequired);
|
||||
return;
|
||||
}
|
||||
state = state.copyWith(step: LegacyAddKidStep.profile, errorMessage: '');
|
||||
return;
|
||||
case LegacyAddKidStep.profile:
|
||||
return;
|
||||
case LegacyAddKidStep.allowance:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void back() {
|
||||
switch (state.step) {
|
||||
case LegacyAddKidStep.intro:
|
||||
return;
|
||||
|
||||
case LegacyAddKidStep.linkInfo:
|
||||
state = state.copyWith(step: LegacyAddKidStep.intro, errorMessage: '');
|
||||
return;
|
||||
case LegacyAddKidStep.scanStrap:
|
||||
state = state.copyWith(step: LegacyAddKidStep.linkInfo);
|
||||
return;
|
||||
case LegacyAddKidStep.scanWatch:
|
||||
state = state.copyWith(step: LegacyAddKidStep.scanStrap);
|
||||
return;
|
||||
case LegacyAddKidStep.profile:
|
||||
state = state.copyWith(step: LegacyAddKidStep.scanWatch);
|
||||
return;
|
||||
case LegacyAddKidStep.allowance:
|
||||
state = state.copyWith(step: LegacyAddKidStep.profile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void onQrScanned({required LegacyScanLinkStep step, required String qr}) {
|
||||
switch (step) {
|
||||
case LegacyScanLinkStep.strap:
|
||||
state = state.copyWith(strapQr: qr, step: LegacyAddKidStep.scanWatch);
|
||||
break;
|
||||
|
||||
case LegacyScanLinkStep.watch:
|
||||
state = state.copyWith(watchQr: qr, step: LegacyAddKidStep.profile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> pickBornAt(BuildContext context) async {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
final now = DateTime.now();
|
||||
final initial = state.bornAt ?? DateTime(now.year - 18, now.month, now.day);
|
||||
|
||||
final safeInitial = initial.isAfter(now) ? now : initial;
|
||||
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: safeInitial,
|
||||
firstDate: DateTime(1900, 1, 1),
|
||||
lastDate: now,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
if (picked == null) return;
|
||||
|
||||
setBornAt(picked);
|
||||
}
|
||||
|
||||
void setBornAt(DateTime date) {
|
||||
bornAtController.text = _formatDate(date);
|
||||
state = state.copyWith(bornAt: date);
|
||||
}
|
||||
|
||||
Future<bool> createChildProfile() async {
|
||||
await getUserInfo();
|
||||
final firstName = state.firstName.trim();
|
||||
final lastName = state.lastName.trim();
|
||||
final birth = state.bornAt!;
|
||||
final bornAt = DateTime.utc(birth.year, birth.month, birth.day)
|
||||
.millisecondsSinceEpoch;
|
||||
final address = state.address.trim();
|
||||
final genrer = state.genrer.trim();
|
||||
final relationType = state.relationType.trim();
|
||||
|
||||
state = state.copyWith(isLoading: true);
|
||||
|
||||
try {
|
||||
await _createChildProfileUseCase.createChildProfile(
|
||||
id: state.id,
|
||||
parentId: state.parentId,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
bornAt: bornAt,
|
||||
genrer: genrer,
|
||||
relationType: relationType,
|
||||
address: address,
|
||||
cardPublicKey: state.strapCode,
|
||||
deviceActivationCode: state.watchCode,
|
||||
scaProof: '',
|
||||
);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
isSuccess: true,
|
||||
);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<UserEntity?> getUserInfo() async {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
final user = await _getUserInfoUseCase.getUserInfo();
|
||||
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false);
|
||||
}
|
||||
|
||||
debugPrint('[getUserInfo] userId => ${user.id}');
|
||||
state = state.copyWith(parentId: user.id);
|
||||
|
||||
return user;
|
||||
} catch (e) {
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool validateProfile() {
|
||||
final isInvalid =
|
||||
state.firstName.trim().isEmpty ||
|
||||
state.lastName.trim().isEmpty ||
|
||||
state.bornAt == null ||
|
||||
state.address.trim().isEmpty ||
|
||||
state.genrer.trim().isEmpty ||
|
||||
state.relationType.trim().isEmpty;
|
||||
|
||||
if (isInvalid) {
|
||||
state = state.copyWith(errorMessage: I18n.errorAllFieldsRequired);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
final dd = date.day.toString().padLeft(2, '0');
|
||||
final mm = date.month.toString().padLeft(2, '0');
|
||||
final yyyy = date.year.toString();
|
||||
return '$dd/$mm/$yyyy';
|
||||
}
|
||||
|
||||
void _onFirstNameChanged() {
|
||||
final text = firstNameController.text;
|
||||
if (text == state.firstName) return;
|
||||
state = state.copyWith(firstName: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void _onLastNameChanged() {
|
||||
final text = lastNameController.text;
|
||||
if (text == state.lastName) return;
|
||||
state = state.copyWith(lastName: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void _onBornAtTextChanged() {
|
||||
final text = bornAtController.text;
|
||||
final parsed = _tryParseDate(text);
|
||||
|
||||
if (text.trim().isEmpty) {
|
||||
if (state.bornAt != null) {
|
||||
state = state.copyWith(bornAt: null, errorMessage: '');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed != null && parsed != state.bornAt) {
|
||||
state = state.copyWith(bornAt: parsed, errorMessage: '');
|
||||
}
|
||||
}
|
||||
|
||||
void _onAddressChanged() {
|
||||
final text = addressController.text;
|
||||
if (text == state.address) return;
|
||||
state = state.copyWith(address: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void _onStrapCodeChanged() {
|
||||
final text = strapCodeController.text;
|
||||
if (text == state.strapCode) return;
|
||||
state = state.copyWith(strapCode: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void _onWatchCodeChanged() {
|
||||
final text = watchCodeController.text;
|
||||
if (text == state.watchCode) return;
|
||||
state = state.copyWith(watchCode: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void _onAllowanceAmountChanged() {
|
||||
final text = allowanceAmountController.text;
|
||||
if (text == state.allowanceAmount) return;
|
||||
state = state.copyWith(allowanceAmount: text, errorMessage: '');
|
||||
}
|
||||
|
||||
void setError(String message) {
|
||||
state = state.copyWith(errorMessage: message);
|
||||
}
|
||||
|
||||
void goToAllowance() {
|
||||
state = state.copyWith(step: LegacyAddKidStep.allowance, errorMessage: '');
|
||||
}
|
||||
|
||||
void onGenrerChanged(String? value) {
|
||||
final v = value ?? '';
|
||||
if (v == state.genrer) return;
|
||||
state = state.copyWith(genrer: v, errorMessage: '');
|
||||
}
|
||||
|
||||
void onRelationTypeChanged(String? value) {
|
||||
final v = value ?? '';
|
||||
if (v == state.relationType) return;
|
||||
state = state.copyWith(relationType: v, errorMessage: '');
|
||||
}
|
||||
|
||||
DateTime? _tryParseDate(String value) {
|
||||
final v = value.trim();
|
||||
if (v.isEmpty) return null;
|
||||
|
||||
final parts = v.split('/');
|
||||
if (parts.length != 3) return null;
|
||||
|
||||
final d = int.tryParse(parts[0]);
|
||||
final m = int.tryParse(parts[1]);
|
||||
final y = int.tryParse(parts[2]);
|
||||
|
||||
if (d == null || m == null || y == null) return null;
|
||||
|
||||
final date = DateTime(y, m, d);
|
||||
if (date.year != y || date.month != m || date.day != d) return null;
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
void resetForNewKid() {
|
||||
firstNameController.clear();
|
||||
lastNameController.clear();
|
||||
bornAtController.clear();
|
||||
addressController.clear();
|
||||
strapCodeController.clear();
|
||||
watchCodeController.clear();
|
||||
allowanceAmountController.clear();
|
||||
|
||||
state = LegacyDeviceSetupViewState(id: const Uuid().v4());
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
// firstNameController.dispose();
|
||||
// lastNameController.dispose();
|
||||
bornAtController.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'device_setup_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyDeviceSetupViewState with _$LegacyDeviceSetupViewState {
|
||||
const factory LegacyDeviceSetupViewState({
|
||||
@Default(LegacyAddKidStep.intro) LegacyAddKidStep step,
|
||||
@Default('') String id,
|
||||
@Default('') String parentId,
|
||||
@Default('') String firstName,
|
||||
@Default('') String lastName,
|
||||
DateTime? bornAt,
|
||||
@Default('') String address,
|
||||
@Default('') String genrer,
|
||||
@Default('') String relationType,
|
||||
|
||||
@Default('') String strapQr,
|
||||
@Default('') String strapCode,
|
||||
@Default('') String watchQr,
|
||||
@Default('') String watchCode,
|
||||
|
||||
@Default(false) bool isLoading,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool isSuccess,
|
||||
|
||||
@Default('') String allowanceAmount,
|
||||
}) = _AddKidFlowState;
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
// 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 'device_setup_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyDeviceSetupViewState {
|
||||
|
||||
LegacyAddKidStep get step; String get id; String get parentId; String get firstName; String get lastName; DateTime? get bornAt; String get address; String get genrer; String get relationType; String get strapQr; String get strapCode; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess; String get allowanceAmount;
|
||||
/// Create a copy of LegacyDeviceSetupViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyDeviceSetupViewStateCopyWith<LegacyDeviceSetupViewState> get copyWith => _$LegacyDeviceSetupViewStateCopyWithImpl<LegacyDeviceSetupViewState>(this as LegacyDeviceSetupViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(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)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyDeviceSetupViewStateCopyWith<$Res> {
|
||||
factory $LegacyDeviceSetupViewStateCopyWith(LegacyDeviceSetupViewState value, $Res Function(LegacyDeviceSetupViewState) _then) = _$LegacyDeviceSetupViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyDeviceSetupViewStateCopyWithImpl<$Res>
|
||||
implements $LegacyDeviceSetupViewStateCopyWith<$Res> {
|
||||
_$LegacyDeviceSetupViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyDeviceSetupViewState _self;
|
||||
final $Res Function(LegacyDeviceSetupViewState) _then;
|
||||
|
||||
/// 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? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
|
||||
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
|
||||
as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable
|
||||
as String,strapCode: null == strapCode ? _self.strapCode : strapCode // 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,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
|
||||
as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyDeviceSetupViewState].
|
||||
extension LegacyDeviceSetupViewStatePatterns on LegacyDeviceSetupViewState {
|
||||
/// 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( _AddKidFlowState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState() 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( _AddKidFlowState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState():
|
||||
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( _AddKidFlowState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState() 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( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState() when $default != null:
|
||||
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);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( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState():
|
||||
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);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( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddKidFlowState() when $default != null:
|
||||
return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _AddKidFlowState implements LegacyDeviceSetupViewState {
|
||||
const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.id = '', this.parentId = '', this.firstName = '', this.lastName = '', this.bornAt, this.address = '', this.genrer = '', this.relationType = '', this.strapQr = '', this.strapCode = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false, this.allowanceAmount = ''});
|
||||
|
||||
|
||||
@override@JsonKey() final LegacyAddKidStep step;
|
||||
@override@JsonKey() final String id;
|
||||
@override@JsonKey() final String parentId;
|
||||
@override@JsonKey() final String firstName;
|
||||
@override@JsonKey() final String lastName;
|
||||
@override final DateTime? bornAt;
|
||||
@override@JsonKey() final String address;
|
||||
@override@JsonKey() final String genrer;
|
||||
@override@JsonKey() final String relationType;
|
||||
@override@JsonKey() final String strapQr;
|
||||
@override@JsonKey() final String strapCode;
|
||||
@override@JsonKey() final String watchQr;
|
||||
@override@JsonKey() final String watchCode;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool isSuccess;
|
||||
@override@JsonKey() final String allowanceAmount;
|
||||
|
||||
/// Create a copy of LegacyDeviceSetupViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AddKidFlowStateCopyWith<_AddKidFlowState> get copyWith => __$AddKidFlowStateCopyWithImpl<_AddKidFlowState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(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)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AddKidFlowStateCopyWith<$Res> implements $LegacyDeviceSetupViewStateCopyWith<$Res> {
|
||||
factory _$AddKidFlowStateCopyWith(_AddKidFlowState value, $Res Function(_AddKidFlowState) _then) = __$AddKidFlowStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AddKidFlowStateCopyWithImpl<$Res>
|
||||
implements _$AddKidFlowStateCopyWith<$Res> {
|
||||
__$AddKidFlowStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AddKidFlowState _self;
|
||||
final $Res Function(_AddKidFlowState) _then;
|
||||
|
||||
/// 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? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) {
|
||||
return _then(_AddKidFlowState(
|
||||
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable
|
||||
as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable
|
||||
as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable
|
||||
as String,strapCode: null == strapCode ? _self.strapCode : strapCode // 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,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
|
||||
as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/intro_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/link_info_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/allowance_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/profile_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyStepBody extends StatelessWidget {
|
||||
const LegacyStepBody({super.key, required this.state});
|
||||
final LegacyDeviceSetupViewState state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (state.step) {
|
||||
case LegacyAddKidStep.intro:
|
||||
return LegacyIntroStepScreen();
|
||||
case LegacyAddKidStep.linkInfo:
|
||||
return LegacyLinkInfoStepScreen();
|
||||
case LegacyAddKidStep.scanStrap:
|
||||
return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.strap);
|
||||
case LegacyAddKidStep.scanWatch:
|
||||
return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.watch);
|
||||
case LegacyAddKidStep.profile:
|
||||
return LegacyProfileStepScreen();
|
||||
case LegacyAddKidStep.allowance:
|
||||
return LegacyAllowanceStepScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyAllowanceStepScreen extends ConsumerWidget {
|
||||
const LegacyAllowanceStepScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_addCreditCard_title),
|
||||
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_addCreditCard_subtitle),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_addCreditCard_info),
|
||||
style: const TextStyle(fontSize: 14),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/numbered_steps.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';
|
||||
|
||||
class LegacyIntroStepScreen extends ConsumerWidget {
|
||||
const LegacyIntroStepScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_title),
|
||||
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_subtitle),
|
||||
style: TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
LegacyNumberedSteps(
|
||||
steps: [
|
||||
context.translate(I18n.deviceSetup_intro_step_1),
|
||||
context.translate(I18n.deviceSetup_intro_step_2),
|
||||
context.translate(I18n.deviceSetup_intro_step_3),
|
||||
],
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_ready_title),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_remember_prefix),
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_plan_name),
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50.0),
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: context.translate(I18n.deviceSetup_intro_web_prefix),
|
||||
style: TextStyle(fontSize: 16, color: Colors.black),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: context.translate(I18n.deviceSetup_intro_web_link),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/link_info_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyLinkInfoStepScreen extends ConsumerWidget {
|
||||
const LegacyLinkInfoStepScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 65),
|
||||
child: Text(
|
||||
context.translate(I18n.deviceSetup_linkInfo_title),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 1.2,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 25),
|
||||
|
||||
SvgPicture.asset("assets/shared/images/formulario.svg"),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
LegacyLinkInfoItem(
|
||||
number: 1,
|
||||
boldWord: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item1_boldWord,
|
||||
),
|
||||
titlePrefix: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item1_prefix,
|
||||
),
|
||||
subtitle: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item1_subtitle,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
LegacyLinkInfoItem(
|
||||
number: 2,
|
||||
boldWord: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item2_boldWord,
|
||||
),
|
||||
titlePrefix: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item2_prefix,
|
||||
),
|
||||
subtitle: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item2_subtitle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_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';
|
||||
|
||||
class LegacyProfileStepScreen extends ConsumerWidget {
|
||||
const LegacyProfileStepScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
const Map<String, String> genrer = <String, String>{
|
||||
'F': 'Femenino',
|
||||
'M': 'Masculino',
|
||||
'O': 'Otro',
|
||||
};
|
||||
|
||||
const Map<String, String> relationship = <String, String>{
|
||||
'FATHER': 'Padre',
|
||||
'MOTHER': 'Madre',
|
||||
'OTHER': 'Otro',
|
||||
};
|
||||
|
||||
final state = ref.watch(legacyDeviceSetupViewModelProvider);
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_intro_step_1),
|
||||
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_accountData_info),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_startWithOneKid_info),
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 24, right: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
CustomTextField(
|
||||
label: context.translate(I18n.firstNameLabel),
|
||||
hint: context.translate(I18n.firstNameHint),
|
||||
controller: vm.firstNameController,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextField(
|
||||
label: context.translate(I18n.lastNameLabel),
|
||||
hint: context.translate(I18n.lastNameHint),
|
||||
controller: vm.lastNameController,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () => vm.pickBornAt(context),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextField(
|
||||
label: context.translate(I18n.birthDateLabel),
|
||||
hint: context.translate(I18n.birthDateHint),
|
||||
controller: vm.bornAtController,
|
||||
readOnly: true,
|
||||
keyboardType: TextInputType.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CustomDropdown(
|
||||
items: genrer.values.map(Text.new).toList(growable: false),
|
||||
values: genrer.keys.toList(growable: false),
|
||||
value: state.genrer.isEmpty ? null : state.genrer,
|
||||
hint: 'Género',
|
||||
onChanged: (v) => vm.onGenrerChanged(v as String?),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CustomDropdown(
|
||||
items: relationship.values
|
||||
.map(Text.new)
|
||||
.toList(growable: false),
|
||||
values: relationship.keys.toList(growable: false),
|
||||
value: state.relationType.isEmpty ? null : state.relationType,
|
||||
hint: 'Relación',
|
||||
onChanged: (v) => vm.onRelationTypeChanged(v as String?),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CustomTextField(
|
||||
label: 'Dirección',
|
||||
hint: 'Dirección',
|
||||
controller: vm.addressController,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/qr_scanner_screen.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyScanStrapAndWatchStepScreen extends ConsumerWidget {
|
||||
const LegacyScanStrapAndWatchStepScreen({super.key, required this.step});
|
||||
|
||||
final LegacyScanLinkStep step;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final activeColor = theme.getColorFor(ThemeCode.buttonPrimary);
|
||||
final inactiveCircleColor = theme.getColorFor(
|
||||
ThemeCode.backgroundSecondary,
|
||||
);
|
||||
final inactiveLineColor = Colors.grey.shade200;
|
||||
final textPrimary = theme.getColorFor(ThemeCode.textPrimary);
|
||||
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
final state = ref.watch(legacyDeviceSetupViewModelProvider);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 65),
|
||||
child: Text(
|
||||
context.translate(I18n.deviceSetup_linkInfo_title),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 1.2,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 18),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 100),
|
||||
child: LegacyScanLinkStepsIndicator(
|
||||
step: step,
|
||||
activeColor: activeColor,
|
||||
inactiveCircleColor: inactiveCircleColor,
|
||||
inactiveLineColor: inactiveLineColor,
|
||||
textPrimary: textPrimary,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 35),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item1_prefix,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item1_boldWord,
|
||||
),
|
||||
style: TextStyle(fontWeight: FontWeight.w800),
|
||||
),
|
||||
],
|
||||
),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item2_prefix,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: context.translate(
|
||||
I18n.deviceSetup_linkInfo_item2_boldWord,
|
||||
),
|
||||
style: TextStyle(fontWeight: FontWeight.w800),
|
||||
),
|
||||
],
|
||||
),
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 28),
|
||||
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () async {
|
||||
final result = await Navigator.of(context).push<String>(
|
||||
MaterialPageRoute(builder: (_) => const LegacyQrScannerScreen()),
|
||||
);
|
||||
if (result == null || result.isEmpty) return;
|
||||
vm.onQrScanned(step: step, qr: result);
|
||||
},
|
||||
child: Container(
|
||||
width: 170,
|
||||
height: 170,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey.shade500, width: 1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
"assets/shared/images/qr.svg",
|
||||
width: 90,
|
||||
height: 90,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 22),
|
||||
|
||||
// if (step == LegacyScanLinkStep.watch) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_watchCode_orInsert),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
hint: "XXXXXXXXXX",
|
||||
controller: LegacyScanLinkStep.strap == step
|
||||
? vm.strapCodeController
|
||||
: vm.watchCodeController,
|
||||
// controller: vm.codeController,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Expanded(
|
||||
// child: PrimaryButton(
|
||||
// onPressed: () {},
|
||||
// text: context.translate(
|
||||
// I18n.deviceSetup_watchCode_continueWithCode,
|
||||
// ),
|
||||
// size: 14,
|
||||
// color: theme.getColorFor(ThemeCode.buttonSecondary),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ],
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.deviceSetup_linkTroubleshoot_title),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
CustomTextButton(
|
||||
onPressed: () {},
|
||||
text: context.translate(I18n.deviceSetup_contactUs),
|
||||
weight: FontWeight.w800,
|
||||
size: 18,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_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';
|
||||
|
||||
class LegacySuccessStepScreen extends ConsumerWidget {
|
||||
const LegacySuccessStepScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final state = ref.watch(legacyDeviceSetupViewModelProvider);
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check,
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
size: 50,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate(I18n.accountCreatedTitle),
|
||||
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
context.translate(I18n.accountCreatedForLabel),
|
||||
style: TextStyle(fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'${state.firstName} ${state.lastName}',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
|
||||
Text(
|
||||
'Reloj: ${state.watchCode}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
'ID de la tarjeta: ${state.strapCode} ',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Text(
|
||||
context.translate(I18n.deviceSetup_firstAllowance_title),
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/steps/success_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_footer.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';
|
||||
|
||||
class LegacySuccessScreen extends ConsumerWidget {
|
||||
const LegacySuccessScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier);
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
Expanded(child: LegacySuccessStepScreen()),
|
||||
LegacyFlowFooter(
|
||||
primaryText: context.translate(
|
||||
I18n.deviceSetup_giveFirstAllowance,
|
||||
),
|
||||
onPrimary: () {
|
||||
vm.goToAllowance();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
secondaryText: context.translate(I18n.deviceSetup_addAnotherKid),
|
||||
onSecondary: () {
|
||||
vm.resetForNewKid();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
theme: theme,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyFlowFooter extends StatelessWidget {
|
||||
const LegacyFlowFooter({
|
||||
super.key,
|
||||
required this.primaryText,
|
||||
required this.onPrimary,
|
||||
required this.theme,
|
||||
this.secondaryText,
|
||||
this.onSecondary,
|
||||
this.error,
|
||||
});
|
||||
|
||||
final String primaryText;
|
||||
final VoidCallback onPrimary;
|
||||
final ThemePort theme;
|
||||
|
||||
final String? secondaryText;
|
||||
final VoidCallback? onSecondary;
|
||||
|
||||
final String? error;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
border: Border(top: BorderSide(color: Colors.grey.shade300, width: 1)),
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (error != null) ...[
|
||||
Text(
|
||||
error!,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 13),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
PrimaryButton(
|
||||
text: primaryText,
|
||||
onPressed: onPrimary,
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
if (secondaryText != null && onSecondary != null) ...[
|
||||
const SizedBox(height: 10),
|
||||
Material(
|
||||
child: InkWell(
|
||||
onTap: onSecondary,
|
||||
child: Text(
|
||||
secondaryText ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/number_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyLinkInfoItem extends StatelessWidget {
|
||||
const LegacyLinkInfoItem({
|
||||
super.key,
|
||||
required this.number,
|
||||
required this.titlePrefix,
|
||||
required this.boldWord,
|
||||
required this.subtitle,
|
||||
});
|
||||
|
||||
final int number;
|
||||
final String titlePrefix;
|
||||
final String boldWord;
|
||||
final String subtitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LegacyNumberCircle(number: number),
|
||||
const SizedBox(width: 10),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: titlePrefix,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF4B4B4B),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: boldWord,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Color(0xFF4B4B4B),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(subtitle, style: const TextStyle(fontSize: 16)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyNumberCircle extends StatelessWidget {
|
||||
const LegacyNumberCircle({super.key, required this.number});
|
||||
|
||||
final int number;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
alignment: Alignment.center,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFF2F2F2),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Text(
|
||||
number.toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyNumberedSteps extends StatelessWidget {
|
||||
const LegacyNumberedSteps({
|
||||
super.key,
|
||||
required this.steps,
|
||||
this.color,
|
||||
this.textColor,
|
||||
this.textStyle,
|
||||
});
|
||||
|
||||
final List<String> steps;
|
||||
|
||||
final Color? color;
|
||||
final Color? textColor;
|
||||
|
||||
final TextStyle? textStyle;
|
||||
|
||||
@override
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color resolvedColor =
|
||||
color ?? Theme.of(context).colorScheme.secondaryContainer;
|
||||
final Color resolvedTextColor = textColor ?? Colors.grey.shade800;
|
||||
final TextStyle resolvedTextStyle =
|
||||
textStyle ??
|
||||
TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: resolvedTextColor,
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(steps.length, (index) {
|
||||
final isLast = index == steps.length - 1;
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 32,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_LegacyStepCircle(
|
||||
number: index + 1,
|
||||
size: 32,
|
||||
color: resolvedColor,
|
||||
),
|
||||
if (!isLast)
|
||||
Container(
|
||||
width: 4,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade400,
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 32 * 0.15),
|
||||
child: Text(steps[index], style: resolvedTextStyle),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LegacyStepCircle extends StatelessWidget {
|
||||
const _LegacyStepCircle({
|
||||
required this.number,
|
||||
required this.size,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
final int number;
|
||||
final double size;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
||||
child: Text(
|
||||
'$number',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: size * 0.55,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart';
|
||||
import 'package:legacy_auth/src/features/device_setup/presentation/widgets/step_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyScanLinkStepsIndicator extends StatelessWidget {
|
||||
const LegacyScanLinkStepsIndicator({
|
||||
super.key,
|
||||
required this.step,
|
||||
required this.activeColor,
|
||||
required this.inactiveCircleColor,
|
||||
required this.inactiveLineColor,
|
||||
required this.textPrimary,
|
||||
});
|
||||
|
||||
final LegacyScanLinkStep step;
|
||||
final Color activeColor;
|
||||
final Color inactiveCircleColor;
|
||||
final Color inactiveLineColor;
|
||||
final Color textPrimary;
|
||||
|
||||
bool get isWatch => step == LegacyScanLinkStep.watch;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const circleSize = 48.0;
|
||||
const lineHeight = 4.0;
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
LegacyStepCircle(
|
||||
label: "1",
|
||||
size: circleSize,
|
||||
background: activeColor,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
child: SizedBox(
|
||||
height: lineHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Container(color: activeColor)),
|
||||
if (!isWatch)
|
||||
Expanded(child: Container(color: inactiveLineColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
LegacyStepCircle(
|
||||
label: "2",
|
||||
size: circleSize,
|
||||
background: isWatch ? activeColor : inactiveCircleColor,
|
||||
textColor: isWatch ? Colors.white : textPrimary,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyStepCircle extends StatelessWidget {
|
||||
const LegacyStepCircle({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.size,
|
||||
required this.background,
|
||||
required this.textColor,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final double size;
|
||||
final Color background;
|
||||
final Color textColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(color: background, shape: BoxShape.circle),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
abstract class LegacyLinkPhoneUseCase {
|
||||
Future<void> requestCode({required String phone});
|
||||
|
||||
Future<void> verifyCode({required String phone, required String code});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/link_phone/domain/use_cases/link_phone_use_case.dart';
|
||||
|
||||
class LegacyLinkPhoneUseCaseImpl implements LegacyLinkPhoneUseCase {
|
||||
LegacyLinkPhoneUseCaseImpl(this._repository);
|
||||
|
||||
final LegacyAuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> requestCode({required String phone}) async {
|
||||
// return _repository.requestPhoneCode(phone: phone);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> verifyCode({required String phone, required String code}) async {
|
||||
// return _repository.verifyPhoneCode(phone: phone, code: code);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:legacy_auth/src/features/link_phone/domain/use_cases/link_phone_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/link_phone/domain/use_cases/link_phone_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyLinkPhoneUseCaseProvider = Provider.autoDispose<LegacyLinkPhoneUseCase>((ref) {
|
||||
final authRepository = ref.read(legacyAuthRepositoryProvider);
|
||||
return LegacyLinkPhoneUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/request_phone/request_link_phone_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class LegacyRequestLinkPhoneBuilder {
|
||||
const LegacyRequestLinkPhoneBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: LegacyRequestLinkPhoneScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/state/link_phone_view_model.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyRequestLinkPhoneScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const LegacyRequestLinkPhoneScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final viewModel = ref.read(legacyLinkPhoneViewModelProvider.notifier);
|
||||
final viewState = ref.watch(legacyLinkPhoneViewModelProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.linkPhoneTitle),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
context.translate(I18n.linkPhoneSubtitle),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 16, letterSpacing: 0),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
context.translate(I18n.mobilePhone),
|
||||
style: const TextStyle(fontSize: 14, letterSpacing: 0),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: viewState.dialCode,
|
||||
onChanged: (country) {
|
||||
viewModel.updateDialCode(
|
||||
country.dialCode ?? viewState.dialCode,
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
controller: viewModel.phoneNumberController,
|
||||
hint: context.translate(I18n.phoneNumber),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
if (viewState.errorMessage.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
viewState.errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color.fromRGBO(239, 17, 17, 1),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
PrimaryButton(
|
||||
onPressed: () async {
|
||||
await viewModel.requestCode();
|
||||
final updatedState = ref.read(legacyLinkPhoneViewModelProvider);
|
||||
if (updatedState.errorMessage.isEmpty) {
|
||||
navigationContract.pushTo(AppRoutes.phoneCode);
|
||||
}
|
||||
},
|
||||
text: context.translate(I18n.next),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/providers/link_phone_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:legacy_auth/src/features/link_phone/domain/use_cases/link_phone_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/state/link_phone_view_state.dart';
|
||||
|
||||
final legacyLinkPhoneViewModelProvider =
|
||||
NotifierProvider.autoDispose<LegacyLinkPhoneViewModel, LegacyLinkPhoneViewState>(
|
||||
LegacyLinkPhoneViewModel.new,
|
||||
);
|
||||
|
||||
class LegacyLinkPhoneViewModel extends Notifier<LegacyLinkPhoneViewState> {
|
||||
late final LegacyLinkPhoneUseCase _linkPhoneUseCase;
|
||||
late final TextEditingController phoneNumberController;
|
||||
late final TextEditingController codeController;
|
||||
|
||||
@override
|
||||
LegacyLinkPhoneViewState build() {
|
||||
_linkPhoneUseCase = ref.read(legacyLinkPhoneUseCaseProvider);
|
||||
|
||||
phoneNumberController = TextEditingController();
|
||||
phoneNumberController.addListener(_onPhoneNumberChanged);
|
||||
|
||||
codeController = TextEditingController();
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
return const LegacyLinkPhoneViewState();
|
||||
}
|
||||
|
||||
void _onPhoneNumberChanged() {
|
||||
final raw = phoneNumberController.text;
|
||||
state = state.copyWith(
|
||||
phoneNumber: raw,
|
||||
errorMessage: '',
|
||||
codeVerified: false,
|
||||
);
|
||||
}
|
||||
|
||||
void updateDialCode(String dialCode) {
|
||||
state = state.copyWith(
|
||||
dialCode: dialCode,
|
||||
errorMessage: '',
|
||||
codeVerified: false,
|
||||
);
|
||||
}
|
||||
|
||||
void updateCode(String code) {
|
||||
codeController.text = code;
|
||||
state = state.copyWith(errorMessage: '', codeVerified: false);
|
||||
}
|
||||
|
||||
Future<void> requestCode() async {
|
||||
final trimmedNumber = state.phoneNumber.trim();
|
||||
|
||||
if (trimmedNumber.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: 'errorMessagePhoneIsEmpty',
|
||||
codeVerified: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final fullPhone = '${state.dialCode}$trimmedNumber';
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: true,
|
||||
errorMessage: '',
|
||||
codeRequested: false,
|
||||
codeVerified: false,
|
||||
);
|
||||
|
||||
try {
|
||||
await _linkPhoneUseCase.requestCode(phone: fullPhone);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: '',
|
||||
codeRequested: true,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: e.toString(),
|
||||
codeRequested: false,
|
||||
codeVerified: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> verifyCode() async {
|
||||
final dialCode = state.dialCode;
|
||||
final phoneNumber = state.phoneNumber.trim();
|
||||
final code = codeController.text.trim();
|
||||
final fullPhone = '$dialCode$phoneNumber';
|
||||
|
||||
if (phoneNumber.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: 'errorMessagePhoneIsEmpty',
|
||||
codeVerified: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (code.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: 'errorMessageCodeIsEmpty',
|
||||
codeVerified: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: true,
|
||||
errorMessage: '',
|
||||
codeVerified: false,
|
||||
);
|
||||
|
||||
try {
|
||||
await _linkPhoneUseCase.verifyCode(phone: fullPhone, code: code);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: '',
|
||||
codeVerified: true,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: e.toString(),
|
||||
codeVerified: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void disposeControllers() {
|
||||
phoneNumberController.removeListener(_onPhoneNumberChanged);
|
||||
phoneNumberController.dispose();
|
||||
codeController.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'link_phone_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyLinkPhoneViewState with _$LegacyLinkPhoneViewState {
|
||||
const factory LegacyLinkPhoneViewState({
|
||||
@Default('') String phoneNumber,
|
||||
@Default('+34') String dialCode,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool isLoading,
|
||||
@Default(false) bool codeRequested,
|
||||
@Default(false) bool codeVerified,
|
||||
}) = _LegacyLinkPhoneViewState;
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
// 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 'link_phone_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyLinkPhoneViewState {
|
||||
|
||||
String get phoneNumber; String get dialCode; String get errorMessage; bool get isLoading; bool get codeRequested; bool get codeVerified;
|
||||
/// Create a copy of LegacyLinkPhoneViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyLinkPhoneViewStateCopyWith<LegacyLinkPhoneViewState> get copyWith => _$LegacyLinkPhoneViewStateCopyWithImpl<LegacyLinkPhoneViewState>(this as LegacyLinkPhoneViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLinkPhoneViewState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.codeRequested, codeRequested) || other.codeRequested == codeRequested)&&(identical(other.codeVerified, codeVerified) || other.codeVerified == codeVerified));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,phoneNumber,dialCode,errorMessage,isLoading,codeRequested,codeVerified);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLinkPhoneViewState(phoneNumber: $phoneNumber, dialCode: $dialCode, errorMessage: $errorMessage, isLoading: $isLoading, codeRequested: $codeRequested, codeVerified: $codeVerified)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyLinkPhoneViewStateCopyWith<$Res> {
|
||||
factory $LegacyLinkPhoneViewStateCopyWith(LegacyLinkPhoneViewState value, $Res Function(LegacyLinkPhoneViewState) _then) = _$LegacyLinkPhoneViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String phoneNumber, String dialCode, String errorMessage, bool isLoading, bool codeRequested, bool codeVerified
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyLinkPhoneViewStateCopyWithImpl<$Res>
|
||||
implements $LegacyLinkPhoneViewStateCopyWith<$Res> {
|
||||
_$LegacyLinkPhoneViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyLinkPhoneViewState _self;
|
||||
final $Res Function(LegacyLinkPhoneViewState) _then;
|
||||
|
||||
/// Create a copy of LegacyLinkPhoneViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = null,Object? dialCode = null,Object? errorMessage = null,Object? isLoading = null,Object? codeRequested = null,Object? codeVerified = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,codeRequested: null == codeRequested ? _self.codeRequested : codeRequested // ignore: cast_nullable_to_non_nullable
|
||||
as bool,codeVerified: null == codeVerified ? _self.codeVerified : codeVerified // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyLinkPhoneViewState].
|
||||
extension LegacyLinkPhoneViewStatePatterns on LegacyLinkPhoneViewState {
|
||||
/// 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( _LegacyLinkPhoneViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState() 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( _LegacyLinkPhoneViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState():
|
||||
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( _LegacyLinkPhoneViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState() 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 phoneNumber, String dialCode, String errorMessage, bool isLoading, bool codeRequested, bool codeVerified)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState() when $default != null:
|
||||
return $default(_that.phoneNumber,_that.dialCode,_that.errorMessage,_that.isLoading,_that.codeRequested,_that.codeVerified);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 phoneNumber, String dialCode, String errorMessage, bool isLoading, bool codeRequested, bool codeVerified) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState():
|
||||
return $default(_that.phoneNumber,_that.dialCode,_that.errorMessage,_that.isLoading,_that.codeRequested,_that.codeVerified);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 phoneNumber, String dialCode, String errorMessage, bool isLoading, bool codeRequested, bool codeVerified)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLinkPhoneViewState() when $default != null:
|
||||
return $default(_that.phoneNumber,_that.dialCode,_that.errorMessage,_that.isLoading,_that.codeRequested,_that.codeVerified);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyLinkPhoneViewState implements LegacyLinkPhoneViewState {
|
||||
const _LegacyLinkPhoneViewState({this.phoneNumber = '', this.dialCode = '+34', this.errorMessage = '', this.isLoading = false, this.codeRequested = false, this.codeVerified = false});
|
||||
|
||||
|
||||
@override@JsonKey() final String phoneNumber;
|
||||
@override@JsonKey() final String dialCode;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool codeRequested;
|
||||
@override@JsonKey() final bool codeVerified;
|
||||
|
||||
/// Create a copy of LegacyLinkPhoneViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyLinkPhoneViewStateCopyWith<_LegacyLinkPhoneViewState> get copyWith => __$LegacyLinkPhoneViewStateCopyWithImpl<_LegacyLinkPhoneViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLinkPhoneViewState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.codeRequested, codeRequested) || other.codeRequested == codeRequested)&&(identical(other.codeVerified, codeVerified) || other.codeVerified == codeVerified));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,phoneNumber,dialCode,errorMessage,isLoading,codeRequested,codeVerified);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLinkPhoneViewState(phoneNumber: $phoneNumber, dialCode: $dialCode, errorMessage: $errorMessage, isLoading: $isLoading, codeRequested: $codeRequested, codeVerified: $codeVerified)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyLinkPhoneViewStateCopyWith<$Res> implements $LegacyLinkPhoneViewStateCopyWith<$Res> {
|
||||
factory _$LegacyLinkPhoneViewStateCopyWith(_LegacyLinkPhoneViewState value, $Res Function(_LegacyLinkPhoneViewState) _then) = __$LegacyLinkPhoneViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String phoneNumber, String dialCode, String errorMessage, bool isLoading, bool codeRequested, bool codeVerified
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyLinkPhoneViewStateCopyWithImpl<$Res>
|
||||
implements _$LegacyLinkPhoneViewStateCopyWith<$Res> {
|
||||
__$LegacyLinkPhoneViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyLinkPhoneViewState _self;
|
||||
final $Res Function(_LegacyLinkPhoneViewState) _then;
|
||||
|
||||
/// Create a copy of LegacyLinkPhoneViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,Object? dialCode = null,Object? errorMessage = null,Object? isLoading = null,Object? codeRequested = null,Object? codeVerified = null,}) {
|
||||
return _then(_LegacyLinkPhoneViewState(
|
||||
phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,codeRequested: null == codeRequested ? _self.codeRequested : codeRequested // ignore: cast_nullable_to_non_nullable
|
||||
as bool,codeVerified: null == codeVerified ? _self.codeVerified : codeVerified // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/verify_code/verify_link_phone_code_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class LegacyVerifyLinkPhoneCodeBuilder {
|
||||
const LegacyVerifyLinkPhoneCodeBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: LegacyVerifyLinkPhoneCodeScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/state/link_phone_view_model.dart';
|
||||
import 'package:legacy_auth/src/features/link_phone/presentation/widgets/link_phone_code_input.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class LegacyVerifyLinkPhoneCodeScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const LegacyVerifyLinkPhoneCodeScreen({
|
||||
super.key,
|
||||
required this.navigationContract,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final viewModel = ref.read(legacyLinkPhoneViewModelProvider.notifier);
|
||||
final viewState = ref.watch(legacyLinkPhoneViewModelProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 48,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.connect),
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: context.translate(I18n.verificationCodeSentTo),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${viewState.dialCode}${viewState.phoneNumber}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
Text(
|
||||
context.translate(I18n.enterCodeHere),
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
LegacyLinkPhoneCodeInput(
|
||||
length: 6,
|
||||
onCodeChanged: viewModel.updateCode,
|
||||
),
|
||||
|
||||
if (viewState.errorMessage.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
viewState.errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color.fromRGBO(239, 17, 17, 1),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
PrimaryButton(
|
||||
onPressed: () async {
|
||||
await viewModel.verifyCode();
|
||||
final updatedState = ref.read(legacyLinkPhoneViewModelProvider);
|
||||
|
||||
if (updatedState.codeVerified) {
|
||||
navigationContract.pushTo(AppRoutes.login);
|
||||
}
|
||||
},
|
||||
text: context.translate(I18n.enter),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
context.translate(I18n.didNotReceiveIt),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
letterSpacing: 0,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextButton(
|
||||
onPressed: () => navigationContract.goBack(),
|
||||
text: context.translate(I18n.tryAgain),
|
||||
size: 18,
|
||||
weight: FontWeight.w500,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class LegacyLinkPhoneCodeInput extends StatefulWidget {
|
||||
const LegacyLinkPhoneCodeInput({
|
||||
super.key,
|
||||
this.length = 6,
|
||||
required this.onCodeChanged,
|
||||
});
|
||||
|
||||
final int length;
|
||||
final ValueChanged<String> onCodeChanged;
|
||||
|
||||
@override
|
||||
State<LegacyLinkPhoneCodeInput> createState() => _LegacyLinkPhoneCodeInputState();
|
||||
}
|
||||
|
||||
class _LegacyLinkPhoneCodeInputState extends State<LegacyLinkPhoneCodeInput> {
|
||||
late final List<TextEditingController> _controllers;
|
||||
late final List<FocusNode> _focusNodes;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controllers = List<TextEditingController>.generate(
|
||||
widget.length,
|
||||
(_) => TextEditingController(),
|
||||
);
|
||||
_focusNodes = List<FocusNode>.generate(widget.length, (_) => FocusNode());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final controller in _controllers) {
|
||||
controller.dispose();
|
||||
}
|
||||
for (final node in _focusNodes) {
|
||||
node.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onDigitChanged(int index, String value) {
|
||||
if (value.length > 1) {
|
||||
final single = value.characters.last;
|
||||
_controllers[index].text = single;
|
||||
_controllers[index].selection = TextSelection.fromPosition(
|
||||
TextPosition(offset: single.length),
|
||||
);
|
||||
}
|
||||
|
||||
if (value.isNotEmpty && index < widget.length - 1) {
|
||||
_focusNodes[index + 1].requestFocus();
|
||||
} else if (value.isEmpty && index > 0) {
|
||||
_focusNodes[index - 1].requestFocus();
|
||||
}
|
||||
|
||||
final code = _controllers.map((c) => c.text).join();
|
||||
widget.onCodeChanged(code);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
spacing: 8,
|
||||
children: List<Widget>.generate(widget.length, (int i) {
|
||||
return Expanded(
|
||||
child: TextField(
|
||||
controller: _controllers[i],
|
||||
focusNode: _focusNodes[i],
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '0',
|
||||
counterText: '',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
maxLength: 1,
|
||||
onChanged: (value) => _onDigitChanged(i, value),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class LegacyLoadingScreen extends StatelessWidget{
|
||||
const LegacyLoadingScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
spacing: 50,
|
||||
children: [
|
||||
Spacer(flex: 8),
|
||||
SvgPicture.asset("assets/shared/images/logo_sf.svg"),
|
||||
AppLoadingIndicator(),
|
||||
Spacer(flex: 10)
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_response_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyLoginResponseEntity with _$LegacyLoginResponseEntity {
|
||||
const factory LegacyLoginResponseEntity({
|
||||
required String token,
|
||||
@Default(<LegacyAvailableMethodEntity>[])
|
||||
List<LegacyAvailableMethodEntity> availableMethods,
|
||||
}) = _LegacyLoginResponseEntity;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class LegacyAvailableMethodEntity with _$LegacyAvailableMethodEntity {
|
||||
const factory LegacyAvailableMethodEntity({
|
||||
required String id,
|
||||
required String userId,
|
||||
required String methodType,
|
||||
required String status,
|
||||
required bool isDefault,
|
||||
required int createdAt,
|
||||
}) = _LegacyAvailableMethodEntity;
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
// 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 'login_response_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyLoginResponseEntity {
|
||||
|
||||
String get token; List<LegacyAvailableMethodEntity> get availableMethods;
|
||||
/// Create a copy of LegacyLoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyLoginResponseEntityCopyWith<LegacyLoginResponseEntity> get copyWith => _$LegacyLoginResponseEntityCopyWithImpl<LegacyLoginResponseEntity>(this as LegacyLoginResponseEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLoginResponseEntity&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginResponseEntity(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyLoginResponseEntityCopyWith<$Res> {
|
||||
factory $LegacyLoginResponseEntityCopyWith(LegacyLoginResponseEntity value, $Res Function(LegacyLoginResponseEntity) _then) = _$LegacyLoginResponseEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String token, List<LegacyAvailableMethodEntity> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyLoginResponseEntityCopyWithImpl<$Res>
|
||||
implements $LegacyLoginResponseEntityCopyWith<$Res> {
|
||||
_$LegacyLoginResponseEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyLoginResponseEntity _self;
|
||||
final $Res Function(LegacyLoginResponseEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodEntity>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyLoginResponseEntity].
|
||||
extension LegacyLoginResponseEntityPatterns on LegacyLoginResponseEntity {
|
||||
/// 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( _LegacyLoginResponseEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity() 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( _LegacyLoginResponseEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity():
|
||||
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( _LegacyLoginResponseEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity() 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 token, List<LegacyAvailableMethodEntity> availableMethods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<LegacyAvailableMethodEntity> availableMethods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity():
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<LegacyAvailableMethodEntity> availableMethods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginResponseEntity() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyLoginResponseEntity implements LegacyLoginResponseEntity {
|
||||
const _LegacyLoginResponseEntity({required this.token, final List<LegacyAvailableMethodEntity> availableMethods = const <LegacyAvailableMethodEntity>[]}): _availableMethods = availableMethods;
|
||||
|
||||
|
||||
@override final String token;
|
||||
final List<LegacyAvailableMethodEntity> _availableMethods;
|
||||
@override@JsonKey() List<LegacyAvailableMethodEntity> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of LegacyLoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyLoginResponseEntityCopyWith<_LegacyLoginResponseEntity> get copyWith => __$LegacyLoginResponseEntityCopyWithImpl<_LegacyLoginResponseEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLoginResponseEntity&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(_availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginResponseEntity(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyLoginResponseEntityCopyWith<$Res> implements $LegacyLoginResponseEntityCopyWith<$Res> {
|
||||
factory _$LegacyLoginResponseEntityCopyWith(_LegacyLoginResponseEntity value, $Res Function(_LegacyLoginResponseEntity) _then) = __$LegacyLoginResponseEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String token, List<LegacyAvailableMethodEntity> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyLoginResponseEntityCopyWithImpl<$Res>
|
||||
implements _$LegacyLoginResponseEntityCopyWith<$Res> {
|
||||
__$LegacyLoginResponseEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyLoginResponseEntity _self;
|
||||
final $Res Function(_LegacyLoginResponseEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_LegacyLoginResponseEntity(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodEntity>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LegacyAvailableMethodEntity {
|
||||
|
||||
String get id; String get userId; String get methodType; String get status; bool get isDefault; int get createdAt;
|
||||
/// Create a copy of LegacyAvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyAvailableMethodEntityCopyWith<LegacyAvailableMethodEntity> get copyWith => _$LegacyAvailableMethodEntityCopyWithImpl<LegacyAvailableMethodEntity>(this as LegacyAvailableMethodEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyAvailableMethodEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAvailableMethodEntity(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyAvailableMethodEntityCopyWith<$Res> {
|
||||
factory $LegacyAvailableMethodEntityCopyWith(LegacyAvailableMethodEntity value, $Res Function(LegacyAvailableMethodEntity) _then) = _$LegacyAvailableMethodEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyAvailableMethodEntityCopyWithImpl<$Res>
|
||||
implements $LegacyAvailableMethodEntityCopyWith<$Res> {
|
||||
_$LegacyAvailableMethodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyAvailableMethodEntity _self;
|
||||
final $Res Function(LegacyAvailableMethodEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyAvailableMethodEntity].
|
||||
extension LegacyAvailableMethodEntityPatterns on LegacyAvailableMethodEntity {
|
||||
/// 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( _LegacyAvailableMethodEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity() 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( _LegacyAvailableMethodEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity():
|
||||
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( _LegacyAvailableMethodEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity():
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyAvailableMethodEntity() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyAvailableMethodEntity implements LegacyAvailableMethodEntity {
|
||||
const _LegacyAvailableMethodEntity({required this.id, required this.userId, required this.methodType, required this.status, required this.isDefault, required this.createdAt});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String userId;
|
||||
@override final String methodType;
|
||||
@override final String status;
|
||||
@override final bool isDefault;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyAvailableMethodEntityCopyWith<_LegacyAvailableMethodEntity> get copyWith => __$LegacyAvailableMethodEntityCopyWithImpl<_LegacyAvailableMethodEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyAvailableMethodEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyAvailableMethodEntity(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyAvailableMethodEntityCopyWith<$Res> implements $LegacyAvailableMethodEntityCopyWith<$Res> {
|
||||
factory _$LegacyAvailableMethodEntityCopyWith(_LegacyAvailableMethodEntity value, $Res Function(_LegacyAvailableMethodEntity) _then) = __$LegacyAvailableMethodEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyAvailableMethodEntityCopyWithImpl<$Res>
|
||||
implements _$LegacyAvailableMethodEntityCopyWith<$Res> {
|
||||
__$LegacyAvailableMethodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyAvailableMethodEntity _self;
|
||||
final $Res Function(_LegacyAvailableMethodEntity) _then;
|
||||
|
||||
/// Create a copy of LegacyAvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_LegacyAvailableMethodEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
|
||||
abstract class LegacyLoginUseCase {
|
||||
Future<LegacyLoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/login_use_case.dart';
|
||||
|
||||
class LegacyLoginUseCaseImpl implements LegacyLoginUseCase {
|
||||
LegacyLoginUseCaseImpl(this._repository);
|
||||
|
||||
final LegacyAuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<LegacyLoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) {
|
||||
return _repository.login(email: email, password: password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class LegacyTwoFARequestCodeUseCase {
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
|
||||
class LegacyTwoFARequestCodeUseCaseImpl implements LegacyTwoFARequestCodeUseCase {
|
||||
LegacyTwoFARequestCodeUseCaseImpl(this._repository);
|
||||
|
||||
final LegacyAuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _repository.twoFARequestCode(token: token, methodType: methodType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract class LegacyTwoFASendCodeUseCase {
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
|
||||
class LegacyTwoFASendCodeUseCaseImpl implements LegacyTwoFASendCodeUseCase {
|
||||
LegacyTwoFASendCodeUseCaseImpl(this._repository);
|
||||
|
||||
final LegacyAuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _repository.twoFASendCode(
|
||||
token: token,
|
||||
methodType: methodType,
|
||||
code: code,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:legacy_auth/src/features/login/presentation/login_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
class LegacyLoginBuilder {
|
||||
const LegacyLoginBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: LegacyLoginScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegacyLoadingGoogleScreen extends StatelessWidget {
|
||||
const LegacyLoadingGoogleScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
spacing: 50,
|
||||
children: [
|
||||
Spacer(flex: 8),
|
||||
Text(
|
||||
"Continuar con Google",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30),
|
||||
),
|
||||
AppLoadingIndicator(),
|
||||
Text("Redirigiendo a Google"),
|
||||
Spacer(flex: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
import 'package:legacy_auth/src/features/login/presentation/state/login_view_model.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/widgets/field_error_text.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/widgets/two_factor_sheet_launcher.dart';
|
||||
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 LegacyLoginScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const LegacyLoginScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final bool isLoading = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.isLoading),
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
legacyLoginViewModelProvider.select(
|
||||
(s) => (
|
||||
error: s.errorMessage,
|
||||
twoFA: s.twoFARequested,
|
||||
verified: s.twoFAVerified,
|
||||
),
|
||||
),
|
||||
(previous, next) {
|
||||
if (next.error.isNotEmpty && !next.twoFA) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(next.error),
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
if (next.twoFA && previous?.twoFA != true) {
|
||||
showTwoFactorSheet(context);
|
||||
}
|
||||
if (next.verified) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.loginSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigationContract.goTo(AppRoutes.controlPanel);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
child: AbsorbPointer(
|
||||
absorbing: isLoading,
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_Header(theme: theme),
|
||||
SizedBox(height: 48),
|
||||
_EmailSection(),
|
||||
SizedBox(height: 24),
|
||||
_PasswordSection(
|
||||
onSubmitted: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
ref.read(legacyLoginViewModelProvider.notifier).login();
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
_ForgotPassword(navigationContract: navigationContract),
|
||||
SizedBox(height: 30),
|
||||
_SignInSection(
|
||||
theme: theme,
|
||||
onSignIn: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
ref.read(legacyLoginViewModelProvider.notifier).login();
|
||||
},
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
_Footer(navigationContract: navigationContract),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Header extends StatelessWidget {
|
||||
const _Header({required this.theme});
|
||||
final ThemePort theme;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check,
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
size: 54,
|
||||
),
|
||||
Text(
|
||||
context.translate(I18n.welcome),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EmailSection extends ConsumerWidget {
|
||||
const _EmailSection();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(legacyLoginViewModelProvider.notifier);
|
||||
final String emailErrorKey = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.emailError),
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CustomTextField(
|
||||
hint: context.translate(I18n.username),
|
||||
label: context.translate(I18n.username),
|
||||
controller: vm.emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
FieldErrorText(errorKey: emailErrorKey),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PasswordSection extends ConsumerWidget {
|
||||
const _PasswordSection({required this.onSubmitted});
|
||||
final VoidCallback onSubmitted;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final vm = ref.read(legacyLoginViewModelProvider.notifier);
|
||||
final bool passwordVisible = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.passwordVisible),
|
||||
);
|
||||
final String passwordErrorKey = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.passwordError),
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CustomTextField(
|
||||
showPassword: passwordVisible,
|
||||
label: context.translate(I18n.password),
|
||||
hint: '********',
|
||||
controller: vm.passwordController,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
),
|
||||
FieldErrorText(errorKey: passwordErrorKey),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ForgotPassword extends ConsumerWidget {
|
||||
const _ForgotPassword({required this.navigationContract});
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bool isLoading = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.isLoading),
|
||||
);
|
||||
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: CustomTextButton(
|
||||
text: context.translate(I18n.forgotPassword),
|
||||
onPressed: isLoading
|
||||
? () {}
|
||||
: () => navigationContract.pushTo(AppRoutes.legacyRecoverPassword),
|
||||
size: 16,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SignInSection extends ConsumerWidget {
|
||||
const _SignInSection({required this.onSignIn, required this.theme});
|
||||
|
||||
final VoidCallback onSignIn;
|
||||
final ThemePort theme;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bool isLoading = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.isLoading),
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
PrimaryButton(
|
||||
onPressed: isLoading ? () {} : onSignIn,
|
||||
text: context.translate(I18n.signIn),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
leading: isLoading
|
||||
? const SizedBox(
|
||||
height: 18,
|
||||
width: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Footer extends ConsumerWidget {
|
||||
const _Footer({required this.navigationContract});
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bool isLoading = ref.watch(
|
||||
legacyLoginViewModelProvider.select((s) => s.isLoading),
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.dontHaveAccount),
|
||||
style: const TextStyle(fontSize: 18, letterSpacing: 0),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () => navigationContract.pushTo(AppRoutes.legacySignup),
|
||||
child: Text(
|
||||
context.translate(I18n.createOneNow),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/login_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/login_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyLoginUseCaseProvider = Provider.autoDispose<LegacyLoginUseCase>((ref) {
|
||||
final authRepository = ref.read(legacyAuthRepositoryProvider);
|
||||
return LegacyLoginUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyTwoFARequestCodeUseCaseProvider =
|
||||
Provider.autoDispose<LegacyTwoFARequestCodeUseCase>((ref) {
|
||||
final authRepository = ref.read(legacyAuthRepositoryProvider);
|
||||
return LegacyTwoFARequestCodeUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final legacyTwoFASendCodeUseCaseProvider = Provider.autoDispose<LegacyTwoFASendCodeUseCase>(
|
||||
(ref) {
|
||||
final authRepository = ref.read(legacyAuthRepositoryProvider);
|
||||
return LegacyTwoFASendCodeUseCaseImpl(authRepository);
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,271 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:legacy_auth/src/features/login/domain/login_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/providers/login_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/providers/two_fa_request_code_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/providers/two_fa_send_code_provider.dart';
|
||||
import 'package:legacy_auth/src/features/login/presentation/state/login_view_state.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
final legacyLoginViewModelProvider =
|
||||
NotifierProvider.autoDispose<LegacyLoginViewModel, LegacyLoginViewState>(
|
||||
LegacyLoginViewModel.new,
|
||||
);
|
||||
|
||||
class LegacyLoginViewModel extends Notifier<LegacyLoginViewState> {
|
||||
late final LegacyLoginUseCase _loginUseCase;
|
||||
late final LegacyTwoFARequestCodeUseCase _twoFARequestCodeUseCase;
|
||||
late final LegacyTwoFASendCodeUseCase _twoFASendCodeUseCase;
|
||||
late final GetUserInfoUseCase _getUserInfoUseCase;
|
||||
|
||||
late final TextEditingController emailController;
|
||||
late final TextEditingController passwordController;
|
||||
|
||||
Timer? _cooldownTimer;
|
||||
|
||||
static const int resendCooldownSeconds = 30;
|
||||
|
||||
static final RegExp _emailRegex = RegExp(
|
||||
r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$',
|
||||
caseSensitive: false,
|
||||
);
|
||||
|
||||
@override
|
||||
LegacyLoginViewState build() {
|
||||
_loginUseCase = ref.read(legacyLoginUseCaseProvider);
|
||||
_twoFARequestCodeUseCase = ref.read(legacyTwoFARequestCodeUseCaseProvider);
|
||||
_twoFASendCodeUseCase = ref.read(legacyTwoFASendCodeUseCaseProvider);
|
||||
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
|
||||
|
||||
emailController = TextEditingController();
|
||||
emailController.addListener(_onEmailChanged);
|
||||
|
||||
passwordController = TextEditingController();
|
||||
passwordController.addListener(_onPasswordChanged);
|
||||
|
||||
ref.onDispose(_dispose);
|
||||
|
||||
return const LegacyLoginViewState();
|
||||
}
|
||||
|
||||
void _onEmailChanged() {
|
||||
final value = emailController.text;
|
||||
if (value == state.email) return;
|
||||
state = state.copyWith(
|
||||
email: value,
|
||||
errorMessage: '',
|
||||
emailError: state.showErrors ? _validateEmail(value) : state.emailError,
|
||||
);
|
||||
}
|
||||
|
||||
void _onPasswordChanged() {
|
||||
final value = passwordController.text;
|
||||
if (value == state.password) return;
|
||||
state = state.copyWith(
|
||||
password: value,
|
||||
errorMessage: '',
|
||||
passwordError:
|
||||
state.showErrors ? _validatePassword(value) : state.passwordError,
|
||||
);
|
||||
}
|
||||
|
||||
void _dispose() {
|
||||
_cooldownTimer?.cancel();
|
||||
emailController.removeListener(_onEmailChanged);
|
||||
emailController.dispose();
|
||||
passwordController.removeListener(_onPasswordChanged);
|
||||
passwordController.dispose();
|
||||
}
|
||||
|
||||
void togglePasswordVisible() {
|
||||
state = state.copyWith(passwordVisible: !state.passwordVisible);
|
||||
}
|
||||
|
||||
String _validateEmail(String value) {
|
||||
final email = value.trim();
|
||||
if (email.isEmpty) return I18n.errorEmailRequired;
|
||||
if (!_emailRegex.hasMatch(email)) return I18n.errorEmailInvalid;
|
||||
return '';
|
||||
}
|
||||
|
||||
String _validatePassword(String value) {
|
||||
final password = value.trim();
|
||||
if (password.isEmpty) return I18n.errorPasswordRequired;
|
||||
if (password.length < 6) return I18n.errorPasswordMinLength;
|
||||
return '';
|
||||
}
|
||||
|
||||
bool _validateForm() {
|
||||
final emailError = _validateEmail(state.email);
|
||||
final passwordError = _validatePassword(state.password);
|
||||
|
||||
state = state.copyWith(
|
||||
showErrors: true,
|
||||
emailError: emailError,
|
||||
passwordError: passwordError,
|
||||
errorMessage: '',
|
||||
);
|
||||
|
||||
return emailError.isEmpty && passwordError.isEmpty;
|
||||
}
|
||||
|
||||
Future<void> login() async {
|
||||
if (!_validateForm()) return;
|
||||
|
||||
final email = state.email.trim();
|
||||
final password = state.password.trim();
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: true,
|
||||
twoFARequested: false,
|
||||
twoFAVerified: false,
|
||||
);
|
||||
|
||||
try {
|
||||
final response = await _loginUseCase.login(
|
||||
email: email,
|
||||
password: password,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
token: response.token,
|
||||
availableMethods: response.availableMethods,
|
||||
code: '',
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: _formatErrorMessage(e),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await _requestTwoFACode(updateLoading: true);
|
||||
}
|
||||
|
||||
void dismissTwoFA() {
|
||||
state = state.copyWith(twoFARequested: false);
|
||||
}
|
||||
|
||||
void setCode(String code) {
|
||||
state = state.copyWith(code: code, codeError: '');
|
||||
}
|
||||
|
||||
String _validateCode(String value) {
|
||||
final code = value.trim();
|
||||
if (code.isEmpty) return I18n.errorTwoFactorCodeRequired;
|
||||
if (code.length != 6) return I18n.errorTwoFactorCodeInvalidLength;
|
||||
return '';
|
||||
}
|
||||
|
||||
Future<void> _requestTwoFACode({bool updateLoading = false}) async {
|
||||
if (state.availableMethods.isEmpty) {
|
||||
state = state.copyWith(
|
||||
errorMessage: I18n.errorTwoFactorNoMethods,
|
||||
isLoading: updateLoading ? false : state.isLoading,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await _twoFARequestCodeUseCase.twoFARequestCode(
|
||||
token: state.token,
|
||||
methodType: state.availableMethods.first.methodType,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
_startResendCooldown();
|
||||
state = state.copyWith(
|
||||
twoFARequested: true,
|
||||
isLoading: updateLoading ? false : state.isLoading,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
errorMessage: _formatErrorMessage(e),
|
||||
isLoading: updateLoading ? false : state.isLoading,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _startResendCooldown() {
|
||||
_cooldownTimer?.cancel();
|
||||
state = state.copyWith(resendCooldown: resendCooldownSeconds);
|
||||
_cooldownTimer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) {
|
||||
if (!ref.mounted) {
|
||||
_cooldownTimer?.cancel();
|
||||
return;
|
||||
}
|
||||
final next = state.resendCooldown - 1;
|
||||
state = state.copyWith(resendCooldown: next);
|
||||
if (next <= 0) _cooldownTimer?.cancel();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> submitTwoFACode() async {
|
||||
final codeError = _validateCode(state.code);
|
||||
if (codeError.isNotEmpty) {
|
||||
state = state.copyWith(showErrors: true, codeError: codeError);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.availableMethods.isEmpty) return;
|
||||
|
||||
final method = state.availableMethods.firstWhere(
|
||||
(m) => m.isDefault,
|
||||
orElse: () => state.availableMethods.first,
|
||||
);
|
||||
|
||||
state = state.copyWith(isLoading: true, errorMessage: '', codeError: '');
|
||||
|
||||
try {
|
||||
await _twoFASendCodeUseCase.twoFASendCode(
|
||||
token: state.token,
|
||||
code: state.code.trim(),
|
||||
methodType: method.methodType,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
await _getUserInfoUseCase.getUserInfo();
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(isLoading: false, twoFAVerified: true);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: _formatErrorMessage(e),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> resendCode() async {
|
||||
state = state.copyWith(code: '', isLoading: true);
|
||||
await _requestTwoFACode(updateLoading: true);
|
||||
}
|
||||
|
||||
static String _formatErrorMessage(Object error) {
|
||||
final raw = error.toString();
|
||||
if (raw.startsWith('Exception: ')) {
|
||||
return raw.substring('Exception: '.length);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LegacyLoginViewState with _$LegacyLoginViewState {
|
||||
const factory LegacyLoginViewState({
|
||||
@Default('') String email,
|
||||
@Default('') String password,
|
||||
@Default(false) bool passwordVisible,
|
||||
@Default('') String emailError,
|
||||
@Default('') String passwordError,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool showErrors,
|
||||
@Default(false) bool isLoading,
|
||||
@Default(<LegacyAvailableMethodEntity>[])
|
||||
List<LegacyAvailableMethodEntity> availableMethods,
|
||||
@Default('') String token,
|
||||
@Default(false) bool twoFARequested,
|
||||
@Default('') String code,
|
||||
@Default('') String codeError,
|
||||
@Default(0) int resendCooldown,
|
||||
@Default(false) bool twoFAVerified,
|
||||
}) = _LegacyLoginViewState;
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
// 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 'login_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LegacyLoginViewState {
|
||||
|
||||
String get email; String get password; bool get passwordVisible; String get emailError; String get passwordError; String get errorMessage; bool get showErrors; bool get isLoading; List<LegacyAvailableMethodEntity> get availableMethods; String get token; bool get twoFARequested; String get code; String get codeError; int get resendCooldown; bool get twoFAVerified;
|
||||
/// Create a copy of LegacyLoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LegacyLoginViewStateCopyWith<LegacyLoginViewState> get copyWith => _$LegacyLoginViewStateCopyWithImpl<LegacyLoginViewState>(this as LegacyLoginViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LegacyLoginViewStateCopyWith<$Res> {
|
||||
factory $LegacyLoginViewStateCopyWith(LegacyLoginViewState value, $Res Function(LegacyLoginViewState) _then) = _$LegacyLoginViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List<LegacyAvailableMethodEntity> availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LegacyLoginViewStateCopyWithImpl<$Res>
|
||||
implements $LegacyLoginViewStateCopyWith<$Res> {
|
||||
_$LegacyLoginViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LegacyLoginViewState _self;
|
||||
final $Res Function(LegacyLoginViewState) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,passwordVisible: null == passwordVisible ? _self.passwordVisible : passwordVisible // ignore: cast_nullable_to_non_nullable
|
||||
as bool,emailError: null == emailError ? _self.emailError : emailError // ignore: cast_nullable_to_non_nullable
|
||||
as String,passwordError: null == passwordError ? _self.passwordError : passwordError // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,showErrors: null == showErrors ? _self.showErrors : showErrors // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodEntity>,token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,twoFARequested: null == twoFARequested ? _self.twoFARequested : twoFARequested // ignore: cast_nullable_to_non_nullable
|
||||
as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
|
||||
as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable
|
||||
as String,resendCooldown: null == resendCooldown ? _self.resendCooldown : resendCooldown // ignore: cast_nullable_to_non_nullable
|
||||
as int,twoFAVerified: null == twoFAVerified ? _self.twoFAVerified : twoFAVerified // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LegacyLoginViewState].
|
||||
extension LegacyLoginViewStatePatterns on LegacyLoginViewState {
|
||||
/// 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( _LegacyLoginViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState() 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( _LegacyLoginViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState():
|
||||
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( _LegacyLoginViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState() 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 email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List<LegacyAvailableMethodEntity> availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState() when $default != null:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);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 email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List<LegacyAvailableMethodEntity> availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState():
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);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 email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List<LegacyAvailableMethodEntity> availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LegacyLoginViewState() when $default != null:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LegacyLoginViewState implements LegacyLoginViewState {
|
||||
const _LegacyLoginViewState({this.email = '', this.password = '', this.passwordVisible = false, this.emailError = '', this.passwordError = '', this.errorMessage = '', this.showErrors = false, this.isLoading = false, final List<LegacyAvailableMethodEntity> availableMethods = const <LegacyAvailableMethodEntity>[], this.token = '', this.twoFARequested = false, this.code = '', this.codeError = '', this.resendCooldown = 0, this.twoFAVerified = false}): _availableMethods = availableMethods;
|
||||
|
||||
|
||||
@override@JsonKey() final String email;
|
||||
@override@JsonKey() final String password;
|
||||
@override@JsonKey() final bool passwordVisible;
|
||||
@override@JsonKey() final String emailError;
|
||||
@override@JsonKey() final String passwordError;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool showErrors;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
final List<LegacyAvailableMethodEntity> _availableMethods;
|
||||
@override@JsonKey() List<LegacyAvailableMethodEntity> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String token;
|
||||
@override@JsonKey() final bool twoFARequested;
|
||||
@override@JsonKey() final String code;
|
||||
@override@JsonKey() final String codeError;
|
||||
@override@JsonKey() final int resendCooldown;
|
||||
@override@JsonKey() final bool twoFAVerified;
|
||||
|
||||
/// Create a copy of LegacyLoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LegacyLoginViewStateCopyWith<_LegacyLoginViewState> get copyWith => __$LegacyLoginViewStateCopyWithImpl<_LegacyLoginViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(_availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LegacyLoginViewStateCopyWith<$Res> implements $LegacyLoginViewStateCopyWith<$Res> {
|
||||
factory _$LegacyLoginViewStateCopyWith(_LegacyLoginViewState value, $Res Function(_LegacyLoginViewState) _then) = __$LegacyLoginViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List<LegacyAvailableMethodEntity> availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LegacyLoginViewStateCopyWithImpl<$Res>
|
||||
implements _$LegacyLoginViewStateCopyWith<$Res> {
|
||||
__$LegacyLoginViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LegacyLoginViewState _self;
|
||||
final $Res Function(_LegacyLoginViewState) _then;
|
||||
|
||||
/// Create a copy of LegacyLoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,}) {
|
||||
return _then(_LegacyLoginViewState(
|
||||
email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
as String,passwordVisible: null == passwordVisible ? _self.passwordVisible : passwordVisible // ignore: cast_nullable_to_non_nullable
|
||||
as bool,emailError: null == emailError ? _self.emailError : emailError // ignore: cast_nullable_to_non_nullable
|
||||
as String,passwordError: null == passwordError ? _self.passwordError : passwordError // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,showErrors: null == showErrors ? _self.showErrors : showErrors // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<LegacyAvailableMethodEntity>,token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,twoFARequested: null == twoFARequested ? _self.twoFARequested : twoFARequested // ignore: cast_nullable_to_non_nullable
|
||||
as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
|
||||
as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable
|
||||
as String,resendCooldown: null == resendCooldown ? _self.resendCooldown : resendCooldown // ignore: cast_nullable_to_non_nullable
|
||||
as int,twoFAVerified: null == twoFAVerified ? _self.twoFAVerified : twoFAVerified // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
class FieldErrorText extends StatelessWidget {
|
||||
const FieldErrorText({super.key, required this.errorKey});
|
||||
final String errorKey;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (errorKey.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
context.translate(errorKey),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user