Skip to content

Commit

Permalink
feat: Replace download button with share option #2026
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Oct 20, 2023
1 parent 599221f commit 770adf4
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions lib/splash/bloclisteners/blocklisteners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<SplashCubit, SplashState>(
listener: (BuildContext context, SplashState state) {
Expand Down Expand Up @@ -321,42 +322,18 @@ final qrCodeBlocListener = BlocListener<QRCodeScanCubit, QRCodeScanState>(
);
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);
Expand Down

0 comments on commit 770adf4

Please sign in to comment.