Skip to content

Commit

Permalink
Adding context in social auth handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ernest-deriv committed May 8, 2024
1 parent 0f221ae commit 0547991
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DerivLoginLayout extends StatefulWidget {
final bool isCreateAccountEnabled;

/// Social auth state handler.
final Function(SocialAuthState) socialAuthStateHandler;
final Function(BuildContext, SocialAuthState) socialAuthStateHandler;

/// Redirect URL for social auth.
final String redirectURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DerivSignupLayout extends StatefulWidget {
final bool isSocialAuthEnabled;

/// Social auth state handler.
final Function(SocialAuthState) socialAuthStateHandler;
final Function(BuildContext, SocialAuthState) socialAuthStateHandler;

/// Redirect URL for social auth.
final String redirectURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LoginPageModel {
final bool isCreateAccountEnabled;

/// Social auth state handler.
final Function(SocialAuthState) socialAuthStateHandler;
final Function(BuildContext, SocialAuthState) socialAuthStateHandler;

/// Redirect URL for social auth.
final String redirectURL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:deriv_auth/deriv_auth.dart';
import 'package:flutter/foundation.dart' show VoidCallback;
import 'package:flutter/material.dart';

/// Sign-up page model
class SignupPageModel {
Expand Down Expand Up @@ -40,7 +41,7 @@ class SignupPageModel {
final bool isSocialAuthEnabled;

/// Social auth state handler.
final Function(SocialAuthState) socialAuthStateHandler;
final Function(BuildContext, SocialAuthState) socialAuthStateHandler;

/// Redirect URL for social auth.
final String redirectURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DerivSocialAuthPanel extends StatefulWidget {
final bool isVisible;

/// Social auth state handler.
final Function(SocialAuthState) socialAuthStateHandler;
final Function(BuildContext, SocialAuthState) socialAuthStateHandler;

/// onPressed callback for social auth buttons.
/// Gives access to the social auth token and dto.
Expand Down Expand Up @@ -63,7 +63,7 @@ class _DerivSocialAuthPanelState extends State<DerivSocialAuthPanel> {
visible: widget.isVisible,
child: BlocListener<SocialAuthCubit, SocialAuthState>(
listener: (BuildContext context, SocialAuthState state) {
widget.socialAuthStateHandler(state);
widget.socialAuthStateHandler(context, state);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -97,7 +98,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -136,7 +138,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -169,7 +172,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -215,7 +219,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -253,7 +258,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -290,7 +296,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -323,7 +330,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -371,7 +379,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
welcomeLabel: welcomeLabel,
Expand Down Expand Up @@ -415,7 +424,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivLoginLayout(
socialAuthStateHandler: (SocialAuthState state) {
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {
onSocialAuthHandlerCalled = true;
},
redirectURL: 'deriv://example',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -109,7 +110,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -149,7 +151,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -180,7 +183,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -217,7 +221,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -259,7 +264,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -297,7 +303,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -334,7 +341,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {},
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {},
redirectURL: 'deriv://example',
onWebViewError: (String error) {},
signupPageLabel: signupPageLabel,
Expand Down Expand Up @@ -370,7 +378,8 @@ void main() {
BlocProvider<SocialAuthCubit>.value(value: socialAuthCubit),
],
child: DerivSignupLayout(
socialAuthStateHandler: (SocialAuthState state) {
socialAuthStateHandler:
(BuildContext context, SocialAuthState state) {
isSocialAuthHandlerCalled = true;
},
redirectURL: 'deriv://example',
Expand Down

0 comments on commit 0547991

Please sign in to comment.