diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 44f6b0b..176dc0d 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -42,4 +42,7 @@
+
+
+
diff --git a/lib/classes/contactClass.dart b/lib/classes/contactClass.dart
index 3d7dd91..005ef24 100644
--- a/lib/classes/contactClass.dart
+++ b/lib/classes/contactClass.dart
@@ -1,9 +1,26 @@
-// Create contact lists
+// contactClass.dart
+
class Contact {
final String name;
final String phoneNumber;
final bool isFavorite;
final bool isLocked;
+ final String? publicKey;
- Contact(this.name, this.phoneNumber, {this.isFavorite = false, this.isLocked = false});
+ Contact(
+ this.name,
+ this.phoneNumber, {
+ this.isFavorite = false,
+ this.isLocked = false,
+ this.publicKey,
+ });
}
+
+// Sample contacts list
+List contacts = [
+ Contact('Alice', '1234567890'),
+ Contact('Bob', '0987654321', isFavorite: true, publicKey: 'ABCD...WXYZ'),
+ Contact('Charlie', '5555555555', isLocked: true),
+ // Add more contacts as needed
+];
+
diff --git a/lib/classes/displayAvatar.dart b/lib/classes/displayAvatar.dart
index f5cacb9..934a0c8 100644
--- a/lib/classes/displayAvatar.dart
+++ b/lib/classes/displayAvatar.dart
@@ -1,3 +1,5 @@
+// displayAvatar.dart
+
import 'package:dialer/classes/contactClass.dart';
import 'package:flutter/material.dart';
diff --git a/lib/classes/displayContact.dart b/lib/classes/displayContact.dart
index 292ae97..b164aa6 100644
--- a/lib/classes/displayContact.dart
+++ b/lib/classes/displayContact.dart
@@ -1,11 +1,21 @@
+// DisplayContact.dart
+
import 'package:dialer/pages/callingPage.dart';
import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayAvatar.dart';
-import 'package:dialer/pages/history.dart';
import 'package:flutter/material.dart';
-
+import 'package:dialer/pages/history.dart';
class DisplayContact extends StatelessWidget {
+ final Contact contact;
+ final History? history;
+
+ const DisplayContact({
+ super.key,
+ required this.contact,
+ this.history,
+ });
+
String getTimeElapsed(DateTime date) {
final now = DateTime.now();
final difference = now.difference(date);
@@ -20,13 +30,13 @@ class DisplayContact extends StatelessWidget {
}
}
- final Contact contact;
- final History? history;
-
- const DisplayContact({super.key, required this.contact, this.history});
-
void _openVisualPage(BuildContext context) {
- Navigator.push(context, MaterialPageRoute(builder: (context) => CallingPage(contact: contact)));
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => CallingPage(contact: contact),
+ ),
+ );
}
@override
@@ -34,13 +44,39 @@ class DisplayContact extends StatelessWidget {
return ListTile(
leading: DisplayAvatar(contact: contact),
title: Text(contact.name),
- subtitle: history != null ? Text(getTimeElapsed(history!.date)) : null,
+ subtitle: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(contact.phoneNumber),
+ if (contact.publicKey != null)
+ Text(
+ 'Key: ${contact.publicKey!.substring(0, 2)}...${contact.publicKey!.substring(contact.publicKey!.length - 2)}',
+ ),
+ if (history != null) ...[
+ Row(
+ children: [
+ Icon(
+ history!.callType == 'incoming'
+ ? Icons.call_received
+ : Icons.call_made,
+ size: 16,
+ color: history!.callStatus == 'missed' ? Colors.red : Colors.green,
+ ),
+ const SizedBox(width: 4),
+ Text('${history!.callStatus}, attempts: ${history!.attempts}'),
+ ],
+ ),
+ Text(getTimeElapsed(history!.date)),
+ ],
+ ],
+ ),
trailing: InkWell(
onTap: () => _openVisualPage(context),
child: const Icon(Icons.call),
),
+ isThreeLine: true,
onTap: () {
- // Ajoutez ici le code pour appeler le contact
+ // Add code here to handle contact tap
},
);
}
diff --git a/lib/pages/chooseSim.dart b/lib/pages/chooseSim.dart
new file mode 100644
index 0000000..0cc1186
--- /dev/null
+++ b/lib/pages/chooseSim.dart
@@ -0,0 +1,87 @@
+// chooseSim.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 {
+ List _simCards = [];
+ int? _selectedSimIndex;
+
+ @override
+ void initState() {
+ super.initState();
+ _fetchSimCards();
+ }
+
+ Future _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(
+ value: index,
+ groupValue: _selectedSimIndex,
+ onChanged: _onSimSelected,
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/pages/contact.dart b/lib/pages/contact.dart
index 913cc42..e39e62c 100644
--- a/lib/pages/contact.dart
+++ b/lib/pages/contact.dart
@@ -1,3 +1,5 @@
+// contact.dart
+
import 'package:flutter/material.dart';
import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayContact.dart';
@@ -8,35 +10,32 @@ class ContactPage extends StatefulWidget {
@override
_ContactPageState createState() => _ContactPageState();
}
-
+
class _ContactPageState extends State {
@override
Widget build(BuildContext context) {
+ // Optionally sort contacts alphabetically
+ final sortedContacts = [...contacts]..sort((a, b) => a.name.compareTo(b.name));
+
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Contacts'),
),
body: ListView.builder(
- itemCount: contacts.length,
+ itemCount: sortedContacts.length,
itemBuilder: (context, index) {
- return DisplayContact(contact: contacts[index]);
+ return DisplayContact(contact: sortedContacts[index]);
},
),
);
}
}
-List contacts = [
- Contact('Axel NAVARRO BOUZEHRIR (arabe)', '0618859419'),
- Contact('Fabrice Iguet', '0618958419'),
- Contact('La Banque Axial', '0619358514'),
- Contact('Maman', '0618955417', isFavorite: true, isLocked: true),
- Contact('Micheline Verdet', '0618527419', isLocked: true),
- Contact('Philippe Mogue', '0618955889', isFavorite: true),
- Contact('Pizza Enrico Pucci', '0618951439', isLocked: true),
- Contact('Quentin Aumas', '0610252019'),
- Contact('Yohan HATOT', '0618102552', isFavorite: true, isLocked: true),
- Contact('Zizou', '0618514479'),
-];
+
+List contacts = [
+ Contact('Alice', '1234567890'),
+ Contact('Bob', '0987654321', isFavorite: true, isLocked: true, publicKey: 'AB...YZ'),
+ Contact('Charlie', '5555555555', isLocked: true),
+];
diff --git a/lib/pages/favorites.dart b/lib/pages/favorites.dart
index 7a40f70..5139612 100644
--- a/lib/pages/favorites.dart
+++ b/lib/pages/favorites.dart
@@ -1,5 +1,7 @@
+// favorites.dart
+
+import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayContact.dart';
-import 'package:dialer/pages/contact.dart';
import 'package:flutter/material.dart';
class FavoritePage extends StatefulWidget {
@@ -12,19 +14,19 @@ class FavoritePage extends StatefulWidget {
class _FavoritePageState extends State {
@override
Widget build(BuildContext context) {
+ // Filter favorite contacts
+ final favoriteContacts =
+ contacts.where((contact) => contact.isFavorite).toList();
+
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Favorites'),
),
body: ListView.builder(
- itemCount: contacts.length,
+ itemCount: favoriteContacts.length,
itemBuilder: (context, index) {
- if (contacts[index].isFavorite) {
- return DisplayContact(contact: contacts[index]);
- } else {
- return const SizedBox.shrink();
- }
+ return DisplayContact(contact: favoriteContacts[index]);
},
),
);
diff --git a/lib/pages/history.dart b/lib/pages/history.dart
index 8a66265..4186016 100644
--- a/lib/pages/history.dart
+++ b/lib/pages/history.dart
@@ -1,20 +1,48 @@
-import 'package:dialer/classes/contactClass.dart';
-import 'package:dialer/pages/contact.dart';
+// history.dart
+
import 'package:flutter/material.dart';
+import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayContact.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(
+ this.contact,
+ this.date,
+ this.callType,
+ this.callStatus,
+ this.attempts,
+ );
+}
List histories = [
- History(contacts[0], DateTime.now().subtract(const Duration(hours: 2))),
- History(contacts[1], DateTime.now().subtract(const Duration(hours: 8))),
- History(contacts[2], DateTime.now().subtract(const Duration(days: 3, hours: 4))),
- History(contacts[3], DateTime.now().subtract(const Duration(days: 4, hours: 5))),
- History(contacts[4], DateTime.now().subtract(const Duration(days: 5, hours: 6))),
- History(contacts[5], DateTime.now().subtract(const Duration(days: 6, hours: 7))),
- History(contacts[6], DateTime.now().subtract(const Duration(days: 7, hours: 8))),
- History(contacts[7], DateTime.now().subtract(const Duration(days: 8, hours: 9))),
- History(contacts[8], DateTime.now().subtract(const Duration(days: 9, hours: 10))),
- History(contacts[9], DateTime.now().subtract(const Duration(days: 10, hours: 11))),
+ History(
+ contacts[0],
+ DateTime.now().subtract(const Duration(hours: 2)),
+ 'outgoing',
+ 'answered',
+ 1,
+ ),
+ History(
+ contacts[1],
+ DateTime.now().subtract(const Duration(hours: 8)),
+ 'incoming',
+ 'missed',
+ 2,
+ ),
+ History(
+ contacts[2],
+ DateTime.now().subtract(const Duration(days: 1, hours: 3)),
+ 'outgoing',
+ 'missed',
+ 1,
+ ),
+ // Add more histories as needed
];
class HistoryPage extends StatefulWidget {
@@ -35,16 +63,12 @@ class _HistoryPageState extends State {
body: ListView.builder(
itemCount: histories.length,
itemBuilder: (context, index) {
- return DisplayContact(contact: histories[index].contact, history: histories[index]);
+ return DisplayContact(
+ contact: histories[index].contact,
+ history: histories[index],
+ );
},
),
);
}
}
-
-class History {
- final Contact contact;
- final DateTime date;
-
- History(this.contact, this.date);
-}
diff --git a/lib/pages/myHomePage.dart b/lib/pages/myHomePage.dart
index 227c229..70a46f9 100644
--- a/lib/pages/myHomePage.dart
+++ b/lib/pages/myHomePage.dart
@@ -2,17 +2,24 @@ import 'package:dialer/pages/contact.dart';
import 'package:dialer/pages/favorites.dart';
import 'package:dialer/pages/history.dart';
import 'package:dialer/pages/composition.dart';
+import 'package:dialer/pages/settings.dart';
import 'package:flutter/material.dart';
+class MyHomePage extends StatefulWidget {
+ const MyHomePage({super.key});
+
+ @override
+ _MyHomePageState createState() => _MyHomePageState();
+}
+
class _MyHomePageState extends State with SingleTickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
- _tabController = TabController(length: 4, vsync: this, initialIndex: 1);
+ _tabController = TabController(length: 5, vsync: this, initialIndex: 1);
_tabController.addListener(_handleTabIndex);
-
}
@override
@@ -27,72 +34,55 @@ class _MyHomePageState extends State with SingleTickerProviderStateM
}
@override
-Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.black,
- body: Stack(
- children: [
- TabBarView(
- controller: _tabController,
- children: const [
- FavoritePage(),
- HistoryPage(),
- ContactPage(),
- CompositionPage(),
- ],
- ),
- 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),
- ],
+ Widget build(BuildContext context) {
+ return Scaffold(
+ backgroundColor: Colors.black,
+ body: Stack(
+ children: [
+ TabBarView(
+ controller: _tabController,
+ children: const [
+ FavoritePage(),
+ HistoryPage(),
+ ContactPage(),
+ CompositionPage(),
+ SettingsPage(),
+ ],
+ ),
+ 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: 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 {
- const MyHomePage({super.key});
-
- @override
- _MyHomePageState createState() => _MyHomePageState();
+ 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.dialpad : Icons.dialpad_outlined)),
+ Tab(icon: Icon(_tabController.index == 4 ? Icons.settings : Icons.settings_outlined)), // Settings icon
+ ],
+ labelColor: Colors.white,
+ unselectedLabelColor: Colors.grey,
+ indicatorSize: TabBarIndicatorSize.label,
+ indicatorColor: Colors.white,
+ ),
+ ),
+ );
+ }
}
diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart
new file mode 100644
index 0000000..def62da
--- /dev/null
+++ b/lib/pages/settings.dart
@@ -0,0 +1,60 @@
+// settings.dart
+
+import 'package:flutter/material.dart';
+import 'package:dialer/pages/settingsCall.dart';
+import 'package:dialer/pages/settingsAccounts.dart'; // Import the new settings page
+
+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;
+ // 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',
+ ];
+
+ 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]);
+ },
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/pages/settingsAccounts.dart b/lib/pages/settingsAccounts.dart
new file mode 100644
index 0000000..6ebfaf8
--- /dev/null
+++ b/lib/pages/settingsAccounts.dart
@@ -0,0 +1,59 @@
+// settingsAccounts.dart
+
+import 'package:flutter/material.dart';
+import 'package:dialer/pages/chooseSim.dart'; // We'll create this next
+import 'package:dialer/pages/simParameters.dart'; // We'll create this next
+
+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]);
+ },
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/pages/settingsCall.dart b/lib/pages/settingsCall.dart
new file mode 100644
index 0000000..82e1a6a
--- /dev/null
+++ b/lib/pages/settingsCall.dart
@@ -0,0 +1,94 @@
+import 'package:flutter/material.dart';
+
+class SettingsCallPage extends StatefulWidget {
+ const SettingsCallPage({super.key});
+
+ @override
+ _SettingsCallPageState createState() => _SettingsCallPageState();
+}
+
+class _SettingsCallPageState extends State {
+ 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);
+ },
+ ),
+ // Add more calling settings as needed
+ ],
+ ),
+ );
+ }
+
+ void _selectRingtone(BuildContext context) {
+ // For demonstration, let's use a simple dialog
+ showDialog(
+ context: context,
+ builder: (BuildContext context) {
+ return SimpleDialog(
+ title: const Text('Select Ringtone'),
+ children: [
+ 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;
+ });
+ }
+ });
+ }
+}
diff --git a/lib/pages/simParameters.dart b/lib/pages/simParameters.dart
new file mode 100644
index 0000000..f19d625
--- /dev/null
+++ b/lib/pages/simParameters.dart
@@ -0,0 +1,85 @@
+// simParameters.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 {
+ List _simCards = [];
+
+ @override
+ void initState() {
+ super.initState();
+ _fetchSimParameters();
+ }
+
+ Future _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);
+ },
+ ),
+ );
+ }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index 1b6c5e6..f92fbd9 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -35,6 +35,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
+ sim_data: ^0.0.2
+ permission_handler: ^10.2.0
dev_dependencies:
flutter_test: