diff --git a/example/lib/main.dart b/example/lib/main.dart index fa2aa2f..efe3987 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -32,6 +32,7 @@ class CalendarViewApp extends StatelessWidget { children: [ 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), diff --git a/lib/calendar_tile.dart b/lib/calendar_tile.dart index c6d2f9f..05a32e7 100644 --- a/lib/calendar_tile.dart +++ b/lib/calendar_tile.dart @@ -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, @@ -20,6 +24,7 @@ class CalendarTile extends StatelessWidget { this.dayOfWeekStyles, this.isDayOfWeek: false, this.isSelected: false, + this.selectedDateCircleColor, }); Widget renderDateOrDayOfWeek(BuildContext context) { @@ -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, ), ), diff --git a/lib/flutter_calendar.dart b/lib/flutter_calendar.dart index 2821dc2..bf78bee 100644 --- a/lib/flutter_calendar.dart +++ b/lib/flutter_calendar.dart @@ -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(); @@ -167,6 +168,7 @@ class _CalendarState extends State { } else { dayWidgets.add( new CalendarTile( + selectedDateCircleColor: widget.selectedDateCircleColor, onDateSelected: () => handleSelectedDateAndUserCallback(day), date: day, dateStyles: configureDateStyle(monthStarted, monthEnded),