From c1e0067b7bbaf94cfd13f342cd05aaa8f65ba497 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Fri, 26 Jan 2024 11:57:27 +0800 Subject: [PATCH 01/48] feat(deriv_auth): single entry feat that adds a single entry to the auth package --- packages/deriv_auth/lib/core/core.dart | 15 ++++++ packages/deriv_auth/lib/deriv_auth.dart | 48 +---------------- .../deriv_auth/lib/features/auth/auth.dart | 4 ++ .../deriv_auth/lib/features/features.dart | 8 +++ .../lib/features/get_started/get_started.dart | 2 + .../deriv_auth/lib/features/login/login.dart | 2 + .../reset_password/reset_password.dart | 6 +++ .../features/setting_page/setting_page.dart | 1 + .../lib/features/signup/signup.dart | 15 ++++++ .../features/single_entry/core/auth_data.dart | 23 ++++++++ .../core/models/auth_entry_model.dart | 20 +++++++ .../get_started/pages/get_started_page.dart | 39 ++++++++++++++ .../features/home/pages/home_page.dart | 30 +++++++++++ .../features/login/pages/login_page.dart | 51 ++++++++++++++++++ .../example_login_repository.dart | 36 +++++++++++++ .../login/services/example_login_service.dart | 52 ++++++++++++++++++ .../pages/choose_new_password_page.dart | 25 +++++++++ .../reset_pass/pages/reset_pass_page.dart | 53 +++++++++++++++++++ .../pages/reset_pass_success_page.dart | 49 +++++++++++++++++ .../services/example_reset_pass_service.dart | 17 ++++++ .../settings/pages/settings_page.dart | 28 ++++++++++ .../signup/pages/country_selection_page.dart | 29 ++++++++++ .../signup/pages/set_password_page.dart | 24 +++++++++ .../features/signup/pages/signup_page.dart | 39 ++++++++++++++ .../signup/pages/verification_done_page.dart | 23 ++++++++ .../signup/pages/verify_email_page.dart | 52 ++++++++++++++++++ .../example_referral_repository.dart | 7 +++ .../example_signup_repository.dart | 17 ++++++ .../single_entry/pages/auth_entry_page.dart | 15 ++++++ .../features/single_entry/single_entry.dart | 2 + packages/deriv_auth/pubspec.yaml | 7 ++- 31 files changed, 692 insertions(+), 47 deletions(-) create mode 100644 packages/deriv_auth/lib/core/core.dart create mode 100644 packages/deriv_auth/lib/features/auth/auth.dart create mode 100644 packages/deriv_auth/lib/features/features.dart create mode 100644 packages/deriv_auth/lib/features/get_started/get_started.dart create mode 100644 packages/deriv_auth/lib/features/login/login.dart create mode 100644 packages/deriv_auth/lib/features/reset_password/reset_password.dart create mode 100644 packages/deriv_auth/lib/features/setting_page/setting_page.dart create mode 100644 packages/deriv_auth/lib/features/signup/signup.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/auth_data.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/single_entry.dart diff --git a/packages/deriv_auth/lib/core/core.dart b/packages/deriv_auth/lib/core/core.dart new file mode 100644 index 000000000..6a88d93ab --- /dev/null +++ b/packages/deriv_auth/lib/core/core.dart @@ -0,0 +1,15 @@ +export 'connection_info.dart'; +export 'exceptions/deriv_auth_exception.dart'; +export 'extensions/extensions.dart'; +export 'layouts/deriv_unavailable_country_layout.dart'; +export 'models/account_model.dart'; +export 'models/auth_error/auth_error.dart'; +export 'models/auth_error/auth_error_model.dart'; +export 'models/authorize_model.dart'; +export 'models/verify_email_model.dart'; +export 'services/jwt/repository/deriv_jwt_repository.dart'; +export 'services/jwt/services/deriv_jwt_service.dart'; +export 'services/referral/models/my_affiliate_referral_code_request_model.dart'; +export 'services/token/models/enums.dart'; +export 'services/token/services/deriv_token_service.dart'; +export 'states/states.dart'; diff --git a/packages/deriv_auth/lib/deriv_auth.dart b/packages/deriv_auth/lib/deriv_auth.dart index b04598088..3f246a444 100644 --- a/packages/deriv_auth/lib/deriv_auth.dart +++ b/packages/deriv_auth/lib/deriv_auth.dart @@ -1,46 +1,2 @@ -export 'core/connection_info.dart'; -export 'core/exceptions/deriv_auth_exception.dart'; -export 'core/extensions/extensions.dart'; -export 'core/models/account_model.dart'; -export 'core/models/auth_error/auth_error.dart'; -export 'core/models/auth_error/auth_error_model.dart'; -export 'core/models/authorize_model.dart'; -export 'core/models/verify_email_model.dart'; -export 'core/services/jwt/repository/deriv_jwt_repository.dart'; -export 'core/services/jwt/services/deriv_jwt_service.dart'; -export 'core/services/token/models/enums.dart'; -export 'core/services/token/services/deriv_token_service.dart'; -export 'core/services/referral/models/my_affiliate_referral_code_request_model.dart'; -export 'features/auth/cubit/deriv_auth_cubit.dart'; -export 'features/auth/models/logout/logout_response.dart'; -export 'features/auth/repository/base_auth_repository.dart'; -export 'features/auth/services/deriv_auth_service.dart'; -export 'features/reset_password/cubit/reset_password_cubit.dart'; -export 'features/reset_password/repository/base_reset_password_repository.dart'; -export 'features/reset_password/services/deriv_reset_password_service.dart'; -export 'features/signup/cubit/signup_cubit.dart'; -export 'features/signup/models/new_virtual_account_request_model.dart'; -export 'features/signup/models/signup_error_type.dart'; -export 'features/signup/repository/base_signup_repository.dart'; -export 'features/signup/services/deriv_signup_service.dart'; -export 'features/social_auth/social_auth.dart'; -export 'core/layouts/deriv_unavailable_country_layout.dart'; -export 'features/get_started/presentation/layouts/deriv_get_started_layout.dart'; -export 'features/get_started/models/deriv_get_started_slide_model.dart'; -export 'features/login/presentation/layouts/deriv_2fa_layout.dart'; -export 'features/login/presentation/layouts/deriv_login_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart'; -export 'features/setting_page/presentation/layouts/deriv_setting_layout.dart'; -export 'features/signup/cubit/deriv_country_selection_cubit.dart'; -export 'features/signup/presentation/layouts/deriv_country_selection_layout.dart'; -export 'features/signup/presentation/layouts/deriv_email_not_received_layout.dart'; -export 'features/signup/presentation/layouts/deriv_set_password_layout.dart'; -export 'features/signup/presentation/layouts/deriv_signup_layout.dart'; -export 'features/signup/presentation/layouts/deriv_verification_done_layout.dart'; -export 'features/signup/presentation/layouts/deriv_verify_email_layout.dart'; -export 'features/signup/models/deriv_auth_utm_model.dart'; -export 'features/signup/models/deriv_password_policy_model.dart'; -export 'features/signup/models/deriv_residence_model.dart'; -export 'core/states/states.dart'; +export 'core/core.dart'; +export 'features/features.dart'; diff --git a/packages/deriv_auth/lib/features/auth/auth.dart b/packages/deriv_auth/lib/features/auth/auth.dart new file mode 100644 index 000000000..5c56748d0 --- /dev/null +++ b/packages/deriv_auth/lib/features/auth/auth.dart @@ -0,0 +1,4 @@ +export 'cubit/deriv_auth_cubit.dart'; +export 'models/logout/logout_response.dart'; +export 'repository/base_auth_repository.dart'; +export 'services/deriv_auth_service.dart'; diff --git a/packages/deriv_auth/lib/features/features.dart b/packages/deriv_auth/lib/features/features.dart new file mode 100644 index 000000000..7712e281d --- /dev/null +++ b/packages/deriv_auth/lib/features/features.dart @@ -0,0 +1,8 @@ +export 'auth/auth.dart'; +export 'get_started/get_started.dart'; +export 'login/login.dart'; +export 'reset_password/reset_password.dart'; +export 'setting_page/setting_page.dart'; +export 'signup/signup.dart'; +export 'single_entry/single_entry.dart'; +export 'social_auth/social_auth.dart'; diff --git a/packages/deriv_auth/lib/features/get_started/get_started.dart b/packages/deriv_auth/lib/features/get_started/get_started.dart new file mode 100644 index 000000000..2604a2649 --- /dev/null +++ b/packages/deriv_auth/lib/features/get_started/get_started.dart @@ -0,0 +1,2 @@ +export 'models/deriv_get_started_slide_model.dart'; +export 'presentation/layouts/deriv_get_started_layout.dart'; diff --git a/packages/deriv_auth/lib/features/login/login.dart b/packages/deriv_auth/lib/features/login/login.dart new file mode 100644 index 000000000..2dba1e7ff --- /dev/null +++ b/packages/deriv_auth/lib/features/login/login.dart @@ -0,0 +1,2 @@ +export 'presentation/layouts/deriv_2fa_layout.dart'; +export 'presentation/layouts/deriv_login_layout.dart'; diff --git a/packages/deriv_auth/lib/features/reset_password/reset_password.dart b/packages/deriv_auth/lib/features/reset_password/reset_password.dart new file mode 100644 index 000000000..96b1adce5 --- /dev/null +++ b/packages/deriv_auth/lib/features/reset_password/reset_password.dart @@ -0,0 +1,6 @@ +export 'cubit/reset_password_cubit.dart'; +export 'presentation/layouts/deriv_choose_new_pass_layout.dart'; +export 'presentation/layouts/deriv_reset_pass_layout.dart'; +export 'presentation/layouts/deriv_success_pass_change_layout.dart'; +export 'repository/base_reset_password_repository.dart'; +export 'services/deriv_reset_password_service.dart'; diff --git a/packages/deriv_auth/lib/features/setting_page/setting_page.dart b/packages/deriv_auth/lib/features/setting_page/setting_page.dart new file mode 100644 index 000000000..224c7bff0 --- /dev/null +++ b/packages/deriv_auth/lib/features/setting_page/setting_page.dart @@ -0,0 +1 @@ +export 'presentation/layouts/deriv_setting_layout.dart'; diff --git a/packages/deriv_auth/lib/features/signup/signup.dart b/packages/deriv_auth/lib/features/signup/signup.dart new file mode 100644 index 000000000..5b3b7d992 --- /dev/null +++ b/packages/deriv_auth/lib/features/signup/signup.dart @@ -0,0 +1,15 @@ +export 'cubit/deriv_country_selection_cubit.dart'; +export 'cubit/signup_cubit.dart'; +export 'models/deriv_auth_utm_model.dart'; +export 'models/deriv_password_policy_model.dart'; +export 'models/deriv_residence_model.dart'; +export 'models/new_virtual_account_request_model.dart'; +export 'models/signup_error_type.dart'; +export 'presentation/layouts/deriv_country_selection_layout.dart'; +export 'presentation/layouts/deriv_email_not_received_layout.dart'; +export 'presentation/layouts/deriv_set_password_layout.dart'; +export 'presentation/layouts/deriv_signup_layout.dart'; +export 'presentation/layouts/deriv_verification_done_layout.dart'; +export 'presentation/layouts/deriv_verify_email_layout.dart'; +export 'repository/base_signup_repository.dart'; +export 'services/deriv_signup_service.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart b/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart new file mode 100644 index 000000000..a611c3682 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart @@ -0,0 +1,23 @@ +// ignore_for_file: unnecessary_getters_setters + +import 'models/auth_entry_model.dart'; + +/// Authentication Data Singleton +class AuthData { + /// AuthData instance + factory AuthData() => _instance; + + AuthData._internal(); + + static final AuthData _instance = AuthData._internal(); + + late AuthEntryModel _data; + + /// data getter + AuthEntryModel get data => _data; + + /// data setter + set data(AuthEntryModel data) { + _data = data; + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart new file mode 100644 index 000000000..6c01c33b6 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -0,0 +1,20 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// +class AuthEntryModel { + /// + const AuthEntryModel({ + required this.slides, + required this.appLogoIconPath, + required this.backgroundImagePath, + }); + + /// + final List slides; + + /// + final String appLogoIconPath; + + /// + final String backgroundImagePath; +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart new file mode 100644 index 000000000..264529e39 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart @@ -0,0 +1,39 @@ +import 'package:deriv_auth/features/get_started/presentation/layouts/deriv_get_started_layout.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/settings/pages/settings_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; +import 'package:flutter/material.dart'; + +/// +class GetStartedPage extends StatelessWidget { + /// + const GetStartedPage(); + + /// + + @override + Widget build(BuildContext context) => DerivGetStartedLayout( + slides: AuthData().data.slides, + appLogoIconPath: AuthData().data.appLogoIconPath, + backgroundImagePath: AuthData().data.backgroundImagePath, + onLoginTapped: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const LoginPage(), + ), + ), + onSignupTapped: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const SignupPage(), + ), + ), + onTapNavigation: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => const SettingsPage(), + ), + ); + }, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart b/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart new file mode 100644 index 000000000..b1ae6832a --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Deriv Auth UI'), + ), + body: const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Deriv Auth UI', + style: TextStyle(fontSize: 24), + ), + SizedBox(height: 16), + Text( + 'Deriv Auth UI is a Flutter package that provides a set of ready-to-use widgets for building authentication flows in your app.', + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart new file mode 100644 index 000000000..18d0507ef --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -0,0 +1,51 @@ +import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; +import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; +import 'package:deriv_auth/features/login/presentation/layouts/deriv_login_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/home/pages/home_page.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class LoginPage extends StatefulWidget { + const LoginPage({super.key}); + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + @override + void initState() { + BlocProvider.of(context).logout(); + super.initState(); + } + + @override + Widget build(BuildContext context) => DerivLoginLayout( + welcomeLabel: 'Welcome back!', + greetingLabel: + 'Log in to your Deriv account to start trading and investing.', + onLoggedIn: (_) => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const HomePage(), + ), + ), + authErrorStateHandler: AuthErrorStateHandler(context: context), + onLoginError: (_) {}, + onResetPassTapped: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ResetPassPage(), + ), + ), + onSignupTapped: () => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const SignupPage(), + ), + ), + onSocialAuthButtonPressed: (_) {}, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart new file mode 100644 index 000000000..2e7f72a29 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart @@ -0,0 +1,36 @@ +import 'package:deriv_auth/core/models/landig_comany_model.dart'; +import 'package:deriv_auth/deriv_auth.dart'; + +class ExampleLoginRepository implements BaseAuthRepository { + @override + Future authorize(String? token) => + Future.value(const AuthorizeResponseEntity()); + + @override + Future getDefaultAccount() => Future.value(AccountModel( + accountId: "accountId", + )); + + @override + Future> getLatestAccounts() => Future.value([ + AccountModel( + accountId: "accountId", + ) + ]); + + @override + Future logout() => Future.value(); + + @override + Future onLogin(AuthorizeEntity authorizeEntity) => Future.value(); + + @override + Future onLogout() => Future.value(); + + @override + Future onPostLogout() => Future.value(); + + @override + Future getLandingCompany(String? countryCode) => + Future.value(const LandingCompanyEntity()); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart b/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart new file mode 100644 index 000000000..63c832a4f --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart @@ -0,0 +1,52 @@ +import 'package:deriv_auth/core/models/account_model.dart'; +import 'package:deriv_auth/core/models/authorize_model.dart'; +import 'package:deriv_auth/core/models/landig_comany_model.dart'; +import 'package:deriv_auth/core/services/token/models/login_request.dart'; +import 'package:deriv_auth/features/auth/repository/base_auth_repository.dart'; +import 'package:deriv_auth/features/auth/services/base_auth_service.dart'; + +/// `DerivGO` implementation of [BaseAuthService]. +class ExampleLoginService extends BaseAuthService { + /// Initializes a [ExampleLoginService] class. + ExampleLoginService({ + required this.authRepository, + }); + + /// Interface of all client related functions. + final BaseAuthRepository authRepository; + + @override + Future onLoginRequest( + {required GetTokensRequestModel request, String? userAgent}) async => + const AuthorizeEntity(); + + @override + Future login( + String token, { + required List accounts, + String? signupProvider, + String? refreshToken, + }) async => + const AuthorizeEntity(); + + @override + Future getDefaultAccount() => + authRepository.getDefaultAccount(); + + @override + Future> getLatestAccounts() => + authRepository.getLatestAccounts(); + + @override + Future logout() => authRepository.logout(); + + @override + Future onLogout() => authRepository.onLogout(); + + @override + Future onPostLogout() => authRepository.onPostLogout(); + + @override + Future getLandingCompany(String? countryCode) => + authRepository.getLandingCompany(countryCode); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart new file mode 100644 index 000000000..7dbf5afdb --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -0,0 +1,25 @@ +import 'package:deriv_auth/features/reset_password/cubit/reset_password_cubit.dart'; +import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart'; +import 'package:flutter/material.dart'; + +class ChooseNewPasswordPage extends StatelessWidget { + const ChooseNewPasswordPage({required this.cubit, super.key}); + + final DerivResetPassCubit cubit; + + @override + Widget build(BuildContext context) { + return DerivChooseNewPassLayout( + token: 'token', + onResetPassSucceed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const ResetPassSuccessPage(), + ), + ); + }, + onResetPassError: (_) {}, + ); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart new file mode 100644 index 000000000..08ebc6fdb --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart @@ -0,0 +1,53 @@ +import 'dart:async'; + +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class ResetPassPage extends StatefulWidget { + const ResetPassPage({super.key}); + + @override + State createState() => _ResetPassPageState(); +} + +class _ResetPassPageState extends State { + late final DerivResetPassCubit cubit; + late final StreamSubscription _streamSubscription; + + @override + void initState() { + super.initState(); + + cubit = DerivResetPassCubit(service: ExampleResetPassService()); + + _streamSubscription = cubit.stream.listen((state) { + if (state is DerivResetPassEmailSentState) { + Timer(const Duration(seconds: 3), () { + if (mounted) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => BlocProvider.value( + value: cubit, child: ChooseNewPasswordPage(cubit: cubit)), + )); + } + }); + } + }); + } + + @override + Widget build(BuildContext context) { + return BlocProvider.value( + value: cubit, child: DerivResetPassLayout(onResetPassError: (_) {})); + } + + @override + void dispose() { + cubit.close(); + _streamSubscription.cancel(); + + super.dispose(); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart new file mode 100644 index 000000000..68ce4c769 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart @@ -0,0 +1,49 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +/// Reset password success page +class ResetPassSuccessPage extends StatefulWidget { + /// Reset password success constructor + const ResetPassSuccessPage({super.key}); + + @override + State createState() => _ResetPassSuccessPageState(); +} + +class _ResetPassSuccessPageState extends State { + static const Duration _successPageHoldDuration = Duration(seconds: 2); + + @override + void initState() { + super.initState(); + + // wait for either [_successPageHoldDuration] or logout to finish + // then navigate to loginPage + Future.wait( + >[ + Future.delayed(_successPageHoldDuration), + BlocProvider.of(context).logout(), + ], + ).then( + (_) { + // Navigator.of(context).pushAndRemoveUntil( + // MaterialPageRoute( + // builder: (context) => const GetStartedPage(), + // ), + // (route) => false, + // ); + + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const LoginPage(), + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) => const DerivSuccessPassChangeLayout(); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart new file mode 100644 index 000000000..f65b527e0 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart @@ -0,0 +1,17 @@ +import 'package:deriv_auth/core/models/verify_email_model.dart'; +import 'package:deriv_auth/features/reset_password/services/base_reset_password_service.dart'; + +class ExampleResetPassService implements BaseResetPasswordService { + @override + Future resetPassword({ + required String verificationCode, + required String newPassword, + }) => + Future.value(true); + + @override + Future sendVerificationEmail( + VerifyEmailRequestEntity request, + ) => + Future.value(const VerifyEmailResponseEntity(verifyEmail: true)); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart new file mode 100644 index 000000000..70d990683 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart @@ -0,0 +1,28 @@ +import 'dart:developer' as logger; +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/material.dart'; + +class SettingsPage extends StatefulWidget { + const SettingsPage({super.key}); + + @override + State createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State { + @override + Widget build(BuildContext context) => DerivSettingLayout( + updateFlavorConfigs: _updateFlavorConfig(), + appLabel: 'appLabel', + saveValues: _saveValues, + ); +} + +_saveValues({required String appId, required String endpoint}) { + logger.log('appId is $appId'); + logger.log('endpoint is $endpoint'); +} + +Future _updateFlavorConfig() async { + logger.log('Flavor CONFIG is updated'); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart new file mode 100644 index 000000000..838961327 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart @@ -0,0 +1,29 @@ +import 'package:deriv_auth/features/signup/models/deriv_residence_model.dart'; +import 'package:deriv_auth/features/signup/presentation/layouts/deriv_country_selection_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/set_password_page.dart'; +import 'package:flutter/material.dart'; + +class CountrySelectionPage extends StatelessWidget { + const CountrySelectionPage({required this.verificationCode, super.key}); + + final String verificationCode; + + @override + Widget build(BuildContext context) { + return DerivCountrySelectionLayout( + onNextPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => const SetPasswordPage(verificationCode: 'code'), + )); + }, + residences: Future.value([ + const DerivResidenceModel( + code: 'ID', name: 'Indonesia', isDisabled: false), + const DerivResidenceModel( + code: 'UK', name: 'England', isDisabled: true), + ]), + verificationCode: verificationCode, + affiliateToken: 'token', + ); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart new file mode 100644 index 000000000..8ec51a504 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart @@ -0,0 +1,24 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SetPasswordPage extends StatelessWidget { + const SetPasswordPage({required this.verificationCode, super.key}); + + final String verificationCode; + + @override + Widget build(BuildContext context) => DerivSetPasswordLayout( + authErrorStateHandler: AuthErrorStateHandler(context: context), + onDerivSignupState: (context, state) { + if (state is DerivSignupDoneState) { + context + .read() + .tokenLogin(state.account?.token ?? 'defaultToken'); + } + }, + onPreviousPressed: () => Navigator.of(context).pop(), + residence: 'residence', + verificationCode: verificationCode, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart new file mode 100644 index 000000000..232e2683c --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart @@ -0,0 +1,39 @@ +import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; +import 'package:deriv_auth/features/signup/presentation/layouts/deriv_signup_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; +import 'package:flutter/material.dart'; + +class SignupPage extends StatefulWidget { + const SignupPage({super.key}); + + @override + State createState() => _SignupPageState(); +} + +class _SignupPageState extends State { + @override + Widget build(BuildContext context) => DerivSignupLayout( + authErrorStateHandler: AuthErrorStateHandler(context: context), + signupPageLabel: 'Start trading with Deriv', + signupPageDescription: + 'Join over 1 million traders worldwide who loves trading at Deriv.', + onSocialAuthButtonPressed: (_) {}, + onSingupError: (_) {}, + onSingupEmailSent: (email) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => VerifyEmailPage(email: email), + ), + ); + }, + onSignupPressed: () {}, + onLoginTapped: () => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const LoginPage(), + ), + ), + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart new file mode 100644 index 000000000..e7b1a42c2 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart @@ -0,0 +1,23 @@ +import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verification_done_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; +import 'package:flutter/material.dart'; + +class VerificationDonePage extends StatelessWidget { + const VerificationDonePage({required this.verificationCode, super.key}); + + final String verificationCode; + + @override + Widget build(BuildContext context) { + return DerivVerificationDoneLayout( + onContinuePressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => + CountrySelectionPage(verificationCode: verificationCode), + )); + }, + verificationCode: verificationCode, + affiliateToken: '', + ); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart new file mode 100644 index 000000000..cbd5a43a5 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart @@ -0,0 +1,52 @@ +import 'dart:async'; + +import 'package:deriv_auth/features/signup/presentation/layouts/deriv_email_not_received_layout.dart'; +import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verify_email_layout.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/verification_done_page.dart'; +import 'package:flutter/material.dart'; + +class VerifyEmailPage extends StatefulWidget { + const VerifyEmailPage({required this.email, super.key}); + final String email; + + @override + State createState() => _VerifyEmailPageState(); +} + +class _VerifyEmailPageState extends State { + @override + void initState() { + super.initState(); + + Timer(const Duration(seconds: 3), () { + if (mounted) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => + const VerificationDonePage(verificationCode: 'code'), + )); + } + }); + } + + @override + Widget build(BuildContext context) => DerivVerifyEmailLayout( + email: widget.email, + onEmailNotReceivedPressed: () => onEmailNotReceivedPressed(context), + ); + + void onEmailNotReceivedPressed(BuildContext context) { + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (context) => DerivEmailNotReceivedLayout( + onReEnterEmailPressed: () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (context) => DerivVerifyEmailLayout( + email: widget.email, + onEmailNotReceivedPressed: () => + onEmailNotReceivedPressed(context), + ), + ), + ), + ), + )); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart new file mode 100644 index 000000000..f59512705 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart @@ -0,0 +1,7 @@ +import 'package:deriv_auth/core/services/referral/base_referral_code_service.dart'; + +class ExampleReferralRepository implements BaseReferralCodeService { + @override + Future getReferralToken(String referralCode) => + Future.value('${referralCode}Token'); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart new file mode 100644 index 000000000..ae24ae64c --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart @@ -0,0 +1,17 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +class ExampleSignupRepository implements BaseSignupRepository { + @override + Future getClientServerTime() => Future.value(DateTime.now()); + + @override + Future openNewVirtualAccount({ + required NewVirtualAccountRequestModel newVirtualAccountModel, + }) => + Future.value(AccountModel(accountId: '1')); + + @override + Future sendVerificationEmail( + VerifyEmailRequestEntity request) => + Future.value(const VerifyEmailResponseEntity(verifyEmail: true)); +} diff --git a/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart new file mode 100644 index 000000000..a5409e9b3 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart @@ -0,0 +1,15 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/get_started/pages/get_started_page.dart'; +import 'package:flutter/material.dart'; + +/// +class AuthEntryPage extends StatelessWidget { + /// + AuthEntryPage(AuthEntryModel entryData) { + AuthData().data = entryData; + } + + @override + Widget build(BuildContext context) => const GetStartedPage(); +} diff --git a/packages/deriv_auth/lib/features/single_entry/single_entry.dart b/packages/deriv_auth/lib/features/single_entry/single_entry.dart new file mode 100644 index 000000000..77dc26ae2 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/single_entry.dart @@ -0,0 +1,2 @@ +export 'core/models/auth_entry_model.dart'; +export 'pages/auth_entry_page.dart'; diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 0239e05a7..c0cde7242 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -29,13 +29,18 @@ dependencies: path: packages/deriv_http_client ref: deriv_http_client-v1.0.0 + flutter_deriv_api: + git: + url: git@github.com:deriv-com/flutter-deriv-api.git + ref: flutter-version-3 + flutter_bloc: ^8.1.3 flutter_svg: ^1.1.6 smooth_page_indicator: ^1.1.0 intl_utils: ^2.8.3 intl: ^0.18.0 equatable: ^2.0.5 - package_info_plus: ^4.2.0 + package_info_plus: ^3.1.2 crypto: ^3.0.2 http: ^0.13.5 From 0e592c4f0ccea44b6a6c002fe404790c53ff5c0a Mon Sep 17 00:00:00 2001 From: Ahrar Date: Fri, 26 Jan 2024 13:58:39 +0800 Subject: [PATCH 02/48] chore(deriv_auth): improve some imports --- .../deriv_auth/lib/core/states/auth_error_state_mapper.dart | 1 - packages/deriv_auth/lib/core/states/auth_state_listener.dart | 1 - .../login/presentation/layouts/deriv_login_layout.dart | 2 -- .../presentation/layouts/deriv_set_password_layout.dart | 2 -- .../signup/presentation/layouts/deriv_signup_layout.dart | 1 - .../features/get_started/pages/get_started_page.dart | 4 ++-- 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart b/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart index 44cfa2036..ba4340725 100644 --- a/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart +++ b/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/states.dart'; import 'package:deriv_auth/deriv_auth.dart'; /// Maps the [DerivAuthErrorState] to the corresponding [AuthErrorStateHandler]. diff --git a/packages/deriv_auth/lib/core/states/auth_state_listener.dart b/packages/deriv_auth/lib/core/states/auth_state_listener.dart index f51e278d0..9fb0e14f6 100644 --- a/packages/deriv_auth/lib/core/states/auth_state_listener.dart +++ b/packages/deriv_auth/lib/core/states/auth_state_listener.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/states.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index da7845066..911ac9ffe 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -1,8 +1,6 @@ import 'dart:async'; import 'package:deriv_auth/core/helpers/semantic_labels.dart'; -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; -import 'package:deriv_auth/core/states/auth_error_state_mapper.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/login/presentation/widgets/deriv_social_auth_divider.dart'; import 'package:deriv_auth/features/login/presentation/widgets/deriv_social_auth_panel.dart'; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart index 301e0944b..ecc3f6720 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart @@ -1,8 +1,6 @@ import 'package:deriv_auth/core/helpers/assets.dart'; -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/signup/models/deriv_auth_utm_model.dart'; import 'package:deriv_auth/features/signup/presentation/widgets/password_policy_checker_widget.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index 7c3bcfe08..3ee53e42e 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -1,5 +1,4 @@ import 'package:deriv_auth/core/helpers/semantic_labels.dart'; -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/login/presentation/widgets/deriv_social_auth_divider.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart index 264529e39..93f407c29 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart @@ -19,12 +19,12 @@ class GetStartedPage extends StatelessWidget { backgroundImagePath: AuthData().data.backgroundImagePath, onLoginTapped: () => Navigator.of(context).push( MaterialPageRoute( - builder: (context) => const LoginPage(), + builder: (BuildContext context) => const LoginPage(), ), ), onSignupTapped: () => Navigator.of(context).push( MaterialPageRoute( - builder: (context) => const SignupPage(), + builder: (BuildContext context) => const SignupPage(), ), ), onTapNavigation: () { From 6a165702f97a3f86fc2e1014f01d125528cf5caa Mon Sep 17 00:00:00 2001 From: Ahrar Date: Mon, 29 Jan 2024 15:24:15 +0800 Subject: [PATCH 03/48] chore(deriv_auth): change deriv-api to dev branch change deriv_api to dev branch and package_info_plus to version 4 --- packages/deriv_auth/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index d4a4ebdaa..cd2559c4c 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: flutter_deriv_api: git: url: git@github.com:deriv-com/flutter-deriv-api.git - ref: flutter-version-3 + ref: dev flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 @@ -40,7 +40,7 @@ dependencies: intl_utils: ^2.8.3 intl: ^0.18.0 equatable: ^2.0.5 - package_info_plus: ^3.1.2 + package_info_plus: ^4.2.0 crypto: ^3.0.2 http: ^0.13.5 From 5ce30c3b0fbd84ad3a4cc191d0c7949ec9691ef5 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Fri, 2 Feb 2024 17:59:09 +0800 Subject: [PATCH 04/48] feat(deriv_auth): adding login page to single entry --- .../core/models/auth_entry_model.dart | 19 +++---- .../core/models/get_started_page_model.dart | 20 +++++++ .../core/models/login_page_model.dart | 44 ++++++++++++++++ .../single_entry/core/models/models.dart | 3 ++ .../get_started/pages/get_started_page.dart | 6 +-- .../features/login/pages/login_page.dart | 15 +++--- .../example_login_repository.dart | 36 ------------- .../login/services/example_login_service.dart | 52 ------------------- .../features/single_entry/single_entry.dart | 2 +- 9 files changed, 87 insertions(+), 110 deletions(-) create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/models.dart delete mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart delete mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index 6c01c33b6..730d811c1 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,20 +1,17 @@ -import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/models/get_started_page_model.dart'; +import 'package:deriv_auth/features/single_entry/core/models/login_page_model.dart'; /// class AuthEntryModel { /// const AuthEntryModel({ - required this.slides, - required this.appLogoIconPath, - required this.backgroundImagePath, + required this.getStartedPage, + required this.loginPageModel, }); - /// - final List slides; - - /// - final String appLogoIconPath; + /// GetStartedPage data model + final GetStartedPageModel getStartedPage; - /// - final String backgroundImagePath; + /// LoginPage data model + final LoginPageModel loginPageModel; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart new file mode 100644 index 000000000..574bf0a55 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart @@ -0,0 +1,20 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// +class GetStartedPageModel { + /// + const GetStartedPageModel({ + required this.slides, + required this.appLogoIconPath, + required this.backgroundImagePath, + }); + + /// + final List slides; + + /// + final String appLogoIconPath; + + /// + final String backgroundImagePath; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart new file mode 100644 index 000000000..a93b42214 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -0,0 +1,44 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// LoginPageModel class +class LoginPageModel { + /// Initializes [LoginPageModel]. + const LoginPageModel({ + required this.onLoggedIn, + required this.onSocialAuthButtonPressed, + required this.welcomeLabel, + required this.greetingLabel, + this.isForgotPasswordEnabled = true, + this.isCreateAccountEnabled = true, + this.isSocialAuthEnabled = true, + this.authErrorStateHandler, + this.onLoginError, + }); + + /// Extension of base [AuthErrorStateHandler]. If not provided, base implementation will be used. + final AuthErrorStateHandler? authErrorStateHandler; + + /// Callback to be called when login error occurs. + final Function(DerivAuthErrorState)? onLoginError; + + /// Callback to be called when user is logged in. + final Function(DerivAuthLoggedInState) onLoggedIn; + + /// Callback to be called when social auth button is tapped. + final void Function(SocialAuthProvider) onSocialAuthButtonPressed; + + /// Welcome text to be displayed on login page. + final String welcomeLabel; + + /// Greeting text to be displayed on login page. + final String greetingLabel; + + /// Whether to display social auth buttons. + final bool isSocialAuthEnabled; + + /// Whether to display forgot password section. + final bool isForgotPasswordEnabled; + + /// Whether to display create account section. + final bool isCreateAccountEnabled; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart new file mode 100644 index 000000000..9a314c7e0 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart @@ -0,0 +1,3 @@ +export 'auth_entry_model.dart'; +export 'get_started_page_model.dart'; +export 'login_page_model.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart index 93f407c29..17d2af0c0 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart @@ -14,9 +14,9 @@ class GetStartedPage extends StatelessWidget { @override Widget build(BuildContext context) => DerivGetStartedLayout( - slides: AuthData().data.slides, - appLogoIconPath: AuthData().data.appLogoIconPath, - backgroundImagePath: AuthData().data.backgroundImagePath, + slides: AuthData().data.getStartedPage.slides, + appLogoIconPath: AuthData().data.getStartedPage.appLogoIconPath, + backgroundImagePath: AuthData().data.getStartedPage.backgroundImagePath, onLoginTapped: () => Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => const LoginPage(), diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index 18d0507ef..d1c2c7503 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -1,6 +1,6 @@ -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; import 'package:deriv_auth/features/login/presentation/layouts/deriv_login_layout.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/home/pages/home_page.dart'; import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_page.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; @@ -23,17 +23,17 @@ class _LoginPageState extends State { @override Widget build(BuildContext context) => DerivLoginLayout( - welcomeLabel: 'Welcome back!', - greetingLabel: - 'Log in to your Deriv account to start trading and investing.', + welcomeLabel: AuthData().data.loginPageModel.welcomeLabel, + greetingLabel: AuthData().data.loginPageModel.greetingLabel, onLoggedIn: (_) => Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const HomePage(), ), ), - authErrorStateHandler: AuthErrorStateHandler(context: context), - onLoginError: (_) {}, + authErrorStateHandler: + AuthData().data.loginPageModel.authErrorStateHandler, + onLoginError: AuthData().data.loginPageModel.onLoginError, onResetPassTapped: () => Navigator.push( context, MaterialPageRoute( @@ -46,6 +46,7 @@ class _LoginPageState extends State { builder: (context) => const SignupPage(), ), ), - onSocialAuthButtonPressed: (_) {}, + onSocialAuthButtonPressed: + AuthData().data.loginPageModel.onSocialAuthButtonPressed, ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart deleted file mode 100644 index 2e7f72a29..000000000 --- a/packages/deriv_auth/lib/features/single_entry/features/login/repositories/example_login_repository.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:deriv_auth/core/models/landig_comany_model.dart'; -import 'package:deriv_auth/deriv_auth.dart'; - -class ExampleLoginRepository implements BaseAuthRepository { - @override - Future authorize(String? token) => - Future.value(const AuthorizeResponseEntity()); - - @override - Future getDefaultAccount() => Future.value(AccountModel( - accountId: "accountId", - )); - - @override - Future> getLatestAccounts() => Future.value([ - AccountModel( - accountId: "accountId", - ) - ]); - - @override - Future logout() => Future.value(); - - @override - Future onLogin(AuthorizeEntity authorizeEntity) => Future.value(); - - @override - Future onLogout() => Future.value(); - - @override - Future onPostLogout() => Future.value(); - - @override - Future getLandingCompany(String? countryCode) => - Future.value(const LandingCompanyEntity()); -} diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart b/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart deleted file mode 100644 index 63c832a4f..000000000 --- a/packages/deriv_auth/lib/features/single_entry/features/login/services/example_login_service.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:deriv_auth/core/models/account_model.dart'; -import 'package:deriv_auth/core/models/authorize_model.dart'; -import 'package:deriv_auth/core/models/landig_comany_model.dart'; -import 'package:deriv_auth/core/services/token/models/login_request.dart'; -import 'package:deriv_auth/features/auth/repository/base_auth_repository.dart'; -import 'package:deriv_auth/features/auth/services/base_auth_service.dart'; - -/// `DerivGO` implementation of [BaseAuthService]. -class ExampleLoginService extends BaseAuthService { - /// Initializes a [ExampleLoginService] class. - ExampleLoginService({ - required this.authRepository, - }); - - /// Interface of all client related functions. - final BaseAuthRepository authRepository; - - @override - Future onLoginRequest( - {required GetTokensRequestModel request, String? userAgent}) async => - const AuthorizeEntity(); - - @override - Future login( - String token, { - required List accounts, - String? signupProvider, - String? refreshToken, - }) async => - const AuthorizeEntity(); - - @override - Future getDefaultAccount() => - authRepository.getDefaultAccount(); - - @override - Future> getLatestAccounts() => - authRepository.getLatestAccounts(); - - @override - Future logout() => authRepository.logout(); - - @override - Future onLogout() => authRepository.onLogout(); - - @override - Future onPostLogout() => authRepository.onPostLogout(); - - @override - Future getLandingCompany(String? countryCode) => - authRepository.getLandingCompany(countryCode); -} diff --git a/packages/deriv_auth/lib/features/single_entry/single_entry.dart b/packages/deriv_auth/lib/features/single_entry/single_entry.dart index 77dc26ae2..a3a619eae 100644 --- a/packages/deriv_auth/lib/features/single_entry/single_entry.dart +++ b/packages/deriv_auth/lib/features/single_entry/single_entry.dart @@ -1,2 +1,2 @@ -export 'core/models/auth_entry_model.dart'; +export 'core/models/models.dart'; export 'pages/auth_entry_page.dart'; From 7ff56536e97f194e60890cab9dc9f3b833fe1540 Mon Sep 17 00:00:00 2001 From: Bassam El Obeid <127500305+bassam-deriv@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:33:41 +0400 Subject: [PATCH 05/48] Update Crowdin configuration file --- crowdin.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 crowdin.yml diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 000000000..0d5ff5853 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,3 @@ +files: + - source: /packages/deriv_localizations/lib/l10n/**/app_en.arb + translation: /packages/deriv_localizations/lib/l10n/**/app_%two_letters_code%.arb From 573a4a787a6aa518537f2678c19a748cebcf0fb4 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Sun, 11 Feb 2024 17:21:45 +0800 Subject: [PATCH 06/48] feat(deriv_auth): single entry login and reset pass added --- .../core/models/auth_entry_model.dart | 7 ++- .../features/login/pages/login_page.dart | 14 +++-- .../pages/choose_new_password_page.dart | 34 +++++------ .../reset_pass/pages/reset_pass_page.dart | 56 +++++-------------- .../pages/reset_pass_success_page.dart | 17 ++---- .../services/example_reset_pass_service.dart | 17 ------ 6 files changed, 49 insertions(+), 96 deletions(-) delete mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index 730d811c1..f0bd98a9f 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,5 +1,4 @@ -import 'package:deriv_auth/features/single_entry/core/models/get_started_page_model.dart'; -import 'package:deriv_auth/features/single_entry/core/models/login_page_model.dart'; +import 'package:deriv_auth/deriv_auth.dart'; /// class AuthEntryModel { @@ -7,6 +6,7 @@ class AuthEntryModel { const AuthEntryModel({ required this.getStartedPage, required this.loginPageModel, + required this.derivAuthCubit, }); /// GetStartedPage data model @@ -14,4 +14,7 @@ class AuthEntryModel { /// LoginPage data model final LoginPageModel loginPageModel; + + /// DerivAuthCubit + final DerivAuthCubit derivAuthCubit; } diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index d1c2c7503..44f80ce93 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -7,7 +7,9 @@ import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_pa import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +/// Login page class LoginPage extends StatefulWidget { + /// Constructor [LoginPage] const LoginPage({super.key}); @override @@ -27,8 +29,8 @@ class _LoginPageState extends State { greetingLabel: AuthData().data.loginPageModel.greetingLabel, onLoggedIn: (_) => Navigator.pushReplacement( context, - MaterialPageRoute( - builder: (context) => const HomePage(), + MaterialPageRoute( + builder: (BuildContext context) => const HomePage(), ), ), authErrorStateHandler: @@ -36,14 +38,14 @@ class _LoginPageState extends State { onLoginError: AuthData().data.loginPageModel.onLoginError, onResetPassTapped: () => Navigator.push( context, - MaterialPageRoute( - builder: (context) => const ResetPassPage(), + MaterialPageRoute( + builder: (BuildContext context) => const ResetPassPage(), ), ), onSignupTapped: () => Navigator.pushReplacement( context, - MaterialPageRoute( - builder: (context) => const SignupPage(), + MaterialPageRoute( + builder: (BuildContext context) => const SignupPage(), ), ), onSocialAuthButtonPressed: diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart index 7dbf5afdb..aa8407a83 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -1,25 +1,25 @@ -import 'package:deriv_auth/features/reset_password/cubit/reset_password_cubit.dart'; -import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; +import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart'; import 'package:flutter/material.dart'; +/// Choose new password page class ChooseNewPasswordPage extends StatelessWidget { - const ChooseNewPasswordPage({required this.cubit, super.key}); + /// Constructor [ChooseNewPasswordPage] + const ChooseNewPasswordPage({required this.token, super.key}); - final DerivResetPassCubit cubit; + /// Token + final String token; @override - Widget build(BuildContext context) { - return DerivChooseNewPassLayout( - token: 'token', - onResetPassSucceed: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const ResetPassSuccessPage(), - ), - ); - }, - onResetPassError: (_) {}, - ); - } + Widget build(BuildContext context) => DerivChooseNewPassLayout( + token: token, + onResetPassSucceed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const ResetPassSuccessPage(), + ), + ); + }, + onResetPassError: (_) {}, + ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart index 08ebc6fdb..24200e4ef 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart @@ -1,53 +1,25 @@ -import 'dart:async'; - import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart'; -import 'package:deriv_auth/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart'; +import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; +/// Reset password page class ResetPassPage extends StatefulWidget { + /// Constructor for reset password page const ResetPassPage({super.key}); @override - State createState() => _ResetPassPageState(); + State createState() => _ResetPasswordPageState(); } -class _ResetPassPageState extends State { - late final DerivResetPassCubit cubit; - late final StreamSubscription _streamSubscription; - +class _ResetPasswordPageState extends State { @override - void initState() { - super.initState(); - - cubit = DerivResetPassCubit(service: ExampleResetPassService()); - - _streamSubscription = cubit.stream.listen((state) { - if (state is DerivResetPassEmailSentState) { - Timer(const Duration(seconds: 3), () { - if (mounted) { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => BlocProvider.value( - value: cubit, child: ChooseNewPasswordPage(cubit: cubit)), - )); - } - }); - } - }); - } - - @override - Widget build(BuildContext context) { - return BlocProvider.value( - value: cubit, child: DerivResetPassLayout(onResetPassError: (_) {})); - } - - @override - void dispose() { - cubit.close(); - _streamSubscription.cancel(); - - super.dispose(); - } + Widget build(BuildContext context) => DerivResetPassLayout( + onResetPassError: (String? errorMessage) { + showErrorDialog( + context: context, + errorMessage: errorMessage, + actionLabel: 'okay', + ); + }, + ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart index 68ce4c769..cec69f638 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart @@ -1,11 +1,11 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -/// Reset password success page +/// Reset Password success page class ResetPassSuccessPage extends StatefulWidget { - /// Reset password success constructor + /// Constructor [ResetPassSuccessPage] const ResetPassSuccessPage({super.key}); @override @@ -24,19 +24,12 @@ class _ResetPassSuccessPageState extends State { Future.wait( >[ Future.delayed(_successPageHoldDuration), - BlocProvider.of(context).logout(), + AuthData().data.derivAuthCubit.logout(), ], ).then( (_) { - // Navigator.of(context).pushAndRemoveUntil( - // MaterialPageRoute( - // builder: (context) => const GetStartedPage(), - // ), - // (route) => false, - // ); - Navigator.of(context).push( - MaterialPageRoute( + MaterialPageRoute( builder: (BuildContext context) => const LoginPage(), ), ); diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart deleted file mode 100644 index f65b527e0..000000000 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/services/example_reset_pass_service.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:deriv_auth/core/models/verify_email_model.dart'; -import 'package:deriv_auth/features/reset_password/services/base_reset_password_service.dart'; - -class ExampleResetPassService implements BaseResetPasswordService { - @override - Future resetPassword({ - required String verificationCode, - required String newPassword, - }) => - Future.value(true); - - @override - Future sendVerificationEmail( - VerifyEmailRequestEntity request, - ) => - Future.value(const VerifyEmailResponseEntity(verifyEmail: true)); -} From f38cc253209afdf3573e3a85fe8ec0cd7082c5d5 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Sun, 11 Feb 2024 19:20:29 +0800 Subject: [PATCH 07/48] feat(deriv_auth): single entry signup page --- .../core/models/auth_entry_model.dart | 5 ++ .../single_entry/core/models/models.dart | 1 + .../core/models/signup_page_model.dart | 26 +++++++++ .../signup/pages/country_selection_page.dart | 58 ++++++++++++------- .../signup/pages/set_password_page.dart | 26 +++++++-- .../features/signup/pages/signup_page.dart | 32 +++++----- .../signup/pages/verification_done_page.dart | 40 ++++++++----- .../signup/pages/verify_email_page.dart | 28 +++------ .../example_signup_repository.dart | 17 ------ ...pository.dart => referral_repository.dart} | 3 +- 10 files changed, 146 insertions(+), 90 deletions(-) create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart delete mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart rename packages/deriv_auth/lib/features/single_entry/features/signup/repositories/{example_referral_repository.dart => referral_repository.dart} (70%) diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index f0bd98a9f..f3cb4b2ea 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/models/signup_page_model.dart'; /// class AuthEntryModel { @@ -7,6 +8,7 @@ class AuthEntryModel { required this.getStartedPage, required this.loginPageModel, required this.derivAuthCubit, + required this.signupPageModel, }); /// GetStartedPage data model @@ -17,4 +19,7 @@ class AuthEntryModel { /// DerivAuthCubit final DerivAuthCubit derivAuthCubit; + + /// SignupPage data model + final SignupPageModel signupPageModel; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart index 9a314c7e0..6c16661b2 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart @@ -1,3 +1,4 @@ export 'auth_entry_model.dart'; export 'get_started_page_model.dart'; export 'login_page_model.dart'; +export 'signup_page_model.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart new file mode 100644 index 000000000..10f12dc06 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart @@ -0,0 +1,26 @@ +/// Sign-up page model +class SignupPageModel { + /// Constructor [SignupPageModel] + SignupPageModel({ + required this.verificationCode, + required this.signupPageLable, + required this.signupPageDescription, + required this.isSocialAuthEnabled, + this.affiliateToken, + }); + + /// verification code + final String verificationCode; + + /// affiliate token + final String? affiliateToken; + + /// sing-up page label + final String signupPageLable; + + /// sign-up page description + final String signupPageDescription; + + /// is social auth enabled + final bool isSocialAuthEnabled; +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart index 838961327..900219243 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart @@ -1,29 +1,47 @@ -import 'package:deriv_auth/features/signup/models/deriv_residence_model.dart'; -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_country_selection_layout.dart'; +import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/set_password_page.dart'; import 'package:flutter/material.dart'; +/// Country selection page class CountrySelectionPage extends StatelessWidget { - const CountrySelectionPage({required this.verificationCode, super.key}); + /// + const CountrySelectionPage({ + required this.verificationCode, + this.affiliateToken, + super.key, + }); + /// Verification code final String verificationCode; + /// + final String? affiliateToken; + @override - Widget build(BuildContext context) { - return DerivCountrySelectionLayout( - onNextPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => const SetPasswordPage(verificationCode: 'code'), - )); - }, - residences: Future.value([ - const DerivResidenceModel( - code: 'ID', name: 'Indonesia', isDisabled: false), - const DerivResidenceModel( - code: 'UK', name: 'England', isDisabled: true), - ]), - verificationCode: verificationCode, - affiliateToken: 'token', - ); - } + Widget build(BuildContext context) => DerivCountrySelectionLayout( + onNextPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => SetPasswordPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ); + }, + residences: Future.value([ + const DerivResidenceModel( + code: 'ID', + name: 'Indonesia', + isDisabled: false, + ), + const DerivResidenceModel( + code: 'UK', + name: 'England', + isDisabled: true, + ), + ]), + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart index 8ec51a504..727c26be2 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart @@ -1,24 +1,42 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +/// Set password page class SetPasswordPage extends StatelessWidget { - const SetPasswordPage({required this.verificationCode, super.key}); + /// Constructor [SetPasswordPage] + const SetPasswordPage({ + required this.verificationCode, + this.affiliateToken, + super.key, + }); + /// Verification code final String verificationCode; + /// + final String? affiliateToken; + @override Widget build(BuildContext context) => DerivSetPasswordLayout( authErrorStateHandler: AuthErrorStateHandler(context: context), - onDerivSignupState: (context, state) { + onDerivSignupState: (BuildContext constext, DerivSignupState state) { if (state is DerivSignupDoneState) { context .read() .tokenLogin(state.account?.token ?? 'defaultToken'); } }, - onPreviousPressed: () => Navigator.of(context).pop(), - residence: 'residence', + onPreviousPressed: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => CountrySelectionPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ), + residence: 'id', verificationCode: verificationCode, ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart index 232e2683c..f3f209cb3 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart @@ -1,10 +1,12 @@ -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_signup_layout.dart'; +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; import 'package:flutter/material.dart'; +/// Sing up page class SignupPage extends StatefulWidget { + /// Constructor for sign up page const SignupPage({super.key}); @override @@ -15,24 +17,24 @@ class _SignupPageState extends State { @override Widget build(BuildContext context) => DerivSignupLayout( authErrorStateHandler: AuthErrorStateHandler(context: context), - signupPageLabel: 'Start trading with Deriv', + signupPageLabel: AuthData().data.signupPageModel.signupPageLable, signupPageDescription: - 'Join over 1 million traders worldwide who loves trading at Deriv.', + AuthData().data.signupPageModel.signupPageDescription, onSocialAuthButtonPressed: (_) {}, onSingupError: (_) {}, - onSingupEmailSent: (email) { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) => VerifyEmailPage(email: email), + onSingupEmailSent: (String email) => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => VerifyEmailPage( + email: email, ), - ); - }, + ), + ), onSignupPressed: () {}, - onLoginTapped: () => Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) => const LoginPage(), + isSocialAuthEnabled: + AuthData().data.signupPageModel.isSocialAuthEnabled, + onLoginTapped: () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => const LoginPage(), ), ), ); diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart index e7b1a42c2..70e34d723 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart @@ -1,23 +1,35 @@ -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verification_done_layout.dart'; +import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; import 'package:flutter/material.dart'; +/// Verification done page class VerificationDonePage extends StatelessWidget { - const VerificationDonePage({required this.verificationCode, super.key}); + /// + const VerificationDonePage({ + required this.verificationCode, + super.key, + this.affiliateToken, + }); + /// verification code final String verificationCode; + /// + final String? affiliateToken; + @override - Widget build(BuildContext context) { - return DerivVerificationDoneLayout( - onContinuePressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => - CountrySelectionPage(verificationCode: verificationCode), - )); - }, - verificationCode: verificationCode, - affiliateToken: '', - ); - } + Widget build(BuildContext context) => DerivVerificationDoneLayout( + onContinuePressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => CountrySelectionPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ); + }, + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart index cbd5a43a5..008bc705f 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart @@ -1,12 +1,12 @@ -import 'dart:async'; - -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_email_not_received_layout.dart'; -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verify_email_layout.dart'; -import 'package:deriv_auth/features/single_entry/features/signup/pages/verification_done_page.dart'; +import 'package:deriv_auth/deriv_auth.dart'; import 'package:flutter/material.dart'; +/// Verify email page class VerifyEmailPage extends StatefulWidget { + /// Constructor for verify email page const VerifyEmailPage({required this.email, super.key}); + + /// email final String email; @override @@ -17,15 +17,6 @@ class _VerifyEmailPageState extends State { @override void initState() { super.initState(); - - Timer(const Duration(seconds: 3), () { - if (mounted) { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => - const VerificationDonePage(verificationCode: 'code'), - )); - } - }); } @override @@ -33,13 +24,12 @@ class _VerifyEmailPageState extends State { email: widget.email, onEmailNotReceivedPressed: () => onEmailNotReceivedPressed(context), ); - void onEmailNotReceivedPressed(BuildContext context) { - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => DerivEmailNotReceivedLayout( + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (BuildContext context) => DerivEmailNotReceivedLayout( onReEnterEmailPressed: () => Navigator.of(context).pushReplacement( - MaterialPageRoute( - builder: (context) => DerivVerifyEmailLayout( + MaterialPageRoute( + builder: (BuildContext context) => DerivVerifyEmailLayout( email: widget.email, onEmailNotReceivedPressed: () => onEmailNotReceivedPressed(context), diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart deleted file mode 100644 index ae24ae64c..000000000 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_signup_repository.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:deriv_auth/deriv_auth.dart'; - -class ExampleSignupRepository implements BaseSignupRepository { - @override - Future getClientServerTime() => Future.value(DateTime.now()); - - @override - Future openNewVirtualAccount({ - required NewVirtualAccountRequestModel newVirtualAccountModel, - }) => - Future.value(AccountModel(accountId: '1')); - - @override - Future sendVerificationEmail( - VerifyEmailRequestEntity request) => - Future.value(const VerifyEmailResponseEntity(verifyEmail: true)); -} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart similarity index 70% rename from packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart rename to packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart index f59512705..f3a42d877 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/example_referral_repository.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart @@ -1,6 +1,7 @@ import 'package:deriv_auth/core/services/referral/base_referral_code_service.dart'; -class ExampleReferralRepository implements BaseReferralCodeService { +/// Referral repository +class ReferralRepository implements BaseReferralCodeService { @override Future getReferralToken(String referralCode) => Future.value('${referralCode}Token'); From 11c8aca2042eb0ab86f3cd462927b1422df7471b Mon Sep 17 00:00:00 2001 From: Ahrar Date: Tue, 13 Feb 2024 13:51:14 +0800 Subject: [PATCH 08/48] chore: setting page fist attempt --- .../core/models/setting_page_model.dart | 8 +++ .../settings/pages/settings_page.dart | 53 +++++++++++++++---- 2 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart new file mode 100644 index 000000000..406a19f1f --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart @@ -0,0 +1,8 @@ +/// Setting page model +class SettingPageModel { + /// Setting page App label + final String appLabel; + + final String appId; + final String endpoint; +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart index 70d990683..7d214a172 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart @@ -1,8 +1,12 @@ -import 'dart:developer' as logger; import 'package:deriv_auth/deriv_auth.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_deriv_api/services/connection/api_manager/connection_information.dart'; +import 'package:flutter_deriv_api/state/connection/connection_cubit.dart'; +/// Setting page class SettingsPage extends StatefulWidget { + /// Constructor for setting page const SettingsPage({super.key}); @override @@ -12,17 +16,46 @@ class SettingsPage extends StatefulWidget { class _SettingsPageState extends State { @override Widget build(BuildContext context) => DerivSettingLayout( - updateFlavorConfigs: _updateFlavorConfig(), - appLabel: 'appLabel', + updateFlavorConfigs: _updateFlavorConfigs(), + appLabel: 'blanc', saveValues: _saveValues, + appId: PrefService.getString('appId') ?? defaultAppId, + endpoint: PrefService.getString('endpoint') ?? defaultEndpoint, ); -} + Future _saveValues({ + required String endpoint, + required String appId, + }) async { + await PrefService.setString('endpoint', endpoint); + await PrefService.setString('appId', appId); + } -_saveValues({required String appId, required String endpoint}) { - logger.log('appId is $appId'); - logger.log('endpoint is $endpoint'); -} + Future _updateFlavorConfigs() async { + final authEndpoint = generateEndpointUrl( + endpoint: PrefService.getString('endpoint'), + isAuthUrl: true, + ) ?? + defaultAuthEndpoint; + + final endpoint = + generateEndpointUrl(endpoint: PrefService.getString('endpoint')) ?? + defaultEndpoint; + + FlavorConfig.instance.copyWith( + FlavorValues( + endPoint: endpoint, + authEndPoint: authEndpoint, + appId: PrefService.getString('appId')!, + ), + ); -Future _updateFlavorConfig() async { - logger.log('Flavor CONFIG is updated'); + await BlocProvider.of(context).reconnect( + connectionInformation: ConnectionInformation( + appId: FlavorConfig.instance.flavorValues.appId, + brand: 'deriv', + endpoint: FlavorConfig.instance.flavorValues.endPoint!, + authEndpoint: FlavorConfig.instance.flavorValues.authEndPoint!, + ), + ); + } } From dc29784f2f74c34a7a5bf9910b4041adca591e74 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Wed, 14 Feb 2024 13:58:07 +0800 Subject: [PATCH 09/48] feat(deriv_auith): single entry setting page --- .../layouts/deriv_setting_layout.dart | 22 ++++---- .../core/models/auth_entry_model.dart | 5 +- .../single_entry/core/models/models.dart | 1 + .../core/models/setting_page_model.dart | 23 ++++++++- .../settings/pages/settings_page.dart | 51 +++---------------- 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart index 9d00ee918..e61f0d754 100644 --- a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart +++ b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart @@ -26,7 +26,8 @@ class DerivSettingLayout extends StatefulWidget { }) : super(key: key); /// Update flavor configurations - final Future updateFlavorConfigs; + final Function({required String endpoint, required String appId}) + updateFlavorConfigs; /// Save values to shared preferences final Function({required String endpoint, required String appId}) saveValues; @@ -75,18 +76,19 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) => WillPopScope( onWillPop: () async { + final String endpoint = _endpointController.text.isNotEmpty + ? _endpointController.text + : defaultEndpoint; + final String appId = _appIdController.text.isNotEmpty + ? _appIdController.text + : defaultAppId; + // Save Values to shared preferences - widget.saveValues( - endpoint: _endpointController.text.isNotEmpty - ? _endpointController.text - : defaultEndpoint, - appId: _appIdController.text.isNotEmpty - ? _appIdController.text - : defaultAppId, - ); + await widget.saveValues(endpoint: endpoint, appId: appId); // Update Flavor Configurations before dismissing the page - await widget.updateFlavorConfigs; + await widget.updateFlavorConfigs(endpoint: endpoint, appId: appId); + return true; }, child: Scaffold( diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index f3cb4b2ea..77c12be75 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,5 +1,4 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/single_entry/core/models/signup_page_model.dart'; /// class AuthEntryModel { @@ -9,6 +8,7 @@ class AuthEntryModel { required this.loginPageModel, required this.derivAuthCubit, required this.signupPageModel, + required this.settingPageModel, }); /// GetStartedPage data model @@ -22,4 +22,7 @@ class AuthEntryModel { /// SignupPage data model final SignupPageModel signupPageModel; + + /// SettingPage data model + final SettingPageModel settingPageModel; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart index 6c16661b2..a4ed79042 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart @@ -2,3 +2,4 @@ export 'auth_entry_model.dart'; export 'get_started_page_model.dart'; export 'login_page_model.dart'; export 'signup_page_model.dart'; +export 'setting_page_model.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart index 406a19f1f..d0e8083d0 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart @@ -1,8 +1,27 @@ /// Setting page model class SettingPageModel { + /// Constructor [SettingPageModel] + SettingPageModel({ + required this.appLabel, + required this.appId, + required this.endpoint, + required this.saveValues, + required this.updateFlavorConfigs, + }); + /// Setting page App label final String appLabel; - final String appId; - final String endpoint; + /// application id + final String Function() appId; + + /// end point + final String Function() endpoint; + + /// Save values to shared preferences + final Function({required String endpoint, required String appId}) saveValues; + + /// Update flavor configurations + final Function({required String endpoint, required String appId}) + updateFlavorConfigs; } diff --git a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart index 7d214a172..149c3a540 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart @@ -1,8 +1,6 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_deriv_api/services/connection/api_manager/connection_information.dart'; -import 'package:flutter_deriv_api/state/connection/connection_cubit.dart'; /// Setting page class SettingsPage extends StatefulWidget { @@ -16,46 +14,11 @@ class SettingsPage extends StatefulWidget { class _SettingsPageState extends State { @override Widget build(BuildContext context) => DerivSettingLayout( - updateFlavorConfigs: _updateFlavorConfigs(), - appLabel: 'blanc', - saveValues: _saveValues, - appId: PrefService.getString('appId') ?? defaultAppId, - endpoint: PrefService.getString('endpoint') ?? defaultEndpoint, + updateFlavorConfigs: + AuthData().data.settingPageModel.updateFlavorConfigs, + appLabel: AuthData().data.settingPageModel.appLabel, + saveValues: AuthData().data.settingPageModel.saveValues, + appId: AuthData().data.settingPageModel.appId.call(), + endpoint: AuthData().data.settingPageModel.endpoint.call(), ); - Future _saveValues({ - required String endpoint, - required String appId, - }) async { - await PrefService.setString('endpoint', endpoint); - await PrefService.setString('appId', appId); - } - - Future _updateFlavorConfigs() async { - final authEndpoint = generateEndpointUrl( - endpoint: PrefService.getString('endpoint'), - isAuthUrl: true, - ) ?? - defaultAuthEndpoint; - - final endpoint = - generateEndpointUrl(endpoint: PrefService.getString('endpoint')) ?? - defaultEndpoint; - - FlavorConfig.instance.copyWith( - FlavorValues( - endPoint: endpoint, - authEndPoint: authEndpoint, - appId: PrefService.getString('appId')!, - ), - ); - - await BlocProvider.of(context).reconnect( - connectionInformation: ConnectionInformation( - appId: FlavorConfig.instance.flavorValues.appId, - brand: 'deriv', - endpoint: FlavorConfig.instance.flavorValues.endPoint!, - authEndpoint: FlavorConfig.instance.flavorValues.authEndPoint!, - ), - ); - } } From f7930d66880d2d091959646dd928e79189ce5704 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Wed, 14 Feb 2024 16:51:03 +0800 Subject: [PATCH 10/48] feat(deriv_auth): single entry reset password and merge conflicts --- packages/deriv_auth/lib/core/core.dart | 1 + .../deriv_auth/lib/core/helpers/helpers.dart | 1 + .../deriv_auth/lib/core/states/states.dart | 1 + .../layouts/deriv_login_layout.dart | 2 -- .../layouts/deriv_signup_layout.dart | 3 +- .../core/models/auth_entry_model.dart | 4 +++ .../core/models/login_page_model.dart | 15 +++++++++- .../single_entry/core/models/models.dart | 1 + .../core/models/reset_pass_page_model.dart | 17 +++++++++++ .../core/models/signup_page_model.dart | 28 +++++++++++++++++++ .../features/login/pages/login_page.dart | 4 +++ .../pages/choose_new_password_page.dart | 20 +++++++------ .../features/signup/pages/signup_page.dart | 12 ++++++-- 13 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart diff --git a/packages/deriv_auth/lib/core/core.dart b/packages/deriv_auth/lib/core/core.dart index 6a88d93ab..d90ac1ac4 100644 --- a/packages/deriv_auth/lib/core/core.dart +++ b/packages/deriv_auth/lib/core/core.dart @@ -13,3 +13,4 @@ export 'services/referral/models/my_affiliate_referral_code_request_model.dart'; export 'services/token/models/enums.dart'; export 'services/token/services/deriv_token_service.dart'; export 'states/states.dart'; +export 'helpers/helpers.dart'; diff --git a/packages/deriv_auth/lib/core/helpers/helpers.dart b/packages/deriv_auth/lib/core/helpers/helpers.dart index ab5f4b441..bc7dc3ce0 100644 --- a/packages/deriv_auth/lib/core/helpers/helpers.dart +++ b/packages/deriv_auth/lib/core/helpers/helpers.dart @@ -2,3 +2,4 @@ export 'account_helpers.dart'; export 'bool_helper.dart'; export 'date_time_helper.dart'; export 'number_helper.dart'; +export 'semantic_labels.dart'; diff --git a/packages/deriv_auth/lib/core/states/states.dart b/packages/deriv_auth/lib/core/states/states.dart index 7545c9d18..3fcce922f 100644 --- a/packages/deriv_auth/lib/core/states/states.dart +++ b/packages/deriv_auth/lib/core/states/states.dart @@ -1,2 +1,3 @@ export 'auth_error_state_mapper.dart'; export 'auth_error_state_handler.dart'; +export 'auth_state_listener.dart'; diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 298a6ac93..cebec3622 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -1,6 +1,4 @@ import 'dart:async'; - -import 'package:deriv_auth/core/helpers/semantic_labels.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index 8b7a95d0e..c466189ed 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -1,5 +1,3 @@ -import 'package:deriv_auth/core/helpers/semantic_labels.dart'; -import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; @@ -137,6 +135,7 @@ class _DerivSignupLayoutState extends State { socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, onWebViewError: widget.onWebViewError, + onPressed: widget.onSocialAuthButtonPressed, ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index 77c12be75..274692cab 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -9,6 +9,7 @@ class AuthEntryModel { required this.derivAuthCubit, required this.signupPageModel, required this.settingPageModel, + required this.resetPassPageModel, }); /// GetStartedPage data model @@ -25,4 +26,7 @@ class AuthEntryModel { /// SettingPage data model final SettingPageModel settingPageModel; + + /// ResetPassPage data model + final ResetPassPageModel resetPassPageModel; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index a93b42214..bfb98d9ef 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -8,6 +8,9 @@ class LoginPageModel { required this.onSocialAuthButtonPressed, required this.welcomeLabel, required this.greetingLabel, + required this.socialAuthStateHandler, + required this.redirectURL, + required this.onWebViewError, this.isForgotPasswordEnabled = true, this.isCreateAccountEnabled = true, this.isSocialAuthEnabled = true, @@ -25,7 +28,8 @@ class LoginPageModel { final Function(DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. - final void Function(SocialAuthProvider) onSocialAuthButtonPressed; + /// Give access to [SocialAuthDto] for 2FA. + final SocialAuthCallback? onSocialAuthButtonPressed; /// Welcome text to be displayed on login page. final String welcomeLabel; @@ -41,4 +45,13 @@ class LoginPageModel { /// Whether to display create account section. final bool isCreateAccountEnabled; + + /// Social auth state handler. + final Function(SocialAuthState) socialAuthStateHandler; + + /// Redirect URL for social auth. + final String redirectURL; + + /// Callback for web view error. + final Function(String) onWebViewError; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart index a4ed79042..4aea9f511 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart @@ -3,3 +3,4 @@ export 'get_started_page_model.dart'; export 'login_page_model.dart'; export 'signup_page_model.dart'; export 'setting_page_model.dart'; +export 'reset_pass_page_model.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart new file mode 100644 index 000000000..e68916f6f --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart @@ -0,0 +1,17 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/foundation.dart' show VoidCallback; + +/// Reset password page model +class ResetPassPageModel { + /// Constructor [ResetPassPageModel] + const ResetPassPageModel({ + required this.onResetPassError, + this.onResetPassSucceed, + }); + + /// Callback to be called when reset pass fails. + final ResetPassErrorCallback onResetPassError; + + /// Callback to be called when reset pass succeeds. + final VoidCallback? onResetPassSucceed; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart index 10f12dc06..a182228c8 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart @@ -1,3 +1,6 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/foundation.dart' show VoidCallback; + /// Sign-up page model class SignupPageModel { /// Constructor [SignupPageModel] @@ -5,7 +8,13 @@ class SignupPageModel { required this.verificationCode, required this.signupPageLable, required this.signupPageDescription, + required this.onSingupError, required this.isSocialAuthEnabled, + required this.socialAuthStateHandler, + required this.redirectURL, + required this.onWebViewError, + this.onSignupPressed, + this.onSocialAuthButtonPressed, this.affiliateToken, }); @@ -15,6 +24,12 @@ class SignupPageModel { /// affiliate token final String? affiliateToken; + /// Callback to be called when signup button is pressed. + final VoidCallback? onSignupPressed; + + /// Callback to be called when signup error occurs. + final Function(DerivSignupErrorState) onSingupError; + /// sing-up page label final String signupPageLable; @@ -23,4 +38,17 @@ class SignupPageModel { /// is social auth enabled final bool isSocialAuthEnabled; + + /// Social auth state handler. + final Function(SocialAuthState) socialAuthStateHandler; + + /// Redirect URL for social auth. + final String redirectURL; + + /// Callback for web view error. + final Function(String) onWebViewError; + + /// Callback to be called when social auth button is tapped. + /// Give access to [SocialAuthDto] for 2FA. + final SocialAuthCallback? onSocialAuthButtonPressed; } diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index 44f80ce93..7df28097f 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -50,5 +50,9 @@ class _LoginPageState extends State { ), onSocialAuthButtonPressed: AuthData().data.loginPageModel.onSocialAuthButtonPressed, + socialAuthStateHandler: + AuthData().data.loginPageModel.socialAuthStateHandler, + redirectURL: AuthData().data.loginPageModel.redirectURL, + onWebViewError: AuthData().data.loginPageModel.onWebViewError, ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart index aa8407a83..7b1ed804b 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart'; import 'package:flutter/material.dart'; @@ -13,13 +14,16 @@ class ChooseNewPasswordPage extends StatelessWidget { @override Widget build(BuildContext context) => DerivChooseNewPassLayout( token: token, - onResetPassSucceed: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => const ResetPassSuccessPage(), - ), - ); - }, - onResetPassError: (_) {}, + onResetPassSucceed: + AuthData().data.resetPassPageModel.onResetPassSucceed ?? + () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => + const ResetPassSuccessPage(), + ), + ); + }, + onResetPassError: AuthData().data.resetPassPageModel.onResetPassError, ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart index f3f209cb3..712b8b31b 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart @@ -3,6 +3,7 @@ import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_deriv_api/api/response/app_update_response_result.dart'; /// Sing up page class SignupPage extends StatefulWidget { @@ -20,8 +21,9 @@ class _SignupPageState extends State { signupPageLabel: AuthData().data.signupPageModel.signupPageLable, signupPageDescription: AuthData().data.signupPageModel.signupPageDescription, - onSocialAuthButtonPressed: (_) {}, - onSingupError: (_) {}, + onSocialAuthButtonPressed: + AuthData().data.signupPageModel.onSocialAuthButtonPressed, + onSingupError: AuthData().data.signupPageModel.onSingupError, onSingupEmailSent: (String email) => Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => VerifyEmailPage( @@ -29,7 +31,7 @@ class _SignupPageState extends State { ), ), ), - onSignupPressed: () {}, + onSignupPressed: AuthData().data.signupPageModel.onSignupPressed, isSocialAuthEnabled: AuthData().data.signupPageModel.isSocialAuthEnabled, onLoginTapped: () => Navigator.of(context).pushReplacement( @@ -37,5 +39,9 @@ class _SignupPageState extends State { builder: (BuildContext context) => const LoginPage(), ), ), + socialAuthStateHandler: + AuthData().data.signupPageModel.socialAuthStateHandler, + redirectURL: AuthData().data.signupPageModel.redirectURL, + onWebViewError: AuthData().data.signupPageModel.onWebViewError, ); } From 5e62ee117adffc744048dfe6821df46c7262a760 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Mon, 19 Feb 2024 15:12:11 +0800 Subject: [PATCH 11/48] chore(deriv_auth): code review comments add docs and minor changes --- .../single_entry/core/models/auth_entry_model.dart | 4 ++-- .../core/models/get_started_page_model.dart | 10 +++++----- .../core/models/reset_pass_page_model.dart | 8 ++++++++ .../get_started/pages/get_started_page.dart | 10 ++++------ .../signup/pages/country_selection_page.dart | 14 ++------------ .../features/signup/pages/set_password_page.dart | 3 ++- .../features/signup/pages/signup_page.dart | 1 - .../features/signup/pages/verify_email_page.dart | 1 + .../single_entry/pages/auth_entry_page.dart | 4 ++-- 9 files changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index 274692cab..23b2a5336 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,8 +1,8 @@ import 'package:deriv_auth/deriv_auth.dart'; -/// +/// Auth Entry Model class class AuthEntryModel { - /// + /// Constructor [AuthEntryModel] const AuthEntryModel({ required this.getStartedPage, required this.loginPageModel, diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart index 574bf0a55..1bf244b2a 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart @@ -1,20 +1,20 @@ import 'package:deriv_auth/deriv_auth.dart'; -/// +/// Get Started Page Model class GetStartedPageModel { - /// + /// Constructor [GetStartedPageModel] const GetStartedPageModel({ required this.slides, required this.appLogoIconPath, required this.backgroundImagePath, }); - /// + /// List of Deriv Get Started page Slides final List slides; - /// + /// Logo icon path final String appLogoIconPath; - /// + /// Background image path final String backgroundImagePath; } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart index e68916f6f..e7cca15bb 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart @@ -6,6 +6,8 @@ class ResetPassPageModel { /// Constructor [ResetPassPageModel] const ResetPassPageModel({ required this.onResetPassError, + required this.residences, + required this.residence, this.onResetPassSucceed, }); @@ -14,4 +16,10 @@ class ResetPassPageModel { /// Callback to be called when reset pass succeeds. final VoidCallback? onResetPassSucceed; + + /// List of residences to be shown. + final Future> residences; + + /// Residence + final String residence; } diff --git a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart index 17d2af0c0..b09669843 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart @@ -5,25 +5,23 @@ import 'package:deriv_auth/features/single_entry/features/settings/pages/setting import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; import 'package:flutter/material.dart'; -/// +/// Get started page class GetStartedPage extends StatelessWidget { - /// + /// Constructor [GetStartedPage] const GetStartedPage(); - /// - @override Widget build(BuildContext context) => DerivGetStartedLayout( slides: AuthData().data.getStartedPage.slides, appLogoIconPath: AuthData().data.getStartedPage.appLogoIconPath, backgroundImagePath: AuthData().data.getStartedPage.backgroundImagePath, onLoginTapped: () => Navigator.of(context).push( - MaterialPageRoute( + MaterialPageRoute( builder: (BuildContext context) => const LoginPage(), ), ), onSignupTapped: () => Navigator.of(context).push( - MaterialPageRoute( + MaterialPageRoute( builder: (BuildContext context) => const SignupPage(), ), ), diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart index 900219243..a9b0f03fe 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/set_password_page.dart'; import 'package:flutter/material.dart'; @@ -29,18 +30,7 @@ class CountrySelectionPage extends StatelessWidget { ), ); }, - residences: Future.value([ - const DerivResidenceModel( - code: 'ID', - name: 'Indonesia', - isDisabled: false, - ), - const DerivResidenceModel( - code: 'UK', - name: 'England', - isDisabled: true, - ), - ]), + residences: AuthData().data.resetPassPageModel.residences, verificationCode: verificationCode, affiliateToken: affiliateToken, ); diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart index 727c26be2..7d373daf9 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -36,7 +37,7 @@ class SetPasswordPage extends StatelessWidget { ), ), ), - residence: 'id', + residence: AuthData().data.resetPassPageModel.residence, verificationCode: verificationCode, ); } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart index 712b8b31b..0a13d63fd 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart @@ -3,7 +3,6 @@ import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_deriv_api/api/response/app_update_response_result.dart'; /// Sing up page class SignupPage extends StatefulWidget { diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart index 008bc705f..09cacf63e 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart @@ -24,6 +24,7 @@ class _VerifyEmailPageState extends State { email: widget.email, onEmailNotReceivedPressed: () => onEmailNotReceivedPressed(context), ); + void onEmailNotReceivedPressed(BuildContext context) { Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (BuildContext context) => DerivEmailNotReceivedLayout( diff --git a/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart index a5409e9b3..f15fcaa86 100644 --- a/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart @@ -3,9 +3,9 @@ import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_auth/features/single_entry/features/get_started/pages/get_started_page.dart'; import 'package:flutter/material.dart'; -/// +/// Auth entry page for single entry class AuthEntryPage extends StatelessWidget { - /// + /// Constructor [AuthEntryPage] AuthEntryPage(AuthEntryModel entryData) { AuthData().data = entryData; } From fac89047f0d03c56358518e37fa3ae6318cad1f0 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Thu, 22 Feb 2024 11:43:08 +0800 Subject: [PATCH 12/48] chore(deriv_auth): change residence to userResidence --- .../single_entry/core/models/reset_pass_page_model.dart | 6 +++--- .../features/signup/pages/set_password_page.dart | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart index e7cca15bb..b19e0dcc7 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart @@ -7,7 +7,7 @@ class ResetPassPageModel { const ResetPassPageModel({ required this.onResetPassError, required this.residences, - required this.residence, + required this.userResidence, this.onResetPassSucceed, }); @@ -20,6 +20,6 @@ class ResetPassPageModel { /// List of residences to be shown. final Future> residences; - /// Residence - final String residence; + /// User residence like 'id' + final String userResidence; } diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart index 7d373daf9..6950bcdb3 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart @@ -37,7 +37,7 @@ class SetPasswordPage extends StatelessWidget { ), ), ), - residence: AuthData().data.resetPassPageModel.residence, + residence: AuthData().data.resetPassPageModel.userResidence, verificationCode: verificationCode, ); } From 59278c7321f69c8f3c1f63a0973efdb5f01ed4f9 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Mon, 26 Feb 2024 14:01:17 +0800 Subject: [PATCH 13/48] doc(deriv_auth): single entry doc and fix error handling --- .../layouts/deriv_choose_new_pass_layout.dart | 5 +- .../layouts/deriv_reset_pass_layout.dart | 7 +- .../lib/features/single_entry/README.md | 86 +++++++++++++++++++ .../reset_pass/pages/reset_pass_page.dart | 10 +-- 4 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 packages/deriv_auth/lib/features/single_entry/README.md diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart index 4ecaf102e..68dafc6cf 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart @@ -60,8 +60,9 @@ class _DerivChooseNewPassLayoutState extends State { widget.onResetPassSucceed(); } else if (state is DerivResetPassErrorState) { widget.onResetPassError( - error: state.errorMessage, - isLinkExpired: state.isLinkExpired); + error: state.errorMessage, + isLinkExpired: state.isLinkExpired, + ); } }, child: _buildChooseNewPassSection(context), diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart index 9dc078629..e5406a496 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart @@ -18,7 +18,7 @@ class DerivResetPassLayout extends StatefulWidget { }) : super(key: key); /// Callback to be called when reset pass fails. - final Function(String?) onResetPassError; + final ResetPassErrorCallback onResetPassError; @override State createState() => _DerivResetPassLayoutState(); @@ -57,7 +57,10 @@ class _DerivResetPassLayoutState extends State { curve: Curves.easeInOut, ); } else if (state is DerivResetPassErrorState) { - widget.onResetPassError(state.errorMessage); + widget.onResetPassError( + error: state.errorMessage, + isLinkExpired: state.isLinkExpired, + ); } }, child: PageView( diff --git a/packages/deriv_auth/lib/features/single_entry/README.md b/packages/deriv_auth/lib/features/single_entry/README.md new file mode 100644 index 000000000..a595a6bfb --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/README.md @@ -0,0 +1,86 @@ +## Single Entry: + +Single entry will enable you to just call one Widget and get the entire Authentication flow
+ +#### Example: + +```Dart +AuthEntryPage( + AuthEntryModel( + getStartedPage: GetStartedPageModel( + slides: [ + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/charts.svg', + supportingText: 'Charts', + ), + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/live_chat.svg', + supportingText: 'Live Chat', + ), + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/markets.svg', + supportingText: 'Markets', + ), + ], + appLogoIconPath: + 'lib/auth/assets/images/ic_logo_extended.svg', + backgroundImagePath: 'lib/auth/assets/images/triangles.svg', + ), + loginPageModel: LoginPageModel( + welcomeLabel: 'Welcome back testing!', + greetingLabel: + 'Log in to your Deriv account to start trading and investing.', + onLoggedIn: (_) => HomePageRoute().go(context), + authErrorStateHandler: + AuthErrorStateHandler(context: context), + onLoginError: (_) {}, + onSocialAuthButtonPressed: (_) {}, + isSocialAuthEnabled: false, + socialAuthStateHandler: (SocialAuthState) {}, + redirectURL: '', + onWebViewError: (String) {}, + ), + derivAuthCubit: BlocProvider.of(context), + signupPageModel: SignupPageModel( + verificationCode: '', + signupPageLable: 'Start trading with Deriv', + signupPageDescription: + 'Join over 1 million traders worldwide who loves trading at Deriv.', + isSocialAuthEnabled: false, + onSingupError: (DerivSignupErrorState) {}, + socialAuthStateHandler: (SocialAuthState) {}, + redirectURL: '', + onWebViewError: (String) {}, + ), + settingPageModel: SettingPageModel( + appLabel: 'dblanc', + appId: () => PrefService.getString('appId') ?? defaultAppId, + endpoint: () => + PrefService.getString('endpoint') ?? defaultEndpoint, + saveValues: _saveValues, + updateFlavorConfigs: _updateFlavorConfigs, + ), + resetPassPageModel: ResetPassPageModel( + onResetPassSucceed: () {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, + residences: Future.value([ + const DerivResidenceModel( + isDisabled: false, + name: 'Indonecsia', + code: 'ID', + ), + const DerivResidenceModel( + isDisabled: true, + name: 'England', + code: 'UK', + ), + ]), + userResidence: 'id', + ), + ), + ), + +``` diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart index 24200e4ef..0c0bcf3c7 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart @@ -1,5 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_ui/deriv_ui.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:flutter/material.dart'; /// Reset password page @@ -14,12 +14,6 @@ class ResetPassPage extends StatefulWidget { class _ResetPasswordPageState extends State { @override Widget build(BuildContext context) => DerivResetPassLayout( - onResetPassError: (String? errorMessage) { - showErrorDialog( - context: context, - errorMessage: errorMessage, - actionLabel: 'okay', - ); - }, + onResetPassError: AuthData().data.resetPassPageModel.onResetPassError, ); } From d4eb573eb7545d423031240a5bcc9f3af71075ff Mon Sep 17 00:00:00 2001 From: Ahrar Date: Mon, 26 Feb 2024 14:07:19 +0800 Subject: [PATCH 14/48] chore(deriv_auth): fixing the deriv reset pass layout test --- .../layouts/deriv_reset_pass_layout_test.dart | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart index 30c43f2a3..b2e69bca5 100644 --- a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart +++ b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart @@ -1,7 +1,6 @@ // ignore_for_file: always_specify_types import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,7 +31,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -53,7 +55,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -77,7 +82,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -102,7 +110,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -132,7 +143,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -162,7 +176,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) { + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) { onResetPassErrorCalled = true; }, ), From e96c81278999fa2dfae57e6adf5785bb82a51fe3 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 26 Feb 2024 18:13:57 +0400 Subject: [PATCH 15/48] feat(deriv_auth): added deriv_passkeys to deriv_auth --- packages/deriv_auth/analysis_options.yaml | 2 - packages/deriv_auth/assets/icons/ic_apple.svg | 6 +- .../deriv_auth/assets/icons/ic_facebook.svg | 7 +-- .../deriv_auth/assets/icons/ic_google.svg | 11 ++-- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- packages/deriv_auth/example/ios/Podfile | 2 +- packages/deriv_auth/example/ios/Podfile.lock | 47 +++++++++----- .../ios/Runner.xcodeproj/project.pbxproj | 8 +-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../deriv_auth_connection_info.dart | 11 ++++ packages/deriv_auth/example/lib/main.dart | 33 +++++++++- packages/deriv_auth/example/pubspec.yaml | 21 +++++++ .../core/extensions/string_extensions.dart | 6 ++ .../widgets/deriv_social_auth_panel.dart | 62 +++++++++++++------ packages/deriv_auth/pubspec.yaml | 17 +++++ 15 files changed, 180 insertions(+), 57 deletions(-) create mode 100644 packages/deriv_auth/example/lib/features/social_auth/deriv_auth_connection_info.dart diff --git a/packages/deriv_auth/analysis_options.yaml b/packages/deriv_auth/analysis_options.yaml index e2bfedad3..fd638b40c 100644 --- a/packages/deriv_auth/analysis_options.yaml +++ b/packages/deriv_auth/analysis_options.yaml @@ -1,6 +1,4 @@ analyzer: - exclude: - - example/** errors: todo: ignore missing_required_param: warning diff --git a/packages/deriv_auth/assets/icons/ic_apple.svg b/packages/deriv_auth/assets/icons/ic_apple.svg index 34181e5d0..c4d2a029c 100644 --- a/packages/deriv_auth/assets/icons/ic_apple.svg +++ b/packages/deriv_auth/assets/icons/ic_apple.svg @@ -1,4 +1,4 @@ - - - + + + diff --git a/packages/deriv_auth/assets/icons/ic_facebook.svg b/packages/deriv_auth/assets/icons/ic_facebook.svg index 65b214b79..cb9d842fd 100644 --- a/packages/deriv_auth/assets/icons/ic_facebook.svg +++ b/packages/deriv_auth/assets/icons/ic_facebook.svg @@ -1,5 +1,4 @@ - - - - + + + diff --git a/packages/deriv_auth/assets/icons/ic_google.svg b/packages/deriv_auth/assets/icons/ic_google.svg index 4759de29f..8c0cc5a9d 100644 --- a/packages/deriv_auth/assets/icons/ic_google.svg +++ b/packages/deriv_auth/assets/icons/ic_google.svg @@ -1,7 +1,6 @@ - - - - - - + + + + + diff --git a/packages/deriv_auth/example/ios/Flutter/AppFrameworkInfo.plist b/packages/deriv_auth/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105d..7c5696400 100644 --- a/packages/deriv_auth/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/deriv_auth/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/packages/deriv_auth/example/ios/Podfile b/packages/deriv_auth/example/ios/Podfile index fdcc671eb..487163519 100644 --- a/packages/deriv_auth/example/ios/Podfile +++ b/packages/deriv_auth/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +platform :ios, '15.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/deriv_auth/example/ios/Podfile.lock b/packages/deriv_auth/example/ios/Podfile.lock index 3d9f26088..68f06f5d9 100644 --- a/packages/deriv_auth/example/ios/Podfile.lock +++ b/packages/deriv_auth/example/ios/Podfile.lock @@ -2,22 +2,29 @@ PODS: - connectivity_plus (0.0.1): - Flutter - ReachabilitySwift + - deriv_passkeys (0.0.1): + - Flutter - device_info_plus (0.0.1): - Flutter - Flutter (1.0.0) - flutter_deriv_api (0.0.1): - Flutter - - flutter_inappwebview (0.0.1): + - flutter_inappwebview_ios (0.0.1): - Flutter - - flutter_inappwebview/Core (= 0.0.1) + - flutter_inappwebview_ios/Core (= 0.0.1) - OrderedSet (~> 5.0) - - flutter_inappwebview/Core (0.0.1): + - flutter_inappwebview_ios/Core (0.0.1): - Flutter - OrderedSet (~> 5.0) - OrderedSet (5.0.0) - package_info_plus (0.4.5): - Flutter - ReachabilitySwift (5.0.0) + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS + - uni_links2 (0.0.1): + - Flutter - url_launcher_ios (0.0.1): - Flutter - webview_flutter_wkwebview (0.0.1): @@ -25,11 +32,14 @@ PODS: DEPENDENCIES: - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) + - deriv_passkeys (from `.symlinks/plugins/deriv_passkeys/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - Flutter (from `Flutter`) - flutter_deriv_api (from `.symlinks/plugins/flutter_deriv_api/ios`) - - flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`) + - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) + - uni_links2 (from `.symlinks/plugins/uni_links2/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) @@ -41,33 +51,42 @@ SPEC REPOS: EXTERNAL SOURCES: connectivity_plus: :path: ".symlinks/plugins/connectivity_plus/ios" + deriv_passkeys: + :path: ".symlinks/plugins/deriv_passkeys/ios" device_info_plus: :path: ".symlinks/plugins/device_info_plus/ios" Flutter: :path: Flutter flutter_deriv_api: :path: ".symlinks/plugins/flutter_deriv_api/ios" - flutter_inappwebview: - :path: ".symlinks/plugins/flutter_inappwebview/ios" + flutter_inappwebview_ios: + :path: ".symlinks/plugins/flutter_inappwebview_ios/ios" package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" + uni_links2: + :path: ".symlinks/plugins/uni_links2/ios" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" webview_flutter_wkwebview: :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: - connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e + connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d + deriv_passkeys: fadd039a48bae6f15ba8b955481a0f8f2b5bdede device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_deriv_api: 9e29abd7cc5091b72303f9c8be549618415f1437 - flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721 + flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c - package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 - url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 - webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a + shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + uni_links2: fbc37081577fc19c6e0f7e6cdbd3baa150023635 + url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 + webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4 -PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 +PODFILE CHECKSUM: 9c46fd01abff66081b39f5fa5767b3f1d0b11d76 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.3 diff --git a/packages/deriv_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/deriv_auth/example/ios/Runner.xcodeproj/project.pbxproj index 3d5f8164c..0572134d3 100644 --- a/packages/deriv_auth/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/deriv_auth/example/ios/Runner.xcodeproj/project.pbxproj @@ -215,7 +215,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 331C8080294A63A400263BE5 = { @@ -452,7 +452,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -579,7 +579,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -628,7 +628,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/packages/deriv_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/deriv_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index e42adcb34..87131a09b 100644 --- a/packages/deriv_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/deriv_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ ConnectionCubit.appId; + + @override + String get endpoint => ConnectionCubit.endpoint; +} diff --git a/packages/deriv_auth/example/lib/main.dart b/packages/deriv_auth/example/lib/main.dart index 3b0ad9175..ed6115f68 100644 --- a/packages/deriv_auth/example/lib/main.dart +++ b/packages/deriv_auth/example/lib/main.dart @@ -1,4 +1,10 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_http_client/deriv_http_client.dart'; +import 'package:deriv_passkeys/data/data_sources/deriv_passkeys_data_source.dart'; +import 'package:deriv_passkeys/data/mappers/deriv_passkeys_mapper.dart'; +import 'package:deriv_passkeys/data/repositories/deriv_passkeys_repository.dart'; +import 'package:deriv_passkeys/interactor/services/deriv_passkeys_service.dart'; +import 'package:deriv_passkeys/presentation/states/bloc/deriv_passkeys_bloc.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:device_preview/device_preview.dart'; import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations.dart'; @@ -6,6 +12,7 @@ import 'package:example/features/get_started/pages/get_started_page.dart'; import 'package:example/features/login/repositories/example_login_repository.dart'; import 'package:example/features/signup/repositories/example_referral_repository.dart'; import 'package:example/features/signup/repositories/example_signup_repository.dart'; +import 'package:example/features/social_auth/deriv_auth_connection_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,9 +22,11 @@ void main() { /// Added [DevicePreview] while fixing on UI issue /// that was only in smaller devices. This later can be removed /// when we are fully using widget book. - runApp(DevicePreview( - builder: (context) => const MyApp(), - )); + runApp( + DevicePreview( + builder: (context) => const MyApp(), + ), + ); } class MyApp extends StatelessWidget { @@ -40,6 +49,24 @@ class MyApp extends StatelessWidget { referralService: ExampleReferralRepository(), ), ), + BlocProvider( + create: (context) => SocialAuthCubit( + socialAuthService: DerivSocialAuthService( + client: HttpClient(), + connectionInfo: DerivAuthConnectionInfo(), + ), + ), + ), + BlocProvider( + create: (context) => DerivPasskeysBloc( + DerivPasskeysService( + DerivPasskeysRepository( + DerivPasskeysDataSource( + DerivPasskeysMapper(), + ), + ), + ), + )), ], child: DerivThemeProvider.builder( initialTheme: ThemeMode.dark, diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index e104b27a4..c6f8b8431 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -17,6 +17,27 @@ dependencies: flutter_bloc: ^8.1.3 http: ^0.13.6 device_preview: ^1.1.0 + deriv_http_client: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_http_client + ref: deriv_http_client-v1.0.0 + deriv_passkeys: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_passkeys + ref: e41aed43e93fdeb66adb37fd8094532e9a8a172f + +dependency_overrides: + flutter_deriv_api: + git: + url: git@github.com:deriv-com/flutter-deriv-api.git + ref: 64ad3673598ad807b43f751fc2ec7bc5ef01203e + deriv_ui: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_ui + ref: deriv_ui-v0.0.6+1 dev_dependencies: flutter_test: diff --git a/packages/deriv_auth/lib/core/extensions/string_extensions.dart b/packages/deriv_auth/lib/core/extensions/string_extensions.dart index 8c2f488ce..dc5727920 100644 --- a/packages/deriv_auth/lib/core/extensions/string_extensions.dart +++ b/packages/deriv_auth/lib/core/extensions/string_extensions.dart @@ -25,3 +25,9 @@ extension RegexExtension on String { /// Signup valid Password Regex. bool get isValidSignupPassword => validPasswordRegex.hasMatch(this); } + +/// Extension methods for capitalizing [String]. +extension Capitalize on String { + /// Capitalize the first letter of the string. + String get capitalize => '${this[0].toUpperCase()}${substring(1)}'; +} diff --git a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart index f13918148..609406fa8 100644 --- a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart +++ b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_passkeys/presentation/widgets/continue_with_passkey_button.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; @@ -65,31 +66,56 @@ class _DerivSocialAuthPanelState extends State { listener: (BuildContext context, SocialAuthState state) { widget.socialAuthStateHandler(state); }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _buildSocialAuthButton(SocialAuthProvider.apple), - const SizedBox(width: ThemeProvider.margin24), - _buildSocialAuthButton(SocialAuthProvider.google), - const SizedBox(width: ThemeProvider.margin24), - _buildSocialAuthButton(SocialAuthProvider.facebook), - ], + child: SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const ContinueWithPasskeyButton(), + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.google), + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.facebook), + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.apple), + ], + ), ), ), ); Widget _buildSocialAuthButton(SocialAuthProvider socialAuthProvider) => - IconButton( - padding: EdgeInsets.zero, - iconSize: ThemeProvider.iconSize40, - icon: Opacity( - opacity: getOpacity(isEnabled: widget.isEnabled), - child: SvgPicture.asset( - _getSocialMediaIcon(socialAuthProvider), - package: 'deriv_auth', + InkWell( + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + color: context.theme.colors.active, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + _getSocialMediaIcon(socialAuthProvider), + package: 'deriv_auth', + ), + const SizedBox(width: 8), + Text( + socialAuthProvider.name.capitalize, + style: context.theme.textStyle( + textStyle: TextStyles.body2, + color: context.theme.colors.prominent, + ), + ), + ], ), ), - onPressed: widget.isEnabled + onTap: widget.isEnabled ? () { _socialAuthCubit.selectSocialLoginProvider( selectedSocialAuthProvider: socialAuthProvider, diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index acd7748e4..a78417720 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -48,6 +48,12 @@ dependencies: path: packages/deriv_localizations ref: deriv_localizations-v1.1.1 + deriv_passkeys: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_passkeys + ref: e41aed43e93fdeb66adb37fd8094532e9a8a172f + flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 smooth_page_indicator: ^1.1.0 @@ -57,6 +63,17 @@ dependencies: http: ^0.13.5 uni_links2: ^0.6.0+2 +dependency_overrides: + flutter_deriv_api: + git: + url: git@github.com:deriv-com/flutter-deriv-api.git + ref: 64ad3673598ad807b43f751fc2ec7bc5ef01203e + deriv_ui: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_ui + ref: deriv_ui-v0.0.6+1 + dev_dependencies: mocktail: ^1.0.3 bloc_test: ^9.1.3 From d966d9f28a743d652dd14174827da5e20a697664 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 27 Feb 2024 15:25:19 +0400 Subject: [PATCH 16/48] refactor(deriv_auth): updated passkeys dependencies. --- packages/deriv_auth/example/pubspec.yaml | 2 +- packages/deriv_auth/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index c6f8b8431..a0f3da94c 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: e41aed43e93fdeb66adb37fd8094532e9a8a172f + ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e dependency_overrides: flutter_deriv_api: diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index a78417720..f52dbd562 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: e41aed43e93fdeb66adb37fd8094532e9a8a172f + ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From ac5dd5895caf6f2f2e60b2906a38f6ac27bfc11a Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 27 Feb 2024 18:47:41 +0400 Subject: [PATCH 17/48] refactor(deriv_auth): fixing deriv_passkeys dependencies --- packages/deriv_auth/example/pubspec.yaml | 2 +- packages/deriv_auth/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index a0f3da94c..85d916e17 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -37,7 +37,7 @@ dependency_overrides: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.0.6+1 + ref: deriv_ui-v0.0.6+2 dev_dependencies: flutter_test: diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index a111a38e0..368979052 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -72,7 +72,7 @@ dependency_overrides: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.0.6+1 + ref: deriv_ui-v0.0.6+2 dev_dependencies: mocktail: ^1.0.3 From 2ade47f5f42a37325e4e4906c8c095fc26d777b6 Mon Sep 17 00:00:00 2001 From: sahani-deriv <125638269+sahani-deriv@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:51:42 +0800 Subject: [PATCH 18/48] refactor(deriv_ui): update deriv_ui dependencies (#499) --- packages/deriv_ui/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_ui/pubspec.yaml b/packages/deriv_ui/pubspec.yaml index d3646bf28..09b93eeca 100644 --- a/packages/deriv_ui/pubspec.yaml +++ b/packages/deriv_ui/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_web_view - ref: deriv_web_view-v0.2.0 + ref: deriv_web_view-v0.2.1 flutter_svg: ^2.0.7 intl: ^0.18.0 From 2a7e09002d70a352bda60d06f9162e91e67d625f Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:56:39 +0800 Subject: [PATCH 19/48] chore(version): bump version and update changelog (#500) * chore(release): publish packages - deriv_ui@0.0.6+4 - deriv_auth@6.0.2 * [create-pull-request] automated change --------- Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: sahani-deriv --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ README.md | 8 ++++---- packages/deriv_auth/CHANGELOG.md | 4 ++++ packages/deriv_auth/pubspec.yaml | 4 ++-- packages/deriv_ui/CHANGELOG.md | 4 ++++ packages/deriv_ui/pubspec.yaml | 2 +- 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a354052..66392cd4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-02-29 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_ui` - `v0.0.6+4`](#deriv_ui---v0064) + - [`deriv_auth` - `v6.0.2`](#deriv_auth---v602) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `deriv_auth` - `v6.0.2` + +--- + +#### `deriv_ui` - `v0.0.6+4` + + - **REFACTOR**(deriv_ui): update deriv_ui dependencies ([#499](https://github.com/regentmarkets/flutter-deriv-packages/issues/499)). ([2ade47f5](https://github.com/regentmarkets/flutter-deriv-packages/commit/2ade47f5f42a37325e4e4906c8c095fc26d777b6)) + + ## 2024-02-29 ### Changes diff --git a/README.md b/README.md index c54c6cb26..5c988f5d5 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ This repository contains private packages & plugins that are used by the company ## Using the packages -Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.0.0)`. To use the package, add the following to your pubspec.yaml file: +Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.0.2)`. To use the package, add the following to your pubspec.yaml file: ```yaml deriv_ui: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.0.6+3 #your prefered version + ref: deriv_ui-v0.0.6+4 #your prefered version ``` ## Packages @@ -19,7 +19,7 @@ deriv_ui: | Name | Description | Version | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase' and 'Segment'. | [v1.0.2](./packages/analytics/CHANGELOG.md) | -| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.0.1 ](./packages/deriv_auth/CHANGELOG.md) | +| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.0.2 ](./packages/deriv_auth/CHANGELOG.md) | | [deriv_banner](./packages/deriv_banner) | A widget to show banner in apps. | [v0.0.1+1](./packages/deriv_banner/CHANGELOG.md) | | [deriv_bloc_manager](./packages/deriv_bloc_manager) | Provides some tools to manage blocs. | [v0.0.1](./packages/deriv_bloc_manager/CHANGELOG.md) | | [deriv_datadog](./packages/deriv_datadog) | A package that helps you monitor the performance and user interactions of your Flutter app by sending data to Datadog. | [v0.0.1](./packages/deriv_datadog/CHANGELOG.md) | @@ -36,7 +36,7 @@ deriv_ui: | [deriv_store_launcher](./packages/deriv_store_launcher) | A plugin to launch app stores base on platform and manufacturer. | [v0.0.1+1](./packages/deriv_store_launcher/CHANGELOG.md) | | [deriv_technical_analysis](./packages/deriv_technical_analysis) | A Dart package for Technical Analysis. | [v0.0.1](./packages/deriv_technical_analysis/CHANGELOG.md) | | [deriv_theme](./packages/deriv_theme) | A package that contains the theme used by Deriv products. | [v2.2.0](./packages/deriv_theme/CHANGELOG.md) | -| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.0.6+3](./packages/deriv_ui/CHANGELOG.md) | +| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.0.6+4](./packages/deriv_ui/CHANGELOG.md) | | [deriv_utilities](./packages/deriv_utilities) | A package that contains the utilities including helper functions, mixins, and extensions. | [v1.0.0](./packages/deriv_utilities/CHANGELOG.md) | | [deriv_websocket](./packages/deriv_web_socket_client) | A package that provides a easy to use websocket client. | [v1.0.1](./packages/deriv_web_socket_client/CHANGELOG.md) | | [deriv_web_view](./packages/deriv_web_view) | Deriv web view package. | [v0.2.1](./packages/deriv_web_view/CHANGELOG.md) | diff --git a/packages/deriv_auth/CHANGELOG.md b/packages/deriv_auth/CHANGELOG.md index acabb075a..50c2ae607 100644 --- a/packages/deriv_auth/CHANGELOG.md +++ b/packages/deriv_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.2 + + - Update a dependency to the latest release. + ## 6.0.0 > Note: This release has breaking changes. diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 86bf4452d..cc506bfa1 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_auth description: Provides deriv authentication functionalities for dart/flutter apps. -version: 6.0.1 +version: 6.0.2 environment: sdk: ">=3.0.0 <4.0.0" @@ -22,7 +22,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.0.6+3 + ref: deriv_ui-v0.0.6+4 deriv_http_client: git: diff --git a/packages/deriv_ui/CHANGELOG.md b/packages/deriv_ui/CHANGELOG.md index 92cd744ff..7d52b3c14 100644 --- a/packages/deriv_ui/CHANGELOG.md +++ b/packages/deriv_ui/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.6+4 + + - **REFACTOR**(deriv_ui): update deriv_ui dependencies ([#499](https://github.com/regentmarkets/flutter-deriv-packages/issues/499)). ([2ade47f5](https://github.com/regentmarkets/flutter-deriv-packages/commit/2ade47f5f42a37325e4e4906c8c095fc26d777b6)) + ## 0.0.6+3 - Update a dependency to the latest release. diff --git a/packages/deriv_ui/pubspec.yaml b/packages/deriv_ui/pubspec.yaml index 09b93eeca..daa329820 100644 --- a/packages/deriv_ui/pubspec.yaml +++ b/packages/deriv_ui/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_ui description: A new Flutter package project. -version: 0.0.6+3 +version: 0.0.6+4 publish_to: none environment: From e594c05b87c05d189913a7de8b9e1e4e6d03b76a Mon Sep 17 00:00:00 2001 From: Ahrar <98078754+ahrar-deriv@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:28:48 +0800 Subject: [PATCH 20/48] feat(deriv_auth): single entry (#420) * feat(deriv_auth): single entry feat that adds a single entry to the auth package * chore(deriv_auth): improve some imports * chore(deriv_auth): change deriv-api to dev branch change deriv_api to dev branch and package_info_plus to version 4 * feat(deriv_auth): adding login page to single entry * feat(deriv_auth): single entry login and reset pass added * feat(deriv_auth): single entry signup page * chore: setting page fist attempt * feat(deriv_auith): single entry setting page * feat(deriv_auth): single entry reset password and merge conflicts * chore(deriv_auth): code review comments add docs and minor changes * chore(deriv_auth): change residence to userResidence * doc(deriv_auth): single entry doc and fix error handling * chore(deriv_auth): fixing the deriv reset pass layout test * chore(deriv_auth): change navigation to signupPage in verifyemailpage --- packages/deriv_auth/lib/core/core.dart | 16 ++++ .../deriv_auth/lib/core/helpers/helpers.dart | 1 + .../core/states/auth_error_state_mapper.dart | 1 - .../lib/core/states/auth_state_listener.dart | 1 - .../deriv_auth/lib/core/states/states.dart | 1 + packages/deriv_auth/lib/deriv_auth.dart | 49 +---------- .../deriv_auth/lib/features/auth/auth.dart | 4 + .../deriv_auth/lib/features/features.dart | 8 ++ .../lib/features/get_started/get_started.dart | 2 + .../deriv_auth/lib/features/login/login.dart | 2 + .../layouts/deriv_choose_new_pass_layout.dart | 5 +- .../layouts/deriv_reset_pass_layout.dart | 7 +- .../reset_password/reset_password.dart | 6 ++ .../layouts/deriv_setting_layout.dart | 22 ++--- .../features/setting_page/setting_page.dart | 1 + .../layouts/deriv_set_password_layout.dart | 2 - .../layouts/deriv_signup_layout.dart | 2 +- .../lib/features/signup/signup.dart | 15 ++++ .../lib/features/single_entry/README.md | 86 +++++++++++++++++++ .../features/single_entry/core/auth_data.dart | 23 +++++ .../core/models/auth_entry_model.dart | 32 +++++++ .../core/models/get_started_page_model.dart | 20 +++++ .../core/models/login_page_model.dart | 57 ++++++++++++ .../single_entry/core/models/models.dart | 6 ++ .../core/models/reset_pass_page_model.dart | 25 ++++++ .../core/models/setting_page_model.dart | 27 ++++++ .../core/models/signup_page_model.dart | 54 ++++++++++++ .../get_started/pages/get_started_page.dart | 37 ++++++++ .../features/home/pages/home_page.dart | 30 +++++++ .../features/login/pages/login_page.dart | 58 +++++++++++++ .../pages/choose_new_password_page.dart | 29 +++++++ .../reset_pass/pages/reset_pass_page.dart | 19 ++++ .../pages/reset_pass_success_page.dart | 42 +++++++++ .../settings/pages/settings_page.dart | 24 ++++++ .../signup/pages/country_selection_page.dart | 37 ++++++++ .../signup/pages/set_password_page.dart | 43 ++++++++++ .../features/signup/pages/signup_page.dart | 46 ++++++++++ .../signup/pages/verification_done_page.dart | 35 ++++++++ .../signup/pages/verify_email_page.dart | 40 +++++++++ .../repositories/referral_repository.dart | 8 ++ .../single_entry/pages/auth_entry_page.dart | 15 ++++ .../features/single_entry/single_entry.dart | 2 + .../layouts/deriv_reset_pass_layout_test.dart | 31 +++++-- 43 files changed, 898 insertions(+), 73 deletions(-) create mode 100644 packages/deriv_auth/lib/core/core.dart create mode 100644 packages/deriv_auth/lib/features/auth/auth.dart create mode 100644 packages/deriv_auth/lib/features/features.dart create mode 100644 packages/deriv_auth/lib/features/get_started/get_started.dart create mode 100644 packages/deriv_auth/lib/features/login/login.dart create mode 100644 packages/deriv_auth/lib/features/reset_password/reset_password.dart create mode 100644 packages/deriv_auth/lib/features/setting_page/setting_page.dart create mode 100644 packages/deriv_auth/lib/features/signup/signup.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/README.md create mode 100644 packages/deriv_auth/lib/features/single_entry/core/auth_data.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/models.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart create mode 100644 packages/deriv_auth/lib/features/single_entry/single_entry.dart diff --git a/packages/deriv_auth/lib/core/core.dart b/packages/deriv_auth/lib/core/core.dart new file mode 100644 index 000000000..d90ac1ac4 --- /dev/null +++ b/packages/deriv_auth/lib/core/core.dart @@ -0,0 +1,16 @@ +export 'connection_info.dart'; +export 'exceptions/deriv_auth_exception.dart'; +export 'extensions/extensions.dart'; +export 'layouts/deriv_unavailable_country_layout.dart'; +export 'models/account_model.dart'; +export 'models/auth_error/auth_error.dart'; +export 'models/auth_error/auth_error_model.dart'; +export 'models/authorize_model.dart'; +export 'models/verify_email_model.dart'; +export 'services/jwt/repository/deriv_jwt_repository.dart'; +export 'services/jwt/services/deriv_jwt_service.dart'; +export 'services/referral/models/my_affiliate_referral_code_request_model.dart'; +export 'services/token/models/enums.dart'; +export 'services/token/services/deriv_token_service.dart'; +export 'states/states.dart'; +export 'helpers/helpers.dart'; diff --git a/packages/deriv_auth/lib/core/helpers/helpers.dart b/packages/deriv_auth/lib/core/helpers/helpers.dart index ab5f4b441..bc7dc3ce0 100644 --- a/packages/deriv_auth/lib/core/helpers/helpers.dart +++ b/packages/deriv_auth/lib/core/helpers/helpers.dart @@ -2,3 +2,4 @@ export 'account_helpers.dart'; export 'bool_helper.dart'; export 'date_time_helper.dart'; export 'number_helper.dart'; +export 'semantic_labels.dart'; diff --git a/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart b/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart index 05d10e41a..430d18fd7 100644 --- a/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart +++ b/packages/deriv_auth/lib/core/states/auth_error_state_mapper.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/states.dart'; import 'package:deriv_auth/deriv_auth.dart'; /// Maps the [DerivAuthErrorState] to the corresponding [AuthErrorStateHandler]. diff --git a/packages/deriv_auth/lib/core/states/auth_state_listener.dart b/packages/deriv_auth/lib/core/states/auth_state_listener.dart index f51e278d0..9fb0e14f6 100644 --- a/packages/deriv_auth/lib/core/states/auth_state_listener.dart +++ b/packages/deriv_auth/lib/core/states/auth_state_listener.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/states.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/packages/deriv_auth/lib/core/states/states.dart b/packages/deriv_auth/lib/core/states/states.dart index 7545c9d18..3fcce922f 100644 --- a/packages/deriv_auth/lib/core/states/states.dart +++ b/packages/deriv_auth/lib/core/states/states.dart @@ -1,2 +1,3 @@ export 'auth_error_state_mapper.dart'; export 'auth_error_state_handler.dart'; +export 'auth_state_listener.dart'; diff --git a/packages/deriv_auth/lib/deriv_auth.dart b/packages/deriv_auth/lib/deriv_auth.dart index c572fd6b2..3f246a444 100644 --- a/packages/deriv_auth/lib/deriv_auth.dart +++ b/packages/deriv_auth/lib/deriv_auth.dart @@ -1,47 +1,2 @@ -export 'core/connection_info.dart'; -export 'core/exceptions/deriv_auth_exception.dart'; -export 'core/extensions/extensions.dart'; -export 'core/models/account_model.dart'; -export 'core/models/auth_error/auth_error.dart'; -export 'core/models/auth_error/auth_error_model.dart'; -export 'core/models/authorize_model.dart'; -export 'core/models/verify_email_model.dart'; -export 'core/services/jwt/repository/deriv_jwt_repository.dart'; -export 'core/services/jwt/services/deriv_jwt_service.dart'; -export 'core/helpers/semantic_labels.dart'; -export 'core/services/token/models/enums.dart'; -export 'core/services/token/services/deriv_token_service.dart'; -export 'core/services/referral/models/my_affiliate_referral_code_request_model.dart'; -export 'features/auth/cubit/deriv_auth_cubit.dart'; -export 'features/auth/models/logout/logout_response.dart'; -export 'features/auth/repository/base_auth_repository.dart'; -export 'features/auth/services/deriv_auth_service.dart'; -export 'features/reset_password/cubit/reset_password_cubit.dart'; -export 'features/reset_password/repository/base_reset_password_repository.dart'; -export 'features/reset_password/services/deriv_reset_password_service.dart'; -export 'features/signup/cubit/signup_cubit.dart'; -export 'features/signup/models/new_virtual_account_request_model.dart'; -export 'features/signup/models/signup_error_type.dart'; -export 'features/signup/repository/base_signup_repository.dart'; -export 'features/signup/services/deriv_signup_service.dart'; -export 'features/social_auth/social_auth.dart'; -export 'core/layouts/deriv_unavailable_country_layout.dart'; -export 'features/get_started/presentation/layouts/deriv_get_started_layout.dart'; -export 'features/get_started/models/deriv_get_started_slide_model.dart'; -export 'features/login/presentation/layouts/deriv_2fa_layout.dart'; -export 'features/login/presentation/layouts/deriv_login_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart'; -export 'features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart'; -export 'features/setting_page/presentation/layouts/deriv_setting_layout.dart'; -export 'features/signup/cubit/deriv_country_selection_cubit.dart'; -export 'features/signup/presentation/layouts/deriv_country_selection_layout.dart'; -export 'features/signup/presentation/layouts/deriv_email_not_received_layout.dart'; -export 'features/signup/presentation/layouts/deriv_set_password_layout.dart'; -export 'features/signup/presentation/layouts/deriv_signup_layout.dart'; -export 'features/signup/presentation/layouts/deriv_verification_done_layout.dart'; -export 'features/signup/presentation/layouts/deriv_verify_email_layout.dart'; -export 'features/signup/models/deriv_auth_utm_model.dart'; -export 'features/signup/models/deriv_password_policy_model.dart'; -export 'features/signup/models/deriv_residence_model.dart'; -export 'core/states/states.dart'; +export 'core/core.dart'; +export 'features/features.dart'; diff --git a/packages/deriv_auth/lib/features/auth/auth.dart b/packages/deriv_auth/lib/features/auth/auth.dart new file mode 100644 index 000000000..5c56748d0 --- /dev/null +++ b/packages/deriv_auth/lib/features/auth/auth.dart @@ -0,0 +1,4 @@ +export 'cubit/deriv_auth_cubit.dart'; +export 'models/logout/logout_response.dart'; +export 'repository/base_auth_repository.dart'; +export 'services/deriv_auth_service.dart'; diff --git a/packages/deriv_auth/lib/features/features.dart b/packages/deriv_auth/lib/features/features.dart new file mode 100644 index 000000000..7712e281d --- /dev/null +++ b/packages/deriv_auth/lib/features/features.dart @@ -0,0 +1,8 @@ +export 'auth/auth.dart'; +export 'get_started/get_started.dart'; +export 'login/login.dart'; +export 'reset_password/reset_password.dart'; +export 'setting_page/setting_page.dart'; +export 'signup/signup.dart'; +export 'single_entry/single_entry.dart'; +export 'social_auth/social_auth.dart'; diff --git a/packages/deriv_auth/lib/features/get_started/get_started.dart b/packages/deriv_auth/lib/features/get_started/get_started.dart new file mode 100644 index 000000000..2604a2649 --- /dev/null +++ b/packages/deriv_auth/lib/features/get_started/get_started.dart @@ -0,0 +1,2 @@ +export 'models/deriv_get_started_slide_model.dart'; +export 'presentation/layouts/deriv_get_started_layout.dart'; diff --git a/packages/deriv_auth/lib/features/login/login.dart b/packages/deriv_auth/lib/features/login/login.dart new file mode 100644 index 000000000..2dba1e7ff --- /dev/null +++ b/packages/deriv_auth/lib/features/login/login.dart @@ -0,0 +1,2 @@ +export 'presentation/layouts/deriv_2fa_layout.dart'; +export 'presentation/layouts/deriv_login_layout.dart'; diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart index 4ecaf102e..68dafc6cf 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart @@ -60,8 +60,9 @@ class _DerivChooseNewPassLayoutState extends State { widget.onResetPassSucceed(); } else if (state is DerivResetPassErrorState) { widget.onResetPassError( - error: state.errorMessage, - isLinkExpired: state.isLinkExpired); + error: state.errorMessage, + isLinkExpired: state.isLinkExpired, + ); } }, child: _buildChooseNewPassSection(context), diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart index 9dc078629..e5406a496 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart @@ -18,7 +18,7 @@ class DerivResetPassLayout extends StatefulWidget { }) : super(key: key); /// Callback to be called when reset pass fails. - final Function(String?) onResetPassError; + final ResetPassErrorCallback onResetPassError; @override State createState() => _DerivResetPassLayoutState(); @@ -57,7 +57,10 @@ class _DerivResetPassLayoutState extends State { curve: Curves.easeInOut, ); } else if (state is DerivResetPassErrorState) { - widget.onResetPassError(state.errorMessage); + widget.onResetPassError( + error: state.errorMessage, + isLinkExpired: state.isLinkExpired, + ); } }, child: PageView( diff --git a/packages/deriv_auth/lib/features/reset_password/reset_password.dart b/packages/deriv_auth/lib/features/reset_password/reset_password.dart new file mode 100644 index 000000000..96b1adce5 --- /dev/null +++ b/packages/deriv_auth/lib/features/reset_password/reset_password.dart @@ -0,0 +1,6 @@ +export 'cubit/reset_password_cubit.dart'; +export 'presentation/layouts/deriv_choose_new_pass_layout.dart'; +export 'presentation/layouts/deriv_reset_pass_layout.dart'; +export 'presentation/layouts/deriv_success_pass_change_layout.dart'; +export 'repository/base_reset_password_repository.dart'; +export 'services/deriv_reset_password_service.dart'; diff --git a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart index 9d00ee918..e61f0d754 100644 --- a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart +++ b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart @@ -26,7 +26,8 @@ class DerivSettingLayout extends StatefulWidget { }) : super(key: key); /// Update flavor configurations - final Future updateFlavorConfigs; + final Function({required String endpoint, required String appId}) + updateFlavorConfigs; /// Save values to shared preferences final Function({required String endpoint, required String appId}) saveValues; @@ -75,18 +76,19 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) => WillPopScope( onWillPop: () async { + final String endpoint = _endpointController.text.isNotEmpty + ? _endpointController.text + : defaultEndpoint; + final String appId = _appIdController.text.isNotEmpty + ? _appIdController.text + : defaultAppId; + // Save Values to shared preferences - widget.saveValues( - endpoint: _endpointController.text.isNotEmpty - ? _endpointController.text - : defaultEndpoint, - appId: _appIdController.text.isNotEmpty - ? _appIdController.text - : defaultAppId, - ); + await widget.saveValues(endpoint: endpoint, appId: appId); // Update Flavor Configurations before dismissing the page - await widget.updateFlavorConfigs; + await widget.updateFlavorConfigs(endpoint: endpoint, appId: appId); + return true; }, child: Scaffold( diff --git a/packages/deriv_auth/lib/features/setting_page/setting_page.dart b/packages/deriv_auth/lib/features/setting_page/setting_page.dart new file mode 100644 index 000000000..224c7bff0 --- /dev/null +++ b/packages/deriv_auth/lib/features/setting_page/setting_page.dart @@ -0,0 +1 @@ +export 'presentation/layouts/deriv_setting_layout.dart'; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart index b08f83c61..d989c1306 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart @@ -1,8 +1,6 @@ import 'package:deriv_auth/core/helpers/assets.dart'; -import 'package:deriv_auth/core/states/auth_error_state_handler.dart'; import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/signup/models/deriv_auth_utm_model.dart'; import 'package:deriv_auth/features/signup/presentation/widgets/password_policy_checker_widget.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index a777f5153..c466189ed 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; @@ -136,6 +135,7 @@ class _DerivSignupLayoutState extends State { socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, onWebViewError: widget.onWebViewError, + onPressed: widget.onSocialAuthButtonPressed, ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), diff --git a/packages/deriv_auth/lib/features/signup/signup.dart b/packages/deriv_auth/lib/features/signup/signup.dart new file mode 100644 index 000000000..5b3b7d992 --- /dev/null +++ b/packages/deriv_auth/lib/features/signup/signup.dart @@ -0,0 +1,15 @@ +export 'cubit/deriv_country_selection_cubit.dart'; +export 'cubit/signup_cubit.dart'; +export 'models/deriv_auth_utm_model.dart'; +export 'models/deriv_password_policy_model.dart'; +export 'models/deriv_residence_model.dart'; +export 'models/new_virtual_account_request_model.dart'; +export 'models/signup_error_type.dart'; +export 'presentation/layouts/deriv_country_selection_layout.dart'; +export 'presentation/layouts/deriv_email_not_received_layout.dart'; +export 'presentation/layouts/deriv_set_password_layout.dart'; +export 'presentation/layouts/deriv_signup_layout.dart'; +export 'presentation/layouts/deriv_verification_done_layout.dart'; +export 'presentation/layouts/deriv_verify_email_layout.dart'; +export 'repository/base_signup_repository.dart'; +export 'services/deriv_signup_service.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/README.md b/packages/deriv_auth/lib/features/single_entry/README.md new file mode 100644 index 000000000..a595a6bfb --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/README.md @@ -0,0 +1,86 @@ +## Single Entry: + +Single entry will enable you to just call one Widget and get the entire Authentication flow
+ +#### Example: + +```Dart +AuthEntryPage( + AuthEntryModel( + getStartedPage: GetStartedPageModel( + slides: [ + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/charts.svg', + supportingText: 'Charts', + ), + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/live_chat.svg', + supportingText: 'Live Chat', + ), + DerivGetStartedSlideModel( + imagePath: 'lib/auth/assets/images/markets.svg', + supportingText: 'Markets', + ), + ], + appLogoIconPath: + 'lib/auth/assets/images/ic_logo_extended.svg', + backgroundImagePath: 'lib/auth/assets/images/triangles.svg', + ), + loginPageModel: LoginPageModel( + welcomeLabel: 'Welcome back testing!', + greetingLabel: + 'Log in to your Deriv account to start trading and investing.', + onLoggedIn: (_) => HomePageRoute().go(context), + authErrorStateHandler: + AuthErrorStateHandler(context: context), + onLoginError: (_) {}, + onSocialAuthButtonPressed: (_) {}, + isSocialAuthEnabled: false, + socialAuthStateHandler: (SocialAuthState) {}, + redirectURL: '', + onWebViewError: (String) {}, + ), + derivAuthCubit: BlocProvider.of(context), + signupPageModel: SignupPageModel( + verificationCode: '', + signupPageLable: 'Start trading with Deriv', + signupPageDescription: + 'Join over 1 million traders worldwide who loves trading at Deriv.', + isSocialAuthEnabled: false, + onSingupError: (DerivSignupErrorState) {}, + socialAuthStateHandler: (SocialAuthState) {}, + redirectURL: '', + onWebViewError: (String) {}, + ), + settingPageModel: SettingPageModel( + appLabel: 'dblanc', + appId: () => PrefService.getString('appId') ?? defaultAppId, + endpoint: () => + PrefService.getString('endpoint') ?? defaultEndpoint, + saveValues: _saveValues, + updateFlavorConfigs: _updateFlavorConfigs, + ), + resetPassPageModel: ResetPassPageModel( + onResetPassSucceed: () {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, + residences: Future.value([ + const DerivResidenceModel( + isDisabled: false, + name: 'Indonecsia', + code: 'ID', + ), + const DerivResidenceModel( + isDisabled: true, + name: 'England', + code: 'UK', + ), + ]), + userResidence: 'id', + ), + ), + ), + +``` diff --git a/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart b/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart new file mode 100644 index 000000000..a611c3682 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/auth_data.dart @@ -0,0 +1,23 @@ +// ignore_for_file: unnecessary_getters_setters + +import 'models/auth_entry_model.dart'; + +/// Authentication Data Singleton +class AuthData { + /// AuthData instance + factory AuthData() => _instance; + + AuthData._internal(); + + static final AuthData _instance = AuthData._internal(); + + late AuthEntryModel _data; + + /// data getter + AuthEntryModel get data => _data; + + /// data setter + set data(AuthEntryModel data) { + _data = data; + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart new file mode 100644 index 000000000..23b2a5336 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -0,0 +1,32 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// Auth Entry Model class +class AuthEntryModel { + /// Constructor [AuthEntryModel] + const AuthEntryModel({ + required this.getStartedPage, + required this.loginPageModel, + required this.derivAuthCubit, + required this.signupPageModel, + required this.settingPageModel, + required this.resetPassPageModel, + }); + + /// GetStartedPage data model + final GetStartedPageModel getStartedPage; + + /// LoginPage data model + final LoginPageModel loginPageModel; + + /// DerivAuthCubit + final DerivAuthCubit derivAuthCubit; + + /// SignupPage data model + final SignupPageModel signupPageModel; + + /// SettingPage data model + final SettingPageModel settingPageModel; + + /// ResetPassPage data model + final ResetPassPageModel resetPassPageModel; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart new file mode 100644 index 000000000..1bf244b2a --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/get_started_page_model.dart @@ -0,0 +1,20 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// Get Started Page Model +class GetStartedPageModel { + /// Constructor [GetStartedPageModel] + const GetStartedPageModel({ + required this.slides, + required this.appLogoIconPath, + required this.backgroundImagePath, + }); + + /// List of Deriv Get Started page Slides + final List slides; + + /// Logo icon path + final String appLogoIconPath; + + /// Background image path + final String backgroundImagePath; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart new file mode 100644 index 000000000..bfb98d9ef --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -0,0 +1,57 @@ +import 'package:deriv_auth/deriv_auth.dart'; + +/// LoginPageModel class +class LoginPageModel { + /// Initializes [LoginPageModel]. + const LoginPageModel({ + required this.onLoggedIn, + required this.onSocialAuthButtonPressed, + required this.welcomeLabel, + required this.greetingLabel, + required this.socialAuthStateHandler, + required this.redirectURL, + required this.onWebViewError, + this.isForgotPasswordEnabled = true, + this.isCreateAccountEnabled = true, + this.isSocialAuthEnabled = true, + this.authErrorStateHandler, + this.onLoginError, + }); + + /// Extension of base [AuthErrorStateHandler]. If not provided, base implementation will be used. + final AuthErrorStateHandler? authErrorStateHandler; + + /// Callback to be called when login error occurs. + final Function(DerivAuthErrorState)? onLoginError; + + /// Callback to be called when user is logged in. + final Function(DerivAuthLoggedInState) onLoggedIn; + + /// Callback to be called when social auth button is tapped. + /// Give access to [SocialAuthDto] for 2FA. + final SocialAuthCallback? onSocialAuthButtonPressed; + + /// Welcome text to be displayed on login page. + final String welcomeLabel; + + /// Greeting text to be displayed on login page. + final String greetingLabel; + + /// Whether to display social auth buttons. + final bool isSocialAuthEnabled; + + /// Whether to display forgot password section. + final bool isForgotPasswordEnabled; + + /// Whether to display create account section. + final bool isCreateAccountEnabled; + + /// Social auth state handler. + final Function(SocialAuthState) socialAuthStateHandler; + + /// Redirect URL for social auth. + final String redirectURL; + + /// Callback for web view error. + final Function(String) onWebViewError; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/models.dart b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart new file mode 100644 index 000000000..4aea9f511 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/models.dart @@ -0,0 +1,6 @@ +export 'auth_entry_model.dart'; +export 'get_started_page_model.dart'; +export 'login_page_model.dart'; +export 'signup_page_model.dart'; +export 'setting_page_model.dart'; +export 'reset_pass_page_model.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart new file mode 100644 index 000000000..b19e0dcc7 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/reset_pass_page_model.dart @@ -0,0 +1,25 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/foundation.dart' show VoidCallback; + +/// Reset password page model +class ResetPassPageModel { + /// Constructor [ResetPassPageModel] + const ResetPassPageModel({ + required this.onResetPassError, + required this.residences, + required this.userResidence, + this.onResetPassSucceed, + }); + + /// Callback to be called when reset pass fails. + final ResetPassErrorCallback onResetPassError; + + /// Callback to be called when reset pass succeeds. + final VoidCallback? onResetPassSucceed; + + /// List of residences to be shown. + final Future> residences; + + /// User residence like 'id' + final String userResidence; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart new file mode 100644 index 000000000..d0e8083d0 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/setting_page_model.dart @@ -0,0 +1,27 @@ +/// Setting page model +class SettingPageModel { + /// Constructor [SettingPageModel] + SettingPageModel({ + required this.appLabel, + required this.appId, + required this.endpoint, + required this.saveValues, + required this.updateFlavorConfigs, + }); + + /// Setting page App label + final String appLabel; + + /// application id + final String Function() appId; + + /// end point + final String Function() endpoint; + + /// Save values to shared preferences + final Function({required String endpoint, required String appId}) saveValues; + + /// Update flavor configurations + final Function({required String endpoint, required String appId}) + updateFlavorConfigs; +} diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart new file mode 100644 index 000000000..a182228c8 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/core/models/signup_page_model.dart @@ -0,0 +1,54 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/foundation.dart' show VoidCallback; + +/// Sign-up page model +class SignupPageModel { + /// Constructor [SignupPageModel] + SignupPageModel({ + required this.verificationCode, + required this.signupPageLable, + required this.signupPageDescription, + required this.onSingupError, + required this.isSocialAuthEnabled, + required this.socialAuthStateHandler, + required this.redirectURL, + required this.onWebViewError, + this.onSignupPressed, + this.onSocialAuthButtonPressed, + this.affiliateToken, + }); + + /// verification code + final String verificationCode; + + /// affiliate token + final String? affiliateToken; + + /// Callback to be called when signup button is pressed. + final VoidCallback? onSignupPressed; + + /// Callback to be called when signup error occurs. + final Function(DerivSignupErrorState) onSingupError; + + /// sing-up page label + final String signupPageLable; + + /// sign-up page description + final String signupPageDescription; + + /// is social auth enabled + final bool isSocialAuthEnabled; + + /// Social auth state handler. + final Function(SocialAuthState) socialAuthStateHandler; + + /// Redirect URL for social auth. + final String redirectURL; + + /// Callback for web view error. + final Function(String) onWebViewError; + + /// Callback to be called when social auth button is tapped. + /// Give access to [SocialAuthDto] for 2FA. + final SocialAuthCallback? onSocialAuthButtonPressed; +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart new file mode 100644 index 000000000..b09669843 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/get_started/pages/get_started_page.dart @@ -0,0 +1,37 @@ +import 'package:deriv_auth/features/get_started/presentation/layouts/deriv_get_started_layout.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/settings/pages/settings_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; +import 'package:flutter/material.dart'; + +/// Get started page +class GetStartedPage extends StatelessWidget { + /// Constructor [GetStartedPage] + const GetStartedPage(); + + @override + Widget build(BuildContext context) => DerivGetStartedLayout( + slides: AuthData().data.getStartedPage.slides, + appLogoIconPath: AuthData().data.getStartedPage.appLogoIconPath, + backgroundImagePath: AuthData().data.getStartedPage.backgroundImagePath, + onLoginTapped: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const LoginPage(), + ), + ), + onSignupTapped: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const SignupPage(), + ), + ), + onTapNavigation: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => const SettingsPage(), + ), + ); + }, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart b/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart new file mode 100644 index 000000000..b1ae6832a --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/home/pages/home_page.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Deriv Auth UI'), + ), + body: const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Deriv Auth UI', + style: TextStyle(fontSize: 24), + ), + SizedBox(height: 16), + Text( + 'Deriv Auth UI is a Flutter package that provides a set of ready-to-use widgets for building authentication flows in your app.', + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart new file mode 100644 index 000000000..7df28097f --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -0,0 +1,58 @@ +import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; +import 'package:deriv_auth/features/login/presentation/layouts/deriv_login_layout.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/home/pages/home_page.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +/// Login page +class LoginPage extends StatefulWidget { + /// Constructor [LoginPage] + const LoginPage({super.key}); + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + @override + void initState() { + BlocProvider.of(context).logout(); + super.initState(); + } + + @override + Widget build(BuildContext context) => DerivLoginLayout( + welcomeLabel: AuthData().data.loginPageModel.welcomeLabel, + greetingLabel: AuthData().data.loginPageModel.greetingLabel, + onLoggedIn: (_) => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (BuildContext context) => const HomePage(), + ), + ), + authErrorStateHandler: + AuthData().data.loginPageModel.authErrorStateHandler, + onLoginError: AuthData().data.loginPageModel.onLoginError, + onResetPassTapped: () => Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => const ResetPassPage(), + ), + ), + onSignupTapped: () => Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (BuildContext context) => const SignupPage(), + ), + ), + onSocialAuthButtonPressed: + AuthData().data.loginPageModel.onSocialAuthButtonPressed, + socialAuthStateHandler: + AuthData().data.loginPageModel.socialAuthStateHandler, + redirectURL: AuthData().data.loginPageModel.redirectURL, + onWebViewError: AuthData().data.loginPageModel.onWebViewError, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart new file mode 100644 index 000000000..7b1ed804b --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -0,0 +1,29 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart'; +import 'package:flutter/material.dart'; + +/// Choose new password page +class ChooseNewPasswordPage extends StatelessWidget { + /// Constructor [ChooseNewPasswordPage] + const ChooseNewPasswordPage({required this.token, super.key}); + + /// Token + final String token; + + @override + Widget build(BuildContext context) => DerivChooseNewPassLayout( + token: token, + onResetPassSucceed: + AuthData().data.resetPassPageModel.onResetPassSucceed ?? + () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => + const ResetPassSuccessPage(), + ), + ); + }, + onResetPassError: AuthData().data.resetPassPageModel.onResetPassError, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart new file mode 100644 index 000000000..0c0bcf3c7 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_page.dart @@ -0,0 +1,19 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:flutter/material.dart'; + +/// Reset password page +class ResetPassPage extends StatefulWidget { + /// Constructor for reset password page + const ResetPassPage({super.key}); + + @override + State createState() => _ResetPasswordPageState(); +} + +class _ResetPasswordPageState extends State { + @override + Widget build(BuildContext context) => DerivResetPassLayout( + onResetPassError: AuthData().data.resetPassPageModel.onResetPassError, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart new file mode 100644 index 000000000..cec69f638 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart @@ -0,0 +1,42 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:flutter/material.dart'; + +/// Reset Password success page +class ResetPassSuccessPage extends StatefulWidget { + /// Constructor [ResetPassSuccessPage] + const ResetPassSuccessPage({super.key}); + + @override + State createState() => _ResetPassSuccessPageState(); +} + +class _ResetPassSuccessPageState extends State { + static const Duration _successPageHoldDuration = Duration(seconds: 2); + + @override + void initState() { + super.initState(); + + // wait for either [_successPageHoldDuration] or logout to finish + // then navigate to loginPage + Future.wait( + >[ + Future.delayed(_successPageHoldDuration), + AuthData().data.derivAuthCubit.logout(), + ], + ).then( + (_) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const LoginPage(), + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) => const DerivSuccessPassChangeLayout(); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart new file mode 100644 index 000000000..149c3a540 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/settings/pages/settings_page.dart @@ -0,0 +1,24 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:flutter/material.dart'; + +/// Setting page +class SettingsPage extends StatefulWidget { + /// Constructor for setting page + const SettingsPage({super.key}); + + @override + State createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State { + @override + Widget build(BuildContext context) => DerivSettingLayout( + updateFlavorConfigs: + AuthData().data.settingPageModel.updateFlavorConfigs, + appLabel: AuthData().data.settingPageModel.appLabel, + saveValues: AuthData().data.settingPageModel.saveValues, + appId: AuthData().data.settingPageModel.appId.call(), + endpoint: AuthData().data.settingPageModel.endpoint.call(), + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart new file mode 100644 index 000000000..a9b0f03fe --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/country_selection_page.dart @@ -0,0 +1,37 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/set_password_page.dart'; +import 'package:flutter/material.dart'; + +/// Country selection page +class CountrySelectionPage extends StatelessWidget { + /// + const CountrySelectionPage({ + required this.verificationCode, + this.affiliateToken, + super.key, + }); + + /// Verification code + final String verificationCode; + + /// + final String? affiliateToken; + + @override + Widget build(BuildContext context) => DerivCountrySelectionLayout( + onNextPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => SetPasswordPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ); + }, + residences: AuthData().data.resetPassPageModel.residences, + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart new file mode 100644 index 000000000..6950bcdb3 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/set_password_page.dart @@ -0,0 +1,43 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +/// Set password page +class SetPasswordPage extends StatelessWidget { + /// Constructor [SetPasswordPage] + const SetPasswordPage({ + required this.verificationCode, + this.affiliateToken, + super.key, + }); + + /// Verification code + final String verificationCode; + + /// + final String? affiliateToken; + + @override + Widget build(BuildContext context) => DerivSetPasswordLayout( + authErrorStateHandler: AuthErrorStateHandler(context: context), + onDerivSignupState: (BuildContext constext, DerivSignupState state) { + if (state is DerivSignupDoneState) { + context + .read() + .tokenLogin(state.account?.token ?? 'defaultToken'); + } + }, + onPreviousPressed: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => CountrySelectionPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ), + residence: AuthData().data.resetPassPageModel.userResidence, + verificationCode: verificationCode, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart new file mode 100644 index 000000000..0a13d63fd --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/signup_page.dart @@ -0,0 +1,46 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; +import 'package:flutter/material.dart'; + +/// Sing up page +class SignupPage extends StatefulWidget { + /// Constructor for sign up page + const SignupPage({super.key}); + + @override + State createState() => _SignupPageState(); +} + +class _SignupPageState extends State { + @override + Widget build(BuildContext context) => DerivSignupLayout( + authErrorStateHandler: AuthErrorStateHandler(context: context), + signupPageLabel: AuthData().data.signupPageModel.signupPageLable, + signupPageDescription: + AuthData().data.signupPageModel.signupPageDescription, + onSocialAuthButtonPressed: + AuthData().data.signupPageModel.onSocialAuthButtonPressed, + onSingupError: AuthData().data.signupPageModel.onSingupError, + onSingupEmailSent: (String email) => Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => VerifyEmailPage( + email: email, + ), + ), + ), + onSignupPressed: AuthData().data.signupPageModel.onSignupPressed, + isSocialAuthEnabled: + AuthData().data.signupPageModel.isSocialAuthEnabled, + onLoginTapped: () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => const LoginPage(), + ), + ), + socialAuthStateHandler: + AuthData().data.signupPageModel.socialAuthStateHandler, + redirectURL: AuthData().data.signupPageModel.redirectURL, + onWebViewError: AuthData().data.signupPageModel.onWebViewError, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart new file mode 100644 index 000000000..70e34d723 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verification_done_page.dart @@ -0,0 +1,35 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; +import 'package:flutter/material.dart'; + +/// Verification done page +class VerificationDonePage extends StatelessWidget { + /// + const VerificationDonePage({ + required this.verificationCode, + super.key, + this.affiliateToken, + }); + + /// verification code + final String verificationCode; + + /// + final String? affiliateToken; + + @override + Widget build(BuildContext context) => DerivVerificationDoneLayout( + onContinuePressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => CountrySelectionPage( + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ), + ), + ); + }, + verificationCode: verificationCode, + affiliateToken: affiliateToken, + ); +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart new file mode 100644 index 000000000..d12203b6f --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/pages/verify_email_page.dart @@ -0,0 +1,40 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; +import 'package:flutter/material.dart'; + +/// Verify email page +class VerifyEmailPage extends StatefulWidget { + /// Constructor for verify email page + const VerifyEmailPage({required this.email, super.key}); + + /// email + final String email; + + @override + State createState() => _VerifyEmailPageState(); +} + +class _VerifyEmailPageState extends State { + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) => DerivVerifyEmailLayout( + email: widget.email, + onEmailNotReceivedPressed: () => onEmailNotReceivedPressed(context), + ); + + void onEmailNotReceivedPressed(BuildContext context) { + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (BuildContext context) => DerivEmailNotReceivedLayout( + onReEnterEmailPressed: () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => const SignupPage(), + ), + ), + ), + )); + } +} diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart new file mode 100644 index 000000000..f3a42d877 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart @@ -0,0 +1,8 @@ +import 'package:deriv_auth/core/services/referral/base_referral_code_service.dart'; + +/// Referral repository +class ReferralRepository implements BaseReferralCodeService { + @override + Future getReferralToken(String referralCode) => + Future.value('${referralCode}Token'); +} diff --git a/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart new file mode 100644 index 000000000..f15fcaa86 --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/pages/auth_entry_page.dart @@ -0,0 +1,15 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_auth/features/single_entry/features/get_started/pages/get_started_page.dart'; +import 'package:flutter/material.dart'; + +/// Auth entry page for single entry +class AuthEntryPage extends StatelessWidget { + /// Constructor [AuthEntryPage] + AuthEntryPage(AuthEntryModel entryData) { + AuthData().data = entryData; + } + + @override + Widget build(BuildContext context) => const GetStartedPage(); +} diff --git a/packages/deriv_auth/lib/features/single_entry/single_entry.dart b/packages/deriv_auth/lib/features/single_entry/single_entry.dart new file mode 100644 index 000000000..a3a619eae --- /dev/null +++ b/packages/deriv_auth/lib/features/single_entry/single_entry.dart @@ -0,0 +1,2 @@ +export 'core/models/models.dart'; +export 'pages/auth_entry_page.dart'; diff --git a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart index 30c43f2a3..b2e69bca5 100644 --- a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart +++ b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_reset_pass_layout_test.dart @@ -1,7 +1,6 @@ // ignore_for_file: always_specify_types import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,7 +31,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -53,7 +55,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -77,7 +82,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -102,7 +110,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -132,7 +143,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) {}, + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) {}, ), ), ); @@ -162,7 +176,10 @@ void main() { BlocProvider.value( value: mockResetPassCubit, child: DerivResetPassLayout( - onResetPassError: (String? error) { + onResetPassError: ({ + required bool isLinkExpired, + String? error, + }) { onResetPassErrorCalled = true; }, ), From 1e5ba63165ff214ec44e589daddb9566ec47b94a Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 15:37:37 +0400 Subject: [PATCH 21/48] refactor(deriv_auth): linked onLoggedIn function in login_page --- .../single_entry/features/login/pages/login_page.dart | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index 7df28097f..034a06c15 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -27,12 +27,7 @@ class _LoginPageState extends State { Widget build(BuildContext context) => DerivLoginLayout( welcomeLabel: AuthData().data.loginPageModel.welcomeLabel, greetingLabel: AuthData().data.loginPageModel.greetingLabel, - onLoggedIn: (_) => Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (BuildContext context) => const HomePage(), - ), - ), + onLoggedIn: AuthData().data.loginPageModel.onLoggedIn, authErrorStateHandler: AuthData().data.loginPageModel.authErrorStateHandler, onLoginError: AuthData().data.loginPageModel.onLoginError, From c12a9ee43fcc321a9f2ca404215a4f15069e4a71 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 15:46:35 +0400 Subject: [PATCH 22/48] refactor(deriv_auth): updated `deriv_http_client` --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 368979052..d69a0778a 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -29,7 +29,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_http_client - ref: deriv_http_client-v1.0.0 + ref: deriv_http_client-v2.0.1 flutter_deriv_api: git: From c3187ba85494198bb3b11e568ad50ff714b69cfa Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 15:59:55 +0400 Subject: [PATCH 23/48] refactor(deriv_auth): updated flutter_deriv_api --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index d69a0778a..5f2a0ad56 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -67,7 +67,7 @@ dependency_overrides: flutter_deriv_api: git: url: git@github.com:deriv-com/flutter-deriv-api.git - ref: 64ad3673598ad807b43f751fc2ec7bc5ef01203e + ref: 82ddc3e22ca6ac85a6c7ff4bac082a1574a90c93 deriv_ui: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git From a3cce1fb5884592d0329e67de4a5a6ca9b55f694 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 16:09:30 +0400 Subject: [PATCH 24/48] fix(deriv_auth): fixed onPressed error. --- .../presentation/widgets/deriv_social_auth_panel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart index 2d6184d96..386e8fffe 100644 --- a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart +++ b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart @@ -115,7 +115,7 @@ class _DerivSocialAuthPanelState extends State { ], ), ), - onPressed: widget.isEnabled + onTap: widget.isEnabled ? () async { final List? socialAuthProviders = await _socialAuthCubit.getSocialAuthProviders(); From c93046abadefeb4af75cb0a2996f69a37415b33e Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 16:34:23 +0400 Subject: [PATCH 25/48] refactor(deriv_auth): added context to onLoggedIn --- .../token/services/deriv_token_service.dart | 3 ++- .../layouts/deriv_login_layout.dart | 4 ++-- .../core/models/login_page_model.dart | 3 ++- .../layouts/deriv_login_layout_test.dart | 20 +++++++++---------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart b/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart index cac73be25..f516b7a96 100644 --- a/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart +++ b/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart @@ -3,6 +3,7 @@ import 'package:deriv_auth/core/services/token/models/login_request.dart'; import 'package:deriv_auth/core/services/token/models/login_response.dart'; import 'package:deriv_auth/core/services/token/services/base_token_service.dart'; import 'package:deriv_http_client/deriv_http_client.dart'; +import 'package:http/http.dart'; /// Deriv Implementation of a [BaseTokenService]. class DerivTokenService implements BaseTokenService { @@ -17,7 +18,7 @@ class DerivTokenService implements BaseTokenService { /// Extract login url from connection info. final String baseUrl = 'https://${connectionInfo.endpoint}/oauth2/api/v1'; final String loginUrl = '$baseUrl/login'; - final BaseHttpClient client = httpClient ?? ProxyAwareHttpClient(baseUrl); + final BaseHttpClient client = httpClient ?? HttpClient(); /// Call API. final Map jsonResponse = await client.post( diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index cebec3622..f6b8253ea 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -40,7 +40,7 @@ class DerivLoginLayout extends StatefulWidget { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(DerivAuthLoggedInState) onLoggedIn; + final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. @@ -309,7 +309,7 @@ class _DerivLoginLayoutState extends State { } if (state is DerivAuthLoggedInState) { - widget.onLoggedIn.call(state); + widget.onLoggedIn.call(context, state); } } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index bfb98d9ef..3bac56864 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter/material.dart'; /// LoginPageModel class class LoginPageModel { @@ -25,7 +26,7 @@ class LoginPageModel { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(DerivAuthLoggedInState) onLoggedIn; + final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. diff --git a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart index e2427526e..637305dc5 100644 --- a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart +++ b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart @@ -67,7 +67,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (SocialAuthDto p0) {}, onLoginError: (_) {}, ), @@ -104,7 +104,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -143,7 +143,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -178,7 +178,7 @@ void main() { onSignupTapped: () { onSignupTappedCalled = true; }, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -222,7 +222,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) { + onLoggedIn: (_, __) { onLoggedInCalled = true; }, onSocialAuthButtonPressed: (_) {}, @@ -263,7 +263,7 @@ void main() { onLoginError: (_) { onLoginErrorCalled = true; }, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -298,7 +298,7 @@ void main() { onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -332,7 +332,7 @@ void main() { onResetPassTappedCalled = true; }, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -378,7 +378,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) { onSocialAuthButtonPressedCalled = true; }, @@ -424,7 +424,7 @@ void main() { greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_) {}, + onLoggedIn: (_, __) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), From 5c19f3aee610bd3ff9e9c25edae4a558ae8a97b8 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 4 Mar 2024 17:11:45 +0400 Subject: [PATCH 26/48] fix(deriv_auth): calling onLoggedIn correctly --- .../features/login/presentation/layouts/deriv_login_layout.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index f6b8253ea..37e321ed0 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -309,7 +309,7 @@ class _DerivLoginLayoutState extends State { } if (state is DerivAuthLoggedInState) { - widget.onLoggedIn.call(context, state); + widget.onLoggedIn(context, state); } } From 7333af283e3e5e00970a2dd49930f243d7f1f558 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Wed, 27 Mar 2024 16:14:20 +0400 Subject: [PATCH 27/48] feat(deriv_passkeys): connected passkeys functionality with deriv auth --- .../features/auth/cubit/deriv_auth_cubit.dart | 28 +++++++++++++++---- .../layouts/deriv_login_layout.dart | 23 ++++++--------- .../layouts/deriv_signup_layout.dart | 1 + .../core/models/auth_entry_model.dart | 5 ++++ .../features/login/pages/login_page.dart | 2 -- .../widgets/deriv_social_auth_panel.dart | 4 +-- packages/deriv_auth/pubspec.yaml | 14 ++++------ 7 files changed, 43 insertions(+), 34 deletions(-) diff --git a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart index 481787c6d..1de3db414 100644 --- a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart +++ b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart @@ -10,6 +10,7 @@ import 'package:deriv_auth/core/services/token/models/login_request.dart'; import 'package:deriv_auth/features/auth/deriv_auth_io.dart'; import 'package:deriv_auth/features/auth/services/base_auth_service.dart'; import 'package:deriv_auth/features/social_auth/models/social_auth_dto.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; part 'deriv_auth_state.dart'; @@ -17,7 +18,19 @@ part 'deriv_auth_state.dart'; /// and it is responsible for all login functionality. class DerivAuthCubit extends Cubit implements DerivAuthIO { /// Initialize a [DerivAuthCubit]. - DerivAuthCubit({required this.authService}) : super(DerivAuthLoadingState()); + DerivAuthCubit({ + required this.authService, + DerivPasskeysBloc? derivPasskeysBloc, + }) : super(DerivAuthLoadingState()) { + if (derivPasskeysBloc != null) { + derivPasskeysBloc.stream.listen((DerivPasskeysState state) async { + if (state is DerivPasskeysCredentialVerifiedState) { + derivPasskeysBloc.add(const DerivPasskeysGetPasskeysListEvent()); + await tokenLogin(state.token); + } + }); + } + } /// [BaseAuthService] handles all login logic of cubit. final BaseAuthService authService; @@ -133,12 +146,15 @@ class DerivAuthCubit extends Cubit implements DerivAuthIO { final LandingCompanyEntity landingCompanyEntity = await authService.getLandingCompany(authorizeEntity.country); _isUserMigrated = _checkUserMigrated(authorizeEntity); - emit(DerivAuthLoggedInState( - DerivAuthModel( - authorizeEntity: authorizeEntity, - landingCompany: landingCompanyEntity, + + emit( + DerivAuthLoggedInState( + DerivAuthModel( + authorizeEntity: authorizeEntity, + landingCompany: landingCompanyEntity, + ), ), - )); + ); } on DerivAuthException catch (error) { emit(DerivAuthErrorState( message: error.message, diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 37e321ed0..8ea23af7c 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -1,5 +1,7 @@ import 'dart:async'; import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; @@ -13,7 +15,6 @@ class DerivLoginLayout extends StatefulWidget { required this.onSignupTapped, required this.onLoggedIn, required this.welcomeLabel, - required this.greetingLabel, required this.socialAuthStateHandler, required this.redirectURL, required this.onWebViewError, @@ -53,9 +54,6 @@ class DerivLoginLayout extends StatefulWidget { /// Welcome text to be displayed on login page. final String welcomeLabel; - /// Greeting text to be displayed on login page. - final String greetingLabel; - /// Whether to display social auth buttons. final bool isSocialAuthEnabled; @@ -122,8 +120,8 @@ class _DerivLoginLayoutState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ ..._buildTopSection(), - const SizedBox(height: ThemeProvider.margin24), - const SizedBox(height: ThemeProvider.margin24), + const SizedBox(height: ThemeProvider.margin14), + // const SizedBox(height: ThemeProvider.margin24), ..._buildTextFields( isEnabled: state is! DerivAuthLoadingState), const SizedBox(height: ThemeProvider.margin24), @@ -139,6 +137,9 @@ class _DerivLoginLayoutState extends State { ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), + ContinueWithPasskeyButton( + derivPasskeysBloc: AuthData().data.derivPasskeysBloc, + ), DerivSocialAuthPanel( socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, @@ -164,18 +165,10 @@ class _DerivLoginLayoutState extends State { Text( widget.welcomeLabel, style: context.theme.textStyle( - textStyle: TextStyles.title, + textStyle: TextStyles.subheading, color: context.theme.colors.prominent, ), ), - const SizedBox(height: ThemeProvider.margin08), - Text( - widget.greetingLabel, - style: context.theme.textStyle( - textStyle: TextStyles.body1, - color: context.theme.colors.general, - ), - ), ]; List _buildTextFields({required bool isEnabled}) => [ diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index c466189ed..d94f7ef15 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart index 23b2a5336..54a93e146 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/auth_entry_model.dart @@ -1,4 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; /// Auth Entry Model class class AuthEntryModel { @@ -7,6 +8,7 @@ class AuthEntryModel { required this.getStartedPage, required this.loginPageModel, required this.derivAuthCubit, + required this.derivPasskeysBloc, required this.signupPageModel, required this.settingPageModel, required this.resetPassPageModel, @@ -21,6 +23,9 @@ class AuthEntryModel { /// DerivAuthCubit final DerivAuthCubit derivAuthCubit; + /// DerivAuthCubit + final DerivPasskeysBloc derivPasskeysBloc; + /// SignupPage data model final SignupPageModel signupPageModel; diff --git a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index 034a06c15..8697e40c0 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart @@ -1,7 +1,6 @@ import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; import 'package:deriv_auth/features/login/presentation/layouts/deriv_login_layout.dart'; import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; -import 'package:deriv_auth/features/single_entry/features/home/pages/home_page.dart'; import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_page.dart'; import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; import 'package:flutter/material.dart'; @@ -26,7 +25,6 @@ class _LoginPageState extends State { @override Widget build(BuildContext context) => DerivLoginLayout( welcomeLabel: AuthData().data.loginPageModel.welcomeLabel, - greetingLabel: AuthData().data.loginPageModel.greetingLabel, onLoggedIn: AuthData().data.loginPageModel.onLoggedIn, authErrorStateHandler: AuthData().data.loginPageModel.authErrorStateHandler, diff --git a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart index 386e8fffe..277fec995 100644 --- a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart +++ b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart @@ -1,5 +1,6 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_passkeys/presentation/widgets/continue_with_passkey_button.dart'; +import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; @@ -71,7 +72,6 @@ class _DerivSocialAuthPanelState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const ContinueWithPasskeyButton(), const SizedBox(height: ThemeProvider.margin08), _buildSocialAuthButton(SocialAuthProvider.google), const SizedBox(height: ThemeProvider.margin08), diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index f70efa9e7..7a0655a37 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -48,10 +48,11 @@ dependencies: ref: deriv_localizations-v1.1.2 deriv_passkeys: - git: - url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_passkeys - ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e + path: ../../../flutter-deriv-packages/packages/deriv_passkeys + # git: + # url: git@github.com:regentmarkets/flutter-deriv-packages.git + # path: packages/deriv_passkeys + # ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 @@ -67,11 +68,6 @@ dependency_overrides: git: url: git@github.com:deriv-com/flutter-deriv-api.git ref: 82ddc3e22ca6ac85a6c7ff4bac082a1574a90c93 - deriv_ui: - git: - url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_ui - ref: deriv_ui-v0.0.6+2 dev_dependencies: mocktail: ^1.0.3 From 45cbbb6c20274e84e4f932057d0816a3b4dc581c Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Thu, 28 Mar 2024 10:32:32 +0400 Subject: [PATCH 28/48] refactor(deriv_auth): integrating deriv_passkeys. --- .../deriv_auth/docs/deriv_auth_layouts.md | 2 - .../get_started/pages/get_started_page.dart | 6 +-- .../lib/features/login/pages/login_page.dart | 18 +++---- .../pages/choose_new_password_page.dart | 2 +- .../reset_pass/pages/reset_pass_page.dart | 34 +++++++++++-- .../pages/reset_pass_success_page.dart | 5 +- .../settings/pages/settings_page.dart | 7 +-- .../signup/pages/country_selection_page.dart | 2 +- .../signup/pages/set_password_page.dart | 4 +- .../features/signup/pages/signup_page.dart | 8 ++-- .../signup/pages/verification_done_page.dart | 2 +- .../signup/pages/verify_email_page.dart | 2 +- packages/deriv_auth/example/lib/main.dart | 33 +++++++------ packages/deriv_auth/example/pubspec.yaml | 19 ++------ .../core/extensions/context_extension.dart | 4 +- .../helpers/country_selection_helper.dart | 2 +- .../deriv_unavailable_country_layout.dart | 8 ++-- .../core/states/auth_error_state_handler.dart | 48 +++++++++---------- .../features/auth/cubit/deriv_auth_cubit.dart | 12 +---- .../layouts/deriv_get_started_layout.dart | 4 +- .../layouts/deriv_2fa_layout.dart | 10 ++-- .../layouts/deriv_login_layout.dart | 21 ++++---- .../layouts/deriv_choose_new_pass_layout.dart | 10 ++-- .../layouts/deriv_reset_pass_layout.dart | 16 +++---- .../deriv_success_pass_change_layout.dart | 6 +-- .../layouts/deriv_setting_layout.dart | 14 +++--- .../deriv_country_selection_layout.dart | 8 ++-- .../deriv_email_not_received_layout.dart | 12 ++--- .../layouts/deriv_set_password_layout.dart | 8 ++-- .../layouts/deriv_signup_layout.dart | 28 +++++------ .../deriv_verification_done_layout.dart | 8 ++-- .../layouts/deriv_verify_email_layout.dart | 9 ++-- .../country_selection_list_widget.dart | 4 +- .../password_policy_checker_widget.dart | 13 +++-- .../lib/features/single_entry/README.md | 2 - .../core/models/login_page_model.dart | 4 -- .../pages/choose_new_password_page.dart | 3 +- .../widgets/deriv_social_auth_panel.dart | 3 -- packages/deriv_auth/pubspec.yaml | 2 +- .../layouts/deriv_login_layout_test.dart | 11 ----- 40 files changed, 197 insertions(+), 217 deletions(-) diff --git a/packages/deriv_auth/docs/deriv_auth_layouts.md b/packages/deriv_auth/docs/deriv_auth_layouts.md index e2bb1f3f7..5c770edfd 100644 --- a/packages/deriv_auth/docs/deriv_auth_layouts.md +++ b/packages/deriv_auth/docs/deriv_auth_layouts.md @@ -18,8 +18,6 @@ ``` dart DerivLoginLayout( welcomeLabel: 'Welcome back!', - greetingLabel: - 'Log in to your Deriv account to start trading and investing.', onResetPassTapped: () { // Navigate to reset password page }, diff --git a/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart index 46b0dc703..586baf711 100644 --- a/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart +++ b/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart @@ -1,8 +1,8 @@ import 'package:deriv_auth/features/get_started/models/deriv_get_started_slide_model.dart'; import 'package:deriv_auth/features/get_started/presentation/layouts/deriv_get_started_layout.dart'; -import 'package:example/features/login/pages/login_page.dart'; -import 'package:example/features/settings/pages/settings_page.dart'; -import 'package:example/features/signup/pages/signup_page.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/settings/pages/settings_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; import 'package:flutter/material.dart'; class GetStartedPage extends StatelessWidget { diff --git a/packages/deriv_auth/example/lib/features/login/pages/login_page.dart b/packages/deriv_auth/example/lib/features/login/pages/login_page.dart index c8f7ea323..2bfcc77a1 100644 --- a/packages/deriv_auth/example/lib/features/login/pages/login_page.dart +++ b/packages/deriv_auth/example/lib/features/login/pages/login_page.dart @@ -1,10 +1,7 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; -import 'package:deriv_auth/features/login/presentation/layouts/deriv_login_layout.dart'; -import 'package:example/core/example_auth_error_state_handler.dart'; -import 'package:example/features/home/pages/home_page.dart'; -import 'package:example/features/reset_pass/pages/reset_pass_page.dart'; -import 'package:example/features/signup/pages/signup_page.dart'; +import 'package:deriv_auth/features/single_entry/features/home/pages/home_page.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/signup_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -25,19 +22,18 @@ class _LoginPageState extends State { @override Widget build(BuildContext context) { return DerivLoginLayout( - socialAuthStateHandler: (_){}, + socialAuthStateHandler: (_) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: 'Welcome back!', - greetingLabel: - 'Log in to your Deriv account to start trading and investing.', - onLoggedIn: (_) => Navigator.pushReplacement( + onLoggedIn: (BuildContext context, DerivAuthLoggedInState state) => + Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const HomePage(), ), ), - authErrorStateHandler: ExampleAuthErrorStateHandler(context: context), + authErrorStateHandler: AuthErrorStateHandler(context: context), onLoginError: (_) {}, onResetPassTapped: () => Navigator.push( context, diff --git a/packages/deriv_auth/example/lib/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/example/lib/features/reset_pass/pages/choose_new_password_page.dart index 8a73b6ae9..e83aa1d0e 100644 --- a/packages/deriv_auth/example/lib/features/reset_pass/pages/choose_new_password_page.dart +++ b/packages/deriv_auth/example/lib/features/reset_pass/pages/choose_new_password_page.dart @@ -1,6 +1,6 @@ import 'package:deriv_auth/features/reset_password/cubit/reset_password_cubit.dart'; import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; -import 'package:example/features/reset_pass/pages/reset_pass_success_page.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/reset_pass_success_page.dart'; import 'package:flutter/material.dart'; class ChooseNewPasswordPage extends StatelessWidget { diff --git a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart index f63728f9c..07786e198 100644 --- a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart +++ b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart'; -import 'package:example/features/reset_pass/pages/choose_new_password_page.dart'; -import 'package:example/features/reset_pass/services/example_reset_pass_service.dart'; +import 'package:deriv_auth/features/reset_password/services/base_reset_password_service.dart'; +import 'package:deriv_auth/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -14,6 +14,22 @@ class ResetPassPage extends StatefulWidget { State createState() => _ResetPassPageState(); } +class ExampleResetPasswordService extends BaseResetPasswordService { + @override + Future resetPassword( + {required String verificationCode, required String newPassword}) { + // TODO: implement resetPassword + throw UnimplementedError(); + } + + @override + Future sendVerificationEmail( + VerifyEmailRequestEntity request) { + // TODO: implement sendVerificationEmail + throw UnimplementedError(); + } +} + class _ResetPassPageState extends State { late final DerivResetPassCubit cubit; late final StreamSubscription _streamSubscription; @@ -22,7 +38,7 @@ class _ResetPassPageState extends State { void initState() { super.initState(); - cubit = DerivResetPassCubit(service: ExampleResetPassService()); + cubit = DerivResetPassCubit(service: ExampleResetPasswordService()); _streamSubscription = cubit.stream.listen((state) { if (state is DerivResetPassEmailSentState) { @@ -30,7 +46,11 @@ class _ResetPassPageState extends State { if (mounted) { Navigator.of(context).push(MaterialPageRoute( builder: (context) => BlocProvider.value( - value: cubit, child: ChooseNewPasswordPage(cubit: cubit)), + value: cubit, + child: ChooseNewPasswordPage( + token: '', + cubit: cubit, + )), )); } }); @@ -41,9 +61,13 @@ class _ResetPassPageState extends State { @override Widget build(BuildContext context) { return BlocProvider.value( - value: cubit, child: DerivResetPassLayout(onResetPassError: (_) {})); + value: cubit, + child: DerivResetPassLayout(onResetPassError: onResetPassError), + ); } + onResetPassError({required bool isLinkExpired, String? error}) {} + @override void dispose() { cubit.close(); diff --git a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_success_page.dart b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_success_page.dart index 71fc15a57..0857ba275 100644 --- a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_success_page.dart +++ b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_success_page.dart @@ -1,7 +1,6 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart'; -import 'package:example/features/get_started/pages/get_started_page.dart'; -import 'package:example/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/get_started/pages/get_started_page.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/packages/deriv_auth/example/lib/features/settings/pages/settings_page.dart b/packages/deriv_auth/example/lib/features/settings/pages/settings_page.dart index 70d990683..6f8054f71 100644 --- a/packages/deriv_auth/example/lib/features/settings/pages/settings_page.dart +++ b/packages/deriv_auth/example/lib/features/settings/pages/settings_page.dart @@ -11,8 +11,8 @@ class SettingsPage extends StatefulWidget { class _SettingsPageState extends State { @override - Widget build(BuildContext context) => DerivSettingLayout( - updateFlavorConfigs: _updateFlavorConfig(), + Widget build(BuildContext context) => const DerivSettingLayout( + updateFlavorConfigs: _updateFlavorConfig, appLabel: 'appLabel', saveValues: _saveValues, ); @@ -23,6 +23,7 @@ _saveValues({required String appId, required String endpoint}) { logger.log('endpoint is $endpoint'); } -Future _updateFlavorConfig() async { +Future _updateFlavorConfig( + {required String appId, required String endpoint}) async { logger.log('Flavor CONFIG is updated'); } diff --git a/packages/deriv_auth/example/lib/features/signup/pages/country_selection_page.dart b/packages/deriv_auth/example/lib/features/signup/pages/country_selection_page.dart index 678e579c2..838961327 100644 --- a/packages/deriv_auth/example/lib/features/signup/pages/country_selection_page.dart +++ b/packages/deriv_auth/example/lib/features/signup/pages/country_selection_page.dart @@ -1,6 +1,6 @@ import 'package:deriv_auth/features/signup/models/deriv_residence_model.dart'; import 'package:deriv_auth/features/signup/presentation/layouts/deriv_country_selection_layout.dart'; -import 'package:example/features/signup/pages/set_password_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/set_password_page.dart'; import 'package:flutter/material.dart'; class CountrySelectionPage extends StatelessWidget { diff --git a/packages/deriv_auth/example/lib/features/signup/pages/set_password_page.dart b/packages/deriv_auth/example/lib/features/signup/pages/set_password_page.dart index 7638a547e..4fe8b51d0 100644 --- a/packages/deriv_auth/example/lib/features/signup/pages/set_password_page.dart +++ b/packages/deriv_auth/example/lib/features/signup/pages/set_password_page.dart @@ -1,6 +1,4 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_set_password_layout.dart'; -import 'package:example/core/example_auth_error_state_handler.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -12,7 +10,7 @@ class SetPasswordPage extends StatelessWidget { @override Widget build(BuildContext context) { return DerivSetPasswordLayout( - authErrorStateHandler: ExampleAuthErrorStateHandler(context: context), + authErrorStateHandler: AuthErrorStateHandler(context: context), onDerivSignupState: (context, state) { if (state is DerivSignupDoneState) { context diff --git a/packages/deriv_auth/example/lib/features/signup/pages/signup_page.dart b/packages/deriv_auth/example/lib/features/signup/pages/signup_page.dart index 347d22b5d..cff86d63f 100644 --- a/packages/deriv_auth/example/lib/features/signup/pages/signup_page.dart +++ b/packages/deriv_auth/example/lib/features/signup/pages/signup_page.dart @@ -1,8 +1,6 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/signup/presentation/layouts/deriv_signup_layout.dart'; -import 'package:example/core/example_auth_error_state_handler.dart'; -import 'package:example/features/login/pages/login_page.dart'; -import 'package:example/features/signup/pages/verify_email_page.dart'; +import 'package:deriv_auth/features/single_entry/features/login/pages/login_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/verify_email_page.dart'; import 'package:flutter/material.dart'; class SignupPage extends StatefulWidget { @@ -18,7 +16,7 @@ class _SignupPageState extends State { socialAuthStateHandler: (_) => {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, - authErrorStateHandler: ExampleAuthErrorStateHandler(context: context), + authErrorStateHandler: AuthErrorStateHandler(context: context), signupPageLabel: 'Start trading with Deriv', signupPageDescription: 'Join over 1 million traders worldwide who loves trading at Deriv.', diff --git a/packages/deriv_auth/example/lib/features/signup/pages/verification_done_page.dart b/packages/deriv_auth/example/lib/features/signup/pages/verification_done_page.dart index 123d0aac3..e7b1a42c2 100644 --- a/packages/deriv_auth/example/lib/features/signup/pages/verification_done_page.dart +++ b/packages/deriv_auth/example/lib/features/signup/pages/verification_done_page.dart @@ -1,5 +1,5 @@ import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verification_done_layout.dart'; -import 'package:example/features/signup/pages/country_selection_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/country_selection_page.dart'; import 'package:flutter/material.dart'; class VerificationDonePage extends StatelessWidget { diff --git a/packages/deriv_auth/example/lib/features/signup/pages/verify_email_page.dart b/packages/deriv_auth/example/lib/features/signup/pages/verify_email_page.dart index a0973cbd3..cbd5a43a5 100644 --- a/packages/deriv_auth/example/lib/features/signup/pages/verify_email_page.dart +++ b/packages/deriv_auth/example/lib/features/signup/pages/verify_email_page.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:deriv_auth/features/signup/presentation/layouts/deriv_email_not_received_layout.dart'; import 'package:deriv_auth/features/signup/presentation/layouts/deriv_verify_email_layout.dart'; -import 'package:example/features/signup/pages/verification_done_page.dart'; +import 'package:deriv_auth/features/single_entry/features/signup/pages/verification_done_page.dart'; import 'package:flutter/material.dart'; class VerifyEmailPage extends StatefulWidget { diff --git a/packages/deriv_auth/example/lib/main.dart b/packages/deriv_auth/example/lib/main.dart index ed6115f68..f16ee0fa0 100644 --- a/packages/deriv_auth/example/lib/main.dart +++ b/packages/deriv_auth/example/lib/main.dart @@ -1,13 +1,9 @@ import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_http_client/deriv_http_client.dart'; -import 'package:deriv_passkeys/data/data_sources/deriv_passkeys_data_source.dart'; -import 'package:deriv_passkeys/data/mappers/deriv_passkeys_mapper.dart'; -import 'package:deriv_passkeys/data/repositories/deriv_passkeys_repository.dart'; -import 'package:deriv_passkeys/interactor/services/deriv_passkeys_service.dart'; -import 'package:deriv_passkeys/presentation/states/bloc/deriv_passkeys_bloc.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; import 'package:deriv_theme/deriv_theme.dart'; -import 'package:device_preview/device_preview.dart'; import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations.dart'; +import 'package:device_preview/device_preview.dart'; import 'package:example/features/get_started/pages/get_started_page.dart'; import 'package:example/features/login/repositories/example_login_repository.dart'; import 'package:example/features/signup/repositories/example_referral_repository.dart'; @@ -58,15 +54,22 @@ class MyApp extends StatelessWidget { ), ), BlocProvider( - create: (context) => DerivPasskeysBloc( - DerivPasskeysService( - DerivPasskeysRepository( - DerivPasskeysDataSource( - DerivPasskeysMapper(), - ), - ), - ), - )), + create: (context) => DerivPasskeysBloc( + getJwtToken: () async => "jwtToken", + derivPasskeysService: DerivPasskeysService( + DerivPasskeysRepository( + DerivPasskeysDataSource( + mapper: DerivPasskeysMapper(), + client: HttpClient(), + ), + ), + ), + connectionInfo: PasskeysConnectionInfoEntity( + appId: DerivAuthConnectionInfo().appId, + endpoint: DerivAuthConnectionInfo().endpoint, + ), + ), + ), ], child: DerivThemeProvider.builder( initialTheme: ThemeMode.dark, diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index 5185e1257..cf8589ebd 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -13,10 +13,7 @@ dependencies: sdk: flutter cupertino_icons: ^1.0.2 deriv_auth: - git: - url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_auth - ref: deriv_auth-v6.2.0 + path: .././ flutter_bloc: ^8.1.3 http: ^0.13.6 @@ -25,23 +22,13 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_http_client - ref: deriv_http_client-v1.0.0 - deriv_passkeys: - git: - url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_passkeys - ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e + ref: deriv_http_client-v2.0.1 dependency_overrides: flutter_deriv_api: git: url: git@github.com:deriv-com/flutter-deriv-api.git - ref: 64ad3673598ad807b43f751fc2ec7bc5ef01203e - deriv_ui: - git: - url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_ui - ref: deriv_ui-v0.0.6+2 + ref: 82ddc3e22ca6ac85a6c7ff4bac082a1574a90c93 dev_dependencies: flutter_test: diff --git a/packages/deriv_auth/lib/core/extensions/context_extension.dart b/packages/deriv_auth/lib/core/extensions/context_extension.dart index a4e731bb5..7c9089c44 100644 --- a/packages/deriv_auth/lib/core/extensions/context_extension.dart +++ b/packages/deriv_auth/lib/core/extensions/context_extension.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; /// Extension methods for [BuildContext]. extension ContextExtension on BuildContext { - /// Gets [DerivAuthUILocalization]. - DerivAuthLocalizations get derivAuthLocalization => + /// Gets [DerivAuthLocalizations]. + DerivAuthLocalizations? get derivAuthLocalization => DerivAuthLocalizations.of(this); } diff --git a/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart b/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart index 06664331c..f442d3ff3 100644 --- a/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart +++ b/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart @@ -32,7 +32,7 @@ String getCountryConsentMessage( } final Map consentMessages = { - 'br': context.derivAuthLocalization.labelCountryConsentBrazil, + 'br': context.derivAuthLocalization!.labelCountryConsentBrazil, // Add more countries and consent messages here. }; diff --git a/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart b/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart index b00eedf59..f4a877d65 100644 --- a/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart +++ b/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart @@ -28,7 +28,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { Widget build(BuildContext context) => Scaffold( appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization.labelNotAvailable), + title: Text(context.derivAuthLocalization!.labelNotAvailable), ), body: Container( padding: @@ -50,7 +50,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { children: [ const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization + context.derivAuthLocalization! .warnNotAvailableCountriesTitle(appName), style: TextStyles.title, textAlign: TextAlign.center, @@ -58,7 +58,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { const SizedBox(height: ThemeProvider.margin08), RichText( text: TextSpan( - text: context.derivAuthLocalization.warnNotAvailableCountries, + text: context.derivAuthLocalization!.warnNotAvailableCountries, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -66,7 +66,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { children: [ buildTextSpanHyperlink( context: context, - label: context.derivAuthLocalization.labelLiveChat, + label: context.derivAuthLocalization!.labelLiveChat, onTap: onLiveChatPressed, style: context.theme.textStyle( textStyle: TextStyles.body1Bold, diff --git a/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart b/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart index e473dfcc8..b01469d26 100644 --- a/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart +++ b/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart @@ -20,8 +20,8 @@ base class AuthErrorStateHandler { void invalid2faCode(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informInvalid2FACode, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informInvalid2FACode, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -29,8 +29,8 @@ base class AuthErrorStateHandler { void onAccountUnavailable(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informDeactivatedAccount, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informDeactivatedAccount, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -38,8 +38,8 @@ base class AuthErrorStateHandler { void onExpiredAccount(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informExpiredAccount, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informExpiredAccount, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -47,8 +47,8 @@ base class AuthErrorStateHandler { void onFailedAuthorization(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informFailedAuthorization, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informFailedAuthorization, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -56,8 +56,8 @@ base class AuthErrorStateHandler { void onInvalidResidence(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informInvalidResidence, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informInvalidResidence, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -65,8 +65,8 @@ base class AuthErrorStateHandler { void onInvalidCredentials(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informInvalidCredentials, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informInvalidCredentials, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -74,8 +74,8 @@ base class AuthErrorStateHandler { void onMissingOtp(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informMissingOtp, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informMissingOtp, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -83,8 +83,8 @@ base class AuthErrorStateHandler { void onSelfClosed(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informSelfClosed, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informSelfClosed, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -92,8 +92,8 @@ base class AuthErrorStateHandler { void onUnexpectedError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informUnexpectedError, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informUnexpectedError, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -101,8 +101,8 @@ base class AuthErrorStateHandler { void onUnsupportedCountry(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informUnsupportedCountry, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informUnsupportedCountry, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -110,8 +110,8 @@ base class AuthErrorStateHandler { void onConnectionError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informConnectionError, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informConnectionError, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } @@ -119,8 +119,8 @@ base class AuthErrorStateHandler { void onSwitchAccountError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization.informSwitchAccountError, - actionLabel: context.derivAuthLocalization.actionTryAgain, + errorMessage: context.derivAuthLocalization!.informSwitchAccountError, + actionLabel: context.derivAuthLocalization!.actionTryAgain, ); } } diff --git a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart index 1de3db414..4ea017900 100644 --- a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart +++ b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart @@ -20,17 +20,7 @@ class DerivAuthCubit extends Cubit implements DerivAuthIO { /// Initialize a [DerivAuthCubit]. DerivAuthCubit({ required this.authService, - DerivPasskeysBloc? derivPasskeysBloc, - }) : super(DerivAuthLoadingState()) { - if (derivPasskeysBloc != null) { - derivPasskeysBloc.stream.listen((DerivPasskeysState state) async { - if (state is DerivPasskeysCredentialVerifiedState) { - derivPasskeysBloc.add(const DerivPasskeysGetPasskeysListEvent()); - await tokenLogin(state.token); - } - }); - } - } + }) : super(DerivAuthLoadingState()); /// [BaseAuthService] handles all login logic of cubit. final BaseAuthService authService; diff --git a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart index 4543a1ce9..eec5f9a06 100644 --- a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart +++ b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart @@ -147,7 +147,7 @@ class _DerivGetStartedLayoutState extends State { onPressed: widget.onSignupTapped, child: Center( child: Text( - context.derivAuthLocalization.actionGetAFreeAccount, + context.derivAuthLocalization!.actionGetAFreeAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, @@ -163,7 +163,7 @@ class _DerivGetStartedLayoutState extends State { onPressed: widget.onLoginTapped, child: Center( child: Text( - context.derivAuthLocalization.actionLogin, + context.derivAuthLocalization!.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart index 86c688214..451f87dfc 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart @@ -50,7 +50,7 @@ class _Deriv2FALayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelLogIn, + context.derivAuthLocalization!.labelLogIn, style: TextStyles.title, ), ), @@ -65,13 +65,13 @@ class _Deriv2FALayoutState extends State { children: [ SvgPicture.asset(Assets.twoFactorAuthIcon), Text( - context.derivAuthLocalization.labelTwoFactorAuth, + context.derivAuthLocalization!.labelTwoFactorAuth, style: context.theme.textStyle(textStyle: TextStyles.title), textAlign: TextAlign.center, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization.informEnterTwoFactorAuthCode, + context.derivAuthLocalization!.informEnterTwoFactorAuthCode, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -82,7 +82,7 @@ class _Deriv2FALayoutState extends State { BaseTextField( controller: _otpController, labelText: context - .derivAuthLocalization.labelTwoFactorAuthenticationCode, + .derivAuthLocalization!.labelTwoFactorAuthenticationCode, labelColor: context.theme.colors.disabled, focusNode: _otpFocusNode, enabled: !_isLoading(), @@ -112,7 +112,7 @@ class _Deriv2FALayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization.actionProceed, + context.derivAuthLocalization!.actionProceed, style: TextStyles.body2.copyWith( color: context.theme.colors.prominent, ), diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 8ea23af7c..0264a096c 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -99,7 +99,7 @@ class _DerivLoginLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelLogIn, + context.derivAuthLocalization!.labelLogIn, style: TextStyles.title, ), backgroundColor: context.theme.colors.secondary, @@ -132,7 +132,8 @@ class _DerivLoginLayoutState extends State { _buildLoginButton(), const SizedBox(height: ThemeProvider.margin24), DerivSocialAuthDivider( - label: context.derivAuthLocalization.informLoginOptions, + label: + context.derivAuthLocalization!.informLoginOptions, isVisible: widget.isSocialAuthEnabled, ), if (widget.isSocialAuthEnabled) @@ -176,7 +177,7 @@ class _DerivLoginLayoutState extends State { semanticLabel: SemanticsLabels.loginEmailFieldSemantic, controller: _emailController, focusNode: _emailFocusNode, - labelText: context.derivAuthLocalization.labelEmail, + labelText: context.derivAuthLocalization!.labelEmail, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, keyboardType: TextInputType.emailAddress, @@ -191,7 +192,7 @@ class _DerivLoginLayoutState extends State { semanticLabel: SemanticsLabels.loginPasswordFieldSemantic, controller: _passwordController, focusNode: _passwordFocusNode, - labelText: context.derivAuthLocalization.labelPassword, + labelText: context.derivAuthLocalization!.labelPassword, obscureText: !_isPasswordVisible, enabled: isEnabled, suffixIcon: IconButton( @@ -217,7 +218,7 @@ class _DerivLoginLayoutState extends State { child: InkWell( onTap: widget.onResetPassTapped, child: Text( - context.derivAuthLocalization.actionForgotPassword, + context.derivAuthLocalization!.actionForgotPassword, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -250,7 +251,7 @@ class _DerivLoginLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization.actionLogin, + context.derivAuthLocalization!.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -267,7 +268,7 @@ class _DerivLoginLayoutState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization.labelDontHaveAnAccountYet, + context.derivAuthLocalization!.labelDontHaveAnAccountYet, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -278,7 +279,7 @@ class _DerivLoginLayoutState extends State { child: Padding( padding: const EdgeInsets.all(ThemeProvider.margin04), child: Text( - context.derivAuthLocalization.actionCreateANewAccount, + context.derivAuthLocalization!.actionCreateANewAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -315,7 +316,7 @@ class _DerivLoginLayoutState extends State { return null; } - return context.derivAuthLocalization.informInvalidEmailFormat; + return context.derivAuthLocalization!.informInvalidEmailFormat; } String? _passwordValidator(String? input) { @@ -323,7 +324,7 @@ class _DerivLoginLayoutState extends State { return null; } - return context.derivAuthLocalization.warnPasswordLength; + return context.derivAuthLocalization!.warnPasswordLength; } Future _onLoginTapped() async { diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart index 68dafc6cf..a9aefe63c 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart @@ -50,7 +50,7 @@ class _DerivChooseNewPassLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelResetPassword, + context.derivAuthLocalization!.labelResetPassword, style: TextStyles.title, ), ), @@ -110,14 +110,14 @@ class _DerivChooseNewPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin48), Text( - context.derivAuthLocalization.labelChooseNewPass, + context.derivAuthLocalization!.labelChooseNewPass, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin24), BaseTextField( controller: _passController, focusNode: _passFocusNode, - labelText: context.derivAuthLocalization.labelCreatePass, + labelText: context.derivAuthLocalization!.labelCreatePass, obscureText: !_isPasswordVisible, suffixIcon: IconButton( icon: Icon( @@ -162,7 +162,7 @@ class _DerivChooseNewPassLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization.actionResetPass, + context.derivAuthLocalization!.actionResetPass, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -193,7 +193,7 @@ class _DerivChooseNewPassLayoutState extends State { return null; } - return context.derivAuthLocalization.informInvalidPasswordFormat; + return context.derivAuthLocalization!.informInvalidPasswordFormat; } bool isFormValid() => _passwordValidator(_passController.text) == null; diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart index e5406a496..72deda390 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart @@ -44,7 +44,7 @@ class _DerivResetPassLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelResetPassword, + context.derivAuthLocalization!.labelResetPassword, style: TextStyles.title, ), ), @@ -87,12 +87,12 @@ class _DerivResetPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin24), Text( - context.derivAuthLocalization.labelCheckEmail, + context.derivAuthLocalization!.labelCheckEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization + context.derivAuthLocalization! .informSendResetPasswordEmail(_emailController.text), textAlign: TextAlign.center, style: context.theme.textStyle( @@ -121,14 +121,14 @@ class _DerivResetPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization.labelResetPassword, + context.derivAuthLocalization!.labelResetPassword, style: TextStyles.title, textAlign: TextAlign.center, ), const SizedBox(height: ThemeProvider.margin08), Center( child: Text( - context.derivAuthLocalization.informResetPassByEmail, + context.derivAuthLocalization!.informResetPassByEmail, textAlign: TextAlign.center, style: context.theme.textStyle( textStyle: TextStyles.body1, @@ -141,7 +141,7 @@ class _DerivResetPassLayoutState extends State { semanticLabel: SemanticsLabels.resetPasswordEmailFieldSemantic, controller: _emailController, focusNode: _emailFocusNode, - labelText: context.derivAuthLocalization.labelEmail, + labelText: context.derivAuthLocalization!.labelEmail, keyboardType: TextInputType.emailAddress, borderColor: context.theme.colors.hover, validator: _emailValidator, @@ -177,7 +177,7 @@ class _DerivResetPassLayoutState extends State { width: ThemeProvider.margin16, ) : Text( - context.derivAuthLocalization.actionResetPass, + context.derivAuthLocalization!.actionResetPass, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -213,7 +213,7 @@ class _DerivResetPassLayoutState extends State { return null; } - return context.derivAuthLocalization.informInvalidEmailFormat; + return context.derivAuthLocalization!.informInvalidEmailFormat; } String _getEmailValue() => _emailController.text.trim(); diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart index 4d6cd57ec..18d39d155 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart @@ -14,7 +14,7 @@ class DerivSuccessPassChangeLayout extends StatelessWidget { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelResetPassword, + context.derivAuthLocalization!.labelResetPassword, style: TextStyles.title, ), ), @@ -37,14 +37,14 @@ class DerivSuccessPassChangeLayout extends StatelessWidget { height: ThemeProvider.margin16, ), Text( - context.derivAuthLocalization.informYourPassHasBeenReset, + context.derivAuthLocalization!.informYourPassHasBeenReset, style: TextStyles.title, ), const SizedBox( height: ThemeProvider.margin08, ), Text( - context.derivAuthLocalization.informRedirectLogin, + context.derivAuthLocalization!.informRedirectLogin, textAlign: TextAlign.center, style: context.theme.textStyle( textStyle: TextStyles.body1, diff --git a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart index e61f0d754..27b3fc266 100644 --- a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart +++ b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart @@ -155,7 +155,7 @@ class _SettingsPageState extends State { top: ThemeProvider.margin24, ), child: Text( - context.derivAuthLocalization.labelDeveloper, + context.derivAuthLocalization!.labelDeveloper, style: context.theme.textStyle( textStyle: TextStyles.body1Bold, color: context.theme.colors.coral, @@ -164,21 +164,21 @@ class _SettingsPageState extends State { ); Widget get _endpoint => _buildTextInputField( - label: context.derivAuthLocalization.labelEndpoint, - semantic: context.derivAuthLocalization.semanticEndpoint, + label: context.derivAuthLocalization!.labelEndpoint, + semantic: context.derivAuthLocalization!.semanticEndpoint, controller: _endpointController, validator: (String? value) => hasOnlySmallLettersAndNumberInput(value!) ? null - : context.derivAuthLocalization.warnInvalidEndpoint, + : context.derivAuthLocalization!.warnInvalidEndpoint, ); Widget get _appId => _buildTextInputField( - label: context.derivAuthLocalization.labelApplicationID, - semantic: context.derivAuthLocalization.semanticApplicationID, + label: context.derivAuthLocalization!.labelApplicationID, + semantic: context.derivAuthLocalization!.semanticApplicationID, controller: _appIdController, validator: (String? value) => hasOnlyNumberInput(value!) ? null - : context.derivAuthLocalization.warnInvalidApplicationID, + : context.derivAuthLocalization!.warnInvalidApplicationID, ); Widget _buildTextInputField({ diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart index 60c564e59..682ebb9a9 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart @@ -100,7 +100,7 @@ class _DerivCountrySelectionLayoutState SvgPicture.asset(Assets.locationIcon, package: 'deriv_auth'), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization.labelSelectCountry, + context.derivAuthLocalization!.labelSelectCountry, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin24), @@ -127,7 +127,7 @@ class _DerivCountrySelectionLayoutState key: _formKey, child: BaseTextField( controller: _textController, - labelText: context.derivAuthLocalization.labelChooseCountry, + labelText: context.derivAuthLocalization!.labelChooseCountry, labelColor: context.theme.colors.disabled, focusNode: _focusNode, focusedLabelColor: context.theme.colors.blue, @@ -157,7 +157,7 @@ class _DerivCountrySelectionLayoutState onPressed: widget.onNextPressed, child: Center( child: Text( - context.derivAuthLocalization.actionNext, + context.derivAuthLocalization!.actionNext, style: TextStyles.button .copyWith(color: context.theme.colors.prominent), ), @@ -225,7 +225,7 @@ class _DerivCountrySelectionLayoutState DerivResidenceModel? selectedCountry, }) { if (selectedCountry != null && selectedCountry.isDisabled) { - return context.derivAuthLocalization.warnCountryNotAvailable; + return context.derivAuthLocalization!.warnCountryNotAvailable; } return null; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart index 115beb538..93cfe423d 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart @@ -42,7 +42,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { child: Column( children: [ Text( - context.derivAuthLocalization.labelEmailIssueHeader, + context.derivAuthLocalization!.labelEmailIssueHeader, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.general, @@ -55,7 +55,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization.labelEmailIssueSpam, + context.derivAuthLocalization!.labelEmailIssueSpam, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -71,7 +71,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization.labelEmailIssueWrongEmail, + context.derivAuthLocalization!.labelEmailIssueWrongEmail, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -87,7 +87,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization.labelEmailIssueTypo, + context.derivAuthLocalization!.labelEmailIssueTypo, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -103,7 +103,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization.labelEmailIssueFirewall, + context.derivAuthLocalization!.labelEmailIssueFirewall, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -127,7 +127,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { onPressed: onReEnterEmailPressed, child: Center( child: Text( - context.derivAuthLocalization.actionReenterEmail, + context.derivAuthLocalization!.actionReenterEmail, style: context.theme.textStyle( textStyle: TextStyles.button .copyWith(color: context.theme.colors.prominent), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart index d989c1306..63455a325 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart @@ -97,7 +97,7 @@ class _DerivSetPasswordLayoutState extends State { SvgPicture.asset(Assets.passwordIcon, package: 'deriv_auth'), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization.labelKeepPassword, + context.derivAuthLocalization!.labelKeepPassword, style: TextStyles.title, textAlign: TextAlign.center, ), @@ -140,7 +140,7 @@ class _DerivSetPasswordLayoutState extends State { focusNode: _passwordFocusNode, controller: _passwordTextController, obscureText: !_isPasswordVisible, - labelText: context.derivAuthLocalization.labelCreatePassword, + labelText: context.derivAuthLocalization!.labelCreatePassword, labelColor: context.theme.colors.disabled, focusedLabelColor: context.theme.colors.blue, suffixIcon: IconButton( @@ -166,7 +166,7 @@ class _DerivSetPasswordLayoutState extends State { strokeWidth: 3, ) : Text( - context.derivAuthLocalization.actionStartTrading, + context.derivAuthLocalization!.actionStartTrading, style: TextStyles.button .copyWith(color: context.theme.colors.prominent), ), @@ -181,7 +181,7 @@ class _DerivSetPasswordLayoutState extends State { onPressed: widget.onPreviousPressed, child: Center( child: Text( - context.derivAuthLocalization.actionPrevious, + context.derivAuthLocalization!.actionPrevious, style: context.theme.textStyle( textStyle: TextStyles.button, ), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index d94f7ef15..3e3bb9b9f 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -96,7 +96,7 @@ class _DerivSignupLayoutState extends State { backgroundColor: context.theme.colors.primary, appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization.labelSignUp, + title: Text(context.derivAuthLocalization!.labelSignUp, style: TextStyles.title), backgroundColor: context.theme.colors.secondary, ), @@ -125,7 +125,7 @@ class _DerivSignupLayoutState extends State { _buildSignUpButton(), const SizedBox(height: ThemeProvider.margin24), DerivSocialAuthDivider( - label: context.derivAuthLocalization.labelOrSignUpWith, + label: context.derivAuthLocalization!.labelOrSignUpWith, isVisible: widget.isSocialAuthEnabled, ), if (widget.isSocialAuthEnabled) @@ -167,16 +167,16 @@ class _DerivSignupLayoutState extends State { children: [ InfoIconButton( dialogTitle: - context.derivAuthLocalization.labelReferralInfoTitle, - dialogDescription: - context.derivAuthLocalization.infoReferralInfoDescription, - positiveActionLabel: context.derivAuthLocalization.actionOk, + context.derivAuthLocalization!.labelReferralInfoTitle, + dialogDescription: context + .derivAuthLocalization!.infoReferralInfoDescription, + positiveActionLabel: context.derivAuthLocalization!.actionOk, iconSize: ThemeProvider.iconSize24, ), const SizedBox(width: ThemeProvider.margin08), Expanded( child: Text( - context.derivAuthLocalization.labelGotReferralCode, + context.derivAuthLocalization!.labelGotReferralCode, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.prominent, @@ -231,7 +231,7 @@ class _DerivSignupLayoutState extends State { } }, focusNode: referralFocusNode, - labelText: context.derivAuthLocalization.labelReferralCode, + labelText: context.derivAuthLocalization!.labelReferralCode, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, textInputAction: TextInputAction.done, @@ -264,7 +264,7 @@ class _DerivSignupLayoutState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization.labelHaveAccount, + context.derivAuthLocalization!.labelHaveAccount, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -275,7 +275,7 @@ class _DerivSignupLayoutState extends State { child: Padding( padding: const EdgeInsets.all(ThemeProvider.margin04), child: Text( - context.derivAuthLocalization.actionLogin, + context.derivAuthLocalization!.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -291,7 +291,7 @@ class _DerivSignupLayoutState extends State { semanticLabel: SemanticsLabels.signupEmailFieldSemantic, controller: emailController, focusNode: emailFocusNode, - labelText: context.derivAuthLocalization.labelEmail, + labelText: context.derivAuthLocalization!.labelEmail, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, keyboardType: TextInputType.emailAddress, @@ -319,7 +319,7 @@ class _DerivSignupLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization.actionCreateAccount, + context.derivAuthLocalization!.actionCreateAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, @@ -349,7 +349,7 @@ class _DerivSignupLayoutState extends State { return null; } - return context.derivAuthLocalization.informInvalidEmailFormat; + return context.derivAuthLocalization!.informInvalidEmailFormat; } String? _referralValidator(String? input) { @@ -357,7 +357,7 @@ class _DerivSignupLayoutState extends State { return null; } - return context.derivAuthLocalization.informInvalidReferralCode; + return context.derivAuthLocalization!.informInvalidReferralCode; } Future _onSignupTapped() async { diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart index 1e30b4649..a85145886 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart @@ -29,7 +29,7 @@ class DerivVerificationDoneLayout extends StatelessWidget { backgroundColor: context.theme.colors.primary, appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization.labelVerifyYourEmail), + title: Text(context.derivAuthLocalization!.labelVerifyYourEmail), ), body: SafeArea( child: Column( @@ -56,12 +56,12 @@ class DerivVerificationDoneLayout extends StatelessWidget { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization.labelThanksEmail, + context.derivAuthLocalization!.labelThanksEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization.informLetsContinue, + context.derivAuthLocalization!.informLetsContinue, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -80,7 +80,7 @@ class DerivVerificationDoneLayout extends StatelessWidget { onPressed: onContinuePressed, child: Center( child: Text( - context.derivAuthLocalization.actionContinue, + context.derivAuthLocalization!.actionContinue, style: context.theme.textStyle( textStyle: TextStyles.button .copyWith(color: context.theme.colors.prominent), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart index eb2996d7d..c89461053 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart @@ -26,7 +26,7 @@ class DerivVerifyEmailLayout extends StatelessWidget { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization.labelVerifyYourEmail, + context.derivAuthLocalization!.labelVerifyYourEmail, style: TextStyles.title, ), backgroundColor: context.theme.colors.secondary, @@ -56,12 +56,13 @@ class DerivVerifyEmailLayout extends StatelessWidget { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization.labelCheckEmail, + context.derivAuthLocalization!.labelCheckEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization.informVerificationEmailSent(email!), + context.derivAuthLocalization! + .informVerificationEmailSent(email!), style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -81,7 +82,7 @@ class DerivVerifyEmailLayout extends StatelessWidget { onPressed: onEmailNotReceivedPressed, child: Center( child: Text( - context.derivAuthLocalization.actionEmailNotReceived, + context.derivAuthLocalization!.actionEmailNotReceived, style: context.theme.textStyle( textStyle: TextStyles.button, ), diff --git a/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart b/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart index 5b72f3fc0..9896a0264 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart @@ -102,7 +102,7 @@ class _CountrySelectionListWidgetState children: [ const SizedBox(width: ThemeProvider.margin48), Text( - context.derivAuthLocalization.labelChooseCountry, + context.derivAuthLocalization!.labelChooseCountry, style: TextStyles.subheading, ), ], @@ -128,7 +128,7 @@ class _CountrySelectionListWidgetState onPressed: () => _searchController.clear(), ), contentPadding: const EdgeInsets.only(top: ThemeProvider.margin08), - hintText: context.derivAuthLocalization.labelSearchCountry, + hintText: context.derivAuthLocalization!.labelSearchCountry, hintStyle: context.theme.textStyle( textStyle: TextStyles.subheading, color: context.theme.colors.active, diff --git a/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart b/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart index 2bb6c1b5b..377a17173 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart @@ -40,20 +40,23 @@ class PasswordPolicyCheckerWidget extends StatelessWidget { BuildContext context) => [ DerivPasswordPolicyModel( - description: context.derivAuthLocalization.informPasswordPolicyLength, + description: + context.derivAuthLocalization!.informPasswordPolicyLength, regex: validPasswordLengthRegex, ), DerivPasswordPolicyModel( description: - context.derivAuthLocalization.informPasswordPolicyLowerAndUpper, + context.derivAuthLocalization!.informPasswordPolicyLowerAndUpper, regex: validPasswordWithUppercaseRegex, ), DerivPasswordPolicyModel( - description: context.derivAuthLocalization.informPasswordPolicyNumber, + description: + context.derivAuthLocalization!.informPasswordPolicyNumber, regex: validPasswordWithNumberRegex, ), DerivPasswordPolicyModel( - description: context.derivAuthLocalization.warnPasswordContainsSymbol, + description: + context.derivAuthLocalization!.warnPasswordContainsSymbol, regex: validPasswordWithSymbols, isOptional: true, ), @@ -67,7 +70,7 @@ class PasswordPolicyCheckerWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization.informPasswordPolicy, + context.derivAuthLocalization!.informPasswordPolicy, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, diff --git a/packages/deriv_auth/lib/features/single_entry/README.md b/packages/deriv_auth/lib/features/single_entry/README.md index a595a6bfb..7068bfb36 100644 --- a/packages/deriv_auth/lib/features/single_entry/README.md +++ b/packages/deriv_auth/lib/features/single_entry/README.md @@ -28,8 +28,6 @@ AuthEntryPage( ), loginPageModel: LoginPageModel( welcomeLabel: 'Welcome back testing!', - greetingLabel: - 'Log in to your Deriv account to start trading and investing.', onLoggedIn: (_) => HomePageRoute().go(context), authErrorStateHandler: AuthErrorStateHandler(context: context), diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index 3bac56864..1075da51b 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -8,7 +8,6 @@ class LoginPageModel { required this.onLoggedIn, required this.onSocialAuthButtonPressed, required this.welcomeLabel, - required this.greetingLabel, required this.socialAuthStateHandler, required this.redirectURL, required this.onWebViewError, @@ -35,9 +34,6 @@ class LoginPageModel { /// Welcome text to be displayed on login page. final String welcomeLabel; - /// Greeting text to be displayed on login page. - final String greetingLabel; - /// Whether to display social auth buttons. final bool isSocialAuthEnabled; diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart index 7b1ed804b..90234fe08 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -6,7 +6,8 @@ import 'package:flutter/material.dart'; /// Choose new password page class ChooseNewPasswordPage extends StatelessWidget { /// Constructor [ChooseNewPasswordPage] - const ChooseNewPasswordPage({required this.token, super.key}); + const ChooseNewPasswordPage( + {required this.token, super.key, required DerivResetPassCubit cubit}); /// Token final String token; diff --git a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart index 277fec995..a1492ce45 100644 --- a/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart +++ b/packages/deriv_auth/lib/features/social_auth/presentation/widgets/deriv_social_auth_panel.dart @@ -1,8 +1,5 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; -import 'package:deriv_passkeys/deriv_passkeys.dart'; import 'package:deriv_theme/deriv_theme.dart'; -import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 7a0655a37..e17a02045 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_localizations - ref: deriv_localizations-v1.1.2 + ref: 9a91d879a5ffd371a46dcbf70e4f3a295bc7b7e1 deriv_passkeys: path: ../../../flutter-deriv-packages/packages/deriv_passkeys diff --git a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart index 637305dc5..5eefd27af 100644 --- a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart +++ b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart @@ -18,7 +18,6 @@ void main() { late MockSocialAuthCubit socialAuthCubit; const String welcomeLabel = 'Welcome Back'; - const String greetingLabel = 'Let\'s start trading.'; setUpAll(() { authCubit = MockAuthCubit(); @@ -64,7 +63,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) {}, @@ -101,7 +99,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) {}, @@ -140,7 +137,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) {}, @@ -173,7 +169,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () { onSignupTappedCalled = true; @@ -219,7 +214,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) { @@ -257,7 +251,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) { @@ -294,7 +287,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) {}, @@ -327,7 +319,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () { onResetPassTappedCalled = true; }, @@ -375,7 +366,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) {}, @@ -421,7 +411,6 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoggedIn: (_, __) {}, From 607eca127e5a394dbb58abe82a5d5d4b4f811156 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Thu, 28 Mar 2024 11:46:39 +0400 Subject: [PATCH 29/48] fix(deriv_auth): fixed deriv_passkeys dependency. --- packages/deriv_auth/pubspec.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index fc0fb9dc5..c3794f88c 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -49,11 +49,10 @@ dependencies: ref: 9a91d879a5ffd371a46dcbf70e4f3a295bc7b7e1 deriv_passkeys: - path: ../../../flutter-deriv-packages/packages/deriv_passkeys - # git: - # url: git@github.com:regentmarkets/flutter-deriv-packages.git - # path: packages/deriv_passkeys - # ref: c9b906bc20edbc94d0ca99f2211b142efa3aaf2e + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_passkeys + ref: 5b89caefd68fcc4f33b1dbe1ae217f6b3558394a flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From 7bb5f71b4a3c364b3ee4455fe1c97b8ac5e83dea Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Thu, 28 Mar 2024 12:28:06 +0400 Subject: [PATCH 30/48] refactor(deriv_auth): new deriv_passkeys commit hash ref. --- .../features/login/presentation/layouts/deriv_login_layout.dart | 1 - packages/deriv_auth/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 0264a096c..4f8c088fc 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -121,7 +121,6 @@ class _DerivLoginLayoutState extends State { children: [ ..._buildTopSection(), const SizedBox(height: ThemeProvider.margin14), - // const SizedBox(height: ThemeProvider.margin24), ..._buildTextFields( isEnabled: state is! DerivAuthLoadingState), const SizedBox(height: ThemeProvider.margin24), diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index c3794f88c..f8725716e 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 5b89caefd68fcc4f33b1dbe1ae217f6b3558394a + ref: 568ecf2acdd9d415ef40c73f8caf6f136e752f33 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From 14b85c22c7edbd8046eb9f2feef68aa49aff8df2 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Fri, 29 Mar 2024 12:18:57 +0400 Subject: [PATCH 31/48] refactor(deriv_auth): updated deriv_passkeys and deriv_localizations versions. --- .../reset_pass/pages/reset_pass_page.dart | 6 +-- packages/deriv_auth/example/pubspec.yaml | 6 --- .../core/extensions/context_extension.dart | 2 +- .../helpers/country_selection_helper.dart | 2 +- .../deriv_unavailable_country_layout.dart | 8 ++-- .../token/services/deriv_token_service.dart | 1 - .../core/states/auth_error_state_handler.dart | 48 +++++++++---------- .../features/auth/cubit/deriv_auth_cubit.dart | 1 - .../layouts/deriv_get_started_layout.dart | 4 +- .../layouts/deriv_2fa_layout.dart | 10 ++-- .../layouts/deriv_login_layout.dart | 21 ++++---- .../layouts/deriv_choose_new_pass_layout.dart | 10 ++-- .../layouts/deriv_reset_pass_layout.dart | 16 +++---- .../deriv_success_pass_change_layout.dart | 6 +-- .../layouts/deriv_setting_layout.dart | 14 +++--- .../deriv_country_selection_layout.dart | 8 ++-- .../deriv_email_not_received_layout.dart | 12 ++--- .../layouts/deriv_set_password_layout.dart | 9 ++-- .../layouts/deriv_signup_layout.dart | 29 ++++++----- .../deriv_verification_done_layout.dart | 8 ++-- .../layouts/deriv_verify_email_layout.dart | 9 ++-- .../country_selection_list_widget.dart | 4 +- .../password_policy_checker_widget.dart | 13 ++--- .../pages/choose_new_password_page.dart | 3 +- .../repositories/referral_repository.dart | 2 +- packages/deriv_auth/pubspec.yaml | 6 +-- .../core/helpers/account_helper_test.dart | 1 - .../states/auth_error_state_mapper_test.dart | 1 - .../core/states/auth_state_listener_test.dart | 1 - .../deriv_choose_new_pass_layout_test.dart | 1 - .../cubit/social_auth_cubit_test.dart | 1 - 31 files changed, 119 insertions(+), 144 deletions(-) diff --git a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart index 07786e198..71f6f3384 100644 --- a/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart +++ b/packages/deriv_auth/example/lib/features/reset_pass/pages/reset_pass_page.dart @@ -46,11 +46,7 @@ class _ResetPassPageState extends State { if (mounted) { Navigator.of(context).push(MaterialPageRoute( builder: (context) => BlocProvider.value( - value: cubit, - child: ChooseNewPasswordPage( - token: '', - cubit: cubit, - )), + value: cubit, child: const ChooseNewPasswordPage(token: '')), )); } }); diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index cf8589ebd..c2481a12a 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -24,12 +24,6 @@ dependencies: path: packages/deriv_http_client ref: deriv_http_client-v2.0.1 -dependency_overrides: - flutter_deriv_api: - git: - url: git@github.com:deriv-com/flutter-deriv-api.git - ref: 82ddc3e22ca6ac85a6c7ff4bac082a1574a90c93 - dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/deriv_auth/lib/core/extensions/context_extension.dart b/packages/deriv_auth/lib/core/extensions/context_extension.dart index 7c9089c44..a3dd6c184 100644 --- a/packages/deriv_auth/lib/core/extensions/context_extension.dart +++ b/packages/deriv_auth/lib/core/extensions/context_extension.dart @@ -4,6 +4,6 @@ import 'package:flutter/material.dart'; /// Extension methods for [BuildContext]. extension ContextExtension on BuildContext { /// Gets [DerivAuthLocalizations]. - DerivAuthLocalizations? get derivAuthLocalization => + DerivAuthLocalizations get derivAuthLocalization => DerivAuthLocalizations.of(this); } diff --git a/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart b/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart index f442d3ff3..06664331c 100644 --- a/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart +++ b/packages/deriv_auth/lib/core/helpers/country_selection_helper.dart @@ -32,7 +32,7 @@ String getCountryConsentMessage( } final Map consentMessages = { - 'br': context.derivAuthLocalization!.labelCountryConsentBrazil, + 'br': context.derivAuthLocalization.labelCountryConsentBrazil, // Add more countries and consent messages here. }; diff --git a/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart b/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart index f4a877d65..b00eedf59 100644 --- a/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart +++ b/packages/deriv_auth/lib/core/layouts/deriv_unavailable_country_layout.dart @@ -28,7 +28,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { Widget build(BuildContext context) => Scaffold( appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization!.labelNotAvailable), + title: Text(context.derivAuthLocalization.labelNotAvailable), ), body: Container( padding: @@ -50,7 +50,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { children: [ const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization! + context.derivAuthLocalization .warnNotAvailableCountriesTitle(appName), style: TextStyles.title, textAlign: TextAlign.center, @@ -58,7 +58,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { const SizedBox(height: ThemeProvider.margin08), RichText( text: TextSpan( - text: context.derivAuthLocalization!.warnNotAvailableCountries, + text: context.derivAuthLocalization.warnNotAvailableCountries, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -66,7 +66,7 @@ class DerivUnavailableCountryLayout extends StatelessWidget { children: [ buildTextSpanHyperlink( context: context, - label: context.derivAuthLocalization!.labelLiveChat, + label: context.derivAuthLocalization.labelLiveChat, onTap: onLiveChatPressed, style: context.theme.textStyle( textStyle: TextStyles.body1Bold, diff --git a/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart b/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart index a2178048b..a2fa5129d 100644 --- a/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart +++ b/packages/deriv_auth/lib/core/services/token/services/deriv_token_service.dart @@ -3,7 +3,6 @@ import 'package:deriv_auth/core/services/token/models/login_request.dart'; import 'package:deriv_auth/core/services/token/models/login_response.dart'; import 'package:deriv_auth/core/services/token/services/base_token_service.dart'; import 'package:deriv_http_client/deriv_http_client.dart'; -import 'package:http/http.dart'; /// Deriv Implementation of a [BaseTokenService]. class DerivTokenService implements BaseTokenService { diff --git a/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart b/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart index b01469d26..e473dfcc8 100644 --- a/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart +++ b/packages/deriv_auth/lib/core/states/auth_error_state_handler.dart @@ -20,8 +20,8 @@ base class AuthErrorStateHandler { void invalid2faCode(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informInvalid2FACode, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informInvalid2FACode, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -29,8 +29,8 @@ base class AuthErrorStateHandler { void onAccountUnavailable(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informDeactivatedAccount, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informDeactivatedAccount, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -38,8 +38,8 @@ base class AuthErrorStateHandler { void onExpiredAccount(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informExpiredAccount, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informExpiredAccount, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -47,8 +47,8 @@ base class AuthErrorStateHandler { void onFailedAuthorization(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informFailedAuthorization, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informFailedAuthorization, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -56,8 +56,8 @@ base class AuthErrorStateHandler { void onInvalidResidence(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informInvalidResidence, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informInvalidResidence, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -65,8 +65,8 @@ base class AuthErrorStateHandler { void onInvalidCredentials(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informInvalidCredentials, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informInvalidCredentials, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -74,8 +74,8 @@ base class AuthErrorStateHandler { void onMissingOtp(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informMissingOtp, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informMissingOtp, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -83,8 +83,8 @@ base class AuthErrorStateHandler { void onSelfClosed(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informSelfClosed, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informSelfClosed, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -92,8 +92,8 @@ base class AuthErrorStateHandler { void onUnexpectedError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informUnexpectedError, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informUnexpectedError, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -101,8 +101,8 @@ base class AuthErrorStateHandler { void onUnsupportedCountry(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informUnsupportedCountry, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informUnsupportedCountry, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -110,8 +110,8 @@ base class AuthErrorStateHandler { void onConnectionError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informConnectionError, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informConnectionError, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } @@ -119,8 +119,8 @@ base class AuthErrorStateHandler { void onSwitchAccountError(DerivAuthErrorState state) { showErrorDialog( context: context, - errorMessage: context.derivAuthLocalization!.informSwitchAccountError, - actionLabel: context.derivAuthLocalization!.actionTryAgain, + errorMessage: context.derivAuthLocalization.informSwitchAccountError, + actionLabel: context.derivAuthLocalization.actionTryAgain, ); } } diff --git a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart index 4ea017900..8d83d5a56 100644 --- a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart +++ b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart @@ -10,7 +10,6 @@ import 'package:deriv_auth/core/services/token/models/login_request.dart'; import 'package:deriv_auth/features/auth/deriv_auth_io.dart'; import 'package:deriv_auth/features/auth/services/base_auth_service.dart'; import 'package:deriv_auth/features/social_auth/models/social_auth_dto.dart'; -import 'package:deriv_passkeys/deriv_passkeys.dart'; part 'deriv_auth_state.dart'; diff --git a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart index eec5f9a06..4543a1ce9 100644 --- a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart +++ b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart @@ -147,7 +147,7 @@ class _DerivGetStartedLayoutState extends State { onPressed: widget.onSignupTapped, child: Center( child: Text( - context.derivAuthLocalization!.actionGetAFreeAccount, + context.derivAuthLocalization.actionGetAFreeAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, @@ -163,7 +163,7 @@ class _DerivGetStartedLayoutState extends State { onPressed: widget.onLoginTapped, child: Center( child: Text( - context.derivAuthLocalization!.actionLogin, + context.derivAuthLocalization.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart index 451f87dfc..86c688214 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_2fa_layout.dart @@ -50,7 +50,7 @@ class _Deriv2FALayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelLogIn, + context.derivAuthLocalization.labelLogIn, style: TextStyles.title, ), ), @@ -65,13 +65,13 @@ class _Deriv2FALayoutState extends State { children: [ SvgPicture.asset(Assets.twoFactorAuthIcon), Text( - context.derivAuthLocalization!.labelTwoFactorAuth, + context.derivAuthLocalization.labelTwoFactorAuth, style: context.theme.textStyle(textStyle: TextStyles.title), textAlign: TextAlign.center, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization!.informEnterTwoFactorAuthCode, + context.derivAuthLocalization.informEnterTwoFactorAuthCode, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -82,7 +82,7 @@ class _Deriv2FALayoutState extends State { BaseTextField( controller: _otpController, labelText: context - .derivAuthLocalization!.labelTwoFactorAuthenticationCode, + .derivAuthLocalization.labelTwoFactorAuthenticationCode, labelColor: context.theme.colors.disabled, focusNode: _otpFocusNode, enabled: !_isLoading(), @@ -112,7 +112,7 @@ class _Deriv2FALayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization!.actionProceed, + context.derivAuthLocalization.actionProceed, style: TextStyles.body2.copyWith( color: context.theme.colors.prominent, ), diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 4f8c088fc..5076d0d0c 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -99,7 +99,7 @@ class _DerivLoginLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelLogIn, + context.derivAuthLocalization.labelLogIn, style: TextStyles.title, ), backgroundColor: context.theme.colors.secondary, @@ -131,8 +131,7 @@ class _DerivLoginLayoutState extends State { _buildLoginButton(), const SizedBox(height: ThemeProvider.margin24), DerivSocialAuthDivider( - label: - context.derivAuthLocalization!.informLoginOptions, + label: context.derivAuthLocalization.informLoginOptions, isVisible: widget.isSocialAuthEnabled, ), if (widget.isSocialAuthEnabled) @@ -176,7 +175,7 @@ class _DerivLoginLayoutState extends State { semanticLabel: SemanticsLabels.loginEmailFieldSemantic, controller: _emailController, focusNode: _emailFocusNode, - labelText: context.derivAuthLocalization!.labelEmail, + labelText: context.derivAuthLocalization.labelEmail, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, keyboardType: TextInputType.emailAddress, @@ -191,7 +190,7 @@ class _DerivLoginLayoutState extends State { semanticLabel: SemanticsLabels.loginPasswordFieldSemantic, controller: _passwordController, focusNode: _passwordFocusNode, - labelText: context.derivAuthLocalization!.labelPassword, + labelText: context.derivAuthLocalization.labelPassword, obscureText: !_isPasswordVisible, enabled: isEnabled, suffixIcon: IconButton( @@ -217,7 +216,7 @@ class _DerivLoginLayoutState extends State { child: InkWell( onTap: widget.onResetPassTapped, child: Text( - context.derivAuthLocalization!.actionForgotPassword, + context.derivAuthLocalization.actionForgotPassword, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -250,7 +249,7 @@ class _DerivLoginLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization!.actionLogin, + context.derivAuthLocalization.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -267,7 +266,7 @@ class _DerivLoginLayoutState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization!.labelDontHaveAnAccountYet, + context.derivAuthLocalization.labelDontHaveAnAccountYet, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -278,7 +277,7 @@ class _DerivLoginLayoutState extends State { child: Padding( padding: const EdgeInsets.all(ThemeProvider.margin04), child: Text( - context.derivAuthLocalization!.actionCreateANewAccount, + context.derivAuthLocalization.actionCreateANewAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -315,7 +314,7 @@ class _DerivLoginLayoutState extends State { return null; } - return context.derivAuthLocalization!.informInvalidEmailFormat; + return context.derivAuthLocalization.informInvalidEmailFormat; } String? _passwordValidator(String? input) { @@ -323,7 +322,7 @@ class _DerivLoginLayoutState extends State { return null; } - return context.derivAuthLocalization!.warnPasswordLength; + return context.derivAuthLocalization.warnPasswordLength; } Future _onLoginTapped() async { diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart index a9aefe63c..68dafc6cf 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart @@ -50,7 +50,7 @@ class _DerivChooseNewPassLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelResetPassword, + context.derivAuthLocalization.labelResetPassword, style: TextStyles.title, ), ), @@ -110,14 +110,14 @@ class _DerivChooseNewPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin48), Text( - context.derivAuthLocalization!.labelChooseNewPass, + context.derivAuthLocalization.labelChooseNewPass, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin24), BaseTextField( controller: _passController, focusNode: _passFocusNode, - labelText: context.derivAuthLocalization!.labelCreatePass, + labelText: context.derivAuthLocalization.labelCreatePass, obscureText: !_isPasswordVisible, suffixIcon: IconButton( icon: Icon( @@ -162,7 +162,7 @@ class _DerivChooseNewPassLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization!.actionResetPass, + context.derivAuthLocalization.actionResetPass, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -193,7 +193,7 @@ class _DerivChooseNewPassLayoutState extends State { return null; } - return context.derivAuthLocalization!.informInvalidPasswordFormat; + return context.derivAuthLocalization.informInvalidPasswordFormat; } bool isFormValid() => _passwordValidator(_passController.text) == null; diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart index 72deda390..e5406a496 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_reset_pass_layout.dart @@ -44,7 +44,7 @@ class _DerivResetPassLayoutState extends State { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelResetPassword, + context.derivAuthLocalization.labelResetPassword, style: TextStyles.title, ), ), @@ -87,12 +87,12 @@ class _DerivResetPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin24), Text( - context.derivAuthLocalization!.labelCheckEmail, + context.derivAuthLocalization.labelCheckEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization! + context.derivAuthLocalization .informSendResetPasswordEmail(_emailController.text), textAlign: TextAlign.center, style: context.theme.textStyle( @@ -121,14 +121,14 @@ class _DerivResetPassLayoutState extends State { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization!.labelResetPassword, + context.derivAuthLocalization.labelResetPassword, style: TextStyles.title, textAlign: TextAlign.center, ), const SizedBox(height: ThemeProvider.margin08), Center( child: Text( - context.derivAuthLocalization!.informResetPassByEmail, + context.derivAuthLocalization.informResetPassByEmail, textAlign: TextAlign.center, style: context.theme.textStyle( textStyle: TextStyles.body1, @@ -141,7 +141,7 @@ class _DerivResetPassLayoutState extends State { semanticLabel: SemanticsLabels.resetPasswordEmailFieldSemantic, controller: _emailController, focusNode: _emailFocusNode, - labelText: context.derivAuthLocalization!.labelEmail, + labelText: context.derivAuthLocalization.labelEmail, keyboardType: TextInputType.emailAddress, borderColor: context.theme.colors.hover, validator: _emailValidator, @@ -177,7 +177,7 @@ class _DerivResetPassLayoutState extends State { width: ThemeProvider.margin16, ) : Text( - context.derivAuthLocalization!.actionResetPass, + context.derivAuthLocalization.actionResetPass, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent.withOpacity( @@ -213,7 +213,7 @@ class _DerivResetPassLayoutState extends State { return null; } - return context.derivAuthLocalization!.informInvalidEmailFormat; + return context.derivAuthLocalization.informInvalidEmailFormat; } String _getEmailValue() => _emailController.text.trim(); diff --git a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart index 18d39d155..4d6cd57ec 100644 --- a/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart +++ b/packages/deriv_auth/lib/features/reset_password/presentation/layouts/deriv_success_pass_change_layout.dart @@ -14,7 +14,7 @@ class DerivSuccessPassChangeLayout extends StatelessWidget { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelResetPassword, + context.derivAuthLocalization.labelResetPassword, style: TextStyles.title, ), ), @@ -37,14 +37,14 @@ class DerivSuccessPassChangeLayout extends StatelessWidget { height: ThemeProvider.margin16, ), Text( - context.derivAuthLocalization!.informYourPassHasBeenReset, + context.derivAuthLocalization.informYourPassHasBeenReset, style: TextStyles.title, ), const SizedBox( height: ThemeProvider.margin08, ), Text( - context.derivAuthLocalization!.informRedirectLogin, + context.derivAuthLocalization.informRedirectLogin, textAlign: TextAlign.center, style: context.theme.textStyle( textStyle: TextStyles.body1, diff --git a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart index 27b3fc266..e61f0d754 100644 --- a/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart +++ b/packages/deriv_auth/lib/features/setting_page/presentation/layouts/deriv_setting_layout.dart @@ -155,7 +155,7 @@ class _SettingsPageState extends State { top: ThemeProvider.margin24, ), child: Text( - context.derivAuthLocalization!.labelDeveloper, + context.derivAuthLocalization.labelDeveloper, style: context.theme.textStyle( textStyle: TextStyles.body1Bold, color: context.theme.colors.coral, @@ -164,21 +164,21 @@ class _SettingsPageState extends State { ); Widget get _endpoint => _buildTextInputField( - label: context.derivAuthLocalization!.labelEndpoint, - semantic: context.derivAuthLocalization!.semanticEndpoint, + label: context.derivAuthLocalization.labelEndpoint, + semantic: context.derivAuthLocalization.semanticEndpoint, controller: _endpointController, validator: (String? value) => hasOnlySmallLettersAndNumberInput(value!) ? null - : context.derivAuthLocalization!.warnInvalidEndpoint, + : context.derivAuthLocalization.warnInvalidEndpoint, ); Widget get _appId => _buildTextInputField( - label: context.derivAuthLocalization!.labelApplicationID, - semantic: context.derivAuthLocalization!.semanticApplicationID, + label: context.derivAuthLocalization.labelApplicationID, + semantic: context.derivAuthLocalization.semanticApplicationID, controller: _appIdController, validator: (String? value) => hasOnlyNumberInput(value!) ? null - : context.derivAuthLocalization!.warnInvalidApplicationID, + : context.derivAuthLocalization.warnInvalidApplicationID, ); Widget _buildTextInputField({ diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart index 682ebb9a9..60c564e59 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_country_selection_layout.dart @@ -100,7 +100,7 @@ class _DerivCountrySelectionLayoutState SvgPicture.asset(Assets.locationIcon, package: 'deriv_auth'), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization!.labelSelectCountry, + context.derivAuthLocalization.labelSelectCountry, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin24), @@ -127,7 +127,7 @@ class _DerivCountrySelectionLayoutState key: _formKey, child: BaseTextField( controller: _textController, - labelText: context.derivAuthLocalization!.labelChooseCountry, + labelText: context.derivAuthLocalization.labelChooseCountry, labelColor: context.theme.colors.disabled, focusNode: _focusNode, focusedLabelColor: context.theme.colors.blue, @@ -157,7 +157,7 @@ class _DerivCountrySelectionLayoutState onPressed: widget.onNextPressed, child: Center( child: Text( - context.derivAuthLocalization!.actionNext, + context.derivAuthLocalization.actionNext, style: TextStyles.button .copyWith(color: context.theme.colors.prominent), ), @@ -225,7 +225,7 @@ class _DerivCountrySelectionLayoutState DerivResidenceModel? selectedCountry, }) { if (selectedCountry != null && selectedCountry.isDisabled) { - return context.derivAuthLocalization!.warnCountryNotAvailable; + return context.derivAuthLocalization.warnCountryNotAvailable; } return null; diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart index 93cfe423d..115beb538 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_email_not_received_layout.dart @@ -42,7 +42,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { child: Column( children: [ Text( - context.derivAuthLocalization!.labelEmailIssueHeader, + context.derivAuthLocalization.labelEmailIssueHeader, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.general, @@ -55,7 +55,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization!.labelEmailIssueSpam, + context.derivAuthLocalization.labelEmailIssueSpam, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -71,7 +71,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization!.labelEmailIssueWrongEmail, + context.derivAuthLocalization.labelEmailIssueWrongEmail, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -87,7 +87,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization!.labelEmailIssueTypo, + context.derivAuthLocalization.labelEmailIssueTypo, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -103,7 +103,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { const SizedBox(width: ThemeProvider.margin24), Flexible( child: Text( - context.derivAuthLocalization!.labelEmailIssueFirewall, + context.derivAuthLocalization.labelEmailIssueFirewall, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -127,7 +127,7 @@ class DerivEmailNotReceivedLayout extends StatelessWidget { onPressed: onReEnterEmailPressed, child: Center( child: Text( - context.derivAuthLocalization!.actionReenterEmail, + context.derivAuthLocalization.actionReenterEmail, style: context.theme.textStyle( textStyle: TextStyles.button .copyWith(color: context.theme.colors.prominent), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart index 63455a325..69f4e3110 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_set_password_layout.dart @@ -1,5 +1,4 @@ import 'package:deriv_auth/core/helpers/assets.dart'; -import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:deriv_auth/features/signup/presentation/widgets/password_policy_checker_widget.dart'; import 'package:deriv_theme/deriv_theme.dart'; @@ -97,7 +96,7 @@ class _DerivSetPasswordLayoutState extends State { SvgPicture.asset(Assets.passwordIcon, package: 'deriv_auth'), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization!.labelKeepPassword, + context.derivAuthLocalization.labelKeepPassword, style: TextStyles.title, textAlign: TextAlign.center, ), @@ -140,7 +139,7 @@ class _DerivSetPasswordLayoutState extends State { focusNode: _passwordFocusNode, controller: _passwordTextController, obscureText: !_isPasswordVisible, - labelText: context.derivAuthLocalization!.labelCreatePassword, + labelText: context.derivAuthLocalization.labelCreatePassword, labelColor: context.theme.colors.disabled, focusedLabelColor: context.theme.colors.blue, suffixIcon: IconButton( @@ -166,7 +165,7 @@ class _DerivSetPasswordLayoutState extends State { strokeWidth: 3, ) : Text( - context.derivAuthLocalization!.actionStartTrading, + context.derivAuthLocalization.actionStartTrading, style: TextStyles.button .copyWith(color: context.theme.colors.prominent), ), @@ -181,7 +180,7 @@ class _DerivSetPasswordLayoutState extends State { onPressed: widget.onPreviousPressed, child: Center( child: Text( - context.derivAuthLocalization!.actionPrevious, + context.derivAuthLocalization.actionPrevious, style: context.theme.textStyle( textStyle: TextStyles.button, ), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart index 3e3bb9b9f..c466189ed 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_signup_layout.dart @@ -1,5 +1,4 @@ import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/single_entry/core/auth_data.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; @@ -96,7 +95,7 @@ class _DerivSignupLayoutState extends State { backgroundColor: context.theme.colors.primary, appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization!.labelSignUp, + title: Text(context.derivAuthLocalization.labelSignUp, style: TextStyles.title), backgroundColor: context.theme.colors.secondary, ), @@ -125,7 +124,7 @@ class _DerivSignupLayoutState extends State { _buildSignUpButton(), const SizedBox(height: ThemeProvider.margin24), DerivSocialAuthDivider( - label: context.derivAuthLocalization!.labelOrSignUpWith, + label: context.derivAuthLocalization.labelOrSignUpWith, isVisible: widget.isSocialAuthEnabled, ), if (widget.isSocialAuthEnabled) @@ -167,16 +166,16 @@ class _DerivSignupLayoutState extends State { children: [ InfoIconButton( dialogTitle: - context.derivAuthLocalization!.labelReferralInfoTitle, - dialogDescription: context - .derivAuthLocalization!.infoReferralInfoDescription, - positiveActionLabel: context.derivAuthLocalization!.actionOk, + context.derivAuthLocalization.labelReferralInfoTitle, + dialogDescription: + context.derivAuthLocalization.infoReferralInfoDescription, + positiveActionLabel: context.derivAuthLocalization.actionOk, iconSize: ThemeProvider.iconSize24, ), const SizedBox(width: ThemeProvider.margin08), Expanded( child: Text( - context.derivAuthLocalization!.labelGotReferralCode, + context.derivAuthLocalization.labelGotReferralCode, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.prominent, @@ -231,7 +230,7 @@ class _DerivSignupLayoutState extends State { } }, focusNode: referralFocusNode, - labelText: context.derivAuthLocalization!.labelReferralCode, + labelText: context.derivAuthLocalization.labelReferralCode, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, textInputAction: TextInputAction.done, @@ -264,7 +263,7 @@ class _DerivSignupLayoutState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization!.labelHaveAccount, + context.derivAuthLocalization.labelHaveAccount, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -275,7 +274,7 @@ class _DerivSignupLayoutState extends State { child: Padding( padding: const EdgeInsets.all(ThemeProvider.margin04), child: Text( - context.derivAuthLocalization!.actionLogin, + context.derivAuthLocalization.actionLogin, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.coral, @@ -291,7 +290,7 @@ class _DerivSignupLayoutState extends State { semanticLabel: SemanticsLabels.signupEmailFieldSemantic, controller: emailController, focusNode: emailFocusNode, - labelText: context.derivAuthLocalization!.labelEmail, + labelText: context.derivAuthLocalization.labelEmail, borderColor: context.theme.colors.hover, focusedBorderColor: context.theme.colors.blue, keyboardType: TextInputType.emailAddress, @@ -319,7 +318,7 @@ class _DerivSignupLayoutState extends State { width: ThemeProvider.iconSize16, ) : Text( - context.derivAuthLocalization!.actionCreateAccount, + context.derivAuthLocalization.actionCreateAccount, style: context.theme.textStyle( textStyle: TextStyles.body2, color: context.theme.colors.prominent, @@ -349,7 +348,7 @@ class _DerivSignupLayoutState extends State { return null; } - return context.derivAuthLocalization!.informInvalidEmailFormat; + return context.derivAuthLocalization.informInvalidEmailFormat; } String? _referralValidator(String? input) { @@ -357,7 +356,7 @@ class _DerivSignupLayoutState extends State { return null; } - return context.derivAuthLocalization!.informInvalidReferralCode; + return context.derivAuthLocalization.informInvalidReferralCode; } Future _onSignupTapped() async { diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart index a85145886..1e30b4649 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verification_done_layout.dart @@ -29,7 +29,7 @@ class DerivVerificationDoneLayout extends StatelessWidget { backgroundColor: context.theme.colors.primary, appBar: AppBar( elevation: ThemeProvider.zeroMargin, - title: Text(context.derivAuthLocalization!.labelVerifyYourEmail), + title: Text(context.derivAuthLocalization.labelVerifyYourEmail), ), body: SafeArea( child: Column( @@ -56,12 +56,12 @@ class DerivVerificationDoneLayout extends StatelessWidget { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization!.labelThanksEmail, + context.derivAuthLocalization.labelThanksEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization!.informLetsContinue, + context.derivAuthLocalization.informLetsContinue, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -80,7 +80,7 @@ class DerivVerificationDoneLayout extends StatelessWidget { onPressed: onContinuePressed, child: Center( child: Text( - context.derivAuthLocalization!.actionContinue, + context.derivAuthLocalization.actionContinue, style: context.theme.textStyle( textStyle: TextStyles.button .copyWith(color: context.theme.colors.prominent), diff --git a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart index c89461053..eb2996d7d 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/layouts/deriv_verify_email_layout.dart @@ -26,7 +26,7 @@ class DerivVerifyEmailLayout extends StatelessWidget { appBar: AppBar( elevation: ThemeProvider.zeroMargin, title: Text( - context.derivAuthLocalization!.labelVerifyYourEmail, + context.derivAuthLocalization.labelVerifyYourEmail, style: TextStyles.title, ), backgroundColor: context.theme.colors.secondary, @@ -56,13 +56,12 @@ class DerivVerifyEmailLayout extends StatelessWidget { ), const SizedBox(height: ThemeProvider.margin16), Text( - context.derivAuthLocalization!.labelCheckEmail, + context.derivAuthLocalization.labelCheckEmail, style: TextStyles.title, ), const SizedBox(height: ThemeProvider.margin08), Text( - context.derivAuthLocalization! - .informVerificationEmailSent(email!), + context.derivAuthLocalization.informVerificationEmailSent(email!), style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, @@ -82,7 +81,7 @@ class DerivVerifyEmailLayout extends StatelessWidget { onPressed: onEmailNotReceivedPressed, child: Center( child: Text( - context.derivAuthLocalization!.actionEmailNotReceived, + context.derivAuthLocalization.actionEmailNotReceived, style: context.theme.textStyle( textStyle: TextStyles.button, ), diff --git a/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart b/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart index 9896a0264..5b72f3fc0 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/widgets/country_selection_list_widget.dart @@ -102,7 +102,7 @@ class _CountrySelectionListWidgetState children: [ const SizedBox(width: ThemeProvider.margin48), Text( - context.derivAuthLocalization!.labelChooseCountry, + context.derivAuthLocalization.labelChooseCountry, style: TextStyles.subheading, ), ], @@ -128,7 +128,7 @@ class _CountrySelectionListWidgetState onPressed: () => _searchController.clear(), ), contentPadding: const EdgeInsets.only(top: ThemeProvider.margin08), - hintText: context.derivAuthLocalization!.labelSearchCountry, + hintText: context.derivAuthLocalization.labelSearchCountry, hintStyle: context.theme.textStyle( textStyle: TextStyles.subheading, color: context.theme.colors.active, diff --git a/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart b/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart index 377a17173..2bb6c1b5b 100644 --- a/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart +++ b/packages/deriv_auth/lib/features/signup/presentation/widgets/password_policy_checker_widget.dart @@ -40,23 +40,20 @@ class PasswordPolicyCheckerWidget extends StatelessWidget { BuildContext context) => [ DerivPasswordPolicyModel( - description: - context.derivAuthLocalization!.informPasswordPolicyLength, + description: context.derivAuthLocalization.informPasswordPolicyLength, regex: validPasswordLengthRegex, ), DerivPasswordPolicyModel( description: - context.derivAuthLocalization!.informPasswordPolicyLowerAndUpper, + context.derivAuthLocalization.informPasswordPolicyLowerAndUpper, regex: validPasswordWithUppercaseRegex, ), DerivPasswordPolicyModel( - description: - context.derivAuthLocalization!.informPasswordPolicyNumber, + description: context.derivAuthLocalization.informPasswordPolicyNumber, regex: validPasswordWithNumberRegex, ), DerivPasswordPolicyModel( - description: - context.derivAuthLocalization!.warnPasswordContainsSymbol, + description: context.derivAuthLocalization.warnPasswordContainsSymbol, regex: validPasswordWithSymbols, isOptional: true, ), @@ -70,7 +67,7 @@ class PasswordPolicyCheckerWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - context.derivAuthLocalization!.informPasswordPolicy, + context.derivAuthLocalization.informPasswordPolicy, style: context.theme.textStyle( textStyle: TextStyles.body1, color: context.theme.colors.general, diff --git a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart index 90234fe08..7b1ed804b 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/reset_pass/pages/choose_new_password_page.dart @@ -6,8 +6,7 @@ import 'package:flutter/material.dart'; /// Choose new password page class ChooseNewPasswordPage extends StatelessWidget { /// Constructor [ChooseNewPasswordPage] - const ChooseNewPasswordPage( - {required this.token, super.key, required DerivResetPassCubit cubit}); + const ChooseNewPasswordPage({required this.token, super.key}); /// Token final String token; diff --git a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart index f3a42d877..f2e6ec693 100644 --- a/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart +++ b/packages/deriv_auth/lib/features/single_entry/features/signup/repositories/referral_repository.dart @@ -4,5 +4,5 @@ import 'package:deriv_auth/core/services/referral/base_referral_code_service.dar class ReferralRepository implements BaseReferralCodeService { @override Future getReferralToken(String referralCode) => - Future.value('${referralCode}Token'); + Future.value('${referralCode}Token'); } diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index f8725716e..6548e4770 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -46,13 +46,13 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_localizations - ref: 9a91d879a5ffd371a46dcbf70e4f3a295bc7b7e1 + ref: 47cd664bbc415b3e5c1808ec373f954348c19298 deriv_passkeys: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 568ecf2acdd9d415ef40c73f8caf6f136e752f33 + ref: 719122d0b8d3e94d2d6ce357ac76538a572947c2 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 @@ -67,7 +67,7 @@ dependency_overrides: flutter_deriv_api: git: url: git@github.com:deriv-com/flutter-deriv-api.git - ref: 82ddc3e22ca6ac85a6c7ff4bac082a1574a90c93 + ref: dev dev_dependencies: mocktail: ^1.0.3 diff --git a/packages/deriv_auth/test/core/helpers/account_helper_test.dart b/packages/deriv_auth/test/core/helpers/account_helper_test.dart index 52f01e24c..de0f64887 100644 --- a/packages/deriv_auth/test/core/helpers/account_helper_test.dart +++ b/packages/deriv_auth/test/core/helpers/account_helper_test.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/helpers/helpers.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:test/test.dart'; diff --git a/packages/deriv_auth/test/core/states/auth_error_state_mapper_test.dart b/packages/deriv_auth/test/core/states/auth_error_state_mapper_test.dart index 0cf52897c..b0daac89b 100644 --- a/packages/deriv_auth/test/core/states/auth_error_state_mapper_test.dart +++ b/packages/deriv_auth/test/core/states/auth_error_state_mapper_test.dart @@ -1,4 +1,3 @@ -import 'package:deriv_auth/core/states/states.dart'; import 'package:flutter/material.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; diff --git a/packages/deriv_auth/test/core/states/auth_state_listener_test.dart b/packages/deriv_auth/test/core/states/auth_state_listener_test.dart index 674380f99..b86f1aea7 100644 --- a/packages/deriv_auth/test/core/states/auth_state_listener_test.dart +++ b/packages/deriv_auth/test/core/states/auth_state_listener_test.dart @@ -1,5 +1,4 @@ import 'package:deriv_auth/core/models/landig_comany_model.dart'; -import 'package:deriv_auth/core/states/auth_state_listener.dart'; import 'package:deriv_auth/deriv_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout_test.dart b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout_test.dart index 1f58aba0d..90cbc2566 100644 --- a/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout_test.dart +++ b/packages/deriv_auth/test/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout_test.dart @@ -1,7 +1,6 @@ // ignore_for_file: always_specify_types import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/reset_password/presentation/layouts/deriv_choose_new_pass_layout.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/packages/deriv_auth/test/features/social_auth/cubit/social_auth_cubit_test.dart b/packages/deriv_auth/test/features/social_auth/cubit/social_auth_cubit_test.dart index 2325dbc36..39efc4363 100644 --- a/packages/deriv_auth/test/features/social_auth/cubit/social_auth_cubit_test.dart +++ b/packages/deriv_auth/test/features/social_auth/cubit/social_auth_cubit_test.dart @@ -1,6 +1,5 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:deriv_auth/deriv_auth.dart'; -import 'package:deriv_auth/features/social_auth/services/base_social_web_view_service.dart'; import 'package:deriv_http_client/deriv_http_client.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; From 02f390b2cb4736993f876fe60f6513490682837a Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 1 Apr 2024 12:51:06 +0400 Subject: [PATCH 32/48] refactor(deriv_passkeys): removed context parameter from onLoggedIn callback --- .../lib/features/login/pages/login_page.dart | 3 +-- .../layouts/deriv_login_layout.dart | 4 ++-- .../core/models/login_page_model.dart | 2 +- .../layouts/deriv_login_layout_test.dart | 20 +++++++++---------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/deriv_auth/example/lib/features/login/pages/login_page.dart b/packages/deriv_auth/example/lib/features/login/pages/login_page.dart index 2bfcc77a1..03d64f5b9 100644 --- a/packages/deriv_auth/example/lib/features/login/pages/login_page.dart +++ b/packages/deriv_auth/example/lib/features/login/pages/login_page.dart @@ -26,8 +26,7 @@ class _LoginPageState extends State { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: 'Welcome back!', - onLoggedIn: (BuildContext context, DerivAuthLoggedInState state) => - Navigator.pushReplacement( + onLoggedIn: (DerivAuthLoggedInState state) => Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const HomePage(), diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index 5076d0d0c..e9ec1b0dc 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -41,7 +41,7 @@ class DerivLoginLayout extends StatefulWidget { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; + final Function(DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. @@ -301,7 +301,7 @@ class _DerivLoginLayoutState extends State { } if (state is DerivAuthLoggedInState) { - widget.onLoggedIn(context, state); + widget.onLoggedIn(state); } } diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index 1075da51b..76115e911 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -25,7 +25,7 @@ class LoginPageModel { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; + final Function(DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. diff --git a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart index 5eefd27af..7fb8322c4 100644 --- a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart +++ b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart @@ -65,7 +65,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (SocialAuthDto p0) {}, onLoginError: (_) {}, ), @@ -101,7 +101,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -139,7 +139,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -173,7 +173,7 @@ void main() { onSignupTapped: () { onSignupTappedCalled = true; }, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -216,7 +216,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) { + onLoggedIn: (_) { onLoggedInCalled = true; }, onSocialAuthButtonPressed: (_) {}, @@ -256,7 +256,7 @@ void main() { onLoginError: (_) { onLoginErrorCalled = true; }, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -290,7 +290,7 @@ void main() { onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -323,7 +323,7 @@ void main() { onResetPassTappedCalled = true; }, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -368,7 +368,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) { onSocialAuthButtonPressedCalled = true; }, @@ -413,7 +413,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (_, __) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), From 572aa5fd54241d09b9993b102c0eceb117594821 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 2 Apr 2024 12:22:13 +0400 Subject: [PATCH 33/48] refactor(deriv_auth): replaced deriv_localizations commit hash ref with tag ref --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index adf5bf5ab..fbb9e1607 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_localizations - ref: 47cd664bbc415b3e5c1808ec373f954348c19298 + ref: deriv_localizations-v1.2.0 deriv_passkeys: git: From 6a2708eb6cb8a3b343fd8688a27ab038fd3c1acb Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 2 Apr 2024 12:40:43 +0400 Subject: [PATCH 34/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- .../layouts/deriv_login_layout.dart | 2 +- .../core/models/login_page_model.dart | 2 +- packages/deriv_auth/pubspec.yaml | 2 +- .../layouts/deriv_login_layout_test.dart | 20 +++++++++---------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index abc7d46cc..e9ec1b0dc 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -41,7 +41,7 @@ class DerivLoginLayout extends StatefulWidget { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; + final Function(DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. diff --git a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index 1075da51b..76115e911 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart @@ -25,7 +25,7 @@ class LoginPageModel { final Function(DerivAuthErrorState)? onLoginError; /// Callback to be called when user is logged in. - final Function(BuildContext, DerivAuthLoggedInState) onLoggedIn; + final Function(DerivAuthLoggedInState) onLoggedIn; /// Callback to be called when social auth button is tapped. /// Give access to [SocialAuthDto] for 2FA. diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index fbb9e1607..cf2aa5dbb 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 719122d0b8d3e94d2d6ce357ac76538a572947c2 + ref: 89dcd570165a053cf0ec89b4c7faf0801869e861 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 diff --git a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart index 3f009caaa..7fb8322c4 100644 --- a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart +++ b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart @@ -65,7 +65,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (SocialAuthDto p0) {}, onLoginError: (_) {}, ), @@ -101,7 +101,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -139,7 +139,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -173,7 +173,7 @@ void main() { onSignupTapped: () { onSignupTappedCalled = true; }, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -216,7 +216,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) { + onLoggedIn: (_) { onLoggedInCalled = true; }, onSocialAuthButtonPressed: (_) {}, @@ -256,7 +256,7 @@ void main() { onLoginError: (_) { onLoginErrorCalled = true; }, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -290,7 +290,7 @@ void main() { onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -323,7 +323,7 @@ void main() { onResetPassTappedCalled = true; }, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -368,7 +368,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) { onSocialAuthButtonPressedCalled = true; }, @@ -413,7 +413,7 @@ void main() { welcomeLabel: welcomeLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), From 608dcf4b812945efa605ae5c553afa06e6a9f8db Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 2 Apr 2024 12:52:40 +0400 Subject: [PATCH 35/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index cf2aa5dbb..c34cd8742 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 89dcd570165a053cf0ec89b4c7faf0801869e861 + ref: 0a61540e0d2e0477ce21f5fad78489d9f51d3a3f flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From 87ff83bbc8050c3893186b86003345ca3ed739bd Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 2 Apr 2024 13:01:26 +0400 Subject: [PATCH 36/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index c34cd8742..8a8018283 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 0a61540e0d2e0477ce21f5fad78489d9f51d3a3f + ref: 0c8dc95f005cc251d7221d557c0b6f75c2c22d1a flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From dcda848bb014f72e138e907c84c258be1a7c5c63 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 2 Apr 2024 15:04:15 +0400 Subject: [PATCH 37/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 8a8018283..da24ce6b0 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 0c8dc95f005cc251d7221d557c0b6f75c2c22d1a + ref: dbec09ab8a0174e28e684d3b49c16a228185c839 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From 82de161098d7cd698dcf465a4ad4a2cdac1fdd75 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 15 Apr 2024 07:39:36 +0400 Subject: [PATCH 38/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index da24ce6b0..bda7f12df 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: dbec09ab8a0174e28e684d3b49c16a228185c839 + ref: 14c421fa006da601441e7ab20e2d4caf1e044ee7 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From ed0f005785991a0c166edaf4f93e03922826ee91 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Thu, 18 Apr 2024 15:08:52 +0400 Subject: [PATCH 39/48] refactor(deriv_auth): updated deriv_passkeys commit hash --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index bda7f12df..8017ccbda 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 14c421fa006da601441e7ab20e2d4caf1e044ee7 + ref: c00a7ce73cbb6c0b97f6262f7df6bd2b15324337 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From a3acdf1ad34bdbba464d866273e165709d908159 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 22 Apr 2024 07:26:59 +0400 Subject: [PATCH 40/48] refactor(deriv_auth): updated deriv_passkeys and deriv_localizations versions. --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 8017ccbda..6554af305 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: c00a7ce73cbb6c0b97f6262f7df6bd2b15324337 + ref: 22c6f7ad191e3f33fad6f5264ceb0f20b1ba31d8 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From 4d43e258d72e71da6c53f1bf2b241f95d4ba4c67 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 29 Apr 2024 13:59:20 +0400 Subject: [PATCH 41/48] refactor(deriv_auth): Updated deriv_localizations --- .../deriv_auth/lib/core/extensions/context_extension.dart | 2 +- packages/deriv_auth/pubspec.yaml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/deriv_auth/lib/core/extensions/context_extension.dart b/packages/deriv_auth/lib/core/extensions/context_extension.dart index a3dd6c184..d239c5090 100644 --- a/packages/deriv_auth/lib/core/extensions/context_extension.dart +++ b/packages/deriv_auth/lib/core/extensions/context_extension.dart @@ -5,5 +5,5 @@ import 'package:flutter/material.dart'; extension ContextExtension on BuildContext { /// Gets [DerivAuthLocalizations]. DerivAuthLocalizations get derivAuthLocalization => - DerivAuthLocalizations.of(this); + DerivAuthLocalizations.of(this)!; } diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 6554af305..cfbbb1431 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_localizations - ref: deriv_localizations-v1.2.0 + ref: da897013ecd1f993ad4e696c1d0856d7ebf3758c deriv_passkeys: git: @@ -68,6 +68,11 @@ dependency_overrides: git: url: git@github.com:deriv-com/flutter-deriv-api.git ref: dev + deriv_localizations: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_localizations + ref: da897013ecd1f993ad4e696c1d0856d7ebf3758c dev_dependencies: mocktail: ^1.0.3 From 41fa9ed899462b0eeef34fa3971ffe82e937ce91 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 7 May 2024 12:39:36 +0400 Subject: [PATCH 42/48] refactor: update deriv_passkeys --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index cfbbb1431..9dfd0b148 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 22c6f7ad191e3f33fad6f5264ceb0f20b1ba31d8 + ref: d065248fd304918977c6523d5fe5959ad1ef85cc flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From cd545c74f7076010d7153d74c20288b2b8db016b Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Tue, 7 May 2024 12:52:36 +0400 Subject: [PATCH 43/48] refactor: update deriv_passkeys --- .../login/presentation/layouts/deriv_login_layout.dart | 4 +--- packages/deriv_auth/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index e9ec1b0dc..c1a4bc76a 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -136,9 +136,7 @@ class _DerivLoginLayoutState extends State { ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), - ContinueWithPasskeyButton( - derivPasskeysBloc: AuthData().data.derivPasskeysBloc, - ), + ContinueWithPasskeyButton(), DerivSocialAuthPanel( socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 9dfd0b148..af8c4afdd 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: d065248fd304918977c6523d5fe5959ad1ef85cc + ref: 4cb6ab174fc11aac2799475ce4cd874612f7e2da flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 From d6eccdcaf9fa37784ae3f9fb2bd13a98e874aae0 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 13 May 2024 08:11:00 +0400 Subject: [PATCH 44/48] refactor(deriv_passkeys): updated deriv_passkeys and deriv_localizations --- .../features/login/presentation/layouts/deriv_login_layout.dart | 2 +- packages/deriv_auth/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart index c1a4bc76a..170a8fc90 100644 --- a/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart +++ b/packages/deriv_auth/lib/features/login/presentation/layouts/deriv_login_layout.dart @@ -136,7 +136,7 @@ class _DerivLoginLayoutState extends State { ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), - ContinueWithPasskeyButton(), + const ContinueWithPasskeyButton(), DerivSocialAuthPanel( socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index af8c4afdd..1366a5974 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_localizations - ref: da897013ecd1f993ad4e696c1d0856d7ebf3758c + ref: deriv_localizations-v1.3.1 deriv_passkeys: git: From 294ca42318568fd876f531856b61d0930efb05b8 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 20 May 2024 13:16:47 +0400 Subject: [PATCH 45/48] refactor(deriv_auth): updated deriv_ui --- packages/deriv_auth/.fvm/flutter_sdk | 1 + packages/deriv_auth/.fvm/fvm_config.json | 4 ++++ .../features/get_started/pages/get_started_page.dart | 2 +- packages/deriv_auth/example/pubspec.yaml | 7 +++++++ packages/deriv_auth/pubspec.yaml | 12 ++++-------- 5 files changed, 17 insertions(+), 9 deletions(-) create mode 120000 packages/deriv_auth/.fvm/flutter_sdk create mode 100644 packages/deriv_auth/.fvm/fvm_config.json diff --git a/packages/deriv_auth/.fvm/flutter_sdk b/packages/deriv_auth/.fvm/flutter_sdk new file mode 120000 index 000000000..30d5c7f1a --- /dev/null +++ b/packages/deriv_auth/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/bassemobeid/fvm/versions/3.10.2 \ No newline at end of file diff --git a/packages/deriv_auth/.fvm/fvm_config.json b/packages/deriv_auth/.fvm/fvm_config.json new file mode 100644 index 000000000..0e8090af0 --- /dev/null +++ b/packages/deriv_auth/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.10.2", + "flavors": {} +} \ No newline at end of file diff --git a/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart b/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart index 586baf711..97b058a48 100644 --- a/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart +++ b/packages/deriv_auth/example/lib/features/get_started/pages/get_started_page.dart @@ -32,7 +32,7 @@ class GetStartedPage extends StatelessWidget { builder: (context) => const SignupPage(), ), ), - onTapNavigation: () { + onTapNavigation: (context) { Navigator.push( context, MaterialPageRoute( diff --git a/packages/deriv_auth/example/pubspec.yaml b/packages/deriv_auth/example/pubspec.yaml index c2481a12a..d1ba03014 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -24,6 +24,13 @@ dependencies: path: packages/deriv_http_client ref: deriv_http_client-v2.0.1 +dependency_overrides: + deriv_ui: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_ui + ref: deriv_ui-v0.0.7+4 + dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 2c0c34234..0ff3efee7 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: 4cb6ab174fc11aac2799475ce4cd874612f7e2da + ref: dabf6e8cc92494522879fe9fbfae592377eb899a deriv_language_selector: git: @@ -70,15 +70,11 @@ dependencies: uni_links2: ^0.6.0+2 dependency_overrides: - flutter_deriv_api: - git: - url: git@github.com:deriv-com/flutter-deriv-api.git - ref: dev - deriv_localizations: + deriv_ui: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git - path: packages/deriv_localizations - ref: da897013ecd1f993ad4e696c1d0856d7ebf3758c + path: packages/deriv_ui + ref: deriv_ui-v0.0.7+4 dev_dependencies: mocktail: ^1.0.3 From be3f0616ee514ea0e1c0dae8f9edb387ed186f90 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 20 May 2024 13:19:47 +0400 Subject: [PATCH 46/48] chore: Remove unused Flutter SDK and fvm configuration files --- packages/deriv_auth/.fvm/flutter_sdk | 1 - packages/deriv_auth/.fvm/fvm_config.json | 4 ---- 2 files changed, 5 deletions(-) delete mode 120000 packages/deriv_auth/.fvm/flutter_sdk delete mode 100644 packages/deriv_auth/.fvm/fvm_config.json diff --git a/packages/deriv_auth/.fvm/flutter_sdk b/packages/deriv_auth/.fvm/flutter_sdk deleted file mode 120000 index 30d5c7f1a..000000000 --- a/packages/deriv_auth/.fvm/flutter_sdk +++ /dev/null @@ -1 +0,0 @@ -/Users/bassemobeid/fvm/versions/3.10.2 \ No newline at end of file diff --git a/packages/deriv_auth/.fvm/fvm_config.json b/packages/deriv_auth/.fvm/fvm_config.json deleted file mode 100644 index 0e8090af0..000000000 --- a/packages/deriv_auth/.fvm/fvm_config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutterSdkVersion": "3.10.2", - "flavors": {} -} \ No newline at end of file From f46208876dfb676310790155ba6d458d4a22f8a5 Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 20 May 2024 13:23:36 +0400 Subject: [PATCH 47/48] chore: Update deriv_auth dependency to deriv_passkeys-v0.0.1+1 --- packages/deriv_auth/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index e06b21479..abb36f4af 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: dabf6e8cc92494522879fe9fbfae592377eb899a + ref: deriv_passkeys-v0.0.1+1 deriv_language_selector: git: From e110f2297d15b5c0d75eed22566f554dd46ed9ef Mon Sep 17 00:00:00 2001 From: bassam-deriv Date: Mon, 20 May 2024 15:27:56 +0400 Subject: [PATCH 48/48] chore: Update deriv_language_selector dependency to v0.0.2+2 and remove unused import in deriv_get_started_layout_test --- packages/deriv_auth/pubspec.yaml | 2 +- .../deriv_get_started_layout_test.dart | 5 ++-- .../layouts/deriv_login_layout_test.dart | 24 ++++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index abb36f4af..5ebd64995 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -58,7 +58,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_language_selector - ref: deriv_language_selector-v0.0.2+1 + ref: deriv_language_selector-v0.0.2+2 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 diff --git a/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart b/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart index ca0c48003..23aa26b08 100644 --- a/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart +++ b/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart @@ -5,7 +5,6 @@ import 'package:deriv_auth/features/get_started/models/deriv_get_started_slide_m import 'package:deriv_auth/features/get_started/presentation/layouts/deriv_get_started_layout.dart'; import 'package:deriv_language_selector/deriv_language_selector.dart'; import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations.dart'; -import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations_ar.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -76,7 +75,7 @@ void main() { ), )); - await $.tap($(SecondaryButton)); + await $(SecondaryButton).tap(); expect(loginTapped, isTrue); }); @@ -107,7 +106,7 @@ void main() { ), ); - await $.tap($(PrimaryButton)); + await $(PrimaryButton).tap(); expect(signupTapped, isTrue); }); diff --git a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart index 7fb8322c4..9d8ddba69 100644 --- a/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart +++ b/packages/deriv_auth/test/features/login/presentation/layouts/deriv_login_layout_test.dart @@ -1,5 +1,7 @@ +import 'package:bloc_test/bloc_test.dart'; import 'package:deriv_auth/core/models/landig_comany_model.dart'; import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_passkeys/deriv_passkeys.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -12,16 +14,26 @@ import '../../../../mocks.dart'; import '../../../../pump_app.dart'; import '../../../social_auth/mocks/mock_social_provider_model.dart'; +class MockDerivPasskeysBloc + extends MockBloc + implements DerivPasskeysBloc {} + void main() { group('DerivLoginLayout', () { late MockAuthCubit authCubit; late MockSocialAuthCubit socialAuthCubit; + late MockDerivPasskeysBloc derivPasskeysBloc; const String welcomeLabel = 'Welcome Back'; setUpAll(() { authCubit = MockAuthCubit(); socialAuthCubit = MockSocialAuthCubit(); + derivPasskeysBloc = MockDerivPasskeysBloc(); + + when(() => derivPasskeysBloc.state).thenReturn( + DerivPasskeysInitializedState(), + ); registerFallbackValue(SocialAuthProvider.google); @@ -57,6 +69,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -93,6 +106,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -131,6 +145,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -163,6 +178,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -208,6 +224,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -245,6 +262,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -281,6 +299,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -313,6 +332,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -360,6 +380,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, @@ -376,7 +397,7 @@ void main() { ), )); - await $(IconButton).at(1).tap(); + await $(InkWell).$(SocialAuthProvider.google.name.capitalize).tap(); expect(onSocialAuthButtonPressedCalled, isTrue); }); @@ -403,6 +424,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {