Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify the header builder #276

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/src/components/month_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 22 additions & 3 deletions lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,28 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
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(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/style/header_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
intl: ^0.18.1

dev_dependencies:
flutter_test:
Expand Down
Loading