Skip to content

Commit

Permalink
doc(deriv_auth): single entry doc and fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrar-deriv committed Feb 26, 2024
1 parent fac8904 commit 59278c7
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ class _DerivChooseNewPassLayoutState extends State<DerivChooseNewPassLayout> {
widget.onResetPassSucceed();
} else if (state is DerivResetPassErrorState) {
widget.onResetPassError(
error: state.errorMessage,
isLinkExpired: state.isLinkExpired);
error: state.errorMessage,
isLinkExpired: state.isLinkExpired,
);
}
},
child: _buildChooseNewPassSection(context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DerivResetPassLayout> createState() => _DerivResetPassLayoutState();
Expand Down Expand Up @@ -57,7 +57,10 @@ class _DerivResetPassLayoutState extends State<DerivResetPassLayout> {
curve: Curves.easeInOut,
);
} else if (state is DerivResetPassErrorState) {
widget.onResetPassError(state.errorMessage);
widget.onResetPassError(
error: state.errorMessage,
isLinkExpired: state.isLinkExpired,
);
}
},
child: PageView(
Expand Down
86 changes: 86 additions & 0 deletions packages/deriv_auth/lib/features/single_entry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Single Entry:

Single entry will enable you to just call one Widget and get the entire Authentication flow</br>

#### 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<DerivAuthCubit>(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',
),
),
),
```
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,12 +14,6 @@ class ResetPassPage extends StatefulWidget {
class _ResetPasswordPageState extends State<ResetPassPage> {
@override
Widget build(BuildContext context) => DerivResetPassLayout(
onResetPassError: (String? errorMessage) {
showErrorDialog(
context: context,
errorMessage: errorMessage,
actionLabel: 'okay',
);
},
onResetPassError: AuthData().data.resetPassPageModel.onResetPassError,
);
}

0 comments on commit 59278c7

Please sign in to comment.