refactor: Rename date parsing helper functions for consistency
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:em2rp/utils/debug_log.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -133,7 +133,7 @@ class EventDetailsDocuments extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
child: Column(
|
||||
|
||||
@@ -132,7 +132,7 @@ class _UserFilterDropdownState extends State<UserFilterDropdown> {
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -241,7 +241,7 @@ class _EquipmentConflictDialogState extends State<EquipmentConflictDialog> {
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
}),
|
||||
|
||||
// Boutons d'action par équipement
|
||||
if (!isRemoved)
|
||||
|
||||
@@ -35,7 +35,7 @@ class ContainerConflictInfo {
|
||||
if (status == ContainerConflictStatus.complete) {
|
||||
return 'Tous les équipements sont déjà utilisés';
|
||||
}
|
||||
return '${conflictingEquipmentIds.length}/${totalChildren} équipement(s) déjà utilisé(s)';
|
||||
return '${conflictingEquipmentIds.length}/$totalChildren équipement(s) déjà utilisé(s)';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,11 +94,11 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
|
||||
Map<String, SelectedItem> _selectedItems = {};
|
||||
final ValueNotifier<int> _selectionChangeNotifier = ValueNotifier<int>(0); // Pour notifier les changements de sélection sans setState
|
||||
Map<String, int> _availableQuantities = {}; // Pour consommables
|
||||
Map<String, List<ContainerModel>> _recommendedContainers = {}; // Recommandations
|
||||
Map<String, List<AvailabilityConflict>> _equipmentConflicts = {}; // Conflits de disponibilité (détaillés)
|
||||
Map<String, ContainerConflictInfo> _containerConflicts = {}; // Conflits des conteneurs
|
||||
Set<String> _expandedContainers = {}; // Conteneurs dépliés dans la liste
|
||||
final Map<String, int> _availableQuantities = {}; // Pour consommables
|
||||
final Map<String, List<ContainerModel>> _recommendedContainers = {}; // Recommandations
|
||||
final Map<String, List<AvailabilityConflict>> _equipmentConflicts = {}; // Conflits de disponibilité (détaillés)
|
||||
final Map<String, ContainerConflictInfo> _containerConflicts = {}; // Conflits des conteneurs
|
||||
final Set<String> _expandedContainers = {}; // Conteneurs dépliés dans la liste
|
||||
|
||||
// NOUVEAU : IDs en conflit récupérés en batch
|
||||
Set<String> _conflictingEquipmentIds = {};
|
||||
@@ -119,12 +119,12 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
bool _hasMoreContainers = true;
|
||||
String? _lastEquipmentId;
|
||||
String? _lastContainerId;
|
||||
List<EquipmentModel> _paginatedEquipments = [];
|
||||
List<ContainerModel> _paginatedContainers = [];
|
||||
final List<EquipmentModel> _paginatedEquipments = [];
|
||||
final List<ContainerModel> _paginatedContainers = [];
|
||||
|
||||
// Cache pour éviter les rebuilds inutiles
|
||||
List<ContainerModel> _cachedContainers = [];
|
||||
List<EquipmentModel> _cachedEquipment = [];
|
||||
final List<ContainerModel> _cachedContainers = [];
|
||||
final List<EquipmentModel> _cachedEquipment = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -1047,7 +1047,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: dialogWidth.clamp(600.0, 1200.0),
|
||||
height: dialogHeight.clamp(500.0, 900.0),
|
||||
child: Column(
|
||||
@@ -1458,66 +1458,6 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Header de section repliable
|
||||
Widget _buildCollapsibleSectionHeader(
|
||||
String title,
|
||||
IconData icon,
|
||||
int count,
|
||||
bool isExpanded,
|
||||
Function(bool) onToggle,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: () => onToggle(!isExpanded),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.rouge.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: AppColors.rouge.withValues(alpha: 0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
||||
color: AppColors.rouge,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(icon, color: AppColors.rouge, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.rouge,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.rouge,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'$count',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEquipmentCard(EquipmentModel equipment, {Key? key}) {
|
||||
final isSelected = _selectedItems.containsKey(equipment.id);
|
||||
final isConsumable = equipment.category == EquipmentCategory.consumable ||
|
||||
@@ -1809,7 +1749,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
}) {
|
||||
final displayQuantity = isSelected ? selectedItem.quantity : 0;
|
||||
|
||||
return Container(
|
||||
return SizedBox(
|
||||
width: 120,
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -2369,7 +2309,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
}
|
||||
|
||||
// Cache local pour les équipements des conteneurs
|
||||
Map<String, List<String>> _containerEquipmentCache = {};
|
||||
final Map<String, List<String>> _containerEquipmentCache = {};
|
||||
|
||||
Widget _buildSelectedContainerTile(String id, SelectedItem item) {
|
||||
final isExpanded = _expandedContainers.contains(id);
|
||||
@@ -2425,7 +2365,7 @@ class _EquipmentSelectionDialogState extends State<EquipmentSelectionDialog> {
|
||||
return _buildSelectedChildEquipmentTile(equipmentId, childItem);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}).toList(),
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:em2rp/models/equipment_model.dart';
|
||||
import 'package:em2rp/views/widgets/event/equipment_selection_dialog.dart';
|
||||
|
||||
/// Widget optimisé pour une card d'équipement qui ne rebuild que si nécessaire
|
||||
class OptimizedEquipmentCard extends StatefulWidget {
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:em2rp/services/data_service.dart';
|
||||
import 'package:em2rp/services/api_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:em2rp/views/widgets/event/equipment_selection_dialog.dart';
|
||||
import 'package:em2rp/views/widgets/event/equipment_conflict_dialog.dart';
|
||||
import 'package:em2rp/services/event_availability_service.dart';
|
||||
|
||||
/// Section pour afficher et gérer le matériel assigné à un événement
|
||||
@@ -40,8 +39,8 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
||||
bool get _canAddMaterial => widget.startDate != null && widget.endDate != null;
|
||||
final EventAvailabilityService _availabilityService = EventAvailabilityService();
|
||||
final DataService _dataService = DataService(FirebaseFunctionsApiService());
|
||||
Map<String, EquipmentModel> _equipmentCache = {};
|
||||
Map<String, ContainerModel> _containerCache = {};
|
||||
final Map<String, EquipmentModel> _equipmentCache = {};
|
||||
final Map<String, ContainerModel> _containerCache = {};
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
@@ -491,7 +490,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
||||
...widget.assignedContainers.map((containerId) {
|
||||
final container = _containerCache[containerId];
|
||||
return _buildContainerItem(container);
|
||||
}).toList(),
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
|
||||
@@ -508,7 +507,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
||||
..._getStandaloneEquipment().map((eq) {
|
||||
final equipment = _equipmentCache[eq.equipmentId];
|
||||
return _buildEquipmentItem(equipment, eq);
|
||||
}).toList(),
|
||||
}),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -597,7 +596,7 @@ class _EventAssignedEquipmentSectionState extends State<EventAssignedEquipmentSe
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:em2rp/models/event_type_model.dart';
|
||||
import 'package:em2rp/views/widgets/event_form/price_ht_ttc_fields.dart';
|
||||
|
||||
@@ -12,8 +12,7 @@ class OptionSelectorWidget extends StatefulWidget {
|
||||
final bool isMobile;
|
||||
final String? eventType;
|
||||
|
||||
const OptionSelectorWidget({
|
||||
Key? key,
|
||||
const OptionSelectorWidget({super.key,
|
||||
this.eventType,
|
||||
required this.selectedOptions,
|
||||
required this.onChanged,
|
||||
|
||||
@@ -210,7 +210,7 @@ class _NotificationPreferencesWidgetState extends State<NotificationPreferencesW
|
||||
),
|
||||
value: value,
|
||||
onChanged: _isSaving ? null : onChanged, // Désactiver pendant sauvegarde
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
activeThumbColor: Theme.of(context).primaryColor,
|
||||
inactiveThumbColor: Colors.grey.shade400, // Couleur visible quand OFF
|
||||
inactiveTrackColor: Colors.grey.shade300, // Track visible quand OFF
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
Reference in New Issue
Block a user