mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-23 21:46:28 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Flutter 3.50 deprecates package:flutter/material.dart, so the app moves to material_ui 1.11.0 together with sync_settings_ui 0.8.0 and github_device_auth 0.5.0 (crdt_sync 0.13.1 rides along). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'package:material_ui/material_ui.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)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|