All checks were successful
/ mirror (push) Successful in 5s
Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#6
56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_contacts/contact.dart';
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
|
class QRCodeButton extends StatelessWidget {
|
|
final List<Contact> contacts;
|
|
final Contact? selfContact;
|
|
|
|
const QRCodeButton({super.key, required this.contacts, this.selfContact});
|
|
|
|
Contact? getSelfContact() {
|
|
if (kDebugMode) {
|
|
debugPrint("Checking for self contact");
|
|
}
|
|
for (var contact in contacts) {
|
|
if (contact.groups.any((group) => group.name.toLowerCase() == "user")) {
|
|
return contact;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return IconButton(
|
|
icon: Icon(Icons.qr_code, color: selfContact != null ? Colors.blue : Colors.grey),
|
|
onPressed: selfContact != null
|
|
? () {
|
|
showDialog(
|
|
barrierColor: Colors.white24,
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
backgroundColor: Colors.black,
|
|
content: SizedBox(
|
|
width: 200,
|
|
height: 220,
|
|
child: QrImageView(
|
|
data: selfContact!.toVCard(),
|
|
version: QrVersions.auto,
|
|
backgroundColor: Colors.white, // Ensure QR code is visible on black background
|
|
size: 200.0,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
: null,
|
|
);
|
|
}
|
|
}
|