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.
40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import '../../enum/bar_chart_view_enum.dart';
|
|
|
|
class ChartViewPickerButton extends StatelessWidget {
|
|
final BarChartViewSelection selected;
|
|
final void Function(BarChartViewSelection) onChange;
|
|
const ChartViewPickerButton({
|
|
super.key,
|
|
required this.selected,
|
|
required this.onChange,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopupMenuButton<BarChartViewSelection>(
|
|
icon: Icon(selected.icon),
|
|
tooltip: L10n.of(context)!.changeView,
|
|
initialValue: selected,
|
|
onSelected: (BarChartViewSelection? barChartView) {
|
|
if (barChartView == null) {
|
|
debugPrint("when is barChartView null?");
|
|
return;
|
|
}
|
|
onChange(barChartView);
|
|
},
|
|
itemBuilder: (BuildContext context) => BarChartViewSelection.values
|
|
.map<PopupMenuEntry<BarChartViewSelection>>(
|
|
(BarChartViewSelection barChartView) {
|
|
return PopupMenuItem<BarChartViewSelection>(
|
|
value: barChartView,
|
|
child: Text(barChartView.string(context)),
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
}
|