Skip to content

Commit

Permalink
Expose dayCrossAxisAlignment and dayMainAxisAlignment to resolve #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Sep 14, 2019
1 parent 8e8a2f7 commit 86a0008
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 45 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## [1.3.21]
## [1.3.23]
+ Support intl >= 0.15.7 < 0.17.0 to inclease `pub` health
+ Removed deprecated methods ~~`markedDates`~~, ~~`markedDateColor`~~
+ Fixes [#101](https://github.com/dooboolab/flutter_calendar_carousel/issues/101)
+ Fixes [#104](https://github.com/dooboolab/flutter_calendar_carousel/issues/104)
+ Fixes [#112](https://github.com/dooboolab/flutter_calendar_carousel/issues/112)
+ Fixes [#119](https://github.com/dooboolab/flutter_calendar_carousel/issues/119)
+ Support long pressed as a feature request[#103](https://github.com/dooboolab/flutter_calendar_carousel/issues/103)
+ Support semantic label as a feature request [#139](https://github.com/dooboolab/flutter_calendar_carousel/issues/139)
+ Expose `dayCrossAxisAlignment` and `dayMainAxisAlignment` to resolve [#122](https://github.com/dooboolab/flutter_calendar_carousel/issues/122)
## [1.3.20]
+ Support intl >= 0.15.7
## [1.3.19]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ For help getting started with Flutter, view our online
| weekDayFormat | `WeekdayFormat` | `short` |
| staticSixWeekFormat | `bool` | `false` |
| showOnlyCurrentMonthDate | `bool` | `false` |
| dayCrossAxisAlignment | `CrossAxisAlignment` | `CrossAxisAlignment.center` |
| dayMainAxisAlignment | `MainAxisAlignment` | `CrossAlignment.center` |

With ``CalendarCarousel<YourEventClass>`` and ``EventList<YourEventClass>`` you can specifiy a custom Event class.

Expand Down
100 changes: 56 additions & 44 deletions lib/flutter_calendar_carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class CalendarCarousel<T> extends StatefulWidget {
final bool showOnlyCurrentMonthDate;
final bool pageSnapping;
final OnDayLongPressed onDayLongPressed;
final CrossAxisAlignment dayCrossAxisAlignment;
final MainAxisAlignment dayMainAxisAlignment;

CalendarCarousel({
this.viewportFraction = 1.0,
Expand Down Expand Up @@ -158,6 +160,8 @@ class CalendarCarousel<T> extends StatefulWidget {
this.showOnlyCurrentMonthDate = false,
this.pageSnapping = false,
this.onDayLongPressed,
this.dayCrossAxisAlignment = CrossAxisAlignment.center,
this.dayMainAxisAlignment = MainAxisAlignment.center,
});

@override
Expand Down Expand Up @@ -284,7 +288,7 @@ class _CalendarState<T> extends State<CalendarCarousel<T>> {
);
}

DefaultTextStyle getDefaultTextStyle(
Widget getDayContainer(
bool isSelectable,
int index,
bool isSelectedDay,
Expand All @@ -296,48 +300,58 @@ class _CalendarState<T> extends State<CalendarCarousel<T>> {
bool isThisMonthDay,
DateTime now,
) {
return DefaultTextStyle(
style: !isSelectable
? defaultInactiveDaysTextStyle
: (_localeDate.dateSymbols.WEEKENDRANGE.contains(
(index - 1 + firstDayOfWeek) % 7)) && !isSelectedDay && !isToday
? (isPrevMonthDay
? defaultPrevDaysTextStyle
: isNextMonthDay
? defaultNextDaysTextStyle
: isSelectable
? defaultWeekendTextStyle
: defaultInactiveWeekendTextStyle)
: isToday
? defaultTodayTextStyle
: isSelectable && textStyle != null
? textStyle
: defaultTextStyle,
child: Text(
'${now.day}',
semanticsLabel: now.day.toString(),
style:
isSelectedDay && widget.selectedDayTextStyle != null
? widget.selectedDayTextStyle
return Container(
width: double.infinity,
height: double.infinity,
child: Row(
crossAxisAlignment: widget.dayCrossAxisAlignment,
mainAxisAlignment: widget.dayMainAxisAlignment,
children: <Widget>[
DefaultTextStyle(
style: !isSelectable
? defaultInactiveDaysTextStyle
: (_localeDate.dateSymbols.WEEKENDRANGE.contains(
(index - 1 + firstDayOfWeek) % 7))
&& !isSelectedDay
&& isThisMonthDay
&& !isToday
? (isSelectable
? widget.weekendTextStyle
: widget.inactiveWeekendTextStyle)
: !isSelectable
? widget.inactiveDaysTextStyle
: isPrevMonthDay
? widget.prevDaysTextStyle
(index - 1 + firstDayOfWeek) % 7)) && !isSelectedDay && !isToday
? (isPrevMonthDay
? defaultPrevDaysTextStyle
: isNextMonthDay
? widget.nextDaysTextStyle
: isToday
? widget.todayTextStyle
: widget.daysTextStyle,
maxLines: 1,
),
? defaultNextDaysTextStyle
: isSelectable
? defaultWeekendTextStyle
: defaultInactiveWeekendTextStyle)
: isToday
? defaultTodayTextStyle
: isSelectable && textStyle != null
? textStyle
: defaultTextStyle,
child: Text(
'${now.day}',
semanticsLabel: now.day.toString(),
style:
isSelectedDay && widget.selectedDayTextStyle != null
? widget.selectedDayTextStyle
: (_localeDate.dateSymbols.WEEKENDRANGE.contains(
(index - 1 + firstDayOfWeek) % 7))
&& !isSelectedDay
&& isThisMonthDay
&& !isToday
? (isSelectable
? widget.weekendTextStyle
: widget.inactiveWeekendTextStyle)
: !isSelectable
? widget.inactiveDaysTextStyle
: isPrevMonthDay
? widget.prevDaysTextStyle
: isNextMonthDay
? widget.nextDaysTextStyle
: isToday
? widget.todayTextStyle
: widget.daysTextStyle,
maxLines: 1,
),
),
],
),
);
}

Expand Down Expand Up @@ -401,9 +415,7 @@ class _CalendarState<T> extends State<CalendarCarousel<T>> {
),
child: Stack(
children: <Widget>[
Center(
child: getDefaultTextStyle(isSelectable, index, isSelectedDay, isToday, isPrevMonthDay, textStyle, defaultTextStyle, isNextMonthDay, isThisMonthDay, now),
),
getDayContainer(isSelectable, index, isSelectedDay, isToday, isPrevMonthDay, textStyle, defaultTextStyle, isNextMonthDay, isThisMonthDay, now),
widget.markedDatesMap != null
? _renderMarkedMapContainer(now)
: Container(),
Expand Down

0 comments on commit 86a0008

Please sign in to comment.