52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
import "package:flutter/material.dart";
|
|
import "package:qr_flutter/qr_flutter.dart";
|
|
|
|
import "package:smol_mail/shared/utils/format.dart";
|
|
|
|
/// Shows [payload] as a scannable QR code in a bottom sheet. Fixed dark
|
|
/// modules on white regardless of theme: contrast is what a scanner needs,
|
|
/// not the palette. Scrolled, because the sheet is height-capped on small
|
|
/// screens.
|
|
Future<void> showQrCodeSheet(BuildContext context, String payload) {
|
|
return showModalBottomSheet<void>(
|
|
context: context,
|
|
builder: (ctx) => SingleChildScrollView(
|
|
padding: const EdgeInsets.fromLTRB(20, 24, 20, 24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
color: Colors.white,
|
|
child: QrImageView(
|
|
data: payload,
|
|
version: QrVersions.auto,
|
|
size: 260,
|
|
backgroundColor: Colors.white,
|
|
eyeStyle: const QrEyeStyle(
|
|
eyeShape: QrEyeShape.square,
|
|
color: Color.fromRGBO(1, 17, 29, 1),
|
|
),
|
|
dataModuleStyle: const QrDataModuleStyle(
|
|
dataModuleShape: QrDataModuleShape.square,
|
|
color: Color.fromRGBO(1, 17, 29, 1),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 15),
|
|
SelectableText(
|
|
payload,
|
|
style: Theme.of(ctx).textTheme.bodySmall,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 10),
|
|
TextButton.icon(
|
|
onPressed: () => copyText(ctx, payload),
|
|
icon: const Icon(Icons.copy, size: 18),
|
|
label: const Text("Copy"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|