From 65bf7c25fb19c865b678f47ac6b7aa06354469ad Mon Sep 17 00:00:00 2001 From: Weng Lok Date: Mon, 8 Jul 2024 14:45:27 +0800 Subject: [PATCH] modified implementation --- .../pages/effortless_passkeys_login_page.dart | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/deriv_passkeys/lib/src/presentation/pages/effortless_passkeys_login_page.dart b/packages/deriv_passkeys/lib/src/presentation/pages/effortless_passkeys_login_page.dart index e8f5c1aff..3c085e1eb 100644 --- a/packages/deriv_passkeys/lib/src/presentation/pages/effortless_passkeys_login_page.dart +++ b/packages/deriv_passkeys/lib/src/presentation/pages/effortless_passkeys_login_page.dart @@ -21,9 +21,7 @@ class EffortlessPasskeysPage extends StatelessWidget required this.onPageClosed, required this.addMorePasskeysNavigationCallback, required this.continueTradingNavigationCallback, - this.createPassKeyButtonKey, - this.hyperLinkInkWellKey, - this.maybeLaterTextButtonKey, + this.effortlessPasskeysPageKeys, super.key, }) { trackOpenEffortlessLoginPage(); @@ -41,14 +39,8 @@ class EffortlessPasskeysPage extends StatelessWidget /// Callback to be called when the flow is complete. final void Function(BuildContext context) onPageClosed; - /// Key for create passkey button widget. - final Key? createPassKeyButtonKey; - - /// Key for hyper link ink well widget. - final Key? hyperLinkInkWellKey; - - /// Key for maybe later text button widget.. - final Key? maybeLaterTextButtonKey; + /// Pass an object of keys to assign to specific widget in this page. + final EffortlessPasskeysPageKeys? effortlessPasskeysPageKeys; @override Widget build(BuildContext context) => WillPopScope( @@ -103,7 +95,8 @@ class EffortlessPasskeysPage extends StatelessWidget child: Padding( padding: const EdgeInsets.all(16), child: TextButton( - key: maybeLaterTextButtonKey, + key: effortlessPasskeysPageKeys + ?.maybeLaterTextButtonKey, onPressed: () { trackMaybeLater(); onPageClosed(context); @@ -183,7 +176,8 @@ class EffortlessPasskeysPage extends StatelessWidget PlaceholderAlignment .middle, child: InkWell( - key: hyperLinkInkWellKey, + key: effortlessPasskeysPageKeys + ?.hyperLinkInkWellKey, onTap: () { Navigator.push( context, @@ -232,7 +226,8 @@ class EffortlessPasskeysPage extends StatelessWidget child: Padding( padding: const EdgeInsets.all(16), child: PrimaryButton( - key: createPassKeyButtonKey, + key: effortlessPasskeysPageKeys + ?.createPassKeyButtonKey, onPressed: () { trackCreatePasskey(); context.read().add( @@ -258,3 +253,22 @@ class EffortlessPasskeysPage extends StatelessWidget ), ); } + +/// A class that allows users to pass keys to [EffortlessPasskeysPage]. +class EffortlessPasskeysPageKeys { + /// Constructs [EffortlessPasskeysPageKeys]. + EffortlessPasskeysPageKeys({ + this.createPassKeyButtonKey, + this.hyperLinkInkWellKey, + this.maybeLaterTextButtonKey, + }); + + /// Key for create passkey button widget. + final Key? createPassKeyButtonKey; + + /// Key for hyper link ink well widget. + final Key? hyperLinkInkWellKey; + + /// Key for maybe later text button widget. + final Key? maybeLaterTextButtonKey; +}