Refactoring + Version améliorée

This commit is contained in:
DahoudG
2024-09-25 21:28:04 +00:00
parent 6b12cfeb41
commit 8e625c1080
28 changed files with 1113 additions and 261 deletions

View File

@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
class DatePickerField extends StatelessWidget {
final DateTime? selectedDate;
final Function(DateTime?) onDatePicked;
const DatePickerField({Key? key, this.selectedDate, required this.onDatePicked}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (picked != null) {
onDatePicked(picked);
}
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(10.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
selectedDate == null
? 'Sélectionnez une date'
: '${selectedDate!.day}/${selectedDate!.month}/${selectedDate!.year}',
style: const TextStyle(color: Colors.white70),
),
const Icon(Icons.calendar_today, color: Colors.white70),
],
),
),
);
}
}