From 51d299ca70c82c54afc235ef21d08471dbd62321 Mon Sep 17 00:00:00 2001 From: AwaisR <74013600+AwaisR@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:36:29 +0500 Subject: [PATCH] modify the header builder --- lib/src/components/month_view_components.dart | 9 ++++--- lib/src/month_view/month_view.dart | 25 ++++++++++++++++--- lib/src/style/header_style.dart | 4 +-- pubspec.yaml | 1 + 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index af17d548..7de1e402 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import '../calendar_event_data.dart'; import '../constants.dart'; @@ -213,14 +214,16 @@ class MonthPageHeader extends CalendarPageHeader { onPreviousDay: onPreviousMonth, onTitleTapped: onTitleTapped, // ignore_for_file: deprecated_member_use_from_same_package - backgroundColor: backgroundColor, + backgroundColor: Colors.white, iconColor: iconColor, dateStringBuilder: dateStringBuilder ?? MonthPageHeader._monthStringBuilder, headerStyle: headerStyle, ); - static String _monthStringBuilder(DateTime date, {DateTime? secondaryDate}) => - "${date.month} - ${date.year}"; + static String _monthStringBuilder(DateTime date, {DateTime? secondaryDate}){ + final DateFormat dateFormat = DateFormat('MMM yyyy'); + return dateFormat.format(date).toUpperCase(); + } } class WeekDayTile extends StatelessWidget { diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 11a794bd..746b6c06 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -286,9 +286,28 @@ class MonthViewState extends State> { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: _width, - child: _headerBuilder(_currentDate), + Row( + children: [ + const Text( + 'Calendar', + style: TextStyle( + color: Color(0xFF475466), + fontSize: 18, + fontFamily: 'Inter', + fontWeight: FontWeight.w700, + ), + ), + Container( + width: 128, + height: 50, + margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15), + decoration: BoxDecoration( + border: Border.all(color: Color(0xffD0D5DD), width: 1), + borderRadius: BorderRadius.circular(8), + color: Colors.white), + child: _headerBuilder(_currentDate), + ), + ], ), Expanded( child: PageView.builder( diff --git a/lib/src/style/header_style.dart b/lib/src/style/header_style.dart index c8929ee8..f70c361b 100644 --- a/lib/src/style/header_style.dart +++ b/lib/src/style/header_style.dart @@ -44,8 +44,8 @@ class HeaderStyle { this.headerTextStyle, this.leftIcon, this.rightIcon, - this.leftIconVisible = true, - this.rightIconVisible = true, + this.leftIconVisible = false, + this.rightIconVisible = false, this.headerMargin = EdgeInsets.zero, this.headerPadding = EdgeInsets.zero, this.leftIconPadding = const EdgeInsets.all(10), diff --git a/pubspec.yaml b/pubspec.yaml index 87539ae1..2b24ad5d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: flutter: sdk: flutter + intl: ^0.18.1 dev_dependencies: flutter_test: