357 lines
11 KiB
Dart
357 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
theme: ThemeData(
|
|
brightness: Brightness.dark
|
|
),
|
|
home: MyHomePage(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
@override
|
|
_MyHomePageState createState() => _MyHomePageState();
|
|
}
|
|
|
|
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_tabController = TabController(length: 3, vsync: this, initialIndex: 1);
|
|
_tabController.addListener(_handleTabIndex);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabController.removeListener(_handleTabIndex);
|
|
_tabController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _handleTabIndex() {
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// appBar: AppBar(
|
|
// backgroundColor: Colors.black,
|
|
// foregroundColor: Colors.black,
|
|
// // title: const Text('Barre de navigation inférieure'),
|
|
// ),
|
|
backgroundColor: Colors.black,
|
|
body: TabBarView(
|
|
controller: _tabController,
|
|
children: [
|
|
FavoritePage(), // Page des favoris
|
|
HistoryPage(), // Page de l'historique
|
|
ContactPage(), // Page des contacts
|
|
],
|
|
),
|
|
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)),
|
|
],
|
|
labelColor: Colors.white,
|
|
unselectedLabelColor: Colors.grey,
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
indicatorPadding: const EdgeInsets.only(bottom: -0), // Ajustez le padding pour élever la ligne blanche au-dessus des icônes si nécessaire
|
|
indicatorColor: Colors.white, // Couleur de la barre horizontale blanche
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ContactPage extends StatefulWidget {
|
|
@override
|
|
_ContactPageState createState() => _ContactPageState();
|
|
}
|
|
|
|
class _ContactPageState extends State<ContactPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
appBar: AppBar(
|
|
title: const Text('Contacts'),
|
|
),
|
|
body: ListView.builder(
|
|
itemCount: contacts.length,
|
|
itemBuilder: (context, index) {
|
|
return DisplayContact(contact: contacts[index]);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class FavoritePage extends StatefulWidget {
|
|
@override
|
|
_FavoritePageState createState() => _FavoritePageState();
|
|
}
|
|
|
|
class _FavoritePageState extends State<FavoritePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
appBar: AppBar(
|
|
title: const Text('Favorites'),
|
|
),
|
|
body: ListView.builder(
|
|
itemCount: contacts.length,
|
|
itemBuilder: (context, index) {
|
|
if (contacts[index].isFavorite) {
|
|
return DisplayContact(contact: contacts[index]);
|
|
} else {
|
|
return const SizedBox.shrink();
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HistoryPage extends StatefulWidget {
|
|
@override
|
|
_HistoryPageState createState() => _HistoryPageState();
|
|
}
|
|
|
|
class _HistoryPageState extends State<HistoryPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
appBar: AppBar(
|
|
title: const Text('History'),
|
|
),
|
|
body: ListView.builder(
|
|
itemCount: histories.length,
|
|
itemBuilder: (context, index) {
|
|
return DisplayContact(contact: histories[index].contact, history: histories[index]);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class DisplayContact extends StatelessWidget {
|
|
String getTimeElapsed(DateTime date) {
|
|
final now = DateTime.now();
|
|
final difference = now.difference(date);
|
|
if (difference.inDays > 0) {
|
|
return '${difference.inDays} days ago';
|
|
} else if (difference.inHours > 0) {
|
|
return '${difference.inHours} hours ago';
|
|
} else if (difference.inMinutes > 0) {
|
|
return '${difference.inMinutes} minutes ago';
|
|
} else {
|
|
return 'Just now';
|
|
}
|
|
}
|
|
|
|
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)));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
leading: DisplayAvatar(contact: contact),
|
|
title: Text(contact.name),
|
|
subtitle: history != null ? Text(getTimeElapsed(history!.date)) : null,
|
|
trailing: InkWell(
|
|
onTap: () => _openVisualPage(context),
|
|
child: const Icon(Icons.call),
|
|
),
|
|
onTap: () {
|
|
// Ajoutez ici le code pour appeler le contact
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class CallingPage extends StatefulWidget {
|
|
final Contact contact;
|
|
|
|
const CallingPage({super.key, required this.contact});
|
|
|
|
@override
|
|
_CallingPageState createState() => _CallingPageState();
|
|
}
|
|
|
|
// display the calling page as if the call is already in progress
|
|
class _CallingPageState extends State<CallingPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final contact = widget.contact;
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
appBar: AppBar(
|
|
title: const Text('Appel en cours'),
|
|
backgroundColor: Colors.black,
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
const CircleAvatar(
|
|
radius: 100.0,
|
|
backgroundImage:
|
|
NetworkImage('https://thispersondoesnotexist.com/'),
|
|
backgroundColor: Colors.transparent,
|
|
),
|
|
const SizedBox(height: 10.0),
|
|
// Add the contact name here
|
|
Text(contact.name, style: const TextStyle(fontSize: 40.0, color: Colors.white)),
|
|
// const SizedBox(height: 10.0),
|
|
const Text('99 : 59 : 59', style:
|
|
TextStyle(fontSize: 40.0, color:
|
|
Colors.white)),
|
|
const SizedBox(height: 50.0),
|
|
contact.isLocked
|
|
? const Text('Con. Health - 98% (excellent)',
|
|
style:
|
|
TextStyle(fontSize:
|
|
16.0,color:
|
|
Colors.green))
|
|
:
|
|
const Text('No Icing available',
|
|
style:
|
|
TextStyle(fontSize:
|
|
16.0,color:
|
|
Colors.white)),
|
|
const SizedBox(height:
|
|
50.0), // Adjust size box height as needed
|
|
const Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceEvenly,
|
|
children:<Widget>[
|
|
Icon(Icons.mic_off,size:
|
|
30.0,color:
|
|
Colors.white),
|
|
Icon(Icons.dialpad,size:
|
|
30.0,color:
|
|
Colors.white),
|
|
Icon(Icons.more_vert,size:
|
|
30.0,color:
|
|
Colors.white),
|
|
Icon(Icons.volume_up,size:
|
|
30.0,color:
|
|
Colors.white),
|
|
],
|
|
),
|
|
const SizedBox(height:
|
|
50.0), // Adjust size box height as needed
|
|
const Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceEvenly,
|
|
children:<Widget>[
|
|
Icon(Icons.pause,size:
|
|
60.0,color:
|
|
Colors.white),
|
|
Icon(Icons.call_end,size:
|
|
60.0,color:
|
|
Colors.red),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class DisplayAvatar extends StatelessWidget {
|
|
final Contact contact;
|
|
|
|
const DisplayAvatar({super.key, required this.contact});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: <Widget>[
|
|
CircleAvatar(
|
|
child: Text(contact.name[0]),
|
|
),
|
|
if (contact.isLocked)
|
|
const Positioned(
|
|
right: 0,
|
|
bottom: 0,
|
|
child: Icon(
|
|
Icons.lock,
|
|
color: Colors.white,
|
|
size: 20.0,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
// Create contact lists
|
|
class Contact {
|
|
final String name;
|
|
final String phoneNumber;
|
|
final bool isFavorite;
|
|
final bool isLocked;
|
|
|
|
Contact(this.name, this.phoneNumber, {this.isFavorite = false, this.isLocked = false});
|
|
}
|
|
|
|
class History {
|
|
final Contact contact;
|
|
final DateTime date;
|
|
|
|
History(this.contact, this.date);
|
|
}
|
|
|
|
List<Contact> 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<History> 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))),
|
|
];
|