You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/pangea/pages/analytics/time_span_menu_button.dart

39 lines
1.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import '../../enum/time_span.dart';
class TimeSpanMenuButton extends StatelessWidget {
final TimeSpan value;
final void Function(TimeSpan) onChange;
const TimeSpanMenuButton({
super.key,
required this.value,
required this.onChange,
});
@override
Widget build(BuildContext context) {
return PopupMenuButton<TimeSpan>(
icon: const Icon(Icons.calendar_month_outlined),
tooltip: L10n.of(context)!.changeDateRange,
initialValue: value,
onSelected: (TimeSpan? timeSpan) {
if (timeSpan == null) {
debugPrint("when is timeSpan null?");
return;
}
onChange(timeSpan);
},
itemBuilder: (BuildContext context) =>
TimeSpan.values.map<PopupMenuEntry<TimeSpan>>((TimeSpan timeSpan) {
return PopupMenuItem<TimeSpan>(
value: timeSpan,
child: Text(timeSpan.string(context)),
);
}).toList(),
);
}
}