|
|
@ -177,8 +177,7 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
void showTicketPage() { |
|
|
void showTicketPage() { |
|
|
Get.offAll(TicketPage( |
|
|
Get.offAll(TicketPage( |
|
|
businessName: 'Youmaz', |
|
|
businessName: 'Youmaz', |
|
|
businessAddress: |
|
|
businessAddress: 'quartier escale, Diourbel, Sénégal, en face de Sonatel', |
|
|
'quartier escale, Diourbel, Sénégal, en face de Sonatel', |
|
|
|
|
|
businessPhoneNumber: '77 446 92 68', |
|
|
businessPhoneNumber: '77 446 92 68', |
|
|
cartItems: selectedProducts, |
|
|
cartItems: selectedProducts, |
|
|
totalCartPrice: calculateTotalPrice(), |
|
|
totalCartPrice: calculateTotalPrice(), |
|
|
@ -192,37 +191,38 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
appBar: CustomAppBar( |
|
|
appBar: CustomAppBar( |
|
|
title: "Accueil", |
|
|
title: "Accueil", |
|
|
subtitle: Text('Bienvenue $username ! (Rôle: $role)', |
|
|
subtitle: Text('Bienvenue $username ! (Rôle: $role)', |
|
|
style: const TextStyle(color: Colors.white70, fontSize: 14)), |
|
|
style: const TextStyle(color: Colors.white70, fontSize: 14)), |
|
|
), |
|
|
), |
|
|
drawer: CustomDrawer(), |
|
|
drawer: CustomDrawer(), |
|
|
body: ParticleBackground( |
|
|
body: ParticleBackground( |
|
|
child: Container( |
|
|
child: Container( |
|
|
decoration: const BoxDecoration( |
|
|
decoration: const BoxDecoration( |
|
|
gradient: LinearGradient( |
|
|
gradient: LinearGradient( |
|
|
begin: Alignment.topLeft, |
|
|
begin: Alignment.topLeft, |
|
|
end: Alignment.bottomRight, |
|
|
end: Alignment.bottomRight, |
|
|
colors: [Colors.white, Color.fromARGB(255, 4, 54, 95)]), |
|
|
colors: [Colors.white, Color.fromARGB(255, 4, 54, 95)]), |
|
|
), |
|
|
), |
|
|
child: FutureBuilder<Map<String, List<Product>>>( |
|
|
child: FutureBuilder<Map<String, List<Product>>>( |
|
|
future: productsFuture, |
|
|
future: productsFuture, |
|
|
builder: (context, snapshot) { |
|
|
builder: (context, snapshot) { |
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
return const Center( |
|
|
return const Center( |
|
|
child: CircularProgressIndicator( |
|
|
child: CircularProgressIndicator( |
|
|
valueColor: AlwaysStoppedAnimation<Color>( |
|
|
valueColor: AlwaysStoppedAnimation<Color>( |
|
|
Color.fromARGB(255, 4, 54, 95),), |
|
|
Color.fromARGB(255, 4, 54, 95), |
|
|
)); |
|
|
), |
|
|
|
|
|
)); |
|
|
} else if (snapshot.hasError) { |
|
|
} else if (snapshot.hasError) { |
|
|
return const Center( |
|
|
return const Center( |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
children: [ |
|
|
children: [ |
|
|
Icon(Icons.error, color: Colors.red, size: 48), |
|
|
Icon(Icons.error, color: Colors.red, size: 48), |
|
|
SizedBox(height: 16), |
|
|
SizedBox(height: 16), |
|
|
Text("Erreur de chargement des produits", |
|
|
Text("Erreur de chargement des produits", |
|
|
style: TextStyle(fontSize: 16, color: Colors.white)), |
|
|
style: TextStyle(fontSize: 16, color: Colors.white)), |
|
|
], |
|
|
], |
|
|
)); |
|
|
)); |
|
|
} else if (snapshot.hasData) { |
|
|
} else if (snapshot.hasData) { |
|
|
final productsByCategory = snapshot.data!; |
|
|
final productsByCategory = snapshot.data!; |
|
|
final categories = productsByCategory.keys.toList(); |
|
|
final categories = productsByCategory.keys.toList(); |
|
|
@ -233,15 +233,13 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
Expanded( |
|
|
Expanded( |
|
|
flex: 3, |
|
|
flex: 3, |
|
|
child: Container( |
|
|
child: Container( |
|
|
padding:const EdgeInsets.all(8), |
|
|
padding: const EdgeInsets.all(8), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
|
|
|
|
|
|
color: Colors.white.withOpacity(0.9), |
|
|
color: Colors.white.withOpacity(0.9), |
|
|
borderRadius: const BorderRadius.only( |
|
|
borderRadius: const BorderRadius.only( |
|
|
topRight: Radius.circular(20), |
|
|
topRight: Radius.circular(20), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
|
|
|
), |
|
|
|
|
|
child: ListView.builder( |
|
|
child: ListView.builder( |
|
|
itemCount: categories.length, |
|
|
itemCount: categories.length, |
|
|
itemBuilder: (context, index) { |
|
|
itemBuilder: (context, index) { |
|
|
@ -252,8 +250,9 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
children: [ |
|
|
children: [ |
|
|
Container( |
|
|
Container( |
|
|
margin: const EdgeInsets.symmetric(vertical: 8), |
|
|
margin: |
|
|
padding:const EdgeInsets.all(12), |
|
|
const EdgeInsets.symmetric(vertical: 8), |
|
|
|
|
|
padding: const EdgeInsets.all(12), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Color.fromARGB(255, 4, 54, 95), |
|
|
color: Color.fromARGB(255, 4, 54, 95), |
|
|
borderRadius: BorderRadius.circular(12), |
|
|
borderRadius: BorderRadius.circular(12), |
|
|
@ -261,7 +260,8 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.1), |
|
|
color: Colors.black.withOpacity(0.1), |
|
|
blurRadius: 4, |
|
|
blurRadius: 4, |
|
|
offset: Offset(0, 2),) |
|
|
offset: Offset(0, 2), |
|
|
|
|
|
) |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
child: Center( |
|
|
child: Center( |
|
|
@ -300,17 +300,16 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
); |
|
|
); |
|
|
}, |
|
|
}, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
|
|
|
// Section panier |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Section panier |
|
|
), |
|
|
), |
|
|
Expanded(flex: 1, |
|
|
Expanded( |
|
|
|
|
|
flex: 1, |
|
|
child: Container( |
|
|
child: Container( |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.grey[200], |
|
|
color: Colors.grey[200], |
|
|
borderRadius:const BorderRadius.only( |
|
|
borderRadius: const BorderRadius.only( |
|
|
topLeft: Radius.circular(20), |
|
|
topLeft: Radius.circular(20), |
|
|
), |
|
|
), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
@ -331,7 +330,7 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
color: Color.fromARGB(255, 4, 54, 95), |
|
|
color: Color.fromARGB(255, 4, 54, 95), |
|
|
borderRadius: BorderRadius.circular(12), |
|
|
borderRadius: BorderRadius.circular(12), |
|
|
), |
|
|
), |
|
|
child:const Text( |
|
|
child: const Text( |
|
|
'Panier', |
|
|
'Panier', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 20, |
|
|
fontSize: 20, |
|
|
@ -348,16 +347,17 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
child: selectedProducts.isEmpty |
|
|
child: selectedProducts.isEmpty |
|
|
? const Center( |
|
|
? const Center( |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: |
|
|
|
|
|
MainAxisAlignment.center, |
|
|
children: [ |
|
|
children: [ |
|
|
Icon(Icons.shopping_cart, |
|
|
Icon(Icons.shopping_cart, |
|
|
size: 48, color: Colors.grey), |
|
|
size: 48, color: Colors.grey), |
|
|
SizedBox(height: 16), |
|
|
SizedBox(height: 16), |
|
|
Text( |
|
|
Text( |
|
|
"Votre panier est vide", |
|
|
"Votre panier est vide", |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16, |
|
|
fontSize: 16, |
|
|
color: Colors.grey), |
|
|
color: Colors.grey), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -365,39 +365,49 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
: ListView.builder( |
|
|
: ListView.builder( |
|
|
itemCount: selectedProducts.length, |
|
|
itemCount: selectedProducts.length, |
|
|
itemBuilder: (context, index) { |
|
|
itemBuilder: (context, index) { |
|
|
final cartItem = selectedProducts[index]; |
|
|
final cartItem = |
|
|
|
|
|
selectedProducts[index]; |
|
|
return Card( |
|
|
return Card( |
|
|
margin: EdgeInsets.symmetric(vertical: 4), |
|
|
margin: |
|
|
|
|
|
EdgeInsets.symmetric(vertical: 4), |
|
|
shape: RoundedRectangleBorder( |
|
|
shape: RoundedRectangleBorder( |
|
|
borderRadius: BorderRadius.circular(10), |
|
|
borderRadius: |
|
|
|
|
|
BorderRadius.circular(10), |
|
|
), |
|
|
), |
|
|
elevation: 2, |
|
|
elevation: 2, |
|
|
child: ListTile( |
|
|
child: ListTile( |
|
|
contentPadding: EdgeInsets.symmetric( |
|
|
contentPadding: |
|
|
horizontal: 12, vertical: 4), |
|
|
EdgeInsets.symmetric( |
|
|
leading: Icon(Icons.shopping_basket, |
|
|
horizontal: 12, |
|
|
color: Color.fromARGB(255, 4, 54, 95),), |
|
|
vertical: 4), |
|
|
|
|
|
leading: Icon( |
|
|
|
|
|
Icons.shopping_basket, |
|
|
|
|
|
color: Color.fromARGB( |
|
|
|
|
|
255, 4, 54, 95), |
|
|
|
|
|
), |
|
|
title: Text( |
|
|
title: Text( |
|
|
cartItem.product.name, |
|
|
cartItem.product.name, |
|
|
style: const TextStyle( |
|
|
style: const TextStyle( |
|
|
fontWeight: FontWeight.bold), |
|
|
fontWeight: FontWeight.bold), |
|
|
), |
|
|
), |
|
|
subtitle: Text( |
|
|
subtitle: Text( |
|
|
'${NumberFormat('#,##0').format(cartItem.product.price)} FCFA x ${cartItem.quantity}', |
|
|
'${NumberFormat('#,##0').format(cartItem.product.price)} MGA x ${cartItem.quantity}', |
|
|
style:const TextStyle(fontSize: 14), |
|
|
style: |
|
|
|
|
|
const TextStyle(fontSize: 14), |
|
|
), |
|
|
), |
|
|
trailing: Row( |
|
|
trailing: Row( |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
children: [ |
|
|
children: [ |
|
|
Text( |
|
|
Text( |
|
|
'${NumberFormat('#,##0').format(cartItem.product.price * cartItem.quantity)}', |
|
|
'${NumberFormat('#,##0').format(cartItem.product.price * cartItem.quantity)}', |
|
|
style:const TextStyle( |
|
|
style: const TextStyle( |
|
|
fontWeight: FontWeight.bold), |
|
|
fontWeight: |
|
|
|
|
|
FontWeight.bold), |
|
|
), |
|
|
), |
|
|
const SizedBox(width: 8), |
|
|
const SizedBox(width: 8), |
|
|
IconButton( |
|
|
IconButton( |
|
|
icon: const Icon(Icons.delete, |
|
|
icon: const Icon(Icons.delete, |
|
|
color: Colors.red), |
|
|
color: Colors.red), |
|
|
onPressed: () { |
|
|
onPressed: () { |
|
|
setState(() { |
|
|
setState(() { |
|
|
selectedProducts |
|
|
selectedProducts |
|
|
@ -430,18 +440,20 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
child: Column( |
|
|
child: Column( |
|
|
children: [ |
|
|
children: [ |
|
|
Row( |
|
|
Row( |
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
mainAxisAlignment: |
|
|
|
|
|
MainAxisAlignment.spaceBetween, |
|
|
children: [ |
|
|
children: [ |
|
|
const Text('Total:', |
|
|
const Text('Total:', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16, |
|
|
fontSize: 16, |
|
|
fontWeight: FontWeight.bold)), |
|
|
fontWeight: FontWeight.bold)), |
|
|
Text( |
|
|
Text( |
|
|
'${NumberFormat('#,##0.00').format(calculateTotalPrice())} FCFA', |
|
|
'${NumberFormat('#,##0.00').format(calculateTotalPrice())} FCFA', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 18, |
|
|
fontSize: 18, |
|
|
fontWeight: FontWeight.bold, |
|
|
fontWeight: FontWeight.bold, |
|
|
color: Color.fromARGB(255, 4, 54, 95),), |
|
|
color: Color.fromARGB(255, 4, 54, 95), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -460,7 +472,8 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
), |
|
|
), |
|
|
onChanged: (value) { |
|
|
onChanged: (value) { |
|
|
setState(() { |
|
|
setState(() { |
|
|
amountPaid = double.tryParse(value) ?? 0; |
|
|
amountPaid = |
|
|
|
|
|
double.tryParse(value) ?? 0; |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
), |
|
|
), |
|
|
@ -468,14 +481,15 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
ElevatedButton.icon( |
|
|
ElevatedButton.icon( |
|
|
style: ElevatedButton.styleFrom( |
|
|
style: ElevatedButton.styleFrom( |
|
|
backgroundColor: Colors.green, |
|
|
backgroundColor: Colors.green, |
|
|
padding: EdgeInsets.symmetric(vertical: 16), |
|
|
padding: |
|
|
|
|
|
EdgeInsets.symmetric(vertical: 16), |
|
|
shape: RoundedRectangleBorder( |
|
|
shape: RoundedRectangleBorder( |
|
|
borderRadius: BorderRadius.circular(10), |
|
|
borderRadius: BorderRadius.circular(10), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
onPressed: saveOrderToDatabase, |
|
|
onPressed: saveOrderToDatabase, |
|
|
icon:const Icon(Icons.check_circle), |
|
|
icon: const Icon(Icons.check_circle), |
|
|
label:const Text( |
|
|
label: const Text( |
|
|
'Valider la commande', |
|
|
'Valider la commande', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16, |
|
|
fontSize: 16, |
|
|
@ -488,13 +502,14 @@ class _AccueilPageState extends State<AccueilPage> { |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
),) |
|
|
), |
|
|
|
|
|
) |
|
|
], |
|
|
], |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
return const Center( |
|
|
return const Center( |
|
|
child: Text("Aucun produit disponible", |
|
|
child: Text("Aucun produit disponible", |
|
|
style: TextStyle(color: Colors.white)), |
|
|
style: TextStyle(color: Colors.white)), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|