monorepo/dialer/lib/features/contacts/widgets/share_own_qr.dart
Florian Griffon ee1f2ee4b1
All checks were successful
/ mirror (push) Successful in 4s
feat: can share any contact using qr code (#30)
Reviewed-on: #30
Co-authored-by: Florian Griffon <florian.griffon@epitech.eu>
Co-committed-by: Florian Griffon <florian.griffon@epitech.eu>
2025-01-30 14:15:07 +00:00

37 lines
1.0 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_contacts/contact.dart';
import 'package:dialer/services/contact_service.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
? () {
// Use the ContactService to show the QR code
ContactService().showContactQRCodeDialog(context, selfContact!);
}
: null,
);
}
}