Skip to content

Commit

Permalink
replace dialog with flushbar message
Browse files Browse the repository at this point in the history
  • Loading branch information
sneurlax committed Aug 5, 2024
1 parent 16a2b23 commit ce74f95
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions lib/widgets/desktop/qr_code_scanner_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:zxing2/qrcode.dart';

import '../../notifications/show_flush_bar.dart';
import '../../utilities/assets.dart';
import '../../utilities/logger.dart';
import '../../utilities/text_styles.dart';
import '../stack_dialog.dart';
import 'desktop_dialog.dart';
import 'desktop_dialog_close_button.dart';

Expand Down Expand Up @@ -322,37 +323,34 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
);

if (result == null || result.files.single.path == null) {
await showDialog<void>(
await showFloatingFlushBar(
type: FlushBarType.info,
message: "No file selected",
iconAsset: Assets.svg.file,
context: context,
builder: (_) => const StackOkDialog(
title: "Error scanning QR code",
message: "No file selected.",
),
);
return;
}

final filePath = result?.files.single.path!;
if (filePath == null) {
await showDialog<void>(
await showFloatingFlushBar(
type: FlushBarType.info,
message: "Error selecting file.",
iconAsset: Assets.svg.file,
context: context,
builder: (_) => const StackOkDialog(
title: "Error scanning QR code",
message: "Error selecting file.",
),
);
return;
}
try {
final img.Image? image =
img.decodeImage(File(filePath!).readAsBytesSync());
if (image == null) {
await showDialog<void>(
await showFloatingFlushBar(
type: FlushBarType.info,
message: "Failed to decode image.",
iconAsset: Assets.svg.file,
context: context,
builder: (_) => const StackOkDialog(
title: "Error scanning QR code",
message: "Failed to decode image.",
),
);
return;
}
Expand All @@ -362,24 +360,22 @@ class _QrCodeScannerDialogState extends State<QrCodeScannerDialog> {
widget.onQrCodeDetected(scanResult);
Navigator.of(context).pop();
} else {
await showDialog<void>(
await showFloatingFlushBar(
type: FlushBarType.info,
message: "No QR code found in the image.",
iconAsset: Assets.svg.file,
context: context,
builder: (_) => const StackOkDialog(
title: "Error scanning QR code",
message: "No QR code found in the image.",
),
);
}
} catch (e, s) {
Logging.instance.log("Failed to decode image: $e\n$s",
level: LogLevel.Error);
await showDialog<void>(
await showFloatingFlushBar(
type: FlushBarType.info,
message:
"Error processing the image. Please try again.",
iconAsset: Assets.svg.file,
context: context,
builder: (_) => const StackOkDialog(
title: "Error scanning QR code",
message:
"Error processing the image. Please try again.",
),
);
}
},
Expand Down

0 comments on commit ce74f95

Please sign in to comment.