Line data Source code
1 : import 'package:flutter/material.dart';
2 : import 'day_picker.dart' as day_picker;
3 : import 'icon_btn.dart';
4 : import 'range_picker.dart';
5 : import 'semantic_sorting.dart';
6 : import 'week_picker.dart';
7 :
8 : /// Month navigation widget for day based date pickers like
9 : /// [day_picker.DayPicker],
10 : /// [WeekPicker],
11 : /// [RangePicker].
12 : ///
13 : /// It is row with [title] of showing month in the center and icons to selects
14 : /// previous and next month around it.
15 : class MonthNavigationRow extends StatelessWidget {
16 : /// Key for previous page icon.
17 : ///
18 : /// Can be useful in integration tests to find icon.
19 : final Key? previousPageIconKey;
20 :
21 : /// Key for next page icon.
22 : ///
23 : /// Can be useful in integration tests to find icon.
24 : final Key? nextPageIconKey;
25 :
26 : /// Function called when [nextIcon] is tapped.
27 : final VoidCallback? onNextMonthTapped;
28 :
29 : /// Function called when [prevIcon] is tapped.
30 : final VoidCallback? onPreviousMonthTapped;
31 :
32 : /// Tooltip for the [nextIcon].
33 : final String? nextMonthTooltip;
34 :
35 : /// Tooltip for the [prevIcon].
36 : final String? previousMonthTooltip;
37 :
38 : /// Widget to use at the end of this row (after title).
39 : final Widget nextIcon;
40 :
41 : /// Widget to use at the beginning of this row (before title).
42 : final Widget prevIcon;
43 :
44 : /// Usually [Text] widget.
45 : final Widget? title;
46 :
47 : /// Creates month navigation row.
48 0 : const MonthNavigationRow({
49 : Key? key,
50 : this.previousPageIconKey,
51 : this.nextPageIconKey,
52 : this.onNextMonthTapped,
53 : this.onPreviousMonthTapped,
54 : this.nextMonthTooltip,
55 : this.previousMonthTooltip,
56 : this.title,
57 : required this.nextIcon,
58 : required this.prevIcon
59 0 : }) : super(key: key);
60 :
61 0 : @override
62 : // ignore: prefer_expression_function_bodies
63 : Widget build(BuildContext context) {
64 0 : return Row(
65 : mainAxisAlignment: MainAxisAlignment.spaceBetween,
66 : crossAxisAlignment: CrossAxisAlignment.center,
67 0 : children: <Widget>[
68 0 : Semantics(
69 : sortKey: MonthPickerSortKey.previousMonth,
70 0 : child: IconBtn(
71 0 : key: previousPageIconKey,
72 0 : icon: prevIcon,
73 0 : tooltip: previousMonthTooltip,
74 0 : onTap: onPreviousMonthTapped,
75 : ),
76 : ),
77 0 : Expanded(
78 0 : child: Container(
79 : alignment: Alignment.center,
80 0 : child: Center(
81 0 : child: ExcludeSemantics(
82 0 : child: title,
83 : ),
84 : ),
85 : ),
86 : ),
87 0 : Semantics(
88 : sortKey: MonthPickerSortKey.nextMonth,
89 0 : child: IconBtn(
90 0 : key: nextPageIconKey,
91 0 : icon: nextIcon,
92 0 : tooltip: nextMonthTooltip,
93 0 : onTap: onNextMonthTapped,
94 : ),
95 : ),
96 : ],
97 : );
98 : }
99 : }
|