From 770adf4a849d48b20128015339391368357ada01 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 20 Oct 2023 14:23:33 +0545 Subject: [PATCH] feat: Replace download button with share option #2026 --- lib/splash/bloclisteners/blocklisteners.dart | 45 +++++--------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/lib/splash/bloclisteners/blocklisteners.dart b/lib/splash/bloclisteners/blocklisteners.dart index f003295bb..4f8e42374 100644 --- a/lib/splash/bloclisteners/blocklisteners.dart +++ b/lib/splash/bloclisteners/blocklisteners.dart @@ -22,6 +22,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:jwt_decode/jwt_decode.dart'; import 'package:polygonid/polygonid.dart'; +import 'package:share_plus/share_plus.dart'; final splashBlocListener = BlocListener( listener: (BuildContext context, SplashState state) { @@ -321,42 +322,18 @@ final qrCodeBlocListener = BlocListener( ); return; }, - onDownload: () async { + onDownload: () { Navigator.of(context).pop(false); - final isPermissionStatusGranted = - await getStoragePermission(); - if (!isPermissionStatusGranted) { - throw ResponseMessage( - message: ResponseString - .STORAGE_PERMISSION_DENIED_MESSAGE, - ); - } - - final dateTime = getDateTimeWithoutSpace(); - final fileName = 'oidc4vci-data-$dateTime'; - - final fileSaver = FileSaver.instance; - - final fileBytes = - Uint8List.fromList(utf8.encode(formattedData)); - - final filePath = await fileSaver.saveAs( - name: fileName, - bytes: fileBytes, - ext: 'txt', - mimeType: MimeType.text, + + final box = context.findRenderObject() as RenderBox?; + final subject = l10n.shareWith; + + Share.share( + formattedData, + subject: subject, + sharePositionOrigin: + box!.localToGlobal(Offset.zero) & box.size, ); - if (filePath != null && filePath.isEmpty) { - // - } else { - AlertMessage.showStateMessage( - context: context, - stateMessage: StateMessage.success( - showDialog: false, - stringMessage: l10n.successfullyDownloaded, - ), - ); - } }, onSkip: () { Navigator.of(context).pop(true);