feat(ui): improve mobile equipment card and unify travel cost dialog
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
/// Configuration de la version de l'application
|
||||
class AppVersion {
|
||||
static const String version = '1.2.4';
|
||||
static const String version = '1.2.7';
|
||||
|
||||
/// Retourne la version complète de l'application
|
||||
static String get fullVersion => 'v$version';
|
||||
|
||||
|
||||
/// Retourne la version avec un préfixe personnalisé
|
||||
static String getVersionWithPrefix(String prefix) => '$prefix $version';
|
||||
}
|
||||
|
||||
|
||||
@@ -72,24 +72,22 @@ class RouteResult {
|
||||
required double maintenanceCostPerKm,
|
||||
required int nbTechnicians,
|
||||
required double hourlyRate,
|
||||
bool applyFreeZone = false,
|
||||
double freeZoneKm = 0,
|
||||
double freeZoneMinutes = 0,
|
||||
}) {
|
||||
const freeKm = 20.0;
|
||||
const freeMinutes = 20.0;
|
||||
|
||||
return fuelCost(
|
||||
consumptionPer100km: consumptionPer100km,
|
||||
fuelPricePerLiter: fuelPricePerLiter,
|
||||
freeZoneKm: applyFreeZone ? freeKm : 0,
|
||||
freeZoneKm: freeZoneKm,
|
||||
) +
|
||||
maintenanceCost(
|
||||
costPerKm: maintenanceCostPerKm,
|
||||
freeZoneKm: applyFreeZone ? freeKm : 0,
|
||||
freeZoneKm: freeZoneKm,
|
||||
) +
|
||||
laborCost(
|
||||
nbTechnicians: nbTechnicians,
|
||||
hourlyRate: hourlyRate,
|
||||
freeZoneMinutes: applyFreeZone ? freeMinutes : 0,
|
||||
freeZoneMinutes: freeZoneMinutes,
|
||||
) +
|
||||
tollCost;
|
||||
}
|
||||
|
||||
@@ -523,6 +523,7 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
|
||||
Widget _buildEquipmentCard(EquipmentModel equipment) {
|
||||
final isSelected = isItemSelected(equipment.id);
|
||||
final isMobile = MediaQuery.of(context).size.width < 800;
|
||||
|
||||
// ✅ RepaintBoundary pour isoler le repaint de chaque carte
|
||||
return RepaintBoundary(
|
||||
@@ -563,9 +564,12 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// 1. leading selection or icon
|
||||
if (isSelectionMode)
|
||||
Padding(
|
||||
@@ -642,15 +646,15 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
|
||||
// 3. Status Badge OR Quantity Display (centered vertically in the row!)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
padding: EdgeInsets.only(right: (!isSelectionMode && !isMobile) ? 16 : 0),
|
||||
child: (equipment.category == EquipmentCategory.consumable ||
|
||||
equipment.category == EquipmentCategory.cable)
|
||||
? _buildQuantityDisplay(equipment)
|
||||
: EquipmentStatusBadge(equipment: equipment),
|
||||
),
|
||||
|
||||
// 4. Trailing Action Buttons
|
||||
if (!isSelectionMode)
|
||||
// 4. Trailing Action Buttons (Desktop inline)
|
||||
if (!isSelectionMode && !isMobile)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -711,6 +715,69 @@ class _EquipmentManagementPageState extends State<EquipmentManagementPage>
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isSelectionMode && isMobile) ...[
|
||||
const Divider(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
// Bouton Restock (uniquement pour consommables/câbles avec permission)
|
||||
if (equipment.category == EquipmentCategory.consumable ||
|
||||
equipment.category == EquipmentCategory.cable)
|
||||
PermissionGate(
|
||||
requiredPermissions: const ['manage_equipment'],
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.add_shopping_cart,
|
||||
color: AppColors.rouge, size: 20),
|
||||
tooltip: 'Restock',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => _showRestockDialog(equipment),
|
||||
),
|
||||
),
|
||||
if (equipment.category == EquipmentCategory.consumable ||
|
||||
equipment.category == EquipmentCategory.cable)
|
||||
const SizedBox(width: 16),
|
||||
// Bouton QR Code
|
||||
IconButton(
|
||||
icon: const Icon(Icons.qr_code, color: AppColors.rouge, size: 20),
|
||||
tooltip: 'QR Code',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
QRCodeDialog.forEquipment(equipment),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Bouton Modifier (permission required)
|
||||
PermissionGate(
|
||||
requiredPermissions: const ['manage_equipment'],
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.edit, color: AppColors.rouge, size: 20),
|
||||
tooltip: 'Modifier',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => _editEquipment(equipment),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Bouton Supprimer (permission required)
|
||||
PermissionGate(
|
||||
requiredPermissions: const ['manage_equipment'],
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.red, size: 20),
|
||||
tooltip: 'Supprimer',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => _deleteEquipment(equipment),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -46,6 +46,8 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
int _nbTechnicians = 2;
|
||||
double _hourlyRate = 25.0;
|
||||
bool _applyFreeZone = false;
|
||||
double _freeZoneKm = 20.0;
|
||||
int _freeZoneMinutes = 20;
|
||||
|
||||
// Résultats
|
||||
List<RouteResult> _routes = [];
|
||||
@@ -142,7 +144,8 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
maintenanceCostPerKm: _selectedVehicle!.maintenanceCostPerKm,
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
applyFreeZone: _applyFreeZone,
|
||||
freeZoneKm: _applyFreeZone ? _freeZoneKm : 0.0,
|
||||
freeZoneMinutes: _applyFreeZone ? _freeZoneMinutes.toDouble() : 0.0,
|
||||
);
|
||||
Navigator.of(context).pop(total);
|
||||
}
|
||||
@@ -230,29 +233,32 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
if (_routes.isEmpty) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: _buildConfigPanel(),
|
||||
);
|
||||
}
|
||||
|
||||
// Résultats
|
||||
final screenW = MediaQuery.of(context).size.width;
|
||||
final isWide = screenW > 900;
|
||||
|
||||
if (isWide) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
child: _routes.isEmpty
|
||||
? const Center(child: Text("Configurez le trajet et cliquez sur Calculer"))
|
||||
: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildResultsPanel(),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildConfigPanel(),
|
||||
if (_routes.isNotEmpty) ...[
|
||||
const Divider(height: 32),
|
||||
_buildResultsPanel(),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -261,13 +267,22 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 260,
|
||||
child: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
),
|
||||
if (_routes.isNotEmpty)
|
||||
SizedBox(
|
||||
height: 260,
|
||||
child: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildResultsPanel(),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildConfigPanel(),
|
||||
if (_routes.isNotEmpty) ...[
|
||||
const Divider(height: 32),
|
||||
_buildResultsPanel(),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -413,10 +428,53 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
activeColor: AppColors.rouge,
|
||||
title: const Text('Appliquer la zone de gratuité'),
|
||||
subtitle:
|
||||
const Text('Déduit 20 km (carburant + maintenance) et 20 min (main-d\'œuvre)'),
|
||||
Text('Déduit ${_freeZoneKm.toStringAsFixed(0)} km (carburant + maintenance) et $_freeZoneMinutes min (main-d\'œuvre)'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
),
|
||||
if (_applyFreeZone)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 32, top: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
initialValue: _freeZoneKm.toStringAsFixed(0),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Distance déduite',
|
||||
border: OutlineInputBorder(),
|
||||
suffixText: 'km',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}'))
|
||||
],
|
||||
onChanged: (v) {
|
||||
final parsed = double.tryParse(v);
|
||||
if (parsed != null) setState(() => _freeZoneKm = parsed);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
initialValue: _freeZoneMinutes.toString(),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Temps déduit',
|
||||
border: OutlineInputBorder(),
|
||||
suffixText: 'min',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
onChanged: (v) {
|
||||
final parsed = int.tryParse(v);
|
||||
if (parsed != null) setState(() => _freeZoneMinutes = parsed);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
@@ -492,21 +550,22 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
maintenanceCostPerKm: vehicle.maintenanceCostPerKm,
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
applyFreeZone: _applyFreeZone,
|
||||
freeZoneKm: _applyFreeZone ? _freeZoneKm : 0.0,
|
||||
freeZoneMinutes: _applyFreeZone ? _freeZoneMinutes.toDouble() : 0.0,
|
||||
);
|
||||
final fuel = route.fuelCost(
|
||||
consumptionPer100km: vehicle.consumptionPer100km,
|
||||
fuelPricePerLiter: fuelPrice,
|
||||
freeZoneKm: _applyFreeZone ? 20 : 0,
|
||||
freeZoneKm: _applyFreeZone ? _freeZoneKm : 0.0,
|
||||
);
|
||||
final maint = route.maintenanceCost(
|
||||
costPerKm: vehicle.maintenanceCostPerKm,
|
||||
freeZoneKm: _applyFreeZone ? 20 : 0,
|
||||
freeZoneKm: _applyFreeZone ? _freeZoneKm : 0.0,
|
||||
);
|
||||
final labor = route.laborCost(
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
freeZoneMinutes: _applyFreeZone ? 20 : 0,
|
||||
freeZoneMinutes: _applyFreeZone ? _freeZoneMinutes.toDouble() : 0.0,
|
||||
);
|
||||
|
||||
final isToll = route.routeType == 'TOLL';
|
||||
|
||||
Reference in New Issue
Block a user