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/docs/deriv_auth_layouts.md b/packages/deriv_auth/docs/deriv_auth_layouts.md index 5110a84f6..fe5f949e2 100644 --- a/packages/deriv_auth/docs/deriv_auth_layouts.md +++ b/packages/deriv_auth/docs/deriv_auth_layouts.md @@ -26,8 +26,6 @@ forgotPasswordButtonKey: Key('forgot password button key'), loginButtonKey: Key('login button key'), 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/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 @@ const SignupPage(), ), ), - onTapNavigation: () { + onTapNavigation: (context) { Navigator.push( context, MaterialPageRoute( 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..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 @@ -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,17 @@ 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: (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..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 @@ -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,7 @@ class _ResetPassPageState extends State { if (mounted) { Navigator.of(context).push(MaterialPageRoute( builder: (context) => BlocProvider.value( - value: cubit, child: ChooseNewPasswordPage(cubit: cubit)), + value: cubit, child: const ChooseNewPasswordPage(token: '')), )); } }); @@ -41,9 +57,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/features/social_auth/deriv_auth_connection_info.dart b/packages/deriv_auth/example/lib/features/social_auth/deriv_auth_connection_info.dart new file mode 100644 index 000000000..4bc773d42 --- /dev/null +++ b/packages/deriv_auth/example/lib/features/social_auth/deriv_auth_connection_info.dart @@ -0,0 +1,11 @@ +import 'package:deriv_auth/deriv_auth.dart'; +import 'package:flutter_deriv_api/state/connection/connection_cubit.dart'; + +/// Class that contains ConnectionInfo +class DerivAuthConnectionInfo implements AuthConnectionInfo { + @override + String get appId => 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..f16ee0fa0 100644 --- a/packages/deriv_auth/example/lib/main.dart +++ b/packages/deriv_auth/example/lib/main.dart @@ -1,11 +1,14 @@ import 'package:deriv_auth/deriv_auth.dart'; +import 'package:deriv_http_client/deriv_http_client.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'; 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 +18,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 +45,31 @@ class MyApp extends StatelessWidget { referralService: ExampleReferralRepository(), ), ), + BlocProvider( + create: (context) => SocialAuthCubit( + socialAuthService: DerivSocialAuthService( + client: HttpClient(), + connectionInfo: DerivAuthConnectionInfo(), + ), + ), + ), + BlocProvider( + 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 8388d95f4..d1ba03014 100644 --- a/packages/deriv_auth/example/pubspec.yaml +++ b/packages/deriv_auth/example/pubspec.yaml @@ -13,14 +13,23 @@ 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 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-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: diff --git a/packages/deriv_auth/lib/core/extensions/context_extension.dart b/packages/deriv_auth/lib/core/extensions/context_extension.dart index a4e731bb5..d239c5090 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]. + /// Gets [DerivAuthLocalizations]. DerivAuthLocalizations get derivAuthLocalization => - DerivAuthLocalizations.of(this); + DerivAuthLocalizations.of(this)!; } 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/auth/cubit/deriv_auth_cubit.dart b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart index 481787c6d..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 @@ -17,7 +17,9 @@ 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, + }) : super(DerivAuthLoadingState()); /// [BaseAuthService] handles all login logic of cubit. final BaseAuthService authService; @@ -133,12 +135,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 35018b066..2e269c7d2 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,8 @@ 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'; @@ -14,7 +16,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, @@ -46,7 +47,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. @@ -59,9 +60,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; @@ -144,8 +142,7 @@ class _DerivLoginLayoutState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ ..._buildTopSection(), - const SizedBox(height: ThemeProvider.margin24), - const SizedBox(height: ThemeProvider.margin24), + const SizedBox(height: ThemeProvider.margin14), ..._buildTextFields( isEnabled: state is! DerivAuthLoadingState), const SizedBox(height: ThemeProvider.margin24), @@ -161,6 +158,7 @@ class _DerivLoginLayoutState extends State { ), if (widget.isSocialAuthEnabled) const SizedBox(height: ThemeProvider.margin24), + const ContinueWithPasskeyButton(), DerivSocialAuthPanel( socialAuthStateHandler: widget.socialAuthStateHandler, redirectURL: widget.redirectURL, @@ -186,18 +184,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}) => [ @@ -335,7 +325,7 @@ class _DerivLoginLayoutState extends State { } if (state is DerivAuthLoggedInState) { - widget.onLoggedIn.call(context, state); + widget.onLoggedIn(state); } } 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..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'; 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/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/core/models/login_page_model.dart b/packages/deriv_auth/lib/features/single_entry/core/models/login_page_model.dart index 3bac56864..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 @@ -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, @@ -26,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. @@ -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/login/pages/login_page.dart b/packages/deriv_auth/lib/features/single_entry/features/login/pages/login_page.dart index 0fee5c411..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 @@ -25,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/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/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 7dd943a7b..ea2241f4e 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,6 +1,5 @@ import 'package:deriv_auth/deriv_auth.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'; @@ -65,18 +64,22 @@ class _DerivSocialAuthPanelState extends State { listener: (BuildContext context, SocialAuthState state) { widget.socialAuthStateHandler(state); }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _buildSocialAuthButton(SocialAuthProvider.apple, - key: const Key('social_auth_button_apple')), - const SizedBox(width: ThemeProvider.margin24), - _buildSocialAuthButton(SocialAuthProvider.google, - key: const Key('social_auth_button_google')), - const SizedBox(width: ThemeProvider.margin24), - _buildSocialAuthButton(SocialAuthProvider.facebook, - key: const Key('social_auth_button_facebook')), - ], + child: SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.google, + key: const Key('social_auth_button_google')), + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.facebook, + key: const Key('social_auth_button_facebook')), + const SizedBox(height: ThemeProvider.margin08), + _buildSocialAuthButton(SocialAuthProvider.apple, + key: const Key('social_auth_button_apple')), + ], + ), ), ), ); @@ -85,18 +88,38 @@ class _DerivSocialAuthPanelState extends State { SocialAuthProvider socialAuthProvider, { Key? key, }) => - IconButton( + InkWell( key: key, - padding: EdgeInsets.zero, - iconSize: ThemeProvider.iconSize40, - icon: Opacity( - opacity: getOpacity(isEnabled: widget.isEnabled), - child: SvgPicture.asset( - _getSocialMediaIcon(socialAuthProvider), - package: 'deriv_auth', + 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 ? () async { final List? socialAuthProviders = await _socialAuthCubit.getSocialAuthProviders(); diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index d31fd0a4f..5ebd64995 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -48,11 +48,17 @@ dependencies: path: packages/deriv_localizations ref: deriv_localizations-v1.4.0 + deriv_passkeys: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_passkeys + ref: deriv_passkeys-v0.0.1+1 + deriv_language_selector: 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 @@ -63,6 +69,13 @@ dependencies: http: ^0.13.5 uni_links2: ^0.6.0+2 +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: mocktail: ^1.0.3 bloc_test: ^9.1.6 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/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 f5a1bbe4b..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,17 +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'; - const String greetingLabel = 'Let\'s start trading.'; setUpAll(() { authCubit = MockAuthCubit(); socialAuthCubit = MockSocialAuthCubit(); + derivPasskeysBloc = MockDerivPasskeysBloc(); + + when(() => derivPasskeysBloc.state).thenReturn( + DerivPasskeysInitializedState(), + ); registerFallbackValue(SocialAuthProvider.google); @@ -58,16 +69,16 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (SocialAuthDto p0) {}, onLoginError: (_) {}, ), @@ -95,16 +106,16 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -134,16 +145,16 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -167,18 +178,18 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () { onSignupTappedCalled = true; }, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -213,16 +224,16 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) { + onLoggedIn: (_) { onLoggedInCalled = true; }, onSocialAuthButtonPressed: (_) {}, @@ -251,19 +262,19 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) { onLoginErrorCalled = true; }, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -288,17 +299,17 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, onLoginError: (_) {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, ), )); @@ -321,18 +332,18 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () { onResetPassTappedCalled = true; }, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), @@ -369,16 +380,16 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) {}, redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) { onSocialAuthButtonPressedCalled = true; }, @@ -386,7 +397,7 @@ void main() { ), )); - await $(IconButton).at(1).tap(); + await $(InkWell).$(SocialAuthProvider.google.name.capitalize).tap(); expect(onSocialAuthButtonPressedCalled, isTrue); }); @@ -413,6 +424,7 @@ void main() { providers: [ BlocProvider.value(value: authCubit), BlocProvider.value(value: socialAuthCubit), + BlocProvider.value(value: derivPasskeysBloc), ], child: DerivLoginLayout( socialAuthStateHandler: (SocialAuthState state) { @@ -421,10 +433,9 @@ void main() { redirectURL: 'deriv://example', onWebViewError: (String error) {}, welcomeLabel: welcomeLabel, - greetingLabel: greetingLabel, onResetPassTapped: () {}, onSignupTapped: () {}, - onLoggedIn: (BuildContext context, _) {}, + onLoggedIn: (_) {}, onSocialAuthButtonPressed: (_) {}, onLoginError: (_) {}, ), 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';