/* SPDX-License-Identifier: GPL-3.0-or-later */ /* Copyright (C) 2024 Marco Groß */ import 'package:calorimeter/utils/date_time_helper.dart'; import 'package:flutter/material.dart'; class CalendarFAB extends StatelessWidget { final DateTime startFromDate; final Function(DateTime?) onDateSelected; const CalendarFAB( {super.key, required this.startFromDate, required this.onDateSelected}); @override Widget build(BuildContext context) { return FloatingActionButton( onPressed: () async { var datePicked = await showDatePicker( context: context, initialDate: startFromDate, currentDate: DateTimeHelper.now(), firstDate: DateTimeHelper.now().subtract(const Duration(days: 365 * 10)), lastDate: DateTimeHelper.now().add(const Duration(days: 365 * 10)), ); if (!context.mounted) return; onDateSelected(datePicked?.copyWith(isUtc: true)); }, heroTag: "calendarFAB", child: const Icon(Icons.date_range), ); } }