From 59278c7321f69c8f3c1f63a0973efdb5f01ed4f9 Mon Sep 17 00:00:00 2001 From: Ahrar Date: Mon, 26 Feb 2024 14:01:17 +0800 Subject: [PATCH] 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, ); }