feat(app): a Pomodoro timer on Home, in the notification and in the top bar

Home has a Pomodoro timer (decided 2026-10-07, after Goodtime): the
profile it runs, chosen there while no timer is set, the time left of
the phase, and Start, Pause or Resume, Skip and Stop. While studying, a
small countdown sits in the study screen's header, and a tap pauses it
or goes on. A phase that ends leads to the next, which starts by itself
where the profile says so and otherwise waits, paused at its full
length.

Profiles follow the person to every device, in their settings (schema
4, still written as schema 3 while the profiles are as they come, so
older apps go on reading the settings): Classic, 25 minutes of focus,
5 of break and 15 after four, and 52/17 without long breaks, built in;
both can be changed, more added and deleted, from Home's card or from
Settings. A profile can start breaks and focus by themselves, and keep
the device quiet while focusing. The running timer is the device's own,
kept in the person's folder: closed and opened again, the app catches
up with the phases that ran out meanwhile.

Android: the app's own foreground service (Kotlin, specialUse, as
Goodtime does) shows an ongoing notification counting the phase down,
with Pause or Resume, Skip and Stop; on Android 16 it is a Live Update,
its progress bar the profile's cycle, each phase a segment, focus in
cobalt and breaks in copper. An exact alarm (USE_EXACT_ALARM) alerts
with sound and vibration when the phase ends, also with the app
closed, and Do Not Disturb goes on while focusing once the person
allowed it, the filter before given back afterwards. No notification
plugin: flutter_local_notifications has Live Updates only in a
prerelease that needs compileSdk 37; androidx.core 1.18, which the
build resolved already, has every API needed.

Linux, over the session bus (package:dbus, already in the build): where
the desktop shows icons in its top bar (GNOME with the AppIndicator
extension, which Ubuntu has built in; KDE) the timer counts down there,
the buttons in the icon's menu, as a StatusNotifierItem written in Dart
on the names and paths the snap's desktop plug allows; elsewhere a
notification with the buttons says until when the phase runs. An alert
with sound ends each phase while the app runs, and GNOME's banners stay
off while focusing, through gsettings. xdg-desktop-portal's Background
status, the planned fallback, serves Flatpaks only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-07 02:54:52 +02:00
commit 918e10bb2b
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_learn_flutter/src/core/content/payload.dart';
import 'package:halkyon_learn_flutter/src/feature/home/model/home_layout.dart';
import 'package:halkyon_learn_flutter/src/feature/home/model/study_goal.dart';
import 'package:halkyon_learn_flutter/src/feature/pomodoro/model/pomodoro_profile.dart';
import 'package:halkyon_learn_flutter/src/feature/settings/data/settings_payload.dart';
import 'package:halkyon_learn_flutter/src/feature/settings/model/person_settings.dart';
import 'package:halkyon_learn_flutter/src/feature/study/model/study_options.dart';
@ -106,6 +107,7 @@ void main() {
order: [
HomeWidget.activity,
HomeWidget.goal,
HomeWidget.pomodoro,
HomeWidget.deadlines,
HomeWidget.week,
],
@ -122,14 +124,15 @@ void main() {
encodePayload(3, {
'studyTags': {},
'home': {
'order': ['activity', 'pomodoro'],
'hidden': ['pomodoro'],
'order': ['activity', 'clock'],
'hidden': ['clock'],
},
}),
);
expect(settings.home.order, [
HomeWidget.activity,
HomeWidget.pomodoro,
HomeWidget.goal,
HomeWidget.deadlines,
HomeWidget.week,
@ -149,4 +152,69 @@ void main() {
expect(folded.restDays, {DateTime(2026, 10, 5), DateTime(2026, 10, 6)});
expect(folded.goal, theirs.goal);
});
group('Pomodoro profiles', () {
const mine = PomodoroProfile(
id: 'mine',
name: 'Exam weeks',
focusMinutes: 40,
shortBreakMinutes: 8,
longBreakMinutes: 20,
longBreakAfter: 3,
autoStartFocus: true,
autoStartBreaks: true,
doNotDisturb: true,
);
test('survive a round trip, in the fourth schema', () {
const settings = PersonSettings(
pomodoro: PomodoroSettings(
profiles: [PomodoroProfile.classic, mine],
selectedId: 'mine',
),
);
final payload = encodeSettingsPayload(settings);
expect(settingsSchemaVersion, 4);
expect(decodePayload(payload, newestSchema: 4)['schemaVersion'], 4);
expect(decodeSettingsPayload(payload), settings);
});
test('as they come, are written in the third schema, which older apps '
'read', () {
final payload = encodeSettingsPayload(const PersonSettings());
expect(decodePayload(payload, newestSchema: 4)['schemaVersion'], 3);
});
test('that are malformed read as they come, keeping the other '
'settings', () {
final settings = decodeSettingsPayload(
encodePayload(4, {
'studyTags': {},
'study': {'newPerDay': 10},
'pomodoro': {
'profiles': [
{'id': 'x', 'focus': 'long'},
],
},
}),
);
expect(settings.pomodoro, const PomodoroSettings());
expect(settings.study.newPerDay, 10);
});
test('folding keeps the profiles of the settings that have any', () {
const theirs = PersonSettings(
pomodoro: PomodoroSettings(profiles: [mine], selectedId: 'mine'),
);
expect(
const PersonSettings().foldedWith(theirs).pomodoro,
theirs.pomodoro,
);
});
});
}