1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
import 'package:flutter/material.dart';
import 'default_styles.dart' show defaultHeaderTextStyle;
class CalendarHeader extends StatelessWidget {
/// Passing in values for [leftButtonIcon] or [rightButtonIcon] will override [headerIconColor]
CalendarHeader(
{required this.headerTitle,
this.headerMargin,
required this.showHeader,
this.headerTextStyle,
this.showHeaderButtons = true,
this.headerIconColor,
this.leftButtonIcon,
this.rightButtonIcon,
required this.onLeftButtonPressed,
required this.onRightButtonPressed,
this.onHeaderTitlePressed})
: isTitleTouchable = onHeaderTitlePressed != null;
final String headerTitle;
final EdgeInsetsGeometry? headerMargin;
final bool showHeader;
final TextStyle? headerTextStyle;
final bool showHeaderButtons;
final Color? headerIconColor;
final Widget? leftButtonIcon;
final Widget? rightButtonIcon;
final VoidCallback onLeftButtonPressed;
final VoidCallback onRightButtonPressed;
final bool isTitleTouchable;
final VoidCallback? onHeaderTitlePressed;
TextStyle get getTextStyle => headerTextStyle ?? defaultHeaderTextStyle;
Widget _leftButton() => IconButton(
onPressed: onLeftButtonPressed,
icon:
leftButtonIcon ?? Icon(Icons.chevron_left, color: headerIconColor),
);
Widget _rightButton() => IconButton(
onPressed: onRightButtonPressed,
icon: rightButtonIcon ??
Icon(Icons.chevron_right, color: headerIconColor),
);
Widget _headerTouchable() => TextButton(
onPressed: onHeaderTitlePressed,
child: Text(
headerTitle,
semanticsLabel: headerTitle,
style: getTextStyle,
),
);
@override
Widget build(BuildContext context) => showHeader
? Container(
margin: headerMargin,
child: DefaultTextStyle(
style: getTextStyle,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
showHeaderButtons ? _leftButton() : Container(),
isTitleTouchable
? _headerTouchable()
: Text(headerTitle, style: getTextStyle),
showHeaderButtons ? _rightButton() : Container(),
])),
)
: Container();
}
|