mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-11 12:07:44 +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 }}) (flutter, flutter-analyze, ) (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,flutter-analyze) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
"""The success screen shown once a workout has been credited.
|
|
|
|
Split out of ``screen_lock`` so that module stays inside the repo's 400-line
|
|
cap; this is pure view code (paint the credit, then hand off to the
|
|
commitment prompt or the close), which is exactly the kind of thing the other
|
|
``_ui_*`` mixins already own.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from screen_locker._constants import EXTRA_BENEFITS_FILE
|
|
from screen_locker._earned import span
|
|
from screen_locker._extra_benefits import current_streak
|
|
|
|
_UNLOCK_DELAY_MS = 1500
|
|
|
|
# Workout kinds that carry a commitment prompt on the way out: they are the
|
|
# ones the user actually performed today, so "will you work out tomorrow?" is
|
|
# a question worth asking.
|
|
_COMMITTABLE = ("phone_verified", "runnerup_verified", "manual_workout")
|
|
|
|
|
|
class UnlockViewMixin:
|
|
"""Paints the unlock screen and routes to whatever follows it."""
|
|
|
|
def unlock_screen(self) -> None:
|
|
"""Apply workout credit and display the success message."""
|
|
credit = self._apply_workout_credit()
|
|
|
|
self.clear_container()
|
|
self._label(
|
|
"Great job! 💪",
|
|
role="display",
|
|
scale=1.5,
|
|
color=self._colors.palette.success,
|
|
pad="lg",
|
|
)
|
|
if credit.shutdown_adjusted:
|
|
self._text(
|
|
"Shutdown time +2h later! 🎁",
|
|
role="title",
|
|
color=self._colors.palette.warning,
|
|
)
|
|
if credit.extra_bonus_delta > 0:
|
|
self._text(
|
|
f"Extra workout today! +{span(credit.extra_bonus_delta)} tonight",
|
|
role="subtitle",
|
|
color=self._colors.palette.warning,
|
|
)
|
|
if credit.new_debt is not None:
|
|
self._text(
|
|
f"Workout debt: {credit.new_debt}",
|
|
role="subtitle",
|
|
color=self._colors.palette.warning
|
|
if credit.new_debt > 0
|
|
else self._colors.palette.muted,
|
|
)
|
|
streak = current_streak(EXTRA_BENEFITS_FILE)
|
|
if streak >= 1:
|
|
self._text(
|
|
f"🔥 {streak}-week streak (5+ workouts each)",
|
|
role="label",
|
|
color=self._colors.palette.muted,
|
|
)
|
|
self._text("Screen Unlocked!", role="display", pad="md")
|
|
if self.workout_data.get("type") in _COMMITTABLE:
|
|
self.root.after(
|
|
_UNLOCK_DELAY_MS,
|
|
lambda: self._show_commitment_prompt(on_done=self.close),
|
|
)
|
|
else:
|
|
self.root.after(_UNLOCK_DELAY_MS, self.close)
|