refactor: Clean up code by removing unnecessary whitespace and improving readability
This commit is contained in:
@@ -11,10 +11,7 @@ import '../../services/error_service.dart';
|
||||
class AddActivityBottomSheet extends StatefulWidget {
|
||||
final Trip trip;
|
||||
|
||||
const AddActivityBottomSheet({
|
||||
Key? key,
|
||||
required this.trip,
|
||||
}) : super(key: key);
|
||||
const AddActivityBottomSheet({super.key, required this.trip});
|
||||
|
||||
@override
|
||||
State<AddActivityBottomSheet> createState() => _AddActivityBottomSheetState();
|
||||
@@ -26,7 +23,7 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
final _descriptionController = TextEditingController();
|
||||
final _addressController = TextEditingController();
|
||||
final ErrorService _errorService = ErrorService();
|
||||
|
||||
|
||||
ActivityCategory _selectedCategory = ActivityCategory.attraction;
|
||||
bool _isLoading = false;
|
||||
|
||||
@@ -43,16 +40,11 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
final theme = Theme.of(context);
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final keyboardHeight = mediaQuery.viewInsets.bottom;
|
||||
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: mediaQuery.size.height * 0.85,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
margin: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.cardColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@@ -167,7 +159,9 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
side: BorderSide(color: theme.colorScheme.outline),
|
||||
side: BorderSide(
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
@@ -193,7 +187,9 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Text('Ajouter'),
|
||||
@@ -214,9 +210,9 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w600),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -240,17 +236,17 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color: isDarkMode
|
||||
? Colors.white.withOpacity(0.2)
|
||||
: Colors.black.withOpacity(0.2),
|
||||
color: isDarkMode
|
||||
? Colors.white.withOpacity(0.2)
|
||||
: Colors.black.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color: isDarkMode
|
||||
? Colors.white.withOpacity(0.2)
|
||||
: Colors.black.withOpacity(0.2),
|
||||
color: isDarkMode
|
||||
? Colors.white.withOpacity(0.2)
|
||||
: Colors.black.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
@@ -265,15 +261,13 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
|
||||
Widget _buildCategorySelector() {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.outline.withOpacity(0.5),
|
||||
),
|
||||
border: Border.all(color: theme.colorScheme.outline.withOpacity(0.5)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -290,7 +284,7 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
runSpacing: 8,
|
||||
children: ActivityCategory.values.map((category) {
|
||||
final isSelected = _selectedCategory == category;
|
||||
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
@@ -298,12 +292,17 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.blue : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: isSelected ? Colors.blue : theme.colorScheme.outline,
|
||||
color: isSelected
|
||||
? Colors.blue
|
||||
: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -312,17 +311,17 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
Icon(
|
||||
_getCategoryIcon(category),
|
||||
size: 16,
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: theme.colorScheme.onSurface,
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
category.displayName,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: theme.colorScheme.onSurface,
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: theme.colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -361,19 +360,18 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
name: _nameController.text.trim(),
|
||||
description: _descriptionController.text.trim(),
|
||||
category: _selectedCategory.displayName,
|
||||
address: _addressController.text.trim().isNotEmpty
|
||||
? _addressController.text.trim()
|
||||
: null,
|
||||
address: _addressController.text.trim().isNotEmpty
|
||||
? _addressController.text.trim()
|
||||
: null,
|
||||
votes: {},
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
|
||||
context.read<ActivityBloc>().add(AddActivity(activity));
|
||||
|
||||
|
||||
// Fermer le bottom sheet
|
||||
Navigator.pop(context);
|
||||
|
||||
} catch (e) {
|
||||
_errorService.showSnackbar(
|
||||
message: 'Erreur lors de l\'ajout de l\'activité',
|
||||
@@ -412,4 +410,4 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
return Icons.spa;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user