All checks were successful
/ mirror (push) Successful in 4s
Reviewed-on: #30 Co-authored-by: Florian Griffon <florian.griffon@epitech.eu> Co-committed-by: Florian Griffon <florian.griffon@epitech.eu>
37 lines
1.0 KiB
Dart
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,
|
|
);
|
|
}
|
|
}
|