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/views/widgets/nav/custom_app_bar.dart';
|
||||||
import 'package:em2rp/providers/equipment_provider.dart';
|
import 'package:em2rp/providers/equipment_provider.dart';
|
||||||
import 'package:em2rp/providers/container_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/equipment_model.dart';
|
||||||
import 'package:em2rp/models/container_model.dart';
|
import 'package:em2rp/models/container_model.dart';
|
||||||
import 'package:em2rp/views/equipment_form_page.dart';
|
import 'package:em2rp/views/equipment_form_page.dart';
|
||||||
@@ -527,7 +528,7 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
|||||||
return RepaintBoundary(
|
return RepaintBoundary(
|
||||||
key: ValueKey(equipment.id),
|
key: ValueKey(equipment.id),
|
||||||
child: Card(
|
child: Card(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12, left: 16, right: 16),
|
||||||
elevation: 1,
|
elevation: 1,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@@ -546,6 +547,20 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
|||||||
onTap: isSelectionMode
|
onTap: isSelectionMode
|
||||||
? () => toggleItemSelection(equipment.id)
|
? () => toggleItemSelection(equipment.id)
|
||||||
: () => _viewEquipmentDetails(equipment),
|
: () => _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(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Row(
|
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(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
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),
|
const SizedBox(width: 16),
|
||||||
|
|
||||||
// 3. Status Badge (centered vertically in the row!)
|
// 3. Status Badge OR Quantity Display (centered vertically in the row!)
|
||||||
if (equipment.category != EquipmentCategory.consumable &&
|
Padding(
|
||||||
equipment.category != EquipmentCategory.cable)
|
padding: const EdgeInsets.only(right: 16),
|
||||||
Padding(
|
child: (equipment.category == EquipmentCategory.consumable ||
|
||||||
padding: const EdgeInsets.only(right: 16),
|
equipment.category == EquipmentCategory.cable)
|
||||||
child: EquipmentStatusBadge(equipment: equipment),
|
? _buildQuantityDisplay(equipment)
|
||||||
),
|
: EquipmentStatusBadge(equipment: equipment),
|
||||||
|
),
|
||||||
|
|
||||||
// 4. Trailing Action Buttons
|
// 4. Trailing Action Buttons
|
||||||
if (!isSelectionMode)
|
if (!isSelectionMode)
|
||||||
@@ -713,55 +723,22 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
|||||||
final criticalThreshold = equipment.criticalThreshold ?? 0;
|
final criticalThreshold = equipment.criticalThreshold ?? 0;
|
||||||
final isCritical =
|
final isCritical =
|
||||||
criticalThreshold > 0 && availableQty <= criticalThreshold;
|
criticalThreshold > 0 && availableQty <= criticalThreshold;
|
||||||
|
final color = isCritical ? Colors.red : Colors.grey.shade600;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isCritical
|
color: color.withValues(alpha: 0.15),
|
||||||
? Colors.red.withOpacity(0.15)
|
borderRadius: BorderRadius.circular(12),
|
||||||
: Colors.grey.withOpacity(0.1),
|
border: Border.all(color: color),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: isCritical ? Colors.red : Colors.grey.shade400,
|
|
||||||
width: isCritical ? 2 : 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Text(
|
||||||
mainAxisSize: MainAxisSize.min,
|
'$availableQty / $totalQty',
|
||||||
children: [
|
style: TextStyle(
|
||||||
Icon(
|
fontSize: 12,
|
||||||
isCritical ? Icons.warning : Icons.inventory,
|
fontWeight: FontWeight.bold,
|
||||||
size: 16,
|
color: color,
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user