Both have fixed geometry, so their text scaling is capped at 1.3. Ruler times shrink instead of wrapping into the period number and are only shown when they fit at the current scale. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
90 lines
2.5 KiB
Dart
90 lines
2.5 KiB
Dart
part of '../custom_workweek_calendar.dart';
|
|
|
|
class _DayHeaderStrip extends StatelessWidget {
|
|
final DateTime weekStart;
|
|
final DateTime today;
|
|
final double rulerWidth;
|
|
|
|
const _DayHeaderStrip({
|
|
super.key,
|
|
required this.weekStart,
|
|
required this.today,
|
|
required this.rulerWidth,
|
|
});
|
|
|
|
@override
|
|
// Fixed-height strip with a 28px day circle: unclamped accessibility
|
|
// sizes overflow it.
|
|
Widget build(BuildContext context) => MediaQuery.withClampedTextScaling(
|
|
maxScaleFactor: 1.3,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: rulerWidth),
|
|
for (var d = 0; d < 5; d++)
|
|
Expanded(
|
|
child: _DayHeaderCell(date: weekStart.addDays(d), today: today),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _DayHeaderCell extends StatelessWidget {
|
|
final DateTime date;
|
|
final DateTime today;
|
|
|
|
const _DayHeaderCell({required this.date, required this.today});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final isToday = date.isSameDay(today);
|
|
final dayName = DateFormat(
|
|
'EE',
|
|
Localizations.localeOf(context).toString(),
|
|
).format(date).toUpperCase();
|
|
|
|
final accent = theme.colorScheme.primary;
|
|
final onAccent = theme.colorScheme.onPrimary;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
dayName,
|
|
style: theme.textTheme.labelSmall?.copyWith(
|
|
color: isToday ? accent : theme.colorScheme.onSurfaceVariant,
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 12,
|
|
height: 1.1,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
AnimatedContainer(
|
|
duration: const Duration(milliseconds: 220),
|
|
curve: Curves.easeOutCubic,
|
|
width: 28,
|
|
height: 28,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: isToday ? accent : Colors.transparent,
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
'${date.day}',
|
|
style: theme.textTheme.titleSmall?.copyWith(
|
|
color: isToday ? onAccent : theme.colorScheme.onSurface,
|
|
fontWeight: isToday ? FontWeight.bold : FontWeight.normal,
|
|
height: 1.0,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|