Browse Source

FCFA to MGA

31052025_01
Stephane 6 months ago
parent
commit
c71f663346
  1. 4
      lib/Components/panier.dart
  2. 1145
      lib/Views/HandleProduct.dart
  3. 2
      lib/Views/bilanMois.dart
  4. 4
      lib/Views/listCommandeHistory.dart
  5. 30
      lib/Views/ticketPage.dart
  6. 147
      lib/accueil.dart
  7. 15
      lib/main.dart

4
lib/Components/panier.dart

@ -53,7 +53,7 @@ class PanierPage extends StatelessWidget {
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('${product.price.toStringAsFixed(2)} fcfa'),
Text('${product.price.toStringAsFixed(2)} MGA'),
const SizedBox(width: 8),
Text('x $quantity'),
const SizedBox(width: 8),
@ -78,7 +78,7 @@ class PanierPage extends StatelessWidget {
),
const SizedBox(height: 16),
Text(
'Total: ${calculateTotalPrice().toStringAsFixed(2)} fcfa',
'Total: ${calculateTotalPrice().toStringAsFixed(2)} MGA',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,

1145
lib/Views/HandleProduct.dart

File diff suppressed because it is too large

2
lib/Views/bilanMois.dart

@ -38,7 +38,7 @@ class _BilanMoisState extends State<BilanMois> {
children: [
_buildInfoCard(
title: 'Chiffre réalisé',
value: '${controller.totalSum.value.toStringAsFixed(2)} fcfa',
value: '${controller.totalSum.value.toStringAsFixed(2)} MGA',
color: Colors.green,
icon: Icons.monetization_on,
),

4
lib/Views/listCommandeHistory.dart

@ -112,7 +112,7 @@ class HistoryDetailPage extends StatelessWidget {
),
),
Text(
'Total Somme: $totalSum fcfa',
'Total Somme: $totalSum MGA',
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
@ -197,7 +197,7 @@ class HistoryDetailPage extends StatelessWidget {
),
],
),
subtitle: Text('Total: ${order.totalPrice} fcfa'),
subtitle: Text('Total: ${order.totalPrice} MGA'),
trailing: Text('Date: ${order.dateTime}'),
leading: Text('vendeur: ${order.user}'),
onTap: () {

30
lib/Views/ticketPage.dart

@ -86,11 +86,11 @@ class TicketPage extends StatelessWidget {
width: 1,
),
PosColumn(
text: '${product.price.toStringAsFixed(2)} fcfa',
text: '${product.price.toStringAsFixed(2)} MGA',
width: 1,
),
PosColumn(
text: '${productTotal.toStringAsFixed(2)} fcfa',
text: '${productTotal.toStringAsFixed(2)} MGA',
width: 1,
),
]);
@ -104,7 +104,7 @@ class TicketPage extends StatelessWidget {
styles: const PosStyles(align: PosAlign.left, bold: true),
),
PosColumn(
text: '${totalCartPrice.toStringAsFixed(2)} fcfa',
text: '${totalCartPrice.toStringAsFixed(2)} MGA',
width: 1,
styles: const PosStyles(align: PosAlign.left, bold: true),
),
@ -116,7 +116,7 @@ class TicketPage extends StatelessWidget {
styles: const PosStyles(align: PosAlign.left),
),
PosColumn(
text: '${amountPaid.toStringAsFixed(2)} fcfa',
text: '${amountPaid.toStringAsFixed(2)} MGA',
width: 1,
styles: const PosStyles(align: PosAlign.left),
),
@ -128,7 +128,7 @@ class TicketPage extends StatelessWidget {
styles: const PosStyles(align: PosAlign.left),
),
PosColumn(
text: '${(amountPaid - totalCartPrice).toStringAsFixed(2)} fcfa',
text: '${(amountPaid - totalCartPrice).toStringAsFixed(2)} MGA',
width: 1,
styles: const PosStyles(align: PosAlign.left),
),
@ -179,8 +179,8 @@ class TicketPage extends StatelessWidget {
return [
product.name,
quantity.toString(),
'${product.price.toStringAsFixed(2)} fcfa',
'${productTotal.toStringAsFixed(2)} fcfa',
'${product.price.toStringAsFixed(2)} MGA',
'${productTotal.toStringAsFixed(2)} MGA',
];
}).toList(),
],
@ -194,7 +194,7 @@ class TicketPage extends StatelessWidget {
pw.Text('Total :',
style: pw.TextStyle(
fontSize: 18, fontWeight: pw.FontWeight.bold)),
pw.Text('${totalCartPrice.toStringAsFixed(2)} fcfa',
pw.Text('${totalCartPrice.toStringAsFixed(2)} MGA',
style: pw.TextStyle(
fontSize: 18, fontWeight: pw.FontWeight.bold)),
],
@ -207,7 +207,7 @@ class TicketPage extends StatelessWidget {
children: [
pw.Text('Somme remise :',
style: const pw.TextStyle(fontSize: 16)),
pw.Text('${amountPaid.toStringAsFixed(2)} fcfa',
pw.Text('${amountPaid.toStringAsFixed(2)} MGA',
style: const pw.TextStyle(fontSize: 16)),
],
),
@ -218,7 +218,7 @@ class TicketPage extends StatelessWidget {
pw.Text('Somme rendue :',
style: const pw.TextStyle(fontSize: 16)),
pw.Text(
'${(amountPaid - totalCartPrice).toStringAsFixed(2)} fcfa',
'${(amountPaid - totalCartPrice).toStringAsFixed(2)} MGA',
style: const pw.TextStyle(fontSize: 16)),
],
),
@ -387,14 +387,14 @@ class TicketPage extends StatelessWidget {
TableCell(
child: Center(
child: Text(
'${product.price.toStringAsFixed(2)} fcfa',
'${product.price.toStringAsFixed(2)} MGA',
),
),
),
TableCell(
child: Center(
child: Text(
'${productTotal.toStringAsFixed(2)} fcfa',
'${productTotal.toStringAsFixed(2)} MGA',
),
),
),
@ -421,7 +421,7 @@ class TicketPage extends StatelessWidget {
),
),
Text(
'${totalOrderAmount.toStringAsFixed(2)} fcfa',
'${totalOrderAmount.toStringAsFixed(2)} MGA',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
@ -446,7 +446,7 @@ class TicketPage extends StatelessWidget {
),
),
Text(
'${amountPaid.toStringAsFixed(2)} fcfa',
'${amountPaid.toStringAsFixed(2)} MGA',
style: const TextStyle(
fontSize: 16,
),
@ -464,7 +464,7 @@ class TicketPage extends StatelessWidget {
),
),
Text(
'${change.toStringAsFixed(2)} fcfa',
'${change.toStringAsFixed(2)} MGA',
style: const TextStyle(
fontSize: 16,
),

147
lib/accueil.dart

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

15
lib/main.dart

@ -8,20 +8,21 @@ import 'package:logging/logging.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
// Initialiser les bases de données une seule fois
// await AppDatabase.instance.deleteDatabaseFile();
//await ProductDatabase.instance.deleteDatabaseFile();
// await AppDatabase.instance.deleteDatabaseFile();
// await ProductDatabase.instance.deleteDatabaseFile();
await ProductDatabase.instance.initDatabase();
await AppDatabase.instance.initDatabase();
// Afficher les informations de la base (pour debug)
await AppDatabase.instance.printDatabaseInfo();
Get.put(UserController()); // Ajoute ce code AVANT tout accès au UserController
Get.put(
UserController()); // Ajoute ce code AVANT tout accès au UserController
setupLogger();
runApp(const GetMaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp(),
@ -44,4 +45,4 @@ void setupLogger() {
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.time}: ${record.message}');
});
}
}

Loading…
Cancel
Save