Skip to content
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
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CalendarViewApp extends StatelessWidget {
children: <Widget>[
new Text('The Default Calendar:'),
new Calendar(
selectedDateCircleColor: Color.fromRGBO(159, 159, 59, 0.5),
onSelectedRangeChange: (range) =>
print("Range is ${range.item1}, ${range.item2}"),
onDateSelected: (date) => handleNewDate(date),
Expand Down
13 changes: 11 additions & 2 deletions lib/calendar_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class CalendarTile extends StatelessWidget {
final TextStyle dateStyles;
final Widget child;

/// selectedDateCircleColor needs where needed customised color
/// instead of app theme color
final Color selectedDateCircleColor;

CalendarTile({
this.onDateSelected,
this.date,
Expand All @@ -20,6 +24,7 @@ class CalendarTile extends StatelessWidget {
this.dayOfWeekStyles,
this.isDayOfWeek: false,
this.isSelected: false,
this.selectedDateCircleColor,
});

Widget renderDateOrDayOfWeek(BuildContext context) {
Expand All @@ -40,13 +45,17 @@ class CalendarTile extends StatelessWidget {
decoration: isSelected
? new BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).primaryColor,
color: this.selectedDateCircleColor == null
? Theme.of(context).primaryColor
: this.selectedDateCircleColor,
)
: new BoxDecoration(),
alignment: Alignment.center,
child: new Text(
Utils.formatDay(date).toString(),
style: isSelected ? Theme.of(context).primaryTextTheme.body1 : dateStyles,
style: isSelected
? Theme.of(context).primaryTextTheme.body1
: dateStyles,
textAlign: TextAlign.center,
),
),
Expand Down
22 changes: 12 additions & 10 deletions lib/flutter_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ class Calendar extends StatefulWidget {
final bool showTodayAction;
final bool showCalendarPickerIcon;
final DateTime initialCalendarDateOverride;

Calendar(
{this.onDateSelected,
this.onSelectedRangeChange,
this.isExpandable: false,
this.dayBuilder,
this.showTodayAction: true,
this.showChevronsToChangeRange: true,
this.showCalendarPickerIcon: true,
this.initialCalendarDateOverride});
final Color selectedDateCircleColor;

Calendar({this.onDateSelected,
this.onSelectedRangeChange,
this.isExpandable: false,
this.dayBuilder,
this.showTodayAction: true,
this.showChevronsToChangeRange: true,
this.showCalendarPickerIcon: true,
this.initialCalendarDateOverride,
this.selectedDateCircleColor});

@override
_CalendarState createState() => new _CalendarState();
Expand Down Expand Up @@ -167,6 +168,7 @@ class _CalendarState extends State<Calendar> {
} else {
dayWidgets.add(
new CalendarTile(
selectedDateCircleColor: widget.selectedDateCircleColor,
onDateSelected: () => handleSelectedDateAndUserCallback(day),
date: day,
dateStyles: configureDateStyle(monthStarted, monthEnded),
Expand Down