Compare commits
2 Commits
f9b6be7104
...
12f9fd063a
| Author | SHA1 | Date | |
|---|---|---|---|
| 12f9fd063a | |||
| c71f663346 |
@ -53,7 +53,7 @@ class PanierPage extends StatelessWidget {
|
|||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text('${product.price.toStringAsFixed(2)} fcfa'),
|
Text('${product.price.toStringAsFixed(2)} MGA'),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text('x $quantity'),
|
Text('x $quantity'),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@ -78,7 +78,7 @@ class PanierPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Total: ${calculateTotalPrice().toStringAsFixed(2)} fcfa',
|
'Total: ${calculateTotalPrice().toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import '../Components/app_bar.dart';
|
|||||||
import '../Models/produit.dart';
|
import '../Models/produit.dart';
|
||||||
import '../Services/productDatabase.dart';
|
import '../Services/productDatabase.dart';
|
||||||
|
|
||||||
|
|
||||||
class ProductManagementPage extends StatefulWidget {
|
class ProductManagementPage extends StatefulWidget {
|
||||||
const ProductManagementPage({super.key});
|
const ProductManagementPage({super.key});
|
||||||
|
|
||||||
@ -32,7 +31,13 @@ class _ProductManagementPageState extends State<ProductManagementPage> {
|
|||||||
|
|
||||||
// Catégories prédéfinies pour l'ajout de produits
|
// Catégories prédéfinies pour l'ajout de produits
|
||||||
final List<String> _predefinedCategories = [
|
final List<String> _predefinedCategories = [
|
||||||
'Sucré', 'Salé', 'Jus', 'Gateaux', 'Snacks', 'Boissons', 'Non catégorisé'
|
'Sucré',
|
||||||
|
'Salé',
|
||||||
|
'Jus',
|
||||||
|
'Gateaux',
|
||||||
|
'Snacks',
|
||||||
|
'Boissons',
|
||||||
|
'Non catégorisé'
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -48,19 +53,14 @@ class _ProductManagementPageState extends State<ProductManagementPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======================================================================================================
|
//======================================================================================================
|
||||||
// Ajoutez ces variables à la classe _ProductManagementPageState
|
// Ajoutez ces variables à la classe _ProductManagementPageState
|
||||||
bool _isImporting = false;
|
bool _isImporting = false;
|
||||||
double _importProgress = 0.0;
|
double _importProgress = 0.0;
|
||||||
String _importStatusText = '';
|
String _importStatusText = '';
|
||||||
|
|
||||||
// Ajoutez ces méthodes à la classe _ProductManagementPageState
|
// Ajoutez ces méthodes à la classe _ProductManagementPageState
|
||||||
|
|
||||||
void _resetImportState() {
|
void _resetImportState() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isImporting = false;
|
_isImporting = false;
|
||||||
@ -195,6 +195,137 @@ Future<void> _importFromExcel() async {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isImporting = false;
|
||||||
|
_importProgress = 0.0;
|
||||||
|
_importStatusText = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showExcelCompatibilityError() {
|
||||||
|
Get.dialog(
|
||||||
|
AlertDialog(
|
||||||
|
title: const Text('Fichier Excel incompatible'),
|
||||||
|
content: const Text(
|
||||||
|
'Ce fichier Excel contient des éléments qui ne sont pas compatibles avec notre système d\'importation.\n\n'
|
||||||
|
'Solutions recommandées :\n'
|
||||||
|
'• Téléchargez notre modèle Excel et copiez-y vos données\n'
|
||||||
|
'• Ou exportez votre fichier en format simple: Classeur Excel .xlsx depuis Excel\n'
|
||||||
|
'• Ou créez un nouveau fichier Excel simple sans formatage complexe'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
child: const Text('Annuler'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
_downloadExcelTemplate();
|
||||||
|
},
|
||||||
|
child: const Text('Télécharger modèle'),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _downloadExcelTemplate() async {
|
||||||
|
try {
|
||||||
|
final excel = Excel.createExcel();
|
||||||
|
excel.delete('Sheet1');
|
||||||
|
excel.copy('Sheet1', 'Produits');
|
||||||
|
excel.delete('Sheet1');
|
||||||
|
|
||||||
|
final sheet = excel['Produits'];
|
||||||
|
|
||||||
|
final headers = ['Nom', 'Prix', 'Catégorie', 'Description', 'Stock'];
|
||||||
|
for (int i = 0; i < headers.length; i++) {
|
||||||
|
final cell =
|
||||||
|
sheet.cell(CellIndex.indexByColumnRow(columnIndex: i, rowIndex: 0));
|
||||||
|
cell.value = headers[i];
|
||||||
|
cell.cellStyle = CellStyle(
|
||||||
|
bold: true,
|
||||||
|
backgroundColorHex: '#E8F4FD',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final examples = [
|
||||||
|
['Croissant', '1.50', 'Sucré', 'Délicieux croissant beurré', '20'],
|
||||||
|
['Sandwich jambon', '4.00', 'Salé', 'Sandwich fait maison', '15'],
|
||||||
|
['Jus d\'orange', '2.50', 'Jus', 'Jus d\'orange frais', '30'],
|
||||||
|
[
|
||||||
|
'Gâteau chocolat',
|
||||||
|
'18.00',
|
||||||
|
'Gateaux',
|
||||||
|
'Gâteau au chocolat portion 8 personnes',
|
||||||
|
'5'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (int row = 0; row < examples.length; row++) {
|
||||||
|
for (int col = 0; col < examples[row].length; col++) {
|
||||||
|
final cell = sheet.cell(
|
||||||
|
CellIndex.indexByColumnRow(columnIndex: col, rowIndex: row + 1));
|
||||||
|
cell.value = examples[row][col];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sheet.setColWidth(0, 20);
|
||||||
|
sheet.setColWidth(1, 10);
|
||||||
|
sheet.setColWidth(2, 15);
|
||||||
|
sheet.setColWidth(3, 30);
|
||||||
|
sheet.setColWidth(4, 10);
|
||||||
|
|
||||||
|
final bytes = excel.save();
|
||||||
|
|
||||||
|
if (bytes == null) {
|
||||||
|
Get.snackbar('Erreur', 'Impossible de créer le fichier modèle');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String? outputFile = await FilePicker.platform.saveFile(
|
||||||
|
fileName: 'modele_import_produits.xlsx',
|
||||||
|
allowedExtensions: ['xlsx'],
|
||||||
|
type: FileType.custom,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (outputFile != null) {
|
||||||
|
try {
|
||||||
|
await File(outputFile).writeAsBytes(bytes);
|
||||||
|
Get.snackbar(
|
||||||
|
'Succès',
|
||||||
|
'Modèle téléchargé avec succès\n$outputFile',
|
||||||
|
duration: const Duration(seconds: 4),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
colorText: Colors.white,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
Get.snackbar('Erreur', 'Impossible d\'écrire le fichier: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Get.snackbar('Erreur', 'Erreur lors de la création du modèle: $e');
|
||||||
|
debugPrint('Erreur création modèle Excel: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _importFromExcel() async {
|
||||||
|
try {
|
||||||
|
final result = await FilePicker.platform.pickFiles(
|
||||||
|
type: FileType.custom,
|
||||||
|
allowedExtensions: ['xlsx', 'xls', 'csv'],
|
||||||
|
allowMultiple: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == null || result.files.isEmpty) {
|
||||||
|
Get.snackbar('Annulé', 'Aucun fichier sélectionné');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isImporting = true;
|
_isImporting = true;
|
||||||
_importProgress = 0.0;
|
_importProgress = 0.0;
|
||||||
@ -241,11 +372,13 @@ Future<void> _importFromExcel() async {
|
|||||||
_resetImportState();
|
_resetImportState();
|
||||||
debugPrint('Erreur décodage Excel: $e');
|
debugPrint('Erreur décodage Excel: $e');
|
||||||
|
|
||||||
if (e.toString().contains('styles') || e.toString().contains('Damaged')) {
|
if (e.toString().contains('styles') ||
|
||||||
|
e.toString().contains('Damaged')) {
|
||||||
_showExcelCompatibilityError();
|
_showExcelCompatibilityError();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Get.snackbar('Erreur', 'Impossible de lire le fichier Excel. Format non supporté.');
|
Get.snackbar('Erreur',
|
||||||
|
'Impossible de lire le fichier Excel. Format non supporté.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,10 +483,12 @@ Future<void> _importFromExcel() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String reference = _generateUniqueReference();
|
String reference = _generateUniqueReference();
|
||||||
var existingProduct = await _productDatabase.getProductByReference(reference);
|
var existingProduct =
|
||||||
|
await _productDatabase.getProductByReference(reference);
|
||||||
while (existingProduct != null) {
|
while (existingProduct != null) {
|
||||||
reference = _generateUniqueReference();
|
reference = _generateUniqueReference();
|
||||||
existingProduct = await _productDatabase.getProductByReference(reference);
|
existingProduct =
|
||||||
|
await _productDatabase.getProductByReference(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
final product = Product(
|
final product = Product(
|
||||||
@ -376,7 +511,6 @@ Future<void> _importFromExcel() async {
|
|||||||
|
|
||||||
await _productDatabase.createProduct(product);
|
await _productDatabase.createProduct(product);
|
||||||
successCount++;
|
successCount++;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
errorMessages.add('Ligne ${i + 1}: Erreur de traitement - $e');
|
errorMessages.add('Ligne ${i + 1}: Erreur de traitement - $e');
|
||||||
@ -412,16 +546,15 @@ Future<void> _importFromExcel() async {
|
|||||||
|
|
||||||
// Recharger la liste des produits après importation
|
// Recharger la liste des produits après importation
|
||||||
_loadProducts();
|
_loadProducts();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_resetImportState();
|
_resetImportState();
|
||||||
Get.snackbar('Erreur', 'Erreur lors de l\'importation Excel: $e');
|
Get.snackbar('Erreur', 'Erreur lors de l\'importation Excel: $e');
|
||||||
debugPrint('Erreur générale import Excel: $e');
|
debugPrint('Erreur générale import Excel: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajoutez ce widget dans votre méthode build, par exemple dans la partie supérieure
|
// Ajoutez ce widget dans votre méthode build, par exemple dans la partie supérieure
|
||||||
Widget _buildImportProgressIndicator() {
|
Widget _buildImportProgressIndicator() {
|
||||||
if (!_isImporting) return const SizedBox.shrink();
|
if (!_isImporting) return const SizedBox.shrink();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
@ -468,7 +601,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================================================================
|
//=============================================================================================================================
|
||||||
Future<void> _loadProducts() async {
|
Future<void> _loadProducts() async {
|
||||||
setState(() => _isLoading = true);
|
setState(() => _isLoading = true);
|
||||||
@ -540,7 +674,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
final path = '${directory.path}/$reference.png';
|
final path = '${directory.path}/$reference.png';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final picData = await painter.toImageData(2048, format: ImageByteFormat.png);
|
final picData =
|
||||||
|
await painter.toImageData(2048, format: ImageByteFormat.png);
|
||||||
if (picData != null) {
|
if (picData != null) {
|
||||||
await File(path).writeAsBytes(picData.buffer.asUint8List());
|
await File(path).writeAsBytes(picData.buffer.asUint8List());
|
||||||
} else {
|
} else {
|
||||||
@ -560,7 +695,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
final descriptionController = TextEditingController();
|
final descriptionController = TextEditingController();
|
||||||
final imageController = TextEditingController();
|
final imageController = TextEditingController();
|
||||||
|
|
||||||
String selectedCategory = _predefinedCategories.last; // 'Non catégorisé' par défaut
|
String selectedCategory =
|
||||||
|
_predefinedCategories.last; // 'Non catégorisé' par défaut
|
||||||
File? pickedImage;
|
File? pickedImage;
|
||||||
String? qrPreviewData;
|
String? qrPreviewData;
|
||||||
String? currentReference;
|
String? currentReference;
|
||||||
@ -588,7 +724,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
color: Colors.green.shade100,
|
color: Colors.green.shade100,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Icon(Icons.add_shopping_cart, color: Colors.green.shade700),
|
child:
|
||||||
|
Icon(Icons.add_shopping_cart, color: Colors.green.shade700),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
const Text('Ajouter un produit'),
|
const Text('Ajouter un produit'),
|
||||||
@ -614,11 +751,13 @@ Widget _buildImportProgressIndicator() {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.info, color: Colors.red.shade600, size: 16),
|
Icon(Icons.info,
|
||||||
|
color: Colors.red.shade600, size: 16),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
const Text(
|
const Text(
|
||||||
'Les champs marqués d\'un * sont obligatoires',
|
'Les champs marqués d\'un * sont obligatoires',
|
||||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
|
style: TextStyle(
|
||||||
|
fontSize: 12, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -649,9 +788,10 @@ Widget _buildImportProgressIndicator() {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: priceController,
|
controller: priceController,
|
||||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
keyboardType: const TextInputType.numberWithOptions(
|
||||||
|
decimal: true),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Prix (FCFA) *',
|
labelText: 'Prix (MGA) *',
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
prefixIcon: const Icon(Icons.attach_money),
|
prefixIcon: const Icon(Icons.attach_money),
|
||||||
filled: true,
|
filled: true,
|
||||||
@ -680,8 +820,10 @@ Widget _buildImportProgressIndicator() {
|
|||||||
// Catégorie
|
// Catégorie
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: selectedCategory,
|
value: selectedCategory,
|
||||||
items: _predefinedCategories.map((category) =>
|
items: _predefinedCategories
|
||||||
DropdownMenuItem(value: category, child: Text(category))).toList(),
|
.map((category) => DropdownMenuItem(
|
||||||
|
value: category, child: Text(category)))
|
||||||
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setDialogState(() => selectedCategory = value!);
|
setDialogState(() => selectedCategory = value!);
|
||||||
},
|
},
|
||||||
@ -750,10 +892,13 @@ Widget _buildImportProgressIndicator() {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final result = await FilePicker.platform.pickFiles(type: FileType.image);
|
final result = await FilePicker.platform
|
||||||
if (result != null && result.files.single.path != null) {
|
.pickFiles(type: FileType.image);
|
||||||
|
if (result != null &&
|
||||||
|
result.files.single.path != null) {
|
||||||
setDialogState(() {
|
setDialogState(() {
|
||||||
pickedImage = File(result.files.single.path!);
|
pickedImage =
|
||||||
|
File(result.files.single.path!);
|
||||||
imageController.text = pickedImage!.path;
|
imageController.text = pickedImage!.path;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -776,11 +921,13 @@ Widget _buildImportProgressIndicator() {
|
|||||||
width: 100,
|
width: 100,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: Colors.grey.shade300),
|
border:
|
||||||
|
Border.all(color: Colors.grey.shade300),
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Image.file(pickedImage!, fit: BoxFit.cover),
|
child: Image.file(pickedImage!,
|
||||||
|
fit: BoxFit.cover),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -802,7 +949,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.qr_code_2, color: Colors.green.shade700),
|
Icon(Icons.qr_code_2,
|
||||||
|
color: Colors.green.shade700),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Aperçu du QR Code',
|
'Aperçu du QR Code',
|
||||||
@ -832,7 +980,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Réf: $currentReference',
|
'Réf: $currentReference',
|
||||||
style: const TextStyle(fontSize: 10, color: Colors.grey),
|
style: const TextStyle(
|
||||||
|
fontSize: 10, color: Colors.grey),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -861,12 +1010,15 @@ Widget _buildImportProgressIndicator() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Générer une référence unique et vérifier son unicité
|
// Générer une référence unique et vérifier son unicité
|
||||||
String finalReference = currentReference ?? _generateUniqueReference();
|
String finalReference =
|
||||||
var existingProduct = await _productDatabase.getProductByReference(finalReference);
|
currentReference ?? _generateUniqueReference();
|
||||||
|
var existingProduct = await _productDatabase
|
||||||
|
.getProductByReference(finalReference);
|
||||||
|
|
||||||
while (existingProduct != null) {
|
while (existingProduct != null) {
|
||||||
finalReference = _generateUniqueReference();
|
finalReference = _generateUniqueReference();
|
||||||
existingProduct = await _productDatabase.getProductByReference(finalReference);
|
existingProduct = await _productDatabase
|
||||||
|
.getProductByReference(finalReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Générer le QR code
|
// Générer le QR code
|
||||||
@ -997,9 +1149,12 @@ Widget _buildImportProgressIndicator() {
|
|||||||
|
|
||||||
void _editProduct(Product product) {
|
void _editProduct(Product product) {
|
||||||
final nameController = TextEditingController(text: product.name);
|
final nameController = TextEditingController(text: product.name);
|
||||||
final priceController = TextEditingController(text: product.price.toString());
|
final priceController =
|
||||||
final stockController = TextEditingController(text: product.stock.toString());
|
TextEditingController(text: product.price.toString());
|
||||||
final descriptionController = TextEditingController(text: product.description ?? '');
|
final stockController =
|
||||||
|
TextEditingController(text: product.stock.toString());
|
||||||
|
final descriptionController =
|
||||||
|
TextEditingController(text: product.description ?? '');
|
||||||
final imageController = TextEditingController(text: product.image);
|
final imageController = TextEditingController(text: product.image);
|
||||||
|
|
||||||
String selectedCategory = product.category;
|
String selectedCategory = product.category;
|
||||||
@ -1022,17 +1177,16 @@ Widget _buildImportProgressIndicator() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: priceController,
|
controller: priceController,
|
||||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
keyboardType:
|
||||||
|
const TextInputType.numberWithOptions(decimal: true),
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Prix*',
|
labelText: 'Prix*',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: stockController,
|
controller: stockController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
@ -1042,7 +1196,6 @@ Widget _buildImportProgressIndicator() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
StatefulBuilder(
|
StatefulBuilder(
|
||||||
builder: (context, setDialogState) {
|
builder: (context, setDialogState) {
|
||||||
return Column(
|
return Column(
|
||||||
@ -1062,11 +1215,14 @@ Widget _buildImportProgressIndicator() {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final result = await FilePicker.platform.pickFiles(type: FileType.image);
|
final result = await FilePicker.platform
|
||||||
if (result != null && result.files.single.path != null) {
|
.pickFiles(type: FileType.image);
|
||||||
|
if (result != null &&
|
||||||
|
result.files.single.path != null) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
setDialogState(() {
|
setDialogState(() {
|
||||||
pickedImage = File(result.files.single.path!);
|
pickedImage =
|
||||||
|
File(result.files.single.path!);
|
||||||
imageController.text = pickedImage!.path;
|
imageController.text = pickedImage!.path;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1077,7 +1233,6 @@ Widget _buildImportProgressIndicator() {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
if (pickedImage != null || product.image!.isNotEmpty)
|
if (pickedImage != null || product.image!.isNotEmpty)
|
||||||
Container(
|
Container(
|
||||||
height: 100,
|
height: 100,
|
||||||
@ -1091,16 +1246,19 @@ Widget _buildImportProgressIndicator() {
|
|||||||
child: pickedImage != null
|
child: pickedImage != null
|
||||||
? Image.file(pickedImage!, fit: BoxFit.cover)
|
? Image.file(pickedImage!, fit: BoxFit.cover)
|
||||||
: (product.image!.isNotEmpty
|
: (product.image!.isNotEmpty
|
||||||
? Image.file(File(product.image!), fit: BoxFit.cover)
|
? Image.file(File(product.image!),
|
||||||
|
fit: BoxFit.cover)
|
||||||
: const Icon(Icons.image, size: 50)),
|
: const Icon(Icons.image, size: 50)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: selectedCategory,
|
value: selectedCategory,
|
||||||
items: _categories.skip(1).map((category) =>
|
items: _categories
|
||||||
DropdownMenuItem(value: category, child: Text(category))).toList(),
|
.skip(1)
|
||||||
|
.map((category) => DropdownMenuItem(
|
||||||
|
value: category, child: Text(category)))
|
||||||
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
setDialogState(() => selectedCategory = value!);
|
setDialogState(() => selectedCategory = value!);
|
||||||
@ -1112,7 +1270,6 @@ Widget _buildImportProgressIndicator() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: descriptionController,
|
controller: descriptionController,
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
@ -1206,7 +1363,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
Get.snackbar('Erreur', 'Suppression échouée: $e');
|
Get.snackbar('Erreur', 'Suppression échouée: $e');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('Supprimer', style: TextStyle(color: Colors.white)),
|
child:
|
||||||
|
const Text('Supprimer', style: TextStyle(color: Colors.white)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -1268,7 +1426,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.blue.shade100,
|
color: Colors.blue.shade100,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@ -1417,8 +1576,10 @@ Widget _buildImportProgressIndicator() {
|
|||||||
),
|
),
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
value: _selectedCategory,
|
value: _selectedCategory,
|
||||||
items: _categories.map((category) =>
|
items: _categories
|
||||||
DropdownMenuItem(value: category, child: Text(category))).toList(),
|
.map((category) => DropdownMenuItem(
|
||||||
|
value: category, child: Text(category)))
|
||||||
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedCategory = value!;
|
_selectedCategory = value!;
|
||||||
@ -1448,7 +1609,8 @@ Widget _buildImportProgressIndicator() {
|
|||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_searchController.text.isNotEmpty || _selectedCategory != 'Tous')
|
if (_searchController.text.isNotEmpty ||
|
||||||
|
_selectedCategory != 'Tous')
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class _BilanMoisState extends State<BilanMois> {
|
|||||||
children: [
|
children: [
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
title: 'Chiffre réalisé',
|
title: 'Chiffre réalisé',
|
||||||
value: '${controller.totalSum.value.toStringAsFixed(2)} fcfa',
|
value: '${controller.totalSum.value.toStringAsFixed(2)} MGA',
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
icon: Icons.monetization_on,
|
icon: Icons.monetization_on,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class HistoryDetailPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Total Somme: $totalSum fcfa',
|
'Total Somme: $totalSum MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18.0,
|
fontSize: 18.0,
|
||||||
fontWeight: FontWeight.bold,
|
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}'),
|
trailing: Text('Date: ${order.dateTime}'),
|
||||||
leading: Text('vendeur: ${order.user}'),
|
leading: Text('vendeur: ${order.user}'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|||||||
@ -86,11 +86,11 @@ class TicketPage extends StatelessWidget {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: '${product.price.toStringAsFixed(2)} fcfa',
|
text: '${product.price.toStringAsFixed(2)} MGA',
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: '${productTotal.toStringAsFixed(2)} fcfa',
|
text: '${productTotal.toStringAsFixed(2)} MGA',
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@ -104,7 +104,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
styles: const PosStyles(align: PosAlign.left, bold: true),
|
styles: const PosStyles(align: PosAlign.left, bold: true),
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: '${totalCartPrice.toStringAsFixed(2)} fcfa',
|
text: '${totalCartPrice.toStringAsFixed(2)} MGA',
|
||||||
width: 1,
|
width: 1,
|
||||||
styles: const PosStyles(align: PosAlign.left, bold: true),
|
styles: const PosStyles(align: PosAlign.left, bold: true),
|
||||||
),
|
),
|
||||||
@ -116,7 +116,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
styles: const PosStyles(align: PosAlign.left),
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: '${amountPaid.toStringAsFixed(2)} fcfa',
|
text: '${amountPaid.toStringAsFixed(2)} MGA',
|
||||||
width: 1,
|
width: 1,
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
),
|
),
|
||||||
@ -128,7 +128,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
styles: const PosStyles(align: PosAlign.left),
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: '${(amountPaid - totalCartPrice).toStringAsFixed(2)} fcfa',
|
text: '${(amountPaid - totalCartPrice).toStringAsFixed(2)} MGA',
|
||||||
width: 1,
|
width: 1,
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
),
|
),
|
||||||
@ -179,8 +179,8 @@ class TicketPage extends StatelessWidget {
|
|||||||
return [
|
return [
|
||||||
product.name,
|
product.name,
|
||||||
quantity.toString(),
|
quantity.toString(),
|
||||||
'${product.price.toStringAsFixed(2)} fcfa',
|
'${product.price.toStringAsFixed(2)} MGA',
|
||||||
'${productTotal.toStringAsFixed(2)} fcfa',
|
'${productTotal.toStringAsFixed(2)} MGA',
|
||||||
];
|
];
|
||||||
}).toList(),
|
}).toList(),
|
||||||
],
|
],
|
||||||
@ -194,7 +194,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
pw.Text('Total :',
|
pw.Text('Total :',
|
||||||
style: pw.TextStyle(
|
style: pw.TextStyle(
|
||||||
fontSize: 18, fontWeight: pw.FontWeight.bold)),
|
fontSize: 18, fontWeight: pw.FontWeight.bold)),
|
||||||
pw.Text('${totalCartPrice.toStringAsFixed(2)} fcfa',
|
pw.Text('${totalCartPrice.toStringAsFixed(2)} MGA',
|
||||||
style: pw.TextStyle(
|
style: pw.TextStyle(
|
||||||
fontSize: 18, fontWeight: pw.FontWeight.bold)),
|
fontSize: 18, fontWeight: pw.FontWeight.bold)),
|
||||||
],
|
],
|
||||||
@ -207,7 +207,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
pw.Text('Somme remise :',
|
pw.Text('Somme remise :',
|
||||||
style: const pw.TextStyle(fontSize: 16)),
|
style: const pw.TextStyle(fontSize: 16)),
|
||||||
pw.Text('${amountPaid.toStringAsFixed(2)} fcfa',
|
pw.Text('${amountPaid.toStringAsFixed(2)} MGA',
|
||||||
style: const pw.TextStyle(fontSize: 16)),
|
style: const pw.TextStyle(fontSize: 16)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -218,7 +218,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
pw.Text('Somme rendue :',
|
pw.Text('Somme rendue :',
|
||||||
style: const pw.TextStyle(fontSize: 16)),
|
style: const pw.TextStyle(fontSize: 16)),
|
||||||
pw.Text(
|
pw.Text(
|
||||||
'${(amountPaid - totalCartPrice).toStringAsFixed(2)} fcfa',
|
'${(amountPaid - totalCartPrice).toStringAsFixed(2)} MGA',
|
||||||
style: const pw.TextStyle(fontSize: 16)),
|
style: const pw.TextStyle(fontSize: 16)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -387,14 +387,14 @@ class TicketPage extends StatelessWidget {
|
|||||||
TableCell(
|
TableCell(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${product.price.toStringAsFixed(2)} fcfa',
|
'${product.price.toStringAsFixed(2)} MGA',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TableCell(
|
TableCell(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${productTotal.toStringAsFixed(2)} fcfa',
|
'${productTotal.toStringAsFixed(2)} MGA',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -421,7 +421,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${totalOrderAmount.toStringAsFixed(2)} fcfa',
|
'${totalOrderAmount.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -446,7 +446,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${amountPaid.toStringAsFixed(2)} fcfa',
|
'${amountPaid.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
@ -464,7 +464,7 @@ class TicketPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${change.toStringAsFixed(2)} fcfa',
|
'${change.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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(),
|
||||||
@ -210,7 +209,8 @@ class _AccueilPageState extends State<AccueilPage> {
|
|||||||
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(
|
||||||
@ -233,14 +233,12 @@ 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,
|
||||||
@ -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(
|
||||||
@ -303,14 +303,13 @@ 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,7 +347,8 @@ 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),
|
||||||
@ -365,34 +365,44 @@ 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(
|
||||||
@ -430,7 +440,8 @@ 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(
|
||||||
@ -441,7 +452,8 @@ class _AccueilPageState extends State<AccueilPage> {
|
|||||||
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,7 +502,8 @@ class _AccueilPageState extends State<AccueilPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),)
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -12,14 +12,15 @@ void main() async {
|
|||||||
try {
|
try {
|
||||||
// Initialiser les bases de données une seule fois
|
// Initialiser les bases de données une seule fois
|
||||||
// await AppDatabase.instance.deleteDatabaseFile();
|
// await AppDatabase.instance.deleteDatabaseFile();
|
||||||
//await ProductDatabase.instance.deleteDatabaseFile();
|
// await ProductDatabase.instance.deleteDatabaseFile();
|
||||||
|
|
||||||
await ProductDatabase.instance.initDatabase();
|
await ProductDatabase.instance.initDatabase();
|
||||||
await AppDatabase.instance.initDatabase();
|
await AppDatabase.instance.initDatabase();
|
||||||
|
|
||||||
// Afficher les informations de la base (pour debug)
|
// Afficher les informations de la base (pour debug)
|
||||||
await AppDatabase.instance.printDatabaseInfo();
|
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();
|
setupLogger();
|
||||||
|
|
||||||
runApp(const GetMaterialApp(
|
runApp(const GetMaterialApp(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user