month_navigation_row.dart 2.7 KB

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