feat: support smol:// QR sharing, deep links and in-dialog scanning
This commit is contained in:
parent
7d2a147fec
commit
aa74e12ee7
20 changed files with 591 additions and 101 deletions
52
lib/presentation/widgets/qr_code_sheet.dart
Normal file
52
lib/presentation/widgets/qr_code_sheet.dart
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue