aboutsummaryrefslogtreecommitdiffstats
path: root/packages/flutter_calendar_carousel/lib/src/calendar_header.dart
diff options
context:
space:
mode:
authorJoel Winarske <joel.winarske@gmail.com>2024-09-05 14:01:44 -0700
committerJoel Winarske <joel.winarske@gmail.com>2024-09-05 15:59:53 -0700
commitd3ea8d7fa4518c258fca3c825ee895487fcaa8ec (patch)
tree36959a2f1f14d147fde981ba817e2020fa55e5e1 /packages/flutter_calendar_carousel/lib/src/calendar_header.dart
parent32d6271fc2430bedd7342475f0fe6e9eb21a9efe (diff)
Flutter SDK 3.24.1
-add flutter_calendar_carousel as local package, and update intl version -address most of the analyze issues; not including flutter_calendar_carousel -update all packages Change-Id: I5db9234726e8e2f8d07e1431e8dac2787c521c08 Signed-off-by: Joel Winarske <joel.winarske@gmail.com> Signed-off-by: Joel Winarske <joel.winarske@toyotaconnected.com> Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
Diffstat (limited to 'packages/flutter_calendar_carousel/lib/src/calendar_header.dart')
-rw-r--r--packages/flutter_calendar_carousel/lib/src/calendar_header.dart73
1 files changed, 73 insertions, 0 deletions
diff --git a/packages/flutter_calendar_carousel/lib/src/calendar_header.dart b/packages/flutter_calendar_carousel/lib/src/calendar_header.dart
new file mode 100644
index 0000000..7fcfd81
--- /dev/null
+++ b/packages/flutter_calendar_carousel/lib/src/calendar_header.dart
@@ -0,0 +1,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();
+}