feat: Redesign calendar page with default week view, improved app bar, and a consolidated activity timeline.
This commit is contained in:
@@ -26,6 +26,7 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
final ErrorService _errorService = ErrorService();
|
||||
|
||||
ActivityCategory _selectedCategory = ActivityCategory.attraction;
|
||||
DateTime? _selectedDate;
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
@@ -150,6 +151,13 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
icon: Icons.location_on,
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Date et heure (optionnel)
|
||||
_buildSectionTitle('Date et heure (optionnel)'),
|
||||
const SizedBox(height: 8),
|
||||
_buildDateTimePicker(),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// Boutons d'action
|
||||
@@ -369,6 +377,7 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
votes: {},
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
date: _selectedDate,
|
||||
createdBy: FirebaseAuth.instance.currentUser?.uid,
|
||||
);
|
||||
|
||||
@@ -414,4 +423,92 @@ class _AddActivityBottomSheetState extends State<AddActivityBottomSheet> {
|
||||
return Icons.spa;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildDateTimePicker() {
|
||||
final theme = Theme.of(context);
|
||||
final isDarkMode = theme.brightness == Brightness.dark;
|
||||
|
||||
return InkWell(
|
||||
onTap: _pickDateTime,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isDarkMode
|
||||
? Colors.white.withValues(alpha: 0.2)
|
||||
: Colors.black.withValues(alpha: 0.2),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.calendar_today,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
_selectedDate != null
|
||||
? '${_selectedDate!.day}/${_selectedDate!.month}/${_selectedDate!.year} à ${_selectedDate!.hour}:${_selectedDate!.minute.toString().padLeft(2, '0')}'
|
||||
: 'Choisir une date et une heure',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: _selectedDate != null
|
||||
? theme.colorScheme.onSurface
|
||||
: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (_selectedDate != null)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.clear, size: 20),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedDate = null;
|
||||
});
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pickDateTime() async {
|
||||
final now = DateTime.now();
|
||||
final initialDate = widget.trip.startDate.isAfter(now)
|
||||
? widget.trip.startDate
|
||||
: now;
|
||||
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _selectedDate ?? initialDate,
|
||||
firstDate: now.subtract(const Duration(days: 365)),
|
||||
lastDate: now.add(const Duration(days: 365 * 2)),
|
||||
);
|
||||
|
||||
if (date == null) return;
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
final time = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(_selectedDate ?? now),
|
||||
);
|
||||
|
||||
if (time == null) return;
|
||||
|
||||
setState(() {
|
||||
_selectedDate = DateTime(
|
||||
date.year,
|
||||
date.month,
|
||||
date.day,
|
||||
time.hour,
|
||||
time.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user