Compare commits
No commits in common. "50235b13c5d9e1d81ca17ee791c5b031f26d3e56" and "74d9eda46483ad093fadb4b7133bec67f9a8e80c" have entirely different histories.
50235b13c5
...
74d9eda464
@ -45,8 +45,5 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSContactsUsageDescription</key>
|
|
||||||
<string>Contacts for calls/string>
|
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
||||||
|
|
||||||
class CompositionPage extends StatefulWidget {
|
class CompositionPage extends StatefulWidget {
|
||||||
const CompositionPage({super.key});
|
const CompositionPage({super.key});
|
||||||
@ -10,228 +9,80 @@ class CompositionPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _CompositionPageState extends State<CompositionPage> {
|
class _CompositionPageState extends State<CompositionPage> {
|
||||||
String dialedNumber = "";
|
String dialedNumber = "";
|
||||||
List<Contact> _allContacts = [];
|
|
||||||
List<Contact> _filteredContacts = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_fetchContacts();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _fetchContacts() async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
_allContacts = await FlutterContacts.getContacts(withProperties: true);
|
|
||||||
_filteredContacts = _allContacts;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _filterContacts() {
|
|
||||||
setState(() {
|
|
||||||
_filteredContacts = _allContacts.where((contact) {
|
|
||||||
final phoneMatch = contact.phones.any((phone) =>
|
|
||||||
phone.number.replaceAll(RegExp(r'\D'), '').contains(dialedNumber));
|
|
||||||
final nameMatch = contact.displayName
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(dialedNumber.toLowerCase());
|
|
||||||
return phoneMatch || nameMatch;
|
|
||||||
}).toList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onNumberPress(String number) {
|
void _onNumberPress(String number) {
|
||||||
setState(() {
|
setState(() {
|
||||||
dialedNumber += number;
|
dialedNumber += number;
|
||||||
_filterContacts();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _onDeletePress() {
|
void _onDeletePress() {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (dialedNumber.isNotEmpty) {
|
if (dialedNumber.isNotEmpty) {
|
||||||
dialedNumber = dialedNumber.substring(0, dialedNumber.length - 1);
|
dialedNumber = dialedNumber.substring(0, dialedNumber.length - 1);
|
||||||
_filterContacts();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onClearPress() {
|
|
||||||
setState(() {
|
|
||||||
dialedNumber = "";
|
|
||||||
_filteredContacts = _allContacts;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Placeholder function for adding contact
|
|
||||||
void addContact(String number) {
|
|
||||||
// This function is empty for now
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Stack(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Expanded(
|
||||||
children: [
|
flex: 1,
|
||||||
// Top half: Display contacts matching dialed number
|
child: Center(
|
||||||
Expanded(
|
child: Text(
|
||||||
flex: 2,
|
dialedNumber,
|
||||||
child:
|
style: const TextStyle(
|
||||||
Container(
|
fontSize: 32,
|
||||||
padding: const EdgeInsets.only(top: 42.0, left: 16.0, right: 16.0, bottom: 16.0),
|
color: Colors.white,
|
||||||
color: Colors.black,
|
letterSpacing: 2.0,
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ListView(
|
|
||||||
children: _filteredContacts.isNotEmpty
|
|
||||||
? _filteredContacts.map((contact) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
contact.displayName,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: contact.phones.isNotEmpty
|
|
||||||
? Text(
|
|
||||||
contact.phones.first.number,
|
|
||||||
style: const TextStyle(color: Colors.grey),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
trailing: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
// Call button
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.phone, color: Colors.green[300], size: 20),
|
|
||||||
onPressed: () {
|
|
||||||
print('Calling ${contact.displayName}');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// Text button
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.message, color: Colors.blue[300], size: 20),
|
|
||||||
onPressed: () {
|
|
||||||
print('Texting ${contact.displayName}');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle contact selection if needed
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList()
|
|
||||||
: [Center(child: Text('No contacts found', style: TextStyle(color: Colors.white)))],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
// Bottom half: Dialpad and Dialed number display with erase button
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
// Display dialed number with erase button
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
|
||||||
dialedNumber,
|
|
||||||
style: const TextStyle(fontSize: 24, color: Colors.white),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: _onClearPress,
|
|
||||||
icon: const Icon(Icons.backspace, color: Colors.white),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
|
|
||||||
// Dialpad
|
|
||||||
Expanded(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildDialButton('1'),
|
|
||||||
_buildDialButton('2'),
|
|
||||||
_buildDialButton('3'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildDialButton('4'),
|
|
||||||
_buildDialButton('5'),
|
|
||||||
_buildDialButton('6'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildDialButton('7'),
|
|
||||||
_buildDialButton('8'),
|
|
||||||
_buildDialButton('9'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildDialButton('*'),
|
|
||||||
_buildDialButton('0'),
|
|
||||||
_buildDialButton('#'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Add Contact Button with empty function call
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 20.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
onPressed: () {
|
|
||||||
addContact(dialedNumber);
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.person_add, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
// Top Row with Back Arrow
|
Expanded(
|
||||||
Positioned(
|
flex: 3,
|
||||||
top: 40.0,
|
child: Padding(
|
||||||
left: 16.0,
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: IconButton(
|
child: GridView.builder(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 3,
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
childAspectRatio: 1,
|
||||||
|
),
|
||||||
|
itemCount: 12,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index < 9) {
|
||||||
|
|
||||||
|
return _buildDialButton((index + 1).toString());
|
||||||
|
} else if (index == 9) {
|
||||||
|
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
} else if (index == 10) {
|
||||||
|
|
||||||
|
return _buildDialButton('0');
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return _buildDeleteButton();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20.0),
|
||||||
|
child: FloatingActionButton(
|
||||||
|
backgroundColor: Colors.green,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
},
|
||||||
|
child: const Icon(Icons.phone, color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -239,13 +90,14 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildDialButton(String number) {
|
Widget _buildDialButton(String number) {
|
||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
onPressed: () => _onNumberPress(number),
|
onPressed: () => _onNumberPress(number),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(20),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
number,
|
number,
|
||||||
@ -256,4 +108,21 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Widget _buildDeleteButton() {
|
||||||
|
return ElevatedButton(
|
||||||
|
onPressed: _onDeletePress,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.backspace,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ class _ContactPageState extends State<ContactPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final contactState = ContactState.of(context);
|
final contactState = ContactState.of(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Contacts'),
|
||||||
|
),
|
||||||
body: contactState.loading
|
body: contactState.loading
|
||||||
? const LoadingIndicatorWidget()
|
? const LoadingIndicatorWidget()
|
||||||
// : ContactListWidget(contacts: contactState.contacts),
|
// : ContactListWidget(contacts: contactState.contacts),
|
||||||
|
@ -12,12 +12,10 @@ class _FavoritePageState extends State<FavoritePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Center( // Center the text within the body
|
appBar: AppBar(
|
||||||
child: Text(
|
title: const Text('Favorites'),
|
||||||
"Hello",
|
|
||||||
style: TextStyle(color: Colors.white), // Change text color for visibility
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
body: Text("Hello")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,111 +1,20 @@
|
|||||||
// history_page.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
||||||
import 'package:intl/intl.dart'; // For date formatting
|
|
||||||
import 'package:dialer/features/contacts/contact_state.dart';
|
|
||||||
|
|
||||||
class History {
|
|
||||||
final Contact contact;
|
|
||||||
final DateTime date;
|
|
||||||
final String callType; // 'incoming' or 'outgoing'
|
|
||||||
final String callStatus; // 'missed' or 'answered'
|
|
||||||
final int attempts;
|
|
||||||
|
|
||||||
History(
|
List<History> histories = [
|
||||||
this.contact,
|
History("Hello"),
|
||||||
this.date,
|
];
|
||||||
this.callType,
|
|
||||||
this.callStatus,
|
|
||||||
this.attempts,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class HistoryPage extends StatefulWidget {
|
class HistoryPage extends StatefulWidget {
|
||||||
const HistoryPage({Key? key}) : super(key: key);
|
const HistoryPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HistoryPageState createState() => _HistoryPageState();
|
_HistoryPageState createState() => _HistoryPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HistoryPageState extends State<HistoryPage> {
|
class _HistoryPageState extends State<HistoryPage> {
|
||||||
List<History> histories = [];
|
|
||||||
bool loading = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
if (loading) {
|
|
||||||
_buildHistories();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _buildHistories() async {
|
|
||||||
final contactState = ContactState.of(context);
|
|
||||||
if (contactState.loading) {
|
|
||||||
// Wait for contacts to be loaded
|
|
||||||
await Future.doWhile(() async {
|
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
|
||||||
return contactState.loading;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
List<Contact> contacts = contactState.contacts;
|
|
||||||
|
|
||||||
// Ensure there are enough contacts
|
|
||||||
if (contacts.isEmpty) {
|
|
||||||
setState(() {
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build histories using the contacts
|
|
||||||
setState(() {
|
|
||||||
histories = List.generate(
|
|
||||||
contacts.length >= 10 ? 10 : contacts.length,
|
|
||||||
(index) => History(
|
|
||||||
contacts[index],
|
|
||||||
DateTime.now().subtract(Duration(hours: (index + 1) * 2)),
|
|
||||||
index % 2 == 0 ? 'outgoing' : 'incoming',
|
|
||||||
index % 3 == 0 ? 'missed' : 'answered',
|
|
||||||
index % 3 + 1,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final contactState = ContactState.of(context);
|
|
||||||
|
|
||||||
if (loading || contactState.loading) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('History'),
|
|
||||||
),
|
|
||||||
body: const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (histories.isEmpty) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('History'),
|
|
||||||
),
|
|
||||||
body: const Center(
|
|
||||||
child: Text(
|
|
||||||
'No call history available.',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@ -114,39 +23,17 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
body: ListView.builder(
|
body: ListView.builder(
|
||||||
itemCount: histories.length,
|
itemCount: histories.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final history = histories[index];
|
return null;
|
||||||
final contact = history.contact;
|
|
||||||
|
|
||||||
return ListTile(
|
//
|
||||||
leading: (contact.thumbnail != null && contact.thumbnail!.isNotEmpty)
|
|
||||||
? CircleAvatar(
|
|
||||||
backgroundImage: MemoryImage(contact.thumbnail!),
|
|
||||||
)
|
|
||||||
: CircleAvatar(
|
|
||||||
child: Text(
|
|
||||||
contact.displayName.isNotEmpty
|
|
||||||
? contact.displayName[0]
|
|
||||||
: '?',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
contact.displayName,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
'${history.callType} - ${history.callStatus} - ${DateFormat('MMM dd, hh:mm a').format(history.date)}',
|
|
||||||
style: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
trailing: Text(
|
|
||||||
'${history.attempts}x',
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle tap event if needed
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class History {
|
||||||
|
final String text;
|
||||||
|
|
||||||
|
History(this.text);
|
||||||
|
}
|
||||||
|
@ -1,46 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/features/contacts/contact_page.dart';
|
|
||||||
import 'package:dialer/features/favorites/favorites_page.dart';
|
|
||||||
import 'package:dialer/features/history/history_page.dart';
|
|
||||||
import 'package:dialer/features/composition/composition.dart';
|
import 'package:dialer/features/composition/composition.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dialer/features/settings/settings.dart';
|
import 'package:dialer/features/contacts/contact_page.dart'; // Import ContactPage
|
||||||
|
import 'package:dialer/features/favorites/favorites_page.dart'; // Import FavoritePage
|
||||||
|
import 'package:dialer/features/history/history_page.dart'; // Import HistoryPage
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage>
|
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
late TabController _tabController;
|
late TabController _tabController;
|
||||||
List<Contact> _allContacts = [];
|
|
||||||
List<Contact> _contactSuggestions = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_tabController = TabController(length: 4, vsync: this, initialIndex: 1);
|
_tabController = TabController(length: 4, vsync: this, initialIndex: 1);
|
||||||
_tabController.addListener(_handleTabIndex);
|
_tabController.addListener(_handleTabIndex);
|
||||||
_fetchContacts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _fetchContacts() async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
_allContacts = await FlutterContacts.getContacts(withProperties: true);
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSearchChanged(String query) {
|
|
||||||
print("Search query: $query");
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
if (query.isEmpty) {
|
|
||||||
_contactSuggestions = List.from(_allContacts);
|
|
||||||
} else {
|
|
||||||
_contactSuggestions = _allContacts.where((contact) {
|
|
||||||
return contact.displayName
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(query.toLowerCase());
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -55,150 +27,66 @@ class _MyHomePageState extends State<MyHomePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Column(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
// Persistent Search Bar
|
TabBarView(
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 24.0,
|
|
||||||
bottom: 10.0,
|
|
||||||
left: 16.0,
|
|
||||||
right: 16.0,
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color.fromARGB(255, 30, 30, 30),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(color: Colors.grey.shade800, width: 1),
|
|
||||||
left: BorderSide(color: Colors.grey.shade800, width: 1),
|
|
||||||
right: BorderSide(color: Colors.grey.shade800, width: 1),
|
|
||||||
bottom: BorderSide(color: Colors.grey.shade800, width: 2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SearchAnchor(
|
|
||||||
builder: (BuildContext context, SearchController controller) {
|
|
||||||
return SearchBar(
|
|
||||||
controller: controller,
|
|
||||||
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
|
|
||||||
const EdgeInsets.only(
|
|
||||||
top: 6.0,
|
|
||||||
bottom: 6.0,
|
|
||||||
left: 16.0,
|
|
||||||
right: 16.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
controller.openView();
|
|
||||||
_onSearchChanged('');
|
|
||||||
},
|
|
||||||
backgroundColor: MaterialStateProperty.all(
|
|
||||||
const Color.fromARGB(255, 30, 30, 30)),
|
|
||||||
hintText: 'Search contacts',
|
|
||||||
hintStyle: MaterialStateProperty.all(
|
|
||||||
const TextStyle(color: Colors.grey, fontSize: 16.0),
|
|
||||||
),
|
|
||||||
leading: const Icon(
|
|
||||||
Icons.search,
|
|
||||||
color: Colors.grey,
|
|
||||||
size: 24.0,
|
|
||||||
),
|
|
||||||
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
||||||
RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
viewOnChanged: (query) {
|
|
||||||
_onSearchChanged(query);
|
|
||||||
},
|
|
||||||
suggestionsBuilder:
|
|
||||||
(BuildContext context, SearchController controller) {
|
|
||||||
return _contactSuggestions.map((contact) {
|
|
||||||
return ListTile(
|
|
||||||
key: ValueKey(contact.id),
|
|
||||||
title: Text(contact.displayName,
|
|
||||||
style: const TextStyle(color: Colors.white)),
|
|
||||||
onTap: () {
|
|
||||||
controller.closeView(contact.displayName);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Main content with TabBarView
|
|
||||||
Expanded(
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
TabBarView(
|
|
||||||
controller: _tabController,
|
|
||||||
children: const [
|
|
||||||
FavoritePage(),
|
|
||||||
HistoryPage(),
|
|
||||||
ContactPage(),
|
|
||||||
SettingsPage(), // Add your SettingsPage here
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
right: 20,
|
|
||||||
bottom: 20,
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const CompositionPage(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(45),
|
|
||||||
),
|
|
||||||
child: const Icon(Icons.dialpad, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
bottomNavigationBar: Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: TabBar(
|
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
tabs: [
|
children: const [
|
||||||
Tab(
|
FavoritePage(),
|
||||||
icon: Icon(_tabController.index == 0
|
HistoryPage(),
|
||||||
? Icons.star
|
ContactPage(),
|
||||||
: Icons.star_border)),
|
CompositionPage(),
|
||||||
Tab(
|
|
||||||
icon: Icon(_tabController.index == 1
|
|
||||||
? Icons.access_time_filled
|
|
||||||
: Icons.access_time_outlined)),
|
|
||||||
Tab(
|
|
||||||
icon: Icon(_tabController.index == 2
|
|
||||||
? Icons.contacts
|
|
||||||
: Icons.contacts_outlined)),
|
|
||||||
Tab(
|
|
||||||
icon: Icon(_tabController.index == 3 // Corrected index
|
|
||||||
? Icons.settings
|
|
||||||
: Icons.settings_outlined)),
|
|
||||||
],
|
],
|
||||||
labelColor: Colors.white,
|
|
||||||
unselectedLabelColor: const Color.fromARGB(255, 158, 158, 158),
|
|
||||||
indicatorSize: TabBarIndicatorSize.label,
|
|
||||||
indicatorColor: Colors.white,
|
|
||||||
),
|
),
|
||||||
|
if (_tabController.index != 3)
|
||||||
|
Positioned(
|
||||||
|
right: 20,
|
||||||
|
bottom: 20,
|
||||||
|
child: FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
|
||||||
|
_tabController.animateTo(3);
|
||||||
|
},
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(45),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.dialpad, color: Colors.white),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
bottomNavigationBar: Container(
|
||||||
|
color: Colors.black,
|
||||||
|
child: TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
tabs: [
|
||||||
|
Tab(icon: Icon(_tabController.index == 0 ? Icons.star : Icons.star_border)),
|
||||||
|
Tab(icon: Icon(_tabController.index == 1 ? Icons.access_time_filled : Icons.access_time_outlined)),
|
||||||
|
Tab(icon: Icon(_tabController.index == 2 ? Icons.contacts : Icons.contacts_outlined)),
|
||||||
|
Tab(icon: Icon(_tabController.index == 3 ? Icons.create : Icons.create_outlined)),
|
||||||
|
],
|
||||||
|
labelColor: Colors.white,
|
||||||
|
unselectedLabelColor: Colors.grey,
|
||||||
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
|
indicatorColor: Colors.white,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SettingsCallPage extends StatefulWidget {
|
|
||||||
const SettingsCallPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_SettingsCallPageState createState() => _SettingsCallPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SettingsCallPageState extends State<SettingsCallPage> {
|
|
||||||
bool _enableVoicemail = true;
|
|
||||||
bool _enableCallRecording = false;
|
|
||||||
String _ringtone = 'Default';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Calling settings'),
|
|
||||||
),
|
|
||||||
body: ListView(
|
|
||||||
children: [
|
|
||||||
SwitchListTile(
|
|
||||||
title: const Text('Enable Voicemail', style: TextStyle(color: Colors.white)),
|
|
||||||
value: _enableVoicemail,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
setState(() {
|
|
||||||
_enableVoicemail = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: const Text('Enable call Recording', style: TextStyle(color: Colors.white)),
|
|
||||||
value: _enableCallRecording,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
setState(() {
|
|
||||||
_enableCallRecording = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: const Text('Ringtone', style: TextStyle(color: Colors.white)),
|
|
||||||
subtitle: Text(_ringtone, style: const TextStyle(color: Colors.grey)),
|
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
|
||||||
onTap: () {
|
|
||||||
_selectRingtone(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _selectRingtone(BuildContext context) {
|
|
||||||
showDialog<String>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: const Text('Select Ringtone'),
|
|
||||||
children: <Widget>[
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, 'Default');
|
|
||||||
},
|
|
||||||
child: const Text('Default'),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, 'Classic');
|
|
||||||
},
|
|
||||||
child: const Text('Classic'),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, 'Beep');
|
|
||||||
},
|
|
||||||
child: const Text('Beep'),
|
|
||||||
),
|
|
||||||
// Add more ringtone options
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).then((value) {
|
|
||||||
if (value != null) {
|
|
||||||
setState(() {
|
|
||||||
_ringtone = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
// delete_key_pair.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SuppressionPaireClesPage extends StatelessWidget {
|
|
||||||
const SuppressionPaireClesPage({super.key});
|
|
||||||
|
|
||||||
void _deleteKeyPair(BuildContext context) {
|
|
||||||
// key deletion logic (not implemented here)
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Show confirmation message
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text('La paire de clés a été supprimée.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Navigate back or update the UI as needed
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showConfirmationDialog(BuildContext context) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Confirmer la Suppression'),
|
|
||||||
content: const Text(
|
|
||||||
'Êtes-vous sûr de vouloir supprimer la paire de clés ? Cette action est irréversible.'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Annuler'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Supprimer'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
_deleteKeyPair(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Suppression d\'une Paire de Clés'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
_showConfirmationDialog(context);
|
|
||||||
},
|
|
||||||
child: const Text('Supprimer la Paire de Clés'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
// export_private_key.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:pointycastle/export.dart' as crypto;
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
|
|
||||||
class ExportationClePriveePage extends StatefulWidget {
|
|
||||||
const ExportationClePriveePage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_ExportationClePriveePageState createState() => _ExportationClePriveePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ExportationClePriveePageState extends State<ExportationClePriveePage> {
|
|
||||||
final TextEditingController _passwordController = TextEditingController();
|
|
||||||
|
|
||||||
Future<void> _exportPrivateKey() async {
|
|
||||||
// Replace with your actual private key retrieval logic
|
|
||||||
final String privateKeyPem = 'Votre clé privée ici';
|
|
||||||
|
|
||||||
// Get the password from the user input
|
|
||||||
final password = _passwordController.text;
|
|
||||||
if (password.isEmpty) {
|
|
||||||
// Show error message
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encrypt the private key using AES-256
|
|
||||||
final encryptedData = _encryptPrivateKey(privateKeyPem, password);
|
|
||||||
|
|
||||||
// Let the user pick a file location
|
|
||||||
final outputFile = await FilePicker.platform.saveFile(
|
|
||||||
dialogTitle: 'Enregistrer la clé privée chiffrée',
|
|
||||||
fileName: 'private_key_encrypted.aes',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (outputFile != null) {
|
|
||||||
// Write the encrypted data to the file
|
|
||||||
// Use appropriate file I/O methods (not shown here)
|
|
||||||
// ...
|
|
||||||
// Show a confirmation dialog or message
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: const Text('Clé Exportée'),
|
|
||||||
content: const Text('La clé privée chiffrée a été exportée avec succès.'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8List _encryptPrivateKey(String privateKey, String password) {
|
|
||||||
// Encryption logic using AES-256
|
|
||||||
final key = crypto.PBKDF2KeyDerivator(crypto.HMac(crypto.SHA256Digest(), 64))
|
|
||||||
.process(Uint8List.fromList(utf8.encode(password)));
|
|
||||||
|
|
||||||
final params = crypto.PaddedBlockCipherParameters(
|
|
||||||
crypto.ParametersWithIV(crypto.KeyParameter(key), Uint8List(16)), // Initialization Vector
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
final cipher = crypto.PaddedBlockCipher('AES/CBC/PKCS7');
|
|
||||||
cipher.init(true, params);
|
|
||||||
|
|
||||||
final input = Uint8List.fromList(utf8.encode(privateKey));
|
|
||||||
final output = cipher.process(input);
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Exportation de la Clé Privée'),
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'Entrez un mot de passe pour chiffrer la clé privée:',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
controller: _passwordController,
|
|
||||||
obscureText: true,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Mot de passe',
|
|
||||||
hintStyle: TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: _exportPrivateKey,
|
|
||||||
child: const Text('Exporter la Clé Privée Chiffrée'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:pointycastle/export.dart' as crypto;
|
|
||||||
import 'dart:math';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'package:asn1lib/asn1lib.dart';
|
|
||||||
|
|
||||||
class GenerationNouvellePaireClesPage extends StatelessWidget {
|
|
||||||
const GenerationNouvellePaireClesPage({super.key});
|
|
||||||
|
|
||||||
Future<Map<String, String>> _generateKeyPair() async {
|
|
||||||
// key generation logic using pointycastle
|
|
||||||
final keyParams = crypto.RSAKeyGeneratorParameters(
|
|
||||||
BigInt.parse('65537'),
|
|
||||||
2048,
|
|
||||||
64,
|
|
||||||
);
|
|
||||||
|
|
||||||
final secureRandom = crypto.FortunaRandom();
|
|
||||||
|
|
||||||
// Seed the random number generator
|
|
||||||
final random = Random.secure();
|
|
||||||
final seeds = List<int>.generate(32, (_) => random.nextInt(256));
|
|
||||||
secureRandom.seed(crypto.KeyParameter(Uint8List.fromList(seeds)));
|
|
||||||
|
|
||||||
final rngParams = crypto.ParametersWithRandom(keyParams, secureRandom);
|
|
||||||
final keyGenerator = crypto.RSAKeyGenerator();
|
|
||||||
keyGenerator.init(rngParams);
|
|
||||||
|
|
||||||
final pair = keyGenerator.generateKeyPair();
|
|
||||||
final publicKey = pair.publicKey as crypto.RSAPublicKey;
|
|
||||||
final privateKey = pair.privateKey as crypto.RSAPrivateKey;
|
|
||||||
|
|
||||||
// Convert keys to PEM format
|
|
||||||
final publicKeyPem = _encodePublicKeyToPemPKCS1(publicKey);
|
|
||||||
final privateKeyPem = _encodePrivateKeyToPemPKCS1(privateKey);
|
|
||||||
|
|
||||||
// Save keys securely (not implemented here)
|
|
||||||
|
|
||||||
return {'publicKey': publicKeyPem, 'privateKey': privateKeyPem};
|
|
||||||
}
|
|
||||||
|
|
||||||
String _encodePublicKeyToPemPKCS1(crypto.RSAPublicKey publicKey) {
|
|
||||||
final bytes = _encodePublicKeyToDer(publicKey);
|
|
||||||
return _formatPem(bytes, 'RSA PUBLIC KEY');
|
|
||||||
}
|
|
||||||
|
|
||||||
String _encodePrivateKeyToPemPKCS1(crypto.RSAPrivateKey privateKey) {
|
|
||||||
final bytes = _encodePrivateKeyToDer(privateKey);
|
|
||||||
return _formatPem(bytes, 'RSA PRIVATE KEY');
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8List _encodePublicKeyToDer(crypto.RSAPublicKey publicKey) {
|
|
||||||
final algorithmSeq = ASN1Sequence();
|
|
||||||
algorithmSeq.add(ASN1ObjectIdentifier.fromName('rsaEncryption'));
|
|
||||||
algorithmSeq.add(ASN1Null());
|
|
||||||
|
|
||||||
final publicKeySeq = ASN1Sequence();
|
|
||||||
publicKeySeq.add(ASN1Integer(publicKey.modulus!));
|
|
||||||
publicKeySeq.add(ASN1Integer(publicKey.exponent!));
|
|
||||||
|
|
||||||
final publicKeyBitString = ASN1BitString(Uint8List.fromList(publicKeySeq.encodedBytes));
|
|
||||||
|
|
||||||
final topLevelSeq = ASN1Sequence();
|
|
||||||
topLevelSeq.add(algorithmSeq);
|
|
||||||
topLevelSeq.add(publicKeyBitString);
|
|
||||||
|
|
||||||
return Uint8List.fromList(topLevelSeq.encodedBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint8List _encodePrivateKeyToDer(crypto.RSAPrivateKey privateKey) {
|
|
||||||
final privateKeySeq = ASN1Sequence();
|
|
||||||
privateKeySeq.add(ASN1Integer(BigInt.from(0))); // Version
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.n!));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.exponent!));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.d!));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.p!));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.q!));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.d! % (privateKey.p! - BigInt.one)));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.d! % (privateKey.q! - BigInt.one)));
|
|
||||||
privateKeySeq.add(ASN1Integer(privateKey.q!.modInverse(privateKey.p!)));
|
|
||||||
|
|
||||||
return Uint8List.fromList(privateKeySeq.encodedBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _formatPem(Uint8List bytes, String label) {
|
|
||||||
final base64 = base64Encode(bytes);
|
|
||||||
final chunks = RegExp('.{1,64}').allMatches(base64).map((m) => m.group(0)!);
|
|
||||||
return '-----BEGIN $label-----\n${chunks.join('\n')}\n-----END $label-----';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Génération d\'une Nouvelle Paire de Clés'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final keys = await _generateKeyPair();
|
|
||||||
// Display a confirmation dialog or message
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: const Text('Clés Générées'),
|
|
||||||
content: const Text('La nouvelle paire de clés a été générée avec succès.'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Générer une Nouvelle Paire de Clés'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
// manage_keys_page.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/features/settings/key/show_public_key_text.dart';
|
|
||||||
import 'package:dialer/features/settings/key/show_public_key_qr.dart';
|
|
||||||
import 'package:dialer/features/settings/key/generate_new_key_pair.dart';
|
|
||||||
import 'package:dialer/features/settings/key/export_private_key.dart';
|
|
||||||
import 'package:dialer/features/settings/key/delete_key_pair.dart';
|
|
||||||
|
|
||||||
class GestionDeClesPage extends StatelessWidget {
|
|
||||||
const GestionDeClesPage({super.key});
|
|
||||||
|
|
||||||
void _navigateToOption(BuildContext context, String option) {
|
|
||||||
switch (option) {
|
|
||||||
case 'Affichage de la clé publique en texte':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const AffichageClePubliqueTextePage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Affichage de la clé publique en QR code':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const AffichageClePubliqueQRCodePage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Génération d\'une nouvelle paire de clés':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const GenerationNouvellePaireClesPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Exportation de la clé privée en fichier chiffré par mot de passe (AES 256)':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const ExportationClePriveePage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Suppression d\'une paire de clés, POPUP d\'avertissement':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const SuppressionPaireClesPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Handle default or unknown options
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final keyManagementOptions = [
|
|
||||||
'Affichage de la clé publique en texte',
|
|
||||||
'Affichage de la clé publique en QR code',
|
|
||||||
'Génération d\'une nouvelle paire de clés',
|
|
||||||
'Exportation de la clé privée en fichier chiffré par mot de passe (AES 256)',
|
|
||||||
'Suppression d\'une paire de clés, POPUP d\'avertissement',
|
|
||||||
];
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Gestion de clés'),
|
|
||||||
),
|
|
||||||
body: ListView.builder(
|
|
||||||
itemCount: keyManagementOptions.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
keyManagementOptions[index],
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
|
||||||
onTap: () {
|
|
||||||
_navigateToOption(context, keyManagementOptions[index]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:pretty_qr_code/pretty_qr_code.dart';
|
|
||||||
|
|
||||||
class AffichageClePubliqueQRCodePage extends StatelessWidget {
|
|
||||||
const AffichageClePubliqueQRCodePage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// Replace with your actual public key retrieval logic
|
|
||||||
final String publicKey = 'Votre clé publique ici';
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Clé Publique en QR Code'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: PrettyQr(
|
|
||||||
data: publicKey,
|
|
||||||
size: 250,
|
|
||||||
roundEdges: true,
|
|
||||||
elementColor: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
// show_public_key_text.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class AffichageClePubliqueTextePage extends StatelessWidget {
|
|
||||||
const AffichageClePubliqueTextePage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// Replace with your actual public key retrieval logic
|
|
||||||
final String publicKey = 'Votre clé publique ici';
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Clé Publique en Texte'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: SelectableText(
|
|
||||||
publicKey,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
// settings.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/features/settings/call/settingsCall.dart';
|
|
||||||
import 'package:dialer/features/settings/sim/settings_accounts.dart';
|
|
||||||
import 'package:dialer/features/settings/key/manage_keys_page.dart';
|
|
||||||
|
|
||||||
class SettingsPage extends StatelessWidget {
|
|
||||||
const SettingsPage({super.key});
|
|
||||||
|
|
||||||
void _navigateToSettings(BuildContext context, String setting) {
|
|
||||||
switch (setting) {
|
|
||||||
case 'Calling settings':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const SettingsCallPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Page des comptes téléphoniques':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const SettingsAccountsPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Gestion de clés':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const GestionDeClesPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
// Add more cases for other settings pages
|
|
||||||
default:
|
|
||||||
// Handle default or unknown settings
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final settingsOptions = [
|
|
||||||
'Calling settings',
|
|
||||||
'Page des comptes téléphoniques',
|
|
||||||
'Gestion de clés', // Add the new option here
|
|
||||||
];
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('settings'),
|
|
||||||
),
|
|
||||||
body: ListView.builder(
|
|
||||||
itemCount: settingsOptions.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
settingsOptions[index],
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
|
||||||
onTap: () {
|
|
||||||
_navigateToSettings(context, settingsOptions[index]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
// choose_sim.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:sim_data/sim_data.dart';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
class ChooseSimPage extends StatefulWidget {
|
|
||||||
const ChooseSimPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_ChooseSimPageState createState() => _ChooseSimPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChooseSimPageState extends State<ChooseSimPage> {
|
|
||||||
List<SimCard> _simCards = [];
|
|
||||||
int? _selectedSimIndex;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_fetchSimCards();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _fetchSimCards() async {
|
|
||||||
if (await Permission.phone.request().isGranted) {
|
|
||||||
try {
|
|
||||||
final simData = await SimDataPlugin.getSimData();
|
|
||||||
setState(() {
|
|
||||||
_simCards = simData.cards;
|
|
||||||
_selectedSimIndex = 0;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Handle error
|
|
||||||
print('Error fetching SIM data: $e');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Permission denied
|
|
||||||
print('Phone permission denied');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onSimSelected(int? index) {
|
|
||||||
if (index != null) {
|
|
||||||
setState(() {
|
|
||||||
_selectedSimIndex = index;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Choisir la SIM'),
|
|
||||||
),
|
|
||||||
body: _simCards.isEmpty
|
|
||||||
? const Center(
|
|
||||||
child: Text(
|
|
||||||
'Aucune carte SIM trouvée',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: ListView.builder(
|
|
||||||
itemCount: _simCards.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final sim = _simCards[index];
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
'SIM ${index + 1}',
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
'Opérateur: ${sim.carrierName}',
|
|
||||||
style: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
trailing: Radio<int>(
|
|
||||||
value: index,
|
|
||||||
groupValue: _selectedSimIndex,
|
|
||||||
onChanged: _onSimSelected,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
// settings_accounts.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/features/settings/sim/choose_sim.dart';
|
|
||||||
import 'package:dialer/features/settings/sim/sim_parameters.dart';
|
|
||||||
|
|
||||||
class SettingsAccountsPage extends StatelessWidget {
|
|
||||||
const SettingsAccountsPage({super.key});
|
|
||||||
|
|
||||||
void _navigateToAccountOption(BuildContext context, String option) {
|
|
||||||
switch (option) {
|
|
||||||
case 'Choisir la SIM':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const ChooseSimPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Paramètre SIM':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const SimParametersPage()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
// Handle more options if needed
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final accountOptions = [
|
|
||||||
'Choisir la SIM',
|
|
||||||
'Paramètre SIM',
|
|
||||||
];
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Page des comptes téléphoniques'),
|
|
||||||
),
|
|
||||||
body: ListView.builder(
|
|
||||||
itemCount: accountOptions.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
accountOptions[index],
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
|
||||||
onTap: () {
|
|
||||||
_navigateToAccountOption(context, accountOptions[index]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
// sim_parameters.dart
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:sim_data/sim_data.dart';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
class SimParametersPage extends StatefulWidget {
|
|
||||||
const SimParametersPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_SimParametersPageState createState() => _SimParametersPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SimParametersPageState extends State<SimParametersPage> {
|
|
||||||
List<SimCard> _simCards = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_fetchSimParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _fetchSimParameters() async {
|
|
||||||
if (await Permission.phone.request().isGranted) {
|
|
||||||
try {
|
|
||||||
final simData = await SimDataPlugin.getSimData();
|
|
||||||
setState(() {
|
|
||||||
_simCards = simData.cards;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Handle error
|
|
||||||
print('Error fetching SIM data: $e');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Permission denied
|
|
||||||
print('Phone permission denied');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSimInfo(SimCard sim, int index) {
|
|
||||||
return Card(
|
|
||||||
color: Colors.grey[850],
|
|
||||||
child: ListTile(
|
|
||||||
title: Text(
|
|
||||||
'SIM ${index + 1}',
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
'''
|
|
||||||
Opérateur: ${sim.carrierName}
|
|
||||||
Pays: ${sim.countryCode ?? 'N/A'}
|
|
||||||
MCC: ${sim.mcc ?? 'N/A'}
|
|
||||||
MNC: ${sim.mnc ?? 'N/A'}
|
|
||||||
Slot Index: ${sim.slotIndex ?? 'N/A'}
|
|
||||||
Display Name: ${sim.displayName ?? 'N/A'}
|
|
||||||
''',
|
|
||||||
style: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Paramètre SIM'),
|
|
||||||
),
|
|
||||||
body: _simCards.isEmpty
|
|
||||||
? const Center(
|
|
||||||
child: Text(
|
|
||||||
'Aucune carte SIM trouvée',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: ListView.builder(
|
|
||||||
itemCount: _simCards.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return _buildSimInfo(_simCards[index], index);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -38,12 +38,6 @@ dependencies:
|
|||||||
flutter_contacts: ^1.1.9+2
|
flutter_contacts: ^1.1.9+2
|
||||||
permission_handler: ^10.2.0 # For handling permissions
|
permission_handler: ^10.2.0 # For handling permissions
|
||||||
cached_network_image: ^3.2.3 # For caching contact images
|
cached_network_image: ^3.2.3 # For caching contact images
|
||||||
sim_data: ^0.0.2
|
|
||||||
pretty_qr_code: ^3.3.0
|
|
||||||
pointycastle: ^3.4.0
|
|
||||||
file_picker: ^5.2.5
|
|
||||||
asn1lib: ^1.0.0
|
|
||||||
intl_utils: ^2.0.7
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user