All checks were successful
/ mirror (push) Successful in 5s
Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#6
57 lines
1.7 KiB
Dart
57 lines
1.7 KiB
Dart
import 'package:android_intent_plus/android_intent.dart';
|
|
import 'package:dialer/widgets/qr_scanner.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class AddContactButton extends StatelessWidget {
|
|
const AddContactButton({super.key});
|
|
|
|
Future<void> createNewContact() async {
|
|
AndroidIntent intent = AndroidIntent(
|
|
action: 'android.intent.action.INSERT',
|
|
type: 'vnd.android.cursor.dir/contact',
|
|
);
|
|
await intent.launch();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
icon: Icon(Icons.add, color: Colors.blue),
|
|
onPressed: () {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: true, // Allows dismissal by tapping outside
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
backgroundColor: Colors.black,
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => QRCodeScannerScreen()),
|
|
);
|
|
},
|
|
child: Text("Scan QR code", style: TextStyle(color: Colors.white)),
|
|
),
|
|
|
|
TextButton(
|
|
onPressed: () async {
|
|
createNewContact();
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text("Create new contact", style: TextStyle(color: Colors.white)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|