|
...
|
...
|
@@ -405,28 +405,33 @@ class TodayTabBody extends StatelessWidget { |
|
|
|
|
|
|
|
Widget _buildWeekdayCell(BuildContext context, DateTime day) {
|
|
|
|
final selected = isSameDay(controller.selectedDate.value, day);
|
|
|
|
final isEnabled = !_isAfterToday(day);
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
child: Container(
|
|
|
|
width: _selectedDayWidth,
|
|
|
|
height: _weekRowsHeight / 2,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: selected
|
|
|
|
? BoxDecoration(
|
|
|
|
color: context.colors.primary,
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
top: Radius.circular(22),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
child: Text(
|
|
|
|
isSameDay(day, controller.lastSelectableDay)
|
|
|
|
? AppLocalizations.of(context)!.today
|
|
|
|
: _weekdayText(context, day),
|
|
|
|
style: TextStyle(
|
|
|
|
color: _calendarTextColor(context, day, selected: selected),
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
return GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: isEnabled ? () => _onDaySelected(day, day) : null,
|
|
|
|
child: Center(
|
|
|
|
child: Container(
|
|
|
|
width: _selectedDayWidth,
|
|
|
|
height: _weekRowsHeight / 2,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: selected
|
|
|
|
? BoxDecoration(
|
|
|
|
color: context.colors.primary,
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
top: Radius.circular(22),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
child: Text(
|
|
|
|
isSameDay(day, controller.lastSelectableDay)
|
|
|
|
? AppLocalizations.of(context)!.today
|
|
|
|
: _weekdayText(context, day),
|
|
|
|
style: TextStyle(
|
|
|
|
color: _calendarTextColor(context, day, selected: selected),
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
...
|
...
|
@@ -438,25 +443,31 @@ class TodayTabBody extends StatelessWidget { |
|
|
|
DateTime day, {
|
|
|
|
bool selected = false,
|
|
|
|
}) {
|
|
|
|
return Center(
|
|
|
|
child: Container(
|
|
|
|
width: _selectedDayWidth,
|
|
|
|
height: _weekRowsHeight / 2,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: selected
|
|
|
|
? BoxDecoration(
|
|
|
|
color: context.colors.primary,
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
bottom: Radius.circular(22),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
child: Text(
|
|
|
|
'${day.day}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: _calendarTextColor(context, day, selected: selected),
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
final isEnabled = !_isAfterToday(day);
|
|
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: isEnabled ? () => _onDaySelected(day, day) : null,
|
|
|
|
child: Center(
|
|
|
|
child: Container(
|
|
|
|
width: _selectedDayWidth,
|
|
|
|
height: _weekRowsHeight / 2,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: selected
|
|
|
|
? BoxDecoration(
|
|
|
|
color: context.colors.primary,
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
bottom: Radius.circular(22),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
child: Text(
|
|
|
|
'${day.day}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: _calendarTextColor(context, day, selected: selected),
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
...
|
...
|
@@ -480,7 +491,12 @@ class TodayTabBody extends StatelessWidget { |
|
|
|
if (isSameDay(selectedDay, today.subtract(const Duration(days: 2)))) {
|
|
|
|
return '前天';
|
|
|
|
}
|
|
|
|
return MaterialLocalizations.of(context).formatShortMonthDay(selectedDay);
|
|
|
|
final locale = Localizations.localeOf(context).toString();
|
|
|
|
if (selectedDay.year == today.year) {
|
|
|
|
return DateFormat.Md(locale).format(selectedDay);
|
|
|
|
} else {
|
|
|
|
return DateFormat.yMd(locale).format(selectedDay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool _isAfterToday(DateTime day) {
|
...
|
...
|
|