mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-24 21:06:22 +01:00
Tapping today or a later normal day opens a sheet with one switch per locker (Workout lock, LeetCode, Book, Diet, Wake alarm), all off, and "Mark sick"; a sick day reopens with its switches, "Save" (keep-only edit, nothing written when unchanged) and "Clear sick day". Past days stay inert. A sick day keeping any locker carries a dot in the calendar and a "Kept: ..." line in the list. DayCell moves to day_cell.dart for the 250-line cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PAhbNszs5JKdtnD4uBi3xp
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
Widget _dot(Color color) => Container(
|
|
key: const ValueKey<String>('day-badge'),
|
|
width: 6,
|
|
height: 6,
|
|
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
|
);
|
|
|
|
/// One day box: renders the state it is handed and reports taps.
|
|
class DayCell extends StatelessWidget {
|
|
/// Creates a cell for [day] of the month.
|
|
const DayCell({
|
|
required this.day,
|
|
required this.isMarked,
|
|
required this.isWorkday,
|
|
required this.isPast,
|
|
required this.markColor,
|
|
required this.onMarkColor,
|
|
required this.onTap,
|
|
this.badge = false,
|
|
super.key,
|
|
});
|
|
|
|
/// Whether a small dot sits in the corner, in [onMarkColor].
|
|
final bool badge;
|
|
|
|
/// The day of the month, as shown in the box.
|
|
final int day;
|
|
|
|
/// Whether this date is marked in the pool.
|
|
final bool isMarked;
|
|
|
|
/// A marked day's fill.
|
|
final Color markColor;
|
|
|
|
/// Text on [markColor].
|
|
final Color onMarkColor;
|
|
|
|
/// Whether this date is a weekly workday (Tue/Wed/Thu), shaded.
|
|
final bool isWorkday;
|
|
|
|
/// Whether this date is read-only (past, or today on the free grid).
|
|
final bool isPast;
|
|
|
|
/// Called on tap, or null when the cell is inert.
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
// Past days keep their marker, faded: the record is history, not a
|
|
// choice still open.
|
|
final fade = isPast ? 0.38 : 1.0;
|
|
final background = isMarked
|
|
? markColor.withValues(alpha: fade)
|
|
: isWorkday
|
|
? colors.surfaceContainerHigh
|
|
: null;
|
|
final foreground = isMarked
|
|
? onMarkColor
|
|
: colors.onSurface.withValues(alpha: fade);
|
|
return InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: background,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
'$day',
|
|
style: TextStyle(
|
|
color: foreground,
|
|
fontWeight: isMarked ? FontWeight.w600 : FontWeight.normal,
|
|
),
|
|
),
|
|
if (badge) Positioned(top: 4, right: 4, child: _dot(foreground)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|