Skip to content

Commit

Permalink
feat(deriv_auth): adding login page to single entry
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrar-deriv committed Feb 2, 2024
1 parent 6a16570 commit 5ce30c3
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -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<DerivGetStartedSlideModel> slides;

///
final String appLogoIconPath;
/// GetStartedPage data model
final GetStartedPageModel getStartedPage;

///
final String backgroundImagePath;
/// LoginPage data model
final LoginPageModel loginPageModel;
}
Original file line number Diff line number Diff line change
@@ -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<DerivGetStartedSlideModel> slides;

///
final String appLogoIconPath;

///
final String backgroundImagePath;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'auth_entry_model.dart';
export 'get_started_page_model.dart';
export 'login_page_model.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -23,17 +23,17 @@ class _LoginPageState extends State<LoginPage> {

@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(
Expand All @@ -46,6 +46,7 @@ class _LoginPageState extends State<LoginPage> {
builder: (context) => const SignupPage(),
),
),
onSocialAuthButtonPressed: (_) {},
onSocialAuthButtonPressed:
AuthData().data.loginPageModel.onSocialAuthButtonPressed,
);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export 'core/models/auth_entry_model.dart';
export 'core/models/models.dart';
export 'pages/auth_entry_page.dart';

0 comments on commit 5ce30c3

Please sign in to comment.