Enhance model and service documentation with detailed comments and descriptions
- Updated Group, Trip, User, and other model classes to include comprehensive documentation for better understanding and maintainability. - Improved error handling and logging in services, including AuthService, ErrorService, and StorageService. - Added validation and business logic explanations in ExpenseService and TripService. - Refactored method comments to follow a consistent format across the codebase. - Translated error messages and comments from French to English for consistency.
This commit is contained in:
@@ -20,8 +20,29 @@ import '../../repositories/group_repository.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
/// Create trip content widget for trip creation and editing functionality.
|
||||
///
|
||||
/// This widget provides a comprehensive form interface for creating new trips
|
||||
/// or editing existing ones. Key features include:
|
||||
/// - Trip creation with validation
|
||||
/// - Location search with autocomplete
|
||||
/// - Date selection for trip duration
|
||||
/// - Budget planning and management
|
||||
/// - Group creation and member management
|
||||
/// - Account setup for expense tracking
|
||||
/// - Integration with mapping services for location selection
|
||||
///
|
||||
/// The widget handles both creation and editing modes based on the
|
||||
/// provided tripToEdit parameter.
|
||||
class CreateTripContent extends StatefulWidget {
|
||||
/// Optional trip to edit. If null, creates a new trip
|
||||
final Trip? tripToEdit;
|
||||
|
||||
/// Creates a create trip content widget.
|
||||
///
|
||||
/// Args:
|
||||
/// [tripToEdit]: Optional trip to edit. If provided, the form will
|
||||
/// be populated with existing trip data for editing
|
||||
const CreateTripContent({
|
||||
super.key,
|
||||
this.tripToEdit,
|
||||
@@ -32,30 +53,44 @@ class CreateTripContent extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CreateTripContentState extends State<CreateTripContent> {
|
||||
/// Service for handling and displaying errors
|
||||
final _errorService = ErrorService();
|
||||
|
||||
/// Form validation key
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
/// Text controllers for form fields
|
||||
final _titleController = TextEditingController();
|
||||
final _descriptionController = TextEditingController();
|
||||
final _locationController = TextEditingController();
|
||||
final _budgetController = TextEditingController();
|
||||
final _participantController = TextEditingController();
|
||||
|
||||
/// Services for user and group operations
|
||||
final _userService = UserService();
|
||||
final _groupRepository = GroupRepository();
|
||||
|
||||
/// Trip date variables
|
||||
DateTime? _startDate;
|
||||
DateTime? _endDate;
|
||||
|
||||
/// Loading and state management variables
|
||||
bool _isLoading = false;
|
||||
String? _createdTripId;
|
||||
|
||||
/// Google Maps API key for location services
|
||||
static final String _apiKey = dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
|
||||
|
||||
/// Participant management
|
||||
final List<String> _participants = [];
|
||||
final _participantController = TextEditingController();
|
||||
|
||||
/// Location autocomplete functionality
|
||||
List<PlaceSuggestion> _placeSuggestions = [];
|
||||
bool _isLoadingSuggestions = false;
|
||||
OverlayEntry? _suggestionsOverlay;
|
||||
final LayerLink _layerLink = LayerLink();
|
||||
|
||||
/// Determines if the widget is in editing mode
|
||||
bool get isEditing => widget.tripToEdit != null;
|
||||
|
||||
@override
|
||||
|
||||
@@ -9,7 +9,20 @@ import '../../blocs/trip/trip_state.dart';
|
||||
import '../../blocs/trip/trip_event.dart';
|
||||
import '../../models/trip.dart';
|
||||
|
||||
/// Home content widget for the main application dashboard.
|
||||
///
|
||||
/// This widget serves as the primary content area of the home screen,
|
||||
/// displaying user trips and providing navigation to trip management
|
||||
/// features. Key functionality includes:
|
||||
/// - Loading and displaying user trips
|
||||
/// - Creating new trips
|
||||
/// - Viewing trip details
|
||||
/// - Managing trip state with proper user authentication
|
||||
///
|
||||
/// The widget maintains state persistence using AutomaticKeepAliveClientMixin
|
||||
/// to preserve content when switching between tabs.
|
||||
class HomeContent extends StatefulWidget {
|
||||
/// Creates a home content widget.
|
||||
const HomeContent({super.key});
|
||||
|
||||
@override
|
||||
@@ -17,20 +30,27 @@ class HomeContent extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeContentState extends State<HomeContent> with AutomaticKeepAliveClientMixin {
|
||||
/// Preserves widget state when switching between tabs
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
/// Flag to prevent duplicate trip loading operations
|
||||
bool _hasLoadedTrips = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// MODIFIÉ : Utiliser addPostFrameCallback pour attendre que le widget tree soit prêt
|
||||
// Use addPostFrameCallback to wait for the widget tree to be ready
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadTripsIfUserLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
/// Loads trips if a user is currently loaded and trips haven't been loaded yet.
|
||||
///
|
||||
/// Checks the current user state and initiates trip loading if the user is
|
||||
/// authenticated and trips haven't been loaded previously. This prevents
|
||||
/// duplicate loading operations.
|
||||
void _loadTripsIfUserLoaded() {
|
||||
if (!_hasLoadedTrips && mounted) {
|
||||
final userState = context.read<UserBloc>().state;
|
||||
|
||||
Reference in New Issue
Block a user