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

Added events counter #49

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
38 changes: 30 additions & 8 deletions lib/calendar_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CalendarTile extends StatelessWidget {
final String dayOfWeek;
final bool isDayOfWeek;
final bool isSelected;
final List<String> events;
final TextStyle dayOfWeekStyles;
final TextStyle dateStyles;
final Widget child;
Expand All @@ -20,6 +21,7 @@ class CalendarTile extends StatelessWidget {
this.dayOfWeekStyles,
this.isDayOfWeek: false,
this.isSelected: false,
this.events: null,
});

Widget renderDateOrDayOfWeek(BuildContext context) {
Expand All @@ -34,20 +36,40 @@ class CalendarTile extends StatelessWidget {
),
);
} else {
return new InkWell(
return InkWell(
onTap: onDateSelected,
child: new Container(
child: Container(
decoration: isSelected
? new BoxDecoration(
? BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).primaryColor,
)
: new BoxDecoration(),
: BoxDecoration(),
alignment: Alignment.center,
child: new Text(
Utils.formatDay(date).toString(),
style: isSelected ? Theme.of(context).primaryTextTheme.body1 : dateStyles,
textAlign: TextAlign.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
Utils.formatDay(date).toString(),
style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400),
),
events != null && events.length > 0
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: events
.map((event) => Container(
margin: EdgeInsets.only(
left: 2.0, right: 2.0, top: 2.0),
width: 4.0,
height: 4.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).accentColor,
),
))
.toList())
: Container(),
],
),
),
);
Expand Down
25 changes: 14 additions & 11 deletions lib/flutter_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ class Calendar extends StatefulWidget {
final bool showTodayAction;
final bool showCalendarPickerIcon;
final DateTime initialCalendarDateOverride;
final Map events;

Calendar(
{this.onDateSelected,
this.onSelectedRangeChange,
this.isExpandable: false,
this.events,
this.dayBuilder,
this.showTodayAction: true,
this.showChevronsToChangeRange: true,
Expand Down Expand Up @@ -136,6 +138,7 @@ class _CalendarState extends State<Calendar> {
(day) {
dayWidgets.add(
new CalendarTile(
events: widget.events[day],
isDayOfWeek: true,
dayOfWeek: day,
),
Expand All @@ -159,6 +162,7 @@ class _CalendarState extends State<Calendar> {
if (this.widget.dayBuilder != null) {
dayWidgets.add(
new CalendarTile(
events: widget.events[day],
child: this.widget.dayBuilder(context, day),
date: day,
onDateSelected: () => handleSelectedDateAndUserCallback(day),
Expand All @@ -167,6 +171,7 @@ class _CalendarState extends State<Calendar> {
} else {
dayWidgets.add(
new CalendarTile(
events: widget.events[day],
onDateSelected: () => handleSelectedDateAndUserCallback(day),
date: day,
dateStyles: configureDateStyle(monthStarted, monthEnded),
Expand All @@ -185,17 +190,15 @@ class _CalendarState extends State<Calendar> {

if (isExpanded) {
final TextStyle body1StyleDisabled = body1Style.copyWith(
color: Color.fromARGB(
100,
body1Style.color.red,
body1Style.color.green,
body1Style.color.blue,
)
);

dateStyles = monthStarted && !monthEnded
? body1Style
: body1StyleDisabled;
color: Color.fromARGB(
100,
body1Style.color.red,
body1Style.color.green,
body1Style.color.blue,
));

dateStyles =
monthStarted && !monthEnded ? body1Style : body1StyleDisabled;
} else {
dateStyles = body1Style;
}
Expand Down