Refactor ProfileContent to use ErrorService for error handling and update instantiation in SettingsContent
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:travel_mate/components/widgets/user_state_widget.dart';
|
import 'package:travel_mate/components/widgets/user_state_widget.dart';
|
||||||
|
import 'package:travel_mate/services/error_service.dart';
|
||||||
import '../../../blocs/user/user_bloc.dart';
|
import '../../../blocs/user/user_bloc.dart';
|
||||||
import '../../../blocs/user/user_state.dart' as user_state;
|
import '../../../blocs/user/user_state.dart' as user_state;
|
||||||
import '../../../blocs/user/user_event.dart' as user_event;
|
import '../../../blocs/user/user_event.dart' as user_event;
|
||||||
import '../../../services/auth_service.dart';
|
import '../../../services/auth_service.dart';
|
||||||
|
|
||||||
class ProfileContent extends StatelessWidget {
|
class ProfileContent extends StatelessWidget {
|
||||||
const ProfileContent({super.key});
|
ProfileContent({super.key});
|
||||||
|
|
||||||
|
final _errorService = ErrorService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -251,11 +254,8 @@ class ProfileContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
SnackBar(
|
message: 'Erreur: Mot de passe actuel incorrect',
|
||||||
content: Text('Erreur: Mot de passe actuel incorrect'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -317,11 +317,8 @@ class ProfileContent extends StatelessWidget {
|
|||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_errorService.showError(
|
||||||
SnackBar(
|
message: 'Erreur: Mot de passe incorrect',
|
||||||
content: Text('Erreur: Mot de passe incorrect'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class SettingsContent extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
children: [
|
children: [
|
||||||
// Section Profil intégrée
|
// Section Profil intégrée
|
||||||
const ProfileContent(),
|
ProfileContent(),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ void main() {
|
|||||||
print('=== Scénario 1: Premier chargement ===');
|
print('=== Scénario 1: Premier chargement ===');
|
||||||
String? existingImage; // Aucune image dans le Storage
|
String? existingImage; // Aucune image dans le Storage
|
||||||
|
|
||||||
if (existingImage == null) {
|
print('✓ Aucune image existante trouvée');
|
||||||
print('✓ Aucune image existante trouvée');
|
print('✓ Téléchargement d\'une nouvelle image depuis Google Places');
|
||||||
print('✓ Téléchargement d\'une nouvelle image depuis Google Places');
|
existingImage = 'https://storage.googleapis.com/image1.jpg';
|
||||||
existingImage = 'https://storage.googleapis.com/image1.jpg';
|
print('✓ Image sauvée: $existingImage');
|
||||||
print('✓ Image sauvée: $existingImage');
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(existingImage, isNotNull);
|
expect(existingImage, isNotNull);
|
||||||
|
|
||||||
// Scénario 2: Rechargement (image existante)
|
// Scénario 2: Rechargement (image existante)
|
||||||
@@ -33,12 +31,10 @@ void main() {
|
|||||||
String?
|
String?
|
||||||
differentLocationImage; // Pas d'image pour cette nouvelle destination
|
differentLocationImage; // Pas d'image pour cette nouvelle destination
|
||||||
|
|
||||||
if (differentLocationImage == null) {
|
print('✓ Nouvelle destination, aucune image existante');
|
||||||
print('✓ Nouvelle destination, aucune image existante');
|
print('✓ Téléchargement autorisé pour cette nouvelle destination');
|
||||||
print('✓ Téléchargement autorisé pour cette nouvelle destination');
|
differentLocationImage = 'https://storage.googleapis.com/image2.jpg';
|
||||||
differentLocationImage = 'https://storage.googleapis.com/image2.jpg';
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(differentLocationImage, isNotNull);
|
expect(differentLocationImage, isNotNull);
|
||||||
expect(differentLocationImage, isNot(equals(existingImage)));
|
expect(differentLocationImage, isNot(equals(existingImage)));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user