refactor: Rename date parsing helper functions for consistency
This commit is contained in:
@@ -33,7 +33,6 @@ import 'services/update_service.dart';
|
||||
import 'views/widgets/common/update_dialog.dart';
|
||||
import 'config/api_config.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'views/widgets/common/update_dialog.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -151,7 +151,7 @@ class AlertModel {
|
||||
|
||||
factory AlertModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime _parseDate(dynamic value) {
|
||||
DateTime parseDate(dynamic value) {
|
||||
if (value == null) return DateTime.now();
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
||||
@@ -174,13 +174,13 @@ class AlertModel {
|
||||
eventId: map['eventId'],
|
||||
equipmentId: map['equipmentId'],
|
||||
createdByUserId: map['createdByUserId'] ?? map['createdBy'],
|
||||
createdAt: _parseDate(map['createdAt']),
|
||||
dueDate: map['dueDate'] != null ? _parseDate(map['dueDate']) : null,
|
||||
createdAt: parseDate(map['createdAt']),
|
||||
dueDate: map['dueDate'] != null ? parseDate(map['dueDate']) : null,
|
||||
actionUrl: map['actionUrl'],
|
||||
isRead: map['isRead'] ?? false,
|
||||
isResolved: map['isResolved'] ?? false,
|
||||
resolution: map['resolution'],
|
||||
resolvedAt: map['resolvedAt'] != null ? _parseDate(map['resolvedAt']) : null,
|
||||
resolvedAt: map['resolvedAt'] != null ? parseDate(map['resolvedAt']) : null,
|
||||
resolvedByUserId: map['resolvedByUserId'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ class ContainerModel {
|
||||
/// Factory depuis Firestore
|
||||
factory ContainerModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime? _parseDate(dynamic value) {
|
||||
DateTime? parseDate(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value);
|
||||
@@ -270,8 +270,8 @@ class ContainerModel {
|
||||
equipmentIds: equipmentIds,
|
||||
eventId: map['eventId'],
|
||||
notes: map['notes'],
|
||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
history: history,
|
||||
);
|
||||
}
|
||||
@@ -351,7 +351,7 @@ class ContainerHistoryEntry {
|
||||
|
||||
factory ContainerHistoryEntry.fromMap(Map<String, dynamic> map) {
|
||||
// Helper pour parser la date
|
||||
DateTime _parseDate(dynamic value) {
|
||||
DateTime parseDate(dynamic value) {
|
||||
if (value == null) return DateTime.now();
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value) ?? DateTime.now();
|
||||
@@ -359,7 +359,7 @@ class ContainerHistoryEntry {
|
||||
}
|
||||
|
||||
return ContainerHistoryEntry(
|
||||
timestamp: _parseDate(map['timestamp']),
|
||||
timestamp: parseDate(map['timestamp']),
|
||||
action: map['action'] ?? '',
|
||||
equipmentId: map['equipmentId'],
|
||||
previousValue: map['previousValue'],
|
||||
|
||||
@@ -388,7 +388,7 @@ class EquipmentModel {
|
||||
|
||||
factory EquipmentModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime? _parseDate(dynamic value) {
|
||||
DateTime? parseDate(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value);
|
||||
@@ -416,13 +416,13 @@ class EquipmentModel {
|
||||
length: map['length']?.toDouble(),
|
||||
width: map['width']?.toDouble(),
|
||||
height: map['height']?.toDouble(),
|
||||
purchaseDate: _parseDate(map['purchaseDate']),
|
||||
nextMaintenanceDate: _parseDate(map['nextMaintenanceDate']),
|
||||
purchaseDate: parseDate(map['purchaseDate']),
|
||||
nextMaintenanceDate: parseDate(map['nextMaintenanceDate']),
|
||||
maintenanceIds: maintenanceIds,
|
||||
imageUrl: map['imageUrl'],
|
||||
notes: map['notes'],
|
||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ class EventModel {
|
||||
factory EventModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
try {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime _parseDate(dynamic value, DateTime defaultValue) {
|
||||
DateTime parseDate(dynamic value, DateTime defaultValue) {
|
||||
if (value == null) return defaultValue;
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value) ?? defaultValue;
|
||||
@@ -370,8 +370,8 @@ class EventModel {
|
||||
}
|
||||
|
||||
// Gestion sécurisée des timestamps avec support ISO string
|
||||
final DateTime startDate = _parseDate(map['StartDateTime'], DateTime.now());
|
||||
final DateTime endDate = _parseDate(map['EndDateTime'], startDate.add(const Duration(hours: 1)));
|
||||
final DateTime startDate = parseDate(map['StartDateTime'], DateTime.now());
|
||||
final DateTime endDate = parseDate(map['EndDateTime'], startDate.add(const Duration(hours: 1)));
|
||||
|
||||
// Gestion sécurisée des documents
|
||||
final docsRaw = map['documents'] ?? [];
|
||||
|
||||
@@ -61,7 +61,7 @@ class MaintenanceModel {
|
||||
|
||||
factory MaintenanceModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
// Fonction helper pour convertir Timestamp ou String ISO en DateTime
|
||||
DateTime? _parseDate(dynamic value) {
|
||||
DateTime? parseDate(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is Timestamp) return value.toDate();
|
||||
if (value is String) return DateTime.tryParse(value);
|
||||
@@ -76,15 +76,15 @@ class MaintenanceModel {
|
||||
id: id,
|
||||
equipmentIds: equipmentIds,
|
||||
type: maintenanceTypeFromString(map['type']),
|
||||
scheduledDate: _parseDate(map['scheduledDate']) ?? DateTime.now(),
|
||||
completedDate: _parseDate(map['completedDate']),
|
||||
scheduledDate: parseDate(map['scheduledDate']) ?? DateTime.now(),
|
||||
completedDate: parseDate(map['completedDate']),
|
||||
name: map['name'] ?? '',
|
||||
description: map['description'] ?? '',
|
||||
performedBy: map['performedBy'],
|
||||
cost: map['cost']?.toDouble(),
|
||||
notes: map['notes'],
|
||||
createdAt: _parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: _parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
createdAt: parseDate(map['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: parseDate(map['updatedAt']) ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ class ContainerProvider with ChangeNotifier {
|
||||
Timer? _searchDebounceTimer;
|
||||
|
||||
// Liste paginée pour la page de gestion
|
||||
List<ContainerModel> _paginatedContainers = [];
|
||||
final List<ContainerModel> _paginatedContainers = [];
|
||||
bool _hasMore = true;
|
||||
bool _isLoadingMore = false;
|
||||
String? _lastVisible;
|
||||
|
||||
// Cache complet pour compatibilité
|
||||
List<ContainerModel> _containers = [];
|
||||
final List<ContainerModel> _containers = [];
|
||||
|
||||
// Filtres et recherche
|
||||
ContainerType? _selectedType;
|
||||
|
||||
@@ -12,13 +12,13 @@ class EquipmentProvider extends ChangeNotifier {
|
||||
Timer? _searchDebounceTimer;
|
||||
|
||||
// Liste paginée pour la page de gestion
|
||||
List<EquipmentModel> _paginatedEquipment = [];
|
||||
final List<EquipmentModel> _paginatedEquipment = [];
|
||||
bool _hasMore = true;
|
||||
bool _isLoadingMore = false;
|
||||
String? _lastVisible;
|
||||
|
||||
// Cache complet pour getEquipmentsByIds et compatibilité
|
||||
List<EquipmentModel> _equipment = [];
|
||||
final List<EquipmentModel> _equipment = [];
|
||||
List<String> _models = [];
|
||||
List<String> _brands = [];
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class EventProvider with ChangeNotifier {
|
||||
bool _lastCanViewAll = false;
|
||||
|
||||
// Nouveau: Cache par mois pour le lazy loading
|
||||
Map<String, List<EventModel>> _eventsByMonth = {}; // "2026-02" => [events]
|
||||
final Map<String, List<EventModel>> _eventsByMonth = {}; // "2026-02" => [events]
|
||||
String? _currentMonth; // Mois actuellement affiché
|
||||
|
||||
List<EventModel> get events => _events;
|
||||
@@ -88,7 +88,7 @@ class EventProvider with ChangeNotifier {
|
||||
_lastUserId = userId;
|
||||
_lastCanViewAll = canViewAllEvents;
|
||||
|
||||
print('Successfully loaded ${_events.length} events (${failedCount} failed)');
|
||||
print('Successfully loaded ${_events.length} events ($failedCount failed)');
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
@@ -176,7 +176,7 @@ class EventProvider with ChangeNotifier {
|
||||
_lastUserId = userId;
|
||||
_lastCanViewAll = canViewAllEvents;
|
||||
|
||||
print('[EventProvider] Successfully loaded ${monthEvents.length} events for $monthKey (${failedCount} failed)');
|
||||
print('[EventProvider] Successfully loaded ${monthEvents.length} events for $monthKey ($failedCount failed)');
|
||||
|
||||
if (!silent) {
|
||||
_isLoading = false;
|
||||
|
||||
@@ -16,7 +16,7 @@ class IcsExportService {
|
||||
Map<String, String>? optionNames,
|
||||
}) async {
|
||||
final now = DateTime.now().toUtc();
|
||||
final timestamp = DateFormat('yyyyMMddTHHmmss').format(now) + 'Z';
|
||||
final timestamp = '${DateFormat('yyyyMMddTHHmmss').format(now)}Z';
|
||||
|
||||
// Récupérer les informations supplémentaires
|
||||
final resolvedEventTypeName = eventTypeName ?? await _getEventTypeName(event.eventTypeId);
|
||||
@@ -238,7 +238,7 @@ END:VCALENDAR''';
|
||||
/// Formate une date au format ICS (yyyyMMddTHHmmssZ)
|
||||
static String _formatDateForIcs(DateTime dateTime) {
|
||||
final utcDate = dateTime.toUtc();
|
||||
return DateFormat('yyyyMMddTHHmmss').format(utcDate) + 'Z';
|
||||
return '${DateFormat('yyyyMMddTHHmmss').format(utcDate)}Z';
|
||||
}
|
||||
|
||||
/// Échappe les caractères spéciaux pour le format ICS
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
@@ -59,7 +59,7 @@ class PerformanceMonitor {
|
||||
static void printSummary() {
|
||||
if (!_enabled || _results.isEmpty) return;
|
||||
|
||||
print('\n' + '=' * 60);
|
||||
print('\n${'=' * 60}');
|
||||
print('PERFORMANCE SUMMARY');
|
||||
print('=' * 60);
|
||||
|
||||
@@ -77,7 +77,7 @@ class PerformanceMonitor {
|
||||
Duration.zero,
|
||||
(sum, duration) => sum + duration,
|
||||
);
|
||||
print('${'=' * 60}');
|
||||
print('=' * 60);
|
||||
print('TOTAL: ${total.inMilliseconds}ms');
|
||||
print('=' * 60 + '\n');
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class _ContainerFormPageState extends State<ContainerFormPage> {
|
||||
|
||||
// Type
|
||||
DropdownButtonFormField<ContainerType>(
|
||||
value: _selectedType,
|
||||
initialValue: _selectedType,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Type de container *',
|
||||
border: OutlineInputBorder(),
|
||||
@@ -194,7 +194,7 @@ class _ContainerFormPageState extends State<ContainerFormPage> {
|
||||
|
||||
// Statut
|
||||
DropdownButtonFormField<EquipmentStatus>(
|
||||
value: _selectedStatus,
|
||||
initialValue: _selectedStatus,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Statut *',
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
@@ -78,7 +78,7 @@ class _DataManagementPageState extends State<DataManagementPage> {
|
||||
child: Column(
|
||||
children: [
|
||||
// Menu horizontal en mobile
|
||||
Container(
|
||||
SizedBox(
|
||||
height: 60,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
|
||||
@@ -271,7 +271,7 @@ class _EquipmentFormPageState extends State<EquipmentFormPage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<EquipmentCategory>(
|
||||
value: _selectedCategory,
|
||||
initialValue: _selectedCategory,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Catégorie *',
|
||||
border: OutlineInputBorder(),
|
||||
@@ -299,7 +299,7 @@ class _EquipmentFormPageState extends State<EquipmentFormPage> {
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<EquipmentStatus>(
|
||||
value: _selectedStatus,
|
||||
initialValue: _selectedStatus,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Statut *',
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
@@ -49,18 +49,18 @@ class _EventPreparationPageState extends State<EventPreparationPage> with Single
|
||||
late final DataService _dataService;
|
||||
late final QRCodeProcessingService _qrCodeService;
|
||||
|
||||
Map<String, EquipmentModel> _equipmentCache = {};
|
||||
Map<String, ContainerModel> _containerCache = {};
|
||||
Map<String, int> _returnedQuantities = {};
|
||||
final Map<String, EquipmentModel> _equipmentCache = {};
|
||||
final Map<String, ContainerModel> _containerCache = {};
|
||||
final Map<String, int> _returnedQuantities = {};
|
||||
|
||||
// État local des validations (non sauvegardé jusqu'à la validation finale)
|
||||
Map<String, bool> _localValidationState = {};
|
||||
final Map<String, bool> _localValidationState = {};
|
||||
|
||||
// Gestion des quantités par étape
|
||||
Map<String, int> _quantitiesAtPreparation = {};
|
||||
Map<String, int> _quantitiesAtLoading = {};
|
||||
Map<String, int> _quantitiesAtUnloading = {};
|
||||
Map<String, int> _quantitiesAtReturn = {};
|
||||
final Map<String, int> _quantitiesAtPreparation = {};
|
||||
final Map<String, int> _quantitiesAtLoading = {};
|
||||
final Map<String, int> _quantitiesAtUnloading = {};
|
||||
final Map<String, int> _quantitiesAtReturn = {};
|
||||
|
||||
bool _isLoading = true;
|
||||
bool _isValidating = false;
|
||||
|
||||
@@ -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