fix: composition doesn't ask permissions twice
This commit is contained in:
parent
3e7845d3d8
commit
05e7f50269
@ -22,11 +22,9 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchContacts() async {
|
Future<void> _fetchContacts() async {
|
||||||
if (await FlutterContacts.requestPermission()) {
|
_allContacts = await _contactService.fetchContacts();
|
||||||
_allContacts = await _contactService.fetchContacts();
|
_filteredContacts = _allContacts;
|
||||||
_filteredContacts = _allContacts;
|
setState(() {});
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterContacts() {
|
void _filterContacts() {
|
||||||
@ -81,9 +79,9 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
// Top half: Display contacts matching dialed number
|
// Top half: Display contacts matching dialed number
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child:
|
child: Container(
|
||||||
Container(
|
padding: const EdgeInsets.only(
|
||||||
padding: const EdgeInsets.only(top: 42.0, left: 16.0, right: 16.0, bottom: 16.0),
|
top: 42.0, left: 16.0, right: 16.0, bottom: 16.0),
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -95,12 +93,14 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
contact.displayName,
|
contact.displayName,
|
||||||
style: const TextStyle(color: Colors.white),
|
style:
|
||||||
|
const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
subtitle: contact.phones.isNotEmpty
|
subtitle: contact.phones.isNotEmpty
|
||||||
? Text(
|
? Text(
|
||||||
contact.phones.first.number,
|
contact.phones.first.number,
|
||||||
style: const TextStyle(color: Colors.grey),
|
style: const TextStyle(
|
||||||
|
color: Colors.grey),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
@ -108,16 +108,22 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
children: [
|
children: [
|
||||||
// Call button
|
// Call button
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.phone, color: Colors.green[300], size: 20),
|
icon: Icon(Icons.phone,
|
||||||
|
color: Colors.green[300],
|
||||||
|
size: 20),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print('Calling ${contact.displayName}');
|
print(
|
||||||
|
'Calling ${contact.displayName}');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// Text button
|
// Text button
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.message, color: Colors.blue[300], size: 20),
|
icon: Icon(Icons.message,
|
||||||
|
color: Colors.blue[300],
|
||||||
|
size: 20),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print('Texting ${contact.displayName}');
|
print(
|
||||||
|
'Texting ${contact.displayName}');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -127,7 +133,12 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}).toList()
|
}).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,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
dialedNumber,
|
dialedNumber,
|
||||||
style: const TextStyle(fontSize: 24, color: Colors.white),
|
style: const TextStyle(
|
||||||
|
fontSize: 24, color: Colors.white),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _onClearPress,
|
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,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('1'),
|
_buildDialButton('1'),
|
||||||
_buildDialButton('2'),
|
_buildDialButton('2'),
|
||||||
@ -180,7 +194,8 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('4'),
|
_buildDialButton('4'),
|
||||||
_buildDialButton('5'),
|
_buildDialButton('5'),
|
||||||
@ -188,7 +203,8 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('7'),
|
_buildDialButton('7'),
|
||||||
_buildDialButton('8'),
|
_buildDialButton('8'),
|
||||||
@ -196,7 +212,8 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('*'),
|
_buildDialButton('*'),
|
||||||
_buildDialButton('0'),
|
_buildDialButton('0'),
|
||||||
|
Loading…
Reference in New Issue
Block a user