screen-locker/scripts/_fit_extra_screens.py
Krzysztof kuhy Rudnicki 8450644a56 Lock screen: "choose lockers…" opens sickdays' KeepPanel in the lock
Next to the one-tap "I'm sick" (unchanged: keeps nothing, unlocks), a small
secondary link lays sickdays 0.3.0's embeddable KeepPanel over every
surface, in-process so it gets input under the lock's grab. Closing the
overlay reveals the untouched screen underneath, so no countdown or phone
check is restarted or skipped.

After the panel's own write + sync: sick with the workout lock standing
down -> sick floor, decision, close (shared with the one-tap path, no second
mark or push); sick with the workout kept -> sick floor and a note, lock
stays; cleared / unchanged / cancel -> the panel just closes.

Tests stub KeepPanel and redirect resolve_paths and sync_quietly in every
sickdays.* module, sickdays.gui._panel included. The fit check measures the
panel on a throwaway pool. Pins bumped to sickdays-v0.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PAhbNszs5JKdtnD4uBi3xp
2026-10-17 14:06:22 +02:00

63 lines
2.2 KiB
Python

"""Lock screens the fit check measures through their own builders.
Split out of ``verify_screen_fits`` for the 250-line cap. These screens are
not painted by a ``ScreenHost`` flow: heat-skip owns a fullscreen ``tk.Tk()``
of its own in production, and the "choose lockers" panel is sickdays'
KeepPanel laid over the lock rather than a repaint of it.
"""
from __future__ import annotations
from pathlib import Path
import tempfile
from typing import TYPE_CHECKING
from gatelock import LockConfig
import sickdays
from screen_locker._heat_skip import build_heat_skip_content
from screen_locker._ui_flows_sick_panel import build_sick_panel
if TYPE_CHECKING:
import tkinter as tk
from gatelock import ScrollableSurface
def _build_heat_skip(surface: ScrollableSurface) -> tk.Misc:
"""Paint the heat-skip screen and return the frame to measure.
Built through its extracted content builder because in production it owns
a fullscreen ``tk.Tk()`` of its own, which this harness cannot measure.
"""
return build_heat_skip_content(
surface.content, 34.0, on_skip=lambda: None, on_decline=lambda: None
)
def _build_sick_panel(surface: ScrollableSurface) -> tk.Misc:
"""Paint the "choose lockers" panel on a throwaway pool and return it.
Today is marked sick there first, because that variant is the tallest
(Save + Clear + Cancel) and because a pool that does not exist keeps the
measurement independent of the live sick-day and free-day pools. The panel
reads the pool once, while it is built, so the directory can go after.
"""
with tempfile.TemporaryDirectory(prefix="fit-sickdays-") as tmp:
pool = sickdays.Paths.under(Path(tmp))
sickdays.add_sick_day(sickdays.today(), is_free=lambda _day: False, paths=pool)
return build_sick_panel(
surface.content,
LockConfig(),
on_saved=lambda _entry: None,
on_cancel=lambda: None,
paths=pool,
)
# Screens built without a ScreenHost, measured through their own builder.
EXTRA_SCREENS: tuple[tuple[str, object], ...] = (
("heat-skip", _build_heat_skip),
("sick-keep-panel", _build_sick_panel),
)