From 10c7853695370e1516810b120a18fd8336e26c9f Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 8 Nov 2024 14:47:24 +0545 Subject: [PATCH] feat: Add continue button while showing data #3054 --- .../json_viewer/view/json_viewer_page.dart | 31 +++++++------------ .../cubit/qr_code_scan_cubit.dart | 4 +-- .../get_and_add_deffered_credential.dart | 2 +- .../get_authorization_uri_for_issuer.dart | 2 +- lib/oidc4vc/get_credential.dart | 4 +-- lib/scan/cubit/scan_cubit.dart | 2 +- lib/splash/bloclisteners/blocklisteners.dart | 24 +++++++++++--- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/lib/dashboard/json_viewer/view/json_viewer_page.dart b/lib/dashboard/json_viewer/view/json_viewer_page.dart index 7c4a01d8d..b4ea4c498 100644 --- a/lib/dashboard/json_viewer/view/json_viewer_page.dart +++ b/lib/dashboard/json_viewer/view/json_viewer_page.dart @@ -8,23 +8,19 @@ class JsonViewerPage extends StatelessWidget { super.key, required this.title, required this.data, - required this.showContinueButton, }); final String title; final String data; - final bool showContinueButton; static Route route({ required String title, required String data, - bool showContinueButton = false, }) => MaterialPageRoute( builder: (_) => JsonViewerPage( title: title, data: data, - showContinueButton: showContinueButton, ), settings: const RouteSettings(name: '/JsonViewerPage'), ); @@ -34,7 +30,6 @@ class JsonViewerPage extends StatelessWidget { return JsonViewerView( title: title, data: data, - showContinueButton: showContinueButton, ); } } @@ -44,12 +39,10 @@ class JsonViewerView extends StatelessWidget { super.key, required this.title, required this.data, - required this.showContinueButton, }); final String title; final String data; - final bool showContinueButton; @override Widget build(BuildContext context) { @@ -64,19 +57,17 @@ class JsonViewerView extends StatelessWidget { ), padding: const EdgeInsets.symmetric(horizontal: 10), body: JsonViewWidget(data: data), - navigation: !showContinueButton - ? null - : Padding( - padding: const EdgeInsets.all( - Sizes.spaceSmall, - ), - child: MyElevatedButton( - text: context.l10n.continueString, - onPressed: () { - Navigator.of(context).pop(true); - }, - ), - ), + navigation: Padding( + padding: const EdgeInsets.all( + Sizes.spaceSmall, + ), + child: MyElevatedButton( + text: context.l10n.continueString, + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + ), ); } } diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index 4b47a450a..dcf57ca4c 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -1238,7 +1238,7 @@ class QRCodeScanCubit extends Cubit { if (profileCubit.state.model.isDeveloperMode) { final value = await showDataBeforeSending( - title: 'Response Data', + title: 'RESPONSE REQUEST', data: responseData, ); if (value) { @@ -1437,7 +1437,7 @@ class QRCodeScanCubit extends Cubit { if (profileCubit.state.model.isDeveloperMode) { final value = await showDataBeforeSending( - title: 'TOKEN DATA', + title: 'TOKEN REQUEST', data: tokenData, ); if (value) { diff --git a/lib/oidc4vc/get_and_add_deffered_credential.dart b/lib/oidc4vc/get_and_add_deffered_credential.dart index 35bd0314b..8607f75cc 100644 --- a/lib/oidc4vc/get_and_add_deffered_credential.dart +++ b/lib/oidc4vc/get_and_add_deffered_credential.dart @@ -52,7 +52,7 @@ Future getAndAddDefferedCredential({ if (profileCubit.state.model.isDeveloperMode) { final value = await qrCodeScanCubit.showDataBeforeSending( - title: 'DEFERRED CREDENTIAL DATA', + title: 'DEFERRED CREDENTIAL REQUEST', data: body, ); diff --git a/lib/oidc4vc/get_authorization_uri_for_issuer.dart b/lib/oidc4vc/get_authorization_uri_for_issuer.dart index 2f829e9bb..0eb854cc0 100644 --- a/lib/oidc4vc/get_authorization_uri_for_issuer.dart +++ b/lib/oidc4vc/get_authorization_uri_for_issuer.dart @@ -134,7 +134,7 @@ Future getAuthorizationUriForIssuer({ if (profileCubit.state.model.isDeveloperMode) { final value = await qrCodeScanCubit.showDataBeforeSending( - title: 'Pushed Authorization Request Data', + title: 'PUSHED AUTHORIZATION REQUEST', data: authorizationRequestParemeters, ); diff --git a/lib/oidc4vc/get_credential.dart b/lib/oidc4vc/get_credential.dart index ae26bc588..c9c1080ba 100644 --- a/lib/oidc4vc/get_credential.dart +++ b/lib/oidc4vc/get_credential.dart @@ -111,7 +111,7 @@ Future< if (profileCubit.state.model.isDeveloperMode) { final value = await qrCodeScanCubit.showDataBeforeSending( - title: 'CREDENTIAL DATA', + title: 'CREDENTIAL REQUEST', data: credentialData, ); @@ -167,7 +167,7 @@ Future< if (profileCubit.state.model.isDeveloperMode) { await qrCodeScanCubit.showDataBeforeSending( - title: 'CREDENTIAL DATA', + title: 'CREDENTIAL REQUEST', data: credentialData, ); diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index 385203526..06c4d0c81 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -620,7 +620,7 @@ class ScanCubit extends Cubit { if (profileCubit.state.model.isDeveloperMode) { final value = await qrCodeScanCubit.showDataBeforeSending( - title: 'Response Data', + title: 'RESPONSE REQUEST', data: body, ); if (value) { diff --git a/lib/splash/bloclisteners/blocklisteners.dart b/lib/splash/bloclisteners/blocklisteners.dart index 28f9219cc..836522d60 100644 --- a/lib/splash/bloclisteners/blocklisteners.dart +++ b/lib/splash/bloclisteners/blocklisteners.dart @@ -348,13 +348,20 @@ final qrCodeBlocListener = BlocListener( context: context, builder: (_) { return DeveloperModeDialog( - onDisplay: () { - Navigator.of(context).push( + onDisplay: () async { + final returnedValue = + await Navigator.of(context).push( JsonViewerPage.route( title: l10n.display, data: formattedData, ), ); + + if (returnedValue != null && + returnedValue is bool && + returnedValue) { + Navigator.of(context).pop(true); + } return; }, onDownload: () { @@ -555,13 +562,21 @@ final qrCodeBlocListener = BlocListener( context: context, builder: (_) { return DeveloperModeDialog( - onDisplay: () { - Navigator.of(context).push( + onDisplay: () async { + final returnedValue = + await Navigator.of(context).push( JsonViewerPage.route( title: l10n.display, data: data, ), ); + + if (returnedValue != null && + returnedValue is bool && + returnedValue) { + Navigator.of(context).pop(true); + } + return; }, onDownload: () { @@ -597,7 +612,6 @@ final qrCodeBlocListener = BlocListener( JsonViewerPage.route( title: l10n.display, data: data, - showContinueButton: true, ), );