calorimeter/lib/utils/calendar_floating_button.dart
Marco cb18e1d1f0 Introduce PageView with manual switching of dates
1. Show PerDate widgets inside of an PageView
2. Introduce GoRouter so we can intercept back button taps with
   BackButtonListener
3. Implement rudimentary navigation
4. Fix bug that still showed a spinner event when the barcode was not
   found.
2024-10-06 02:20:08 +02:00

32 lines
914 B
Dart

import 'package:flutter/material.dart';
class CalendarFloatingButton extends StatelessWidget {
final DateTime startFromDate;
final Function(DateTime?) onDateSelected;
const CalendarFloatingButton(
{super.key, required this.startFromDate, required this.onDateSelected});
@override
Widget build(BuildContext context) {
return FloatingActionButton(
onPressed: () async {
var datePicked = await showDatePicker(
locale: const Locale('de'),
context: context,
initialDate: startFromDate,
currentDate: DateTime.now(),
firstDate: DateTime.now().subtract(const Duration(days: 365 * 10)),
lastDate: DateTime.now().add(const Duration(days: 365 * 10)),
);
if (!context.mounted) return;
onDateSelected(datePicked);
},
heroTag: "calendarFAB",
child: const Icon(Icons.today),
);
}
}