diff --git a/lib/screens/product_list_screen.dart b/lib/screens/product_list_screen.dart index 142d4fb..ea23d8a 100644 --- a/lib/screens/product_list_screen.dart +++ b/lib/screens/product_list_screen.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import '../services/database_helper.dart'; import '../models/product.dart'; import 'add_edit_product_screen.dart'; @@ -77,11 +78,54 @@ class _ProductListScreenState extends State { ), child: ListTile( leading: CircleAvatar( - child: Text(product.quantity.toString()), + backgroundColor: Colors.grey[200], + backgroundImage: + product.imageUrl != null && + product.imageUrl!.startsWith('http') + ? NetworkImage(product.imageUrl!) + as ImageProvider? + : null, + child: + product.imageUrl == null || + !product.imageUrl!.startsWith('http') + ? const Icon( + Icons.inventory_2, + color: Colors.blueGrey, + ) + : null, ), title: Text(product.name), - subtitle: Text( - 'کد: ${product.code} | قیمت: ${product.price} تومان', + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'کد: ${product.code} | قیمت: ${product.price} تومان', + ), + if (product.category != null || product.brand != null) + Text( + 'دسته: ${product.category ?? 'نامشخص'} | برند: ${product.brand ?? 'نامشخص'}', + style: TextStyle( + color: Colors.grey[700], + fontSize: 12, + ), + ), + if (product.location != null) + Text( + 'موقعیت: ${product.location}', + style: TextStyle( + color: Colors.grey[700], + fontSize: 12, + ), + ), + if (product.expirationDate != null) + Text( + 'انقضا: ${DateFormat('yyyy-MM-dd').format(product.expirationDate!)}', + style: TextStyle( + color: Colors.red[700], + fontSize: 12, + ), + ), + ], ), trailing: Row( mainAxisSize: MainAxisSize.min, @@ -110,8 +154,7 @@ class _ProductListScreenState extends State { TextButton( onPressed: () { _deleteProduct(product.id!); - if (!mounted) - return; // Add this check + if (!mounted) return; Navigator.pop(context); }, child: const Text('بله'),