feat(todo): a project's Calendar as a month on wide windows (ADR 0033, D17)

From 720 pixels of the Calendar's own width on, a month grid in place
of the agenda: the month's weeks from the week's first day, the days
of the months beside it muted, each day with as many of its tasks as
fit and the rest counted, opening the day's tasks in a sheet; past
days with their overdue and done tasks. A task held and dropped on
another day moves there (moveTask), a day's free space tapped adds a
task on it, a line tapped opens its task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-01 21:33:51 +01:00
commit 0b6f79244f
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 761 additions and 51 deletions

View file

@ -12,6 +12,7 @@ import 'package:halkyon_todo_flutter/src/feature/label/model/label.dart';
import 'package:halkyon_todo_flutter/src/feature/project/data/project_repository.dart';
import 'package:halkyon_todo_flutter/src/feature/project/model/project.dart';
import 'package:halkyon_todo_flutter/src/feature/project/model/project_view.dart';
import 'package:halkyon_todo_flutter/src/feature/project/widget/month_grid.dart';
import 'package:halkyon_todo_flutter/src/feature/project/widget/project_board.dart';
import 'package:halkyon_todo_flutter/src/feature/project/widget/project_calendar_view.dart';
import 'package:halkyon_todo_flutter/src/feature/section/data/section_repository.dart';
@ -713,6 +714,146 @@ void main() {
);
expect(find.byTooltip('Mark as done'), findsOneWidget);
});
group('as a month on a wide window', () {
/// Another day of today's month, so in its grid.
Day otherDay() {
final today = Day.of(DateTime.now());
return today.plus(1).month == today.month
? today.plus(1)
: today.plus(-1);
}
/// The Inbox's Calendar on a desktop's window, [titles] today.
Future<List<String>> monthOf(
WidgetTester tester, [
List<String> titles = const ['Dentist'],
]) async {
await calendarOf(tester);
for (final title in titles) {
await seed(
tester,
TaskContent(
title: title,
projectId: inbox(),
date: TaskDate(Day.of(DateTime.now())),
),
);
}
tester.view.physicalSize = const Size(1000, 900);
await tester.pumpAndSettle();
final stored = await tester.runAsync(() => tasks().all());
return [
for (final title in titles)
stored!.singleWhere((t) => t.content?.title == title).id,
];
}
testWidgets('the month’s weeks, each day with its tasks; the agenda '
'again once the window narrows', (tester) async {
final [id] = await monthOf(tester);
final today = Day.of(DateTime.now());
expect(find.byType(MonthGrid), findsOneWidget);
expect(find.byType(WeekStrip), findsNothing);
expect(
find.byKey(MonthGrid.chipKey(id, today)),
findsOneWidget,
);
expect(
find.byKey(MonthGrid.dayKey(Day(today.year, today.month, 1))),
findsOneWidget,
);
await tester.tap(find.byTooltip('Following month'));
await tester.pumpAndSettle();
expect(find.byKey(MonthGrid.chipKey(id, today)), findsNothing);
await tester.tap(find.byTooltip('Back to today'));
await tester.pumpAndSettle();
expect(
find.byKey(MonthGrid.chipKey(id, today)),
findsOneWidget,
);
tester.view.physicalSize = const Size(412, 900);
await tester.pumpAndSettle();
expect(find.byType(MonthGrid), findsNothing);
expect(find.byType(WeekStrip), findsOneWidget);
});
testWidgets('a task held and dropped on another day moves there, '
'which can be undone', (tester) async {
final [id] = await monthOf(tester);
final today = Day.of(DateTime.now());
final target = otherDay();
final from = tester.getCenter(
find.byKey(MonthGrid.chipKey(id, today)),
);
final to = tester.getCenter(find.byKey(MonthGrid.dayKey(target)));
final gesture = await tester.startGesture(from);
await tester.pump(
kLongPressTimeout + const Duration(milliseconds: 50),
);
for (var step = 1; step <= 10; step++) {
await gesture.moveTo(Offset.lerp(from, to, step / 10)!);
await tester.pump();
}
await gesture.up();
await tester.pumpAndSettle();
Future<Day?> dayOf() async {
final stored = await tester.runAsync(() => tasks().all());
return stored!.singleWhere((t) => t.id == id).content!.date?.day;
}
expect(await dayOf(), target);
expect(find.byKey(MonthGrid.chipKey(id, target)), findsOneWidget);
await tester.tap(find.text('Undo'));
await tester.pumpAndSettle();
expect(await dayOf(), today);
});
testWidgets('a day with more than fits counts the rest, which open '
'with the others in a sheet', (tester) async {
final titles = [for (var i = 1; i <= 8; i++) 'Task $i'];
await monthOf(tester, titles);
final today = Day.of(DateTime.now());
final more = find.byKey(MonthGrid.moreKey(today));
expect(more, findsOneWidget);
final shown = titles
.where((title) => find.text(title).evaluate().isNotEmpty)
.length;
expect(shown, lessThan(titles.length));
expect(find.text('${titles.length - shown} more'), findsOneWidget);
await tester.tap(more);
await tester.pumpAndSettle();
for (final title in titles) {
expect(row(title), findsOneWidget);
}
});
testWidgets('a day’s free space tapped adds a task on it', (
tester,
) async {
await monthOf(tester);
final target = otherDay();
final cell = find.byKey(MonthGrid.dayKey(target));
await tester.tapAt(
tester.getBottomRight(cell) - const Offset(8, 8),
);
await tester.pumpAndSettle();
await tester.enterText(find.byKey(quickAddTitleKey), 'Call');
await tester.pump();
await tester.tap(find.widgetWithText(FilledButton, 'Add'));
await tester.pumpAndSettle();
final stored = await tester.runAsync(() => tasks().all());
final call = stored!.singleWhere((t) => t.content?.title == 'Call');
expect(call.content!.date!.day, target);
expect(call.content!.projectId, inbox());
});
});
});
});
group("Upcoming's Display (D17)", () {

View file

@ -171,4 +171,89 @@ void main() {
);
expect(shown(calendar), {today: 'a,b'});
});
group('a month as a grid (D17)', () {
test('its weeks from the one with its first day to the one with its '
'last, starting on the week’s first day', () {
// November 2026 starts on a Sunday and ends on a Monday.
expect(monthWeeks(const Day(2026, 11, 1), DateTime.monday), [
const Day(2026, 10, 26),
const Day(2026, 11, 2),
const Day(2026, 11, 9),
const Day(2026, 11, 16),
const Day(2026, 11, 23),
const Day(2026, 11, 30),
]);
expect(monthWeeks(const Day(2026, 11, 20), DateTime.sunday), [
const Day(2026, 11, 1),
const Day(2026, 11, 8),
const Day(2026, 11, 15),
const Day(2026, 11, 22),
const Day(2026, 11, 29),
]);
// February 2027 fills four weeks from a Monday.
expect(monthWeeks(const Day(2027, 2, 1), DateTime.monday), hasLength(4));
});
test('each day from its first to before its end with its tasks, past '
'ones too, done ones where kept, by time', () {
final days = monthOf(
[
task('none'),
task('late', day: today.plus(-3)),
task('done', day: today.plus(-1), completed: true),
task('noon', day: today.plus(2), time: 12 * 60),
task('morning', day: today.plus(2), time: 8 * 60),
task('after', day: today.plus(30)),
],
today,
from: today.plus(-5),
to: today.plus(30),
);
expect(days.keys.first, today.plus(-5));
expect(days, hasLength(35));
expect(
{
for (final MapEntry(:key, :value) in days.entries)
if (value.isNotEmpty)
key: [for (final entry in value) entry.task.id].join(','),
},
{
today.plus(-3): 'late',
today.plus(-1): 'done',
today.plus(2): 'morning,noon',
},
);
});
test('later times of repeating tasks from today on alone, where asked', () {
final weekly = task(
'weekly',
day: today.plus(-7),
repeat: const Repeat(RepeatUnit.week),
);
expect(
monthOf([weekly], today, from: today.plus(-14), to: today.plus(14))
.values
.expand((entries) => entries)
.map((entry) => entry.task.content.date!.day),
[today.plus(-7)],
);
final days = monthOf(
[weekly],
today,
from: today.plus(-14),
to: today.plus(14),
occurrences: true,
);
final later = [
for (final MapEntry(:key, :value) in days.entries)
for (final entry in value)
if (entry.occurrence) key,
];
// Overdue a week, done today it would come a week on, then the
// grid ends.
expect(later, [today.plus(7)]);
});
});
}