Integrate UserStateWrapper for user state management in group and home components; refactor profile and settings imports
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:travel_mate/components/home/create_trip_content.dart';
|
||||
import 'package:travel_mate/components/widgets/user_state_widget.dart';
|
||||
import '../home/show_trip_details_content.dart';
|
||||
import 'package:travel_mate/components/home/trip_card.dart';
|
||||
import 'package:travel_mate/services/trip_image_service.dart';
|
||||
@@ -73,33 +74,8 @@ class _HomeContentState extends State<HomeContent>
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context); // Important pour AutomaticKeepAliveClientMixin
|
||||
|
||||
return BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, userState) {
|
||||
if (userState is UserLoading) {
|
||||
return Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
|
||||
if (userState is UserError) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error, size: 64, color: Colors.red),
|
||||
SizedBox(height: 16),
|
||||
Text('Erreur: ${userState.message}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (userState is! UserLoaded) {
|
||||
return Scaffold(body: Center(child: Text('Veuillez vous connecter')));
|
||||
}
|
||||
|
||||
final user = userState.user;
|
||||
|
||||
return UserStateWrapper(
|
||||
builder: (context, user) {
|
||||
return BlocConsumer<TripBloc, TripState>(
|
||||
listener: (context, tripState) {
|
||||
if (tripState is TripOperationSuccess) {
|
||||
@@ -281,12 +257,13 @@ class _HomeContentState extends State<HomeContent>
|
||||
Widget _buildTripsList(List<Trip> trips) {
|
||||
// Charger les images manquantes en arrière-plan
|
||||
_loadMissingImagesInBackground(trips);
|
||||
|
||||
|
||||
return Column(
|
||||
children: trips.map((trip) => TripCard(
|
||||
trip: trip,
|
||||
onTap: () => _showTripDetails(trip),
|
||||
)).toList(),
|
||||
children: trips
|
||||
.map(
|
||||
(trip) => TripCard(trip: trip, onTap: () => _showTripDetails(trip)),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user