Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rwbr/flutter_neat_and_clean_calendar
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	pubspec.lock
  • Loading branch information
agfeo-rw committed Jun 30, 2022
2 parents 585b287 + c5c7e3c commit 315774c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## [0.3.6+19] - 2022-06-30
## [0.3.7+20] - 2022-06-30
* Support for macOS widgets

## [0.3.6+19] - 2022-06-03
* Issue #37 closed

## [0.3.5+18] - 2022-05-04
* Option to change color of selected day when same date as today

Expand Down
26 changes: 18 additions & 8 deletions lib/flutter_neat_and_clean_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ class _CalendarState extends State<Calendar> {
super.initState();
isExpanded = widget.isExpanded;

_selectedDate = widget.initialDate ?? DateTime.now();
initializeDateFormatting(widget.locale, null).then((_) => setState(() {
var monthFormat =
DateFormat('MMMM yyyy', widget.locale).format(_selectedDate);
displayMonth =
'${monthFormat[0].toUpperCase()}${monthFormat.substring(1)}';
}));
}

/// The method [_updateEventsMap] has the purpose to update the eventsMap, when the calendar widget
/// renders its view. When this method executes, it fills the eventsMap with the contents of the
/// given eventsList. This can be used to update the events shown by the calendar.
void _updateEventsMap() {
eventsMap = widget.events ?? {};
// If the user provided a list of events, then convert it to a map, but only if there
// was no map of events provided. To provide the events in form of a map is the way,
Expand Down Expand Up @@ -261,21 +274,16 @@ class _CalendarState extends State<Calendar> {
}
});
}

_selectedDate = widget.initialDate ?? DateTime.now();
selectedMonthsDays = _daysInMonth(_selectedDate);
selectedWeekDays = Utils.daysInRange(
_firstDayOfWeek(_selectedDate), _lastDayOfWeek(_selectedDate))
.toList();
initializeDateFormatting(widget.locale, null).then((_) => setState(() {
var monthFormat =
DateFormat('MMMM yyyy', widget.locale).format(_selectedDate);
displayMonth =
'${monthFormat[0].toUpperCase()}${monthFormat.substring(1)}';
}));

_selectedEvents = eventsMap?[DateTime(
_selectedDate.year, _selectedDate.month, _selectedDate.day)] ??
[];

print('eventsMap has ${eventsMap?.length} entries');
}

Widget get nameAndIconRow {
Expand Down Expand Up @@ -715,6 +723,8 @@ class _CalendarState extends State<Calendar> {

@override
Widget build(BuildContext context) {
_updateEventsMap();

// If _selectedEvents is not null, then we sort the events by isAllDay propeerty, so that
// all day events are displayed at the top of the list.
// Slightly inexxficient, to do this sort each time, the widget builds.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ packages:
source: hosted
version: "2.1.2"
sdks:
dart: ">=2.17.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.20.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
Simple and clean flutter calendar with ability to slide up/down to show
weekly/monthly calendar. Fork of
https://pub.dev/packages/flutter_clean_calendar
version: 0.3.6+19
version: 0.3.7+20
homepage: https://github.com/rwbr/flutter_neat_and_clean_calendar

environment:
Expand Down

0 comments on commit 315774c

Please sign in to comment.