Compare commits

...

2 Commits

Author SHA1 Message Date
27e2b7adbd feat: contact-modal has 3 dots menu
All checks were successful
/ mirror (push) Successful in 4s
2024-12-15 02:32:38 +01:00
05e7f50269 fix: composition doesn't ask permissions twice 2024-12-15 02:32:18 +01:00
2 changed files with 95 additions and 30 deletions

View File

@ -22,11 +22,9 @@ class _CompositionPageState extends State<CompositionPage> {
}
Future<void> _fetchContacts() async {
if (await FlutterContacts.requestPermission()) {
_allContacts = await _contactService.fetchContacts();
_filteredContacts = _allContacts;
setState(() {});
}
_allContacts = await _contactService.fetchContacts();
_filteredContacts = _allContacts;
setState(() {});
}
void _filterContacts() {
@ -81,9 +79,9 @@ class _CompositionPageState extends State<CompositionPage> {
// Top half: Display contacts matching dialed number
Expanded(
flex: 2,
child:
Container(
padding: const EdgeInsets.only(top: 42.0, left: 16.0, right: 16.0, bottom: 16.0),
child: Container(
padding: const EdgeInsets.only(
top: 42.0, left: 16.0, right: 16.0, bottom: 16.0),
color: Colors.black,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -95,12 +93,14 @@ class _CompositionPageState extends State<CompositionPage> {
return ListTile(
title: Text(
contact.displayName,
style: const TextStyle(color: Colors.white),
style:
const TextStyle(color: Colors.white),
),
subtitle: contact.phones.isNotEmpty
? Text(
contact.phones.first.number,
style: const TextStyle(color: Colors.grey),
style: const TextStyle(
color: Colors.grey),
)
: null,
trailing: Row(
@ -108,16 +108,22 @@ class _CompositionPageState extends State<CompositionPage> {
children: [
// Call button
IconButton(
icon: Icon(Icons.phone, color: Colors.green[300], size: 20),
icon: Icon(Icons.phone,
color: Colors.green[300],
size: 20),
onPressed: () {
print('Calling ${contact.displayName}');
print(
'Calling ${contact.displayName}');
},
),
// Text button
IconButton(
icon: Icon(Icons.message, color: Colors.blue[300], size: 20),
icon: Icon(Icons.message,
color: Colors.blue[300],
size: 20),
onPressed: () {
print('Texting ${contact.displayName}');
print(
'Texting ${contact.displayName}');
},
),
],
@ -127,7 +133,12 @@ class _CompositionPageState extends State<CompositionPage> {
},
);
}).toList()
: [Center(child: Text('No contacts found', style: TextStyle(color: Colors.white)))],
: [
Center(
child: Text('No contacts found',
style:
TextStyle(color: Colors.white)))
],
),
),
],
@ -152,14 +163,16 @@ class _CompositionPageState extends State<CompositionPage> {
alignment: Alignment.center,
child: Text(
dialedNumber,
style: const TextStyle(fontSize: 24, color: Colors.white),
style: const TextStyle(
fontSize: 24, color: Colors.white),
overflow: TextOverflow.ellipsis,
),
),
),
IconButton(
onPressed: _onClearPress,
icon: const Icon(Icons.backspace, color: Colors.white),
icon: const Icon(Icons.backspace,
color: Colors.white),
),
],
),
@ -172,7 +185,8 @@ class _CompositionPageState extends State<CompositionPage> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
_buildDialButton('1'),
_buildDialButton('2'),
@ -180,7 +194,8 @@ class _CompositionPageState extends State<CompositionPage> {
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
_buildDialButton('4'),
_buildDialButton('5'),
@ -188,7 +203,8 @@ class _CompositionPageState extends State<CompositionPage> {
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
_buildDialButton('7'),
_buildDialButton('8'),
@ -196,7 +212,8 @@ class _CompositionPageState extends State<CompositionPage> {
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
_buildDialButton('*'),
_buildDialButton('0'),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:dialer/widgets/username_color_generator.dart';
import 'package:flutter/material.dart';
class ContactModal extends StatelessWidget {
final Contact contact;
@ -69,17 +70,64 @@ class ContactModal extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
// Modal Handle
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Container(
width: 50,
height: 5,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(5),
// Top Bar with Handle and Three-Dot Menu
Stack(
children: [
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Container(
width: 50,
height: 5,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(5),
),
),
),
),
),
Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.only(top: 10, right: 10),
child: PopupMenuButton<String>(
icon: Icon(Icons.more_vert, color: Colors.white),
onSelected: (String choice) {
print(
'Selected: $choice'); // Placeholder for menu actions
},
itemBuilder: (BuildContext context) {
return <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'show_associated_contacts',
child: Text('Show associated contacts'),
),
PopupMenuItem<String>(
value: 'delete',
child: Text('Delete'),
),
PopupMenuItem<String>(
value: 'share',
child: Text('Share (via QR code)'),
),
PopupMenuItem<String>(
value: 'create_shortcut',
child:
Text('Create shortcut (to home screen)'),
),
PopupMenuItem<String>(
value: 'set_ringtone',
child: Text('Set ringtone'),
),
];
},
),
),
),
],
),
// Contact Profile
Padding(
padding: const EdgeInsets.all(16.0),