You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
import 'package:flutter/material.dart';
|
|
|
|
import '../helpers/snack_bar_builder.dart';
|
|
import '../l10n/l10n.dart';
|
|
import '../models/contact.dart';
|
|
import '../utils/platform_info.dart';
|
|
import '../widgets/qr_scanner_widget.dart';
|
|
|
|
/// Whether a contact QR can be scanned on this platform.
|
|
///
|
|
/// `mobile_scanner` covers Android, iOS, macOS and web, but not Windows or
|
|
/// Linux. On those the QR half of the exchange is the RENDER side: show your
|
|
/// own code from the desktop and let the other person scan it with a phone.
|
|
///
|
|
/// Lives here rather than on a caller because both the key-entry field and the
|
|
/// contacts menu need it. (#629)
|
|
bool get contactQrScanAvailable =>
|
|
PlatformInfo.isMobile || PlatformInfo.isMacOS || PlatformInfo.isWeb;
|
|
|
|
/// Scans a contact QR and pops the raw `meshcore://contact/add` string. (#629)
|
|
///
|
|
/// A contact QR is only that URI rendered visually, so this validates with the
|
|
/// same [Contact.isValidShareUri] the paste path uses. There is no second
|
|
/// format and no second parser.
|
|
class ContactQrScannerScreen extends StatelessWidget {
|
|
const ContactQrScannerScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(context.l10n.contacts_scanContactQr),
|
|
centerTitle: true,
|
|
),
|
|
body: QrScannerWidget(
|
|
instructions: context.l10n.contacts_scanContactQrInstructions,
|
|
validator: Contact.isValidShareUri,
|
|
onScanned: (data) => Navigator.of(context).pop(data),
|
|
onValidationFailed: (_) => showDismissibleSnackBar(
|
|
context,
|
|
content: Text(context.l10n.contacts_invalidContactQr),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|