style: add margins to cards, move quantity display to badge column with identical size, and implement long press to edit
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:em2rp/views/widgets/nav/main_drawer.dart';
|
||||
import 'package:em2rp/views/widgets/nav/custom_app_bar.dart';
|
||||
import 'package:em2rp/providers/equipment_provider.dart';
|
||||
import 'package:em2rp/providers/container_provider.dart';
|
||||
import 'package:em2rp/providers/local_user_provider.dart';
|
||||
import 'package:em2rp/models/equipment_model.dart';
|
||||
import 'package:em2rp/models/container_model.dart';
|
||||
import 'package:em2rp/views/equipment_form_page.dart';
|
||||
@@ -527,7 +528,7 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
return RepaintBoundary(
|
||||
key: ValueKey(equipment.id),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
margin: const EdgeInsets.only(bottom: 12, left: 16, right: 16),
|
||||
elevation: 1,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -546,6 +547,20 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
onTap: isSelectionMode
|
||||
? () => toggleItemSelection(equipment.id)
|
||||
: () => _viewEquipmentDetails(equipment),
|
||||
onLongPress: isSelectionMode
|
||||
? null
|
||||
: () {
|
||||
final localUserProvider = Provider.of<LocalUserProvider>(context, listen: false);
|
||||
if (localUserProvider.hasPermission('manage_equipment')) {
|
||||
_editEquipment(equipment);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("Vous n'avez pas la permission de modifier cet équipement"),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
@@ -580,7 +595,7 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
),
|
||||
),
|
||||
|
||||
// 2. Info details (ID, Brand/Model, Subcategory/Quantity)
|
||||
// 2. Info details (ID, Brand/Model, Subcategory)
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -619,25 +634,20 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
),
|
||||
),
|
||||
],
|
||||
// Quantité pour consommables
|
||||
if (equipment.category == EquipmentCategory.consumable ||
|
||||
equipment.category == EquipmentCategory.cable) ...[
|
||||
const SizedBox(height: 6),
|
||||
_buildQuantityDisplay(equipment),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 3. Status Badge (centered vertically in the row!)
|
||||
if (equipment.category != EquipmentCategory.consumable &&
|
||||
equipment.category != EquipmentCategory.cable)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: EquipmentStatusBadge(equipment: equipment),
|
||||
),
|
||||
// 3. Status Badge OR Quantity Display (centered vertically in the row!)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: (equipment.category == EquipmentCategory.consumable ||
|
||||
equipment.category == EquipmentCategory.cable)
|
||||
? _buildQuantityDisplay(equipment)
|
||||
: EquipmentStatusBadge(equipment: equipment),
|
||||
),
|
||||
|
||||
// 4. Trailing Action Buttons
|
||||
if (!isSelectionMode)
|
||||
@@ -713,55 +723,22 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
final criticalThreshold = equipment.criticalThreshold ?? 0;
|
||||
final isCritical =
|
||||
criticalThreshold > 0 && availableQty <= criticalThreshold;
|
||||
final color = isCritical ? Colors.red : Colors.grey.shade600;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isCritical
|
||||
? Colors.red.withOpacity(0.15)
|
||||
: Colors.grey.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isCritical ? Colors.red : Colors.grey.shade400,
|
||||
width: isCritical ? 2 : 1,
|
||||
),
|
||||
color: color.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
isCritical ? Icons.warning : Icons.inventory,
|
||||
size: 16,
|
||||
color: isCritical ? Colors.red : Colors.grey[700],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'Disponible: $availableQty / $totalQty',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isCritical ? FontWeight.bold : FontWeight.normal,
|
||||
color: isCritical ? Colors.red : Colors.grey[700],
|
||||
),
|
||||
),
|
||||
if (isCritical) ...[
|
||||
const SizedBox(width: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Text(
|
||||
'CRITIQUE',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
child: Text(
|
||||
'$availableQty / $totalQty',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user