Update: lib/screens/product_list_screen.dart
This commit is contained in:
parent
5757d0f823
commit
25ad603299
|
@ -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,12 +78,55 @@ class _ProductListScreenState extends State<ProductListScreen> {
|
|||
),
|
||||
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<Object>?
|
||||
: null,
|
||||
child:
|
||||
product.imageUrl == null ||
|
||||
!product.imageUrl!.startsWith('http')
|
||||
? const Icon(
|
||||
Icons.inventory_2,
|
||||
color: Colors.blueGrey,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text(product.name),
|
||||
subtitle: Text(
|
||||
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,
|
||||
children: [
|
||||
|
@ -110,8 +154,7 @@ class _ProductListScreenState extends State<ProductListScreen> {
|
|||
TextButton(
|
||||
onPressed: () {
|
||||
_deleteProduct(product.id!);
|
||||
if (!mounted)
|
||||
return; // Add this check
|
||||
if (!mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('بله'),
|
||||
|
|
Loading…
Reference in New Issue