Compare commits
No commits in common. "0c6f6957a8d46d8744b04357fa081aad909839aa" and "541db3701d21850ed9912a79cdf31a607385d569" have entirely different histories.
0c6f6957a8
...
541db3701d
@ -98,7 +98,7 @@ repos:
|
||||
- --jobs=4
|
||||
additional_dependencies:
|
||||
- pytest
|
||||
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock
|
||||
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock
|
||||
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
||||
- mcp
|
||||
- pydantic
|
||||
|
||||
@ -7,7 +7,7 @@ requires-python = ">=3.10"
|
||||
# crdt-sync: shared CRDT merge scheme + GitHub-Contents-API sync transport,
|
||||
# also used by diet_guard; here for phone-workout GitHub sync (Workstream C)
|
||||
dependencies = [
|
||||
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock",
|
||||
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock",
|
||||
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync",
|
||||
]
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ bandit>=1.7.0
|
||||
codespell>=2.2.0
|
||||
coverage>=7.4.0
|
||||
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
||||
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock
|
||||
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock
|
||||
mcp>=1.9
|
||||
mypy>=1.8.0
|
||||
pre-commit>=3.6.0
|
||||
|
||||
@ -5,17 +5,15 @@ from __future__ import annotations
|
||||
import logging
|
||||
import tkinter as tk
|
||||
|
||||
from gatelock import LockConfig
|
||||
|
||||
from screen_locker._constants import HEAT_SKIP_CITY, HEAT_SKIP_TEMP_THRESHOLD
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
# Sourced from the shared gatelock LockConfig (unified-design-system) instead
|
||||
# of a locally-invented token block -- this was the one file in the package
|
||||
# that already knew centralizing tokens was worth doing; now it points at
|
||||
# the actual shared source instead of its own unshared copy.
|
||||
_COLORS = LockConfig()
|
||||
_BG = "#1a1a1a"
|
||||
_FG_MAIN = "#ff9900"
|
||||
_FG_SUB = "#cccccc"
|
||||
_BTN_SKIP = "#cc4400"
|
||||
_BTN_NO = "#333333"
|
||||
_FONT = "monospace"
|
||||
|
||||
|
||||
@ -35,22 +33,22 @@ class HeatSkipMixin:
|
||||
# This window is destroyed before the main GateRoot is created.
|
||||
root = tk.Tk()
|
||||
root.title("Extreme Heat")
|
||||
root.configure(bg=_COLORS.bg)
|
||||
root.configure(bg=_BG)
|
||||
root.attributes("-fullscreen", True)
|
||||
root.attributes("-topmost", True)
|
||||
root.grab_set()
|
||||
root.focus_force()
|
||||
|
||||
# Content centred on the fullscreen canvas
|
||||
outer = tk.Frame(root, bg=_COLORS.bg)
|
||||
outer = tk.Frame(root, bg=_BG)
|
||||
outer.place(relx=0.5, rely=0.5, anchor="center")
|
||||
|
||||
tk.Label(
|
||||
outer,
|
||||
text="☀ Too hot to workout?",
|
||||
font=(_FONT, 18, "bold"),
|
||||
bg=_COLORS.bg,
|
||||
fg=_COLORS.warning,
|
||||
bg=_BG,
|
||||
fg=_FG_MAIN,
|
||||
).pack(pady=(0, 10))
|
||||
|
||||
tk.Label(
|
||||
@ -59,20 +57,20 @@ class HeatSkipMixin:
|
||||
f"{HEAT_SKIP_CITY}: {temp:.0f}°C"
|
||||
f" (threshold: {HEAT_SKIP_TEMP_THRESHOLD}°C)"
|
||||
),
|
||||
font=(_FONT, 16),
|
||||
bg=_COLORS.bg,
|
||||
fg=_COLORS.muted,
|
||||
font=(_FONT, 13),
|
||||
bg=_BG,
|
||||
fg=_FG_SUB,
|
||||
).pack(pady=6)
|
||||
|
||||
tk.Label(
|
||||
outer,
|
||||
text="Skip today's workout due to extreme heat?",
|
||||
font=(_FONT, 16),
|
||||
bg=_COLORS.bg,
|
||||
fg=_COLORS.muted,
|
||||
font=(_FONT, 12),
|
||||
bg=_BG,
|
||||
fg=_FG_SUB,
|
||||
).pack(pady=(6, 0))
|
||||
|
||||
btn_frame = tk.Frame(outer, bg=_COLORS.bg)
|
||||
btn_frame = tk.Frame(outer, bg=_BG)
|
||||
btn_frame.pack(pady=28)
|
||||
|
||||
def _on_skip() -> None:
|
||||
@ -87,12 +85,12 @@ class HeatSkipMixin:
|
||||
btn_frame,
|
||||
text="Skip workout",
|
||||
command=_on_skip,
|
||||
bg=_COLORS.warning,
|
||||
fg=_COLORS.on_fill,
|
||||
activebackground=_COLORS.warning,
|
||||
font=(_FONT, 14),
|
||||
padx=16,
|
||||
pady=8,
|
||||
bg=_BTN_SKIP,
|
||||
fg="white",
|
||||
activebackground="#aa3300",
|
||||
font=(_FONT, 11),
|
||||
padx=14,
|
||||
pady=5,
|
||||
relief="flat",
|
||||
).pack(side="left", padx=12)
|
||||
|
||||
@ -100,12 +98,12 @@ class HeatSkipMixin:
|
||||
btn_frame,
|
||||
text="No, I'll workout",
|
||||
command=_on_no,
|
||||
bg=_COLORS.field_bg,
|
||||
fg=_COLORS.fg,
|
||||
activebackground=_COLORS.field_bg,
|
||||
font=(_FONT, 14),
|
||||
padx=16,
|
||||
pady=8,
|
||||
bg=_BTN_NO,
|
||||
fg="white",
|
||||
activebackground="#444444",
|
||||
font=(_FONT, 11),
|
||||
padx=14,
|
||||
pady=5,
|
||||
relief="flat",
|
||||
).pack(side="left", padx=12)
|
||||
|
||||
|
||||
@ -39,28 +39,23 @@ class ManualWorkoutDialogMixin(ManualWorkoutFormWidgetsMixin):
|
||||
def _show_manual_workout_form(self) -> None:
|
||||
"""Render the manual-workout evidence form, or a budget-exhausted note."""
|
||||
self.clear_container()
|
||||
self._label("Log Manual Workout", color=self._colors.accent, pady=10)
|
||||
self._label("Log Manual Workout", color="#0088cc", pady=10)
|
||||
if _manual_workout.is_budget_exhausted(self.log_file):
|
||||
self._text(
|
||||
"Manual-workout budget exhausted for this window.",
|
||||
color=self._colors.danger,
|
||||
)
|
||||
self._text(
|
||||
_manual_workout.budget_summary(self.log_file),
|
||||
color=self._colors.muted,
|
||||
color="#ff4444",
|
||||
)
|
||||
self._text(_manual_workout.budget_summary(self.log_file), color="#888888")
|
||||
row = self._button_row()
|
||||
self._button(
|
||||
row,
|
||||
"BACK",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#aa0000",
|
||||
command=self._on_manual_workout_cancelled,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
return
|
||||
self._text(
|
||||
_manual_workout.budget_summary(self.log_file), color=self._colors.accent
|
||||
)
|
||||
self._text(_manual_workout.budget_summary(self.log_file), color="#88ccff")
|
||||
self._build_manual_workout_form()
|
||||
|
||||
def _mw_scrollable_form(self) -> tk.Frame:
|
||||
@ -72,11 +67,11 @@ class ManualWorkoutDialogMixin(ManualWorkoutFormWidgetsMixin):
|
||||
the inner form to the viewport so its two columns split the full width.
|
||||
Harmless on StatusWindow, whose container already fills its window.
|
||||
"""
|
||||
outer = tk.Frame(self.container, bg=self._colors.bg)
|
||||
outer = tk.Frame(self.container, bg="#1a1a1a")
|
||||
outer.pack(fill="both", expand=True, pady=10)
|
||||
canvas = tk.Canvas(outer, bg=self._colors.bg, highlightthickness=0)
|
||||
canvas = tk.Canvas(outer, bg="#1a1a1a", highlightthickness=0)
|
||||
scrollbar = tk.Scrollbar(outer, orient="vertical", command=canvas.yview)
|
||||
form = tk.Frame(canvas, bg=self._colors.bg)
|
||||
form = tk.Frame(canvas, bg="#1a1a1a")
|
||||
form.grid_columnconfigure(0, weight=1, uniform="mw")
|
||||
form.grid_columnconfigure(1, weight=1, uniform="mw")
|
||||
form.bind(
|
||||
@ -134,8 +129,8 @@ class ManualWorkoutDialogMixin(ManualWorkoutFormWidgetsMixin):
|
||||
# Both sport sub-frames occupy the same full-width grid slot; only the
|
||||
# selected one is shown (see _on_mw_sport_changed).
|
||||
act_row = self._mw_next_full_row(form)
|
||||
self._mw_tt_frame = tk.Frame(form, bg=self._colors.bg)
|
||||
self._mw_other_frame = tk.Frame(form, bg=self._colors.bg)
|
||||
self._mw_tt_frame = tk.Frame(form, bg="#1a1a1a")
|
||||
self._mw_other_frame = tk.Frame(form, bg="#1a1a1a")
|
||||
for sport_frame in (self._mw_tt_frame, self._mw_other_frame):
|
||||
sport_frame.grid_columnconfigure(0, weight=1, uniform="mwact")
|
||||
sport_frame.grid_columnconfigure(1, weight=1, uniform="mwact")
|
||||
@ -173,19 +168,19 @@ class ManualWorkoutDialogMixin(ManualWorkoutFormWidgetsMixin):
|
||||
f"(min {MANUAL_WORKOUT_REFLECTION_MIN_CHARS} chars):",
|
||||
)
|
||||
|
||||
self._mw_error_label = self._text("", color=self._colors.danger, pady=8)
|
||||
self._mw_error_label = self._text("", color="#ff4444", pady=5)
|
||||
button_row = self._button_row()
|
||||
self._button(
|
||||
button_row,
|
||||
"SUBMIT",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._submit_manual_workout_form,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
self._button(
|
||||
button_row,
|
||||
"BACK",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#aa0000",
|
||||
command=self._on_manual_workout_cancelled,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
@ -195,13 +190,13 @@ class ManualWorkoutDialogMixin(ManualWorkoutFormWidgetsMixin):
|
||||
self._mw_sport_var = tk.StringVar(
|
||||
value=_manual_workout.SPORT_LABELS[_manual_workout.SPORT_TABLE_TENNIS]
|
||||
)
|
||||
row = tk.Frame(parent, bg=self._colors.bg)
|
||||
row = tk.Frame(parent, bg="#1a1a1a")
|
||||
tk.Label(
|
||||
row,
|
||||
text="Sport:",
|
||||
font=(self._colors.font_family, 16),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 16),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
).pack(side="left", padx=5)
|
||||
tk.OptionMenu(
|
||||
row,
|
||||
|
||||
@ -44,7 +44,7 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
columnspan=2 if full else 1,
|
||||
sticky="ew",
|
||||
padx=12,
|
||||
pady=8,
|
||||
pady=6,
|
||||
)
|
||||
counters[id(parent)] = idx + (2 if full else 1)
|
||||
|
||||
@ -67,9 +67,9 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
label = tk.Label(
|
||||
parent,
|
||||
text=title,
|
||||
font=(self._colors.font_family, 20, "bold"),
|
||||
fg=self._colors.accent,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 20, "bold"),
|
||||
fg="#88ccff",
|
||||
bg="#1a1a1a",
|
||||
anchor="w",
|
||||
)
|
||||
self._mw_grid(parent, label, full=True)
|
||||
@ -82,24 +82,24 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
the two-column grid. Paste stays disabled via ``disable_paste``.
|
||||
"""
|
||||
var = tk.StringVar()
|
||||
cell = tk.Frame(parent, bg=self._colors.bg)
|
||||
cell = tk.Frame(parent, bg="#1a1a1a")
|
||||
tk.Label(
|
||||
cell,
|
||||
text=label,
|
||||
font=(self._colors.font_family, 16),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 16),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
anchor="w",
|
||||
).pack(fill="x")
|
||||
entry = tk.Entry(
|
||||
cell,
|
||||
textvariable=var,
|
||||
font=(self._colors.font_family, 18),
|
||||
bg=self._colors.field_bg,
|
||||
fg=self._colors.fg,
|
||||
insertbackground=self._colors.fg,
|
||||
font=("Arial", 18),
|
||||
bg="#2a2a2a",
|
||||
fg="white",
|
||||
insertbackground="white",
|
||||
)
|
||||
entry.pack(fill="x", pady=4)
|
||||
entry.pack(fill="x", pady=2)
|
||||
disable_paste(entry)
|
||||
self._mw_grid(parent, cell)
|
||||
return var
|
||||
@ -109,13 +109,13 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
) -> tk.IntVar:
|
||||
"""Add a half-width label + numeric Spinbox and return its IntVar."""
|
||||
var = tk.IntVar(value=0)
|
||||
row = tk.Frame(parent, bg=self._colors.bg)
|
||||
row = tk.Frame(parent, bg="#1a1a1a")
|
||||
tk.Label(
|
||||
row,
|
||||
text=label,
|
||||
font=(self._colors.font_family, 16),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 16),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
).pack(side="left", padx=5)
|
||||
tk.Spinbox(
|
||||
row,
|
||||
@ -123,47 +123,47 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
to=to,
|
||||
textvariable=var,
|
||||
width=4,
|
||||
font=(self._colors.font_family, 16),
|
||||
font=("Arial", 16),
|
||||
).pack(side="left", padx=5)
|
||||
self._mw_grid(parent, row)
|
||||
return var
|
||||
|
||||
def _mw_textbox(self, parent: tk.Widget, label: str) -> tk.Text:
|
||||
"""Add a full-width label + multi-line Text cell and return the widget."""
|
||||
cell = tk.Frame(parent, bg=self._colors.bg)
|
||||
cell = tk.Frame(parent, bg="#1a1a1a")
|
||||
tk.Label(
|
||||
cell,
|
||||
text=label,
|
||||
font=(self._colors.font_family, 16),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 16),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
anchor="w",
|
||||
).pack(fill="x", pady=(8, 0))
|
||||
).pack(fill="x", pady=(5, 0))
|
||||
text_widget = tk.Text(
|
||||
cell,
|
||||
height=3,
|
||||
font=(self._colors.font_family, 14),
|
||||
bg=self._colors.field_bg,
|
||||
fg=self._colors.fg,
|
||||
insertbackground=self._colors.fg,
|
||||
font=("Arial", 14),
|
||||
bg="#2a2a2a",
|
||||
fg="white",
|
||||
insertbackground="white",
|
||||
)
|
||||
text_widget.pack(pady=4, fill="x")
|
||||
text_widget.pack(pady=2, fill="x")
|
||||
disable_paste(text_widget)
|
||||
self._mw_grid(parent, cell, full=True)
|
||||
return text_widget
|
||||
|
||||
def _mw_rpe_row(self, parent: tk.Widget) -> None:
|
||||
"""Add the RPE (rate of perceived exertion) spinbox row."""
|
||||
row = tk.Frame(parent, bg=self._colors.bg)
|
||||
row = tk.Frame(parent, bg="#1a1a1a")
|
||||
tk.Label(
|
||||
row,
|
||||
text=(
|
||||
f"RPE — perceived exertion "
|
||||
f"({MANUAL_WORKOUT_RPE_MIN}-{MANUAL_WORKOUT_RPE_MAX}):"
|
||||
),
|
||||
font=(self._colors.font_family, 16),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 16),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
).pack(side="left", padx=5)
|
||||
tk.Spinbox(
|
||||
row,
|
||||
@ -171,6 +171,6 @@ class ManualWorkoutFormWidgetsMixin:
|
||||
to=MANUAL_WORKOUT_RPE_MAX,
|
||||
textvariable=self._mw_rpe_var,
|
||||
width=4,
|
||||
font=(self._colors.font_family, 16),
|
||||
font=("Arial", 16),
|
||||
).pack(side="left", padx=5)
|
||||
self._mw_grid(parent, row)
|
||||
|
||||
@ -34,34 +34,32 @@ class SickDialogMixin:
|
||||
history = _sick_tracker.load_history()
|
||||
self._sick_history_cache: SickHistory = history
|
||||
self.clear_container()
|
||||
self._label("Sick Day Request", color=self._colors.warning, pady=10)
|
||||
self._text(_sick_tracker.budget_summary(history), color=self._colors.warning)
|
||||
self._label("Sick Day Request", color="#cc6600", pady=10)
|
||||
self._text(_sick_tracker.budget_summary(history), color="#ffaa00")
|
||||
|
||||
recent = _sick_tracker.format_recent_justifications(history)
|
||||
if recent:
|
||||
self._text(
|
||||
"Recent sick days:", font_size=14, color=self._colors.muted, pady=8
|
||||
)
|
||||
self._text(recent, font_size=14, color=self._colors.muted, pady=8)
|
||||
self._text("Recent sick days:", font_size=14, color="#888888", pady=5)
|
||||
self._text(recent, font_size=14, color="#cccccc", pady=5)
|
||||
|
||||
had_commitment = _sick_tracker.had_commitment_for_today(history)
|
||||
if had_commitment:
|
||||
self._text(
|
||||
"⚠ Yesterday you committed to working out today.",
|
||||
font_size=18,
|
||||
color=self._colors.danger,
|
||||
color="#ff6666",
|
||||
)
|
||||
self._text(
|
||||
"Breaking the commitment costs 2 sick-budget days.",
|
||||
font_size=14,
|
||||
color=self._colors.danger,
|
||||
color="#ff6666",
|
||||
)
|
||||
|
||||
self._build_justification_form(had_commitment=had_commitment)
|
||||
|
||||
def _build_justification_form(self, *, had_commitment: bool) -> None:
|
||||
"""Add justification form fields and submit button to the container."""
|
||||
form = tk.Frame(self.container, bg=self._colors.bg)
|
||||
form = tk.Frame(self.container, bg="#1a1a1a")
|
||||
form.pack(pady=10)
|
||||
|
||||
self._sick_symptom_var = tk.StringVar()
|
||||
@ -69,16 +67,13 @@ class SickDialogMixin:
|
||||
self._sick_severity_var = tk.IntVar(value=5)
|
||||
self._sick_text_widget = self._add_form_widgets(form)
|
||||
|
||||
self._sick_error_label = self._text("", color=self._colors.danger, pady=8)
|
||||
self._sick_error_label = self._text("", color="#ff4444", pady=5)
|
||||
|
||||
button_row = self._button_row()
|
||||
# Starts disabled during the forced-read delay -- field_bg (our
|
||||
# neutral/secondary token) signals "not yet actionable" better than
|
||||
# the accent used for an immediately-clickable submit.
|
||||
self._sick_submit_button = self._button(
|
||||
button_row,
|
||||
"SUBMIT",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#666666",
|
||||
command=self._submit_sick_justification,
|
||||
width=12,
|
||||
)
|
||||
@ -86,7 +81,7 @@ class SickDialogMixin:
|
||||
self._button(
|
||||
button_row,
|
||||
"BACK",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#aa0000",
|
||||
command=self._start_phone_check,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
@ -108,14 +103,14 @@ class SickDialogMixin:
|
||||
label="When did it start? (e.g. last night):",
|
||||
variable=self._sick_onset_var,
|
||||
)
|
||||
sev_row = tk.Frame(parent, bg=self._colors.bg)
|
||||
sev_row.pack(pady=8)
|
||||
sev_row = tk.Frame(parent, bg="#1a1a1a")
|
||||
sev_row.pack(pady=5)
|
||||
tk.Label(
|
||||
sev_row,
|
||||
text="Severity (1-10):",
|
||||
font=(self._colors.font_family, 14),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 14),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
).pack(side="left", padx=5)
|
||||
tk.Spinbox(
|
||||
sev_row,
|
||||
@ -123,26 +118,26 @@ class SickDialogMixin:
|
||||
to=10,
|
||||
textvariable=self._sick_severity_var,
|
||||
width=4,
|
||||
font=(self._colors.font_family, 14),
|
||||
font=("Arial", 14),
|
||||
).pack(side="left", padx=5)
|
||||
|
||||
tk.Label(
|
||||
parent,
|
||||
text=(f"Describe how you feel (min {SICK_JUSTIFICATION_MIN_CHARS} chars):"),
|
||||
font=(self._colors.font_family, 14),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
).pack(pady=8)
|
||||
font=("Arial", 14),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
).pack(pady=5)
|
||||
text_widget = tk.Text(
|
||||
parent,
|
||||
width=60,
|
||||
height=6,
|
||||
font=(self._colors.font_family, 14),
|
||||
bg=self._colors.field_bg,
|
||||
fg=self._colors.fg,
|
||||
insertbackground=self._colors.fg,
|
||||
font=("Arial", 12),
|
||||
bg="#2a2a2a",
|
||||
fg="white",
|
||||
insertbackground="white",
|
||||
)
|
||||
text_widget.pack(pady=8)
|
||||
text_widget.pack(pady=5)
|
||||
_disable_paste(text_widget)
|
||||
return text_widget
|
||||
|
||||
@ -204,35 +199,32 @@ class SickDialogMixin:
|
||||
self._label(
|
||||
"Commit to working out tomorrow?",
|
||||
font_size=32,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
pady=20,
|
||||
)
|
||||
# ~80 chars at font_size 16 would render as one unbroken line past the
|
||||
# ~70-char readable range (rule 21) -- wrap it explicitly.
|
||||
prompt = self._text(
|
||||
self._text(
|
||||
"If you say YES and skip via 'I'm sick' tomorrow, "
|
||||
"the sick day costs 2x normal.",
|
||||
font_size=16,
|
||||
)
|
||||
prompt.config(wraplength=560, justify="center")
|
||||
self._commitment_done_fn = on_done
|
||||
self._commitment_remaining = COMMITMENT_PROMPT_TIMEOUT_SECONDS
|
||||
self._commitment_timer_label = self._text(
|
||||
f"Auto-skipping in {COMMITMENT_PROMPT_TIMEOUT_SECONDS}s",
|
||||
color=self._colors.muted,
|
||||
color="#888888",
|
||||
)
|
||||
row = self._button_row()
|
||||
self._button(
|
||||
row,
|
||||
"YES",
|
||||
bg=self._colors.success,
|
||||
bg="#00aa00",
|
||||
command=lambda: self._answer_commitment(commit=True),
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
self._button(
|
||||
row,
|
||||
"NO",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#aa0000",
|
||||
command=lambda: self._answer_commitment(commit=False),
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
|
||||
@ -40,23 +40,21 @@ class TemperatureStatusMixin:
|
||||
self._label("Warsaw Temperature", font_size=16, pady=8)
|
||||
result = self._temp_result
|
||||
if result is None:
|
||||
self._text(
|
||||
"Checking Warsaw temperature…", font_size=12, color=self._colors.muted
|
||||
)
|
||||
self._text("Checking Warsaw temperature…", font_size=12, color="#888888")
|
||||
return
|
||||
if result.timed_out:
|
||||
self._text(
|
||||
f"Warsaw temperature check timed out after ~"
|
||||
f"{int(HARD_TIMEOUT_SECONDS)}s — network may be down.",
|
||||
font_size=12,
|
||||
color=self._colors.warning,
|
||||
color="#ff8844",
|
||||
)
|
||||
return
|
||||
if result.temp_celsius is None:
|
||||
self._text(
|
||||
"Warsaw temperature check failed (network/API error).",
|
||||
font_size=12,
|
||||
color=self._colors.warning,
|
||||
color="#ff8844",
|
||||
)
|
||||
return
|
||||
hot = result.temp_celsius >= HEAT_SKIP_TEMP_THRESHOLD
|
||||
@ -64,14 +62,10 @@ class TemperatureStatusMixin:
|
||||
f"Warsaw: {result.temp_celsius:.0f}°C (heat-skip threshold "
|
||||
f"{HEAT_SKIP_TEMP_THRESHOLD}°C)",
|
||||
font_size=12,
|
||||
color=self._colors.warning if hot else self._colors.muted,
|
||||
color="#ff8844" if hot else "#cccccc",
|
||||
)
|
||||
if hot:
|
||||
self._text(
|
||||
"Would trigger heat-skip today.",
|
||||
font_size=11,
|
||||
color=self._colors.danger,
|
||||
)
|
||||
self._text("Would trigger heat-skip today.", font_size=11, color="#ff4444")
|
||||
|
||||
def _start_temperature_check(self) -> None:
|
||||
"""Submit a background Warsaw-temperature fetch and start polling it.
|
||||
|
||||
@ -22,9 +22,7 @@ class UIFlowsMixin:
|
||||
def _start_phone_check(self) -> None:
|
||||
"""Check phone for today's workout immediately at startup."""
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"Checking phone...", font_size=36, color=self._colors.warning, pady=30
|
||||
)
|
||||
self._label("Checking phone...", font_size=36, color="#ffaa00", pady=30)
|
||||
self._text("Looking for today's workout in StrongLifts...", font_size=18)
|
||||
executor = ThreadPoolExecutor(max_workers=1)
|
||||
self._phone_future = executor.submit(self._verify_phone_workout)
|
||||
@ -42,46 +40,42 @@ class UIFlowsMixin:
|
||||
def _show_retry_and_sick(self, message: str) -> None:
|
||||
"""Show TRY AGAIN and (if budget allows) I'm sick after a failed check."""
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"No Workout Found", font_size=36, color=self._colors.danger, pady=20
|
||||
)
|
||||
self._text(message, color=self._colors.warning)
|
||||
self._label("No Workout Found", font_size=36, color="#ff4444", pady=20)
|
||||
self._text(message, color="#ffaa00")
|
||||
history = _sick_tracker.load_history()
|
||||
self._text(_sick_tracker.budget_summary(history), color=self._colors.muted)
|
||||
self._text(
|
||||
_manual_workout.budget_summary(self.log_file), color=self._colors.muted
|
||||
)
|
||||
self._text(_sick_tracker.budget_summary(history), color="#888888")
|
||||
self._text(_manual_workout.budget_summary(self.log_file), color="#888888")
|
||||
frame = self._button_row()
|
||||
self._button(
|
||||
frame,
|
||||
"TRY AGAIN",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._start_phone_check,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
if _sick_tracker.is_budget_exhausted(history):
|
||||
self._text(
|
||||
"Sick budget exhausted. No 'I'm sick' option available.",
|
||||
color=self._colors.danger,
|
||||
color="#ff6666",
|
||||
)
|
||||
else:
|
||||
self._button(
|
||||
frame,
|
||||
"I'm sick",
|
||||
bg=self._colors.warning,
|
||||
bg="#cc6600",
|
||||
command=self.ask_if_sick,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
if _manual_workout.is_budget_exhausted(self.log_file):
|
||||
self._text(
|
||||
"Manual-workout budget exhausted. No manual-log option available.",
|
||||
color=self._colors.danger,
|
||||
color="#ff6666",
|
||||
)
|
||||
else:
|
||||
self._button(
|
||||
frame,
|
||||
"Log Manual Workout",
|
||||
bg=self._colors.accent,
|
||||
bg="#0088cc",
|
||||
command=self._show_manual_workout_form,
|
||||
width=16,
|
||||
).pack(side="left", padx=10)
|
||||
@ -90,14 +84,9 @@ class UIFlowsMixin:
|
||||
"""Show confirmation and unlock after a manual-workout entry is built."""
|
||||
self.workout_data = entry
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"✓ Manual Workout Logged!",
|
||||
font_size=42,
|
||||
color=self._colors.success,
|
||||
pady=30,
|
||||
)
|
||||
self._text(entry.get("source", ""), font_size=20, color=self._colors.success)
|
||||
self._text("Unlocking...", font_size=18, color=self._colors.muted)
|
||||
self._label("✓ Manual Workout Logged!", font_size=42, color="#00cc44", pady=30)
|
||||
self._text(entry.get("source", ""), font_size=20, color="#aaffaa")
|
||||
self._text("Unlocking...", font_size=18, color="#888888")
|
||||
unlock_delay = 1500 if self.demo_mode else 2000
|
||||
self.root.after(unlock_delay, self.unlock_screen)
|
||||
|
||||
@ -111,14 +100,9 @@ class UIFlowsMixin:
|
||||
self.workout_data["type"] = "phone_verified"
|
||||
self.workout_data["source"] = message
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"✓ Workout Verified!",
|
||||
font_size=42,
|
||||
color=self._colors.success,
|
||||
pady=30,
|
||||
)
|
||||
self._text(message, font_size=20, color=self._colors.success)
|
||||
self._text("Unlocking...", font_size=18, color=self._colors.muted)
|
||||
self._label("✓ Workout Verified!", font_size=42, color="#00cc44", pady=30)
|
||||
self._text(message, font_size=20, color="#aaffaa")
|
||||
self._text("Unlocking...", font_size=18, color="#888888")
|
||||
unlock_delay = 1500 if self.demo_mode else 2000
|
||||
self.root.after(unlock_delay, self.unlock_screen)
|
||||
elif status == "too_short":
|
||||
@ -154,9 +138,7 @@ class UIFlowsMixin:
|
||||
either unlocks (run verified) or calls ``on_failure``.
|
||||
"""
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"Checking RunnerUp...", font_size=36, color=self._colors.warning, pady=30
|
||||
)
|
||||
self._label("Checking RunnerUp...", font_size=36, color="#ffaa00", pady=30)
|
||||
self._text("Looking for today's run in RunnerUp...", font_size=18)
|
||||
executor = ThreadPoolExecutor(max_workers=1)
|
||||
self._runnerup_future = executor.submit(self._verify_runnerup_workout)
|
||||
@ -172,14 +154,9 @@ class UIFlowsMixin:
|
||||
self.workout_data["type"] = "runnerup_verified"
|
||||
self.workout_data["source"] = message
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"✓ Run Verified!",
|
||||
font_size=42,
|
||||
color=self._colors.success,
|
||||
pady=30,
|
||||
)
|
||||
self._text(message, font_size=20, color=self._colors.success)
|
||||
self._text("Unlocking...", font_size=18, color=self._colors.muted)
|
||||
self._label("✓ Run Verified!", font_size=42, color="#00cc44", pady=30)
|
||||
self._text(message, font_size=20, color="#aaffaa")
|
||||
self._text("Unlocking...", font_size=18, color="#888888")
|
||||
unlock_delay = 1500 if self.demo_mode else 2000
|
||||
self.root.after(unlock_delay, self.unlock_screen)
|
||||
else:
|
||||
@ -194,15 +171,12 @@ class UIFlowsMixin:
|
||||
def _get_sick_day_status(self) -> tuple[str, str]:
|
||||
"""Determine sick day status text and color."""
|
||||
if self._sick_mode_used_today():
|
||||
return "Shutdown time already adjusted today", self._colors.warning
|
||||
return "Shutdown time already adjusted today", "#ffaa00"
|
||||
if self._adjust_shutdown_time_earlier():
|
||||
return (
|
||||
"Shutdown time moved 1.5 hours earlier ✓\n(Will revert tomorrow)"
|
||||
), self._colors.success
|
||||
return (
|
||||
"Could not adjust shutdown time (check permissions)",
|
||||
self._colors.danger,
|
||||
)
|
||||
), "#00aa00"
|
||||
return "Could not adjust shutdown time (check permissions)", "#ff4444"
|
||||
|
||||
def _proceed_to_sick_countdown(self) -> None:
|
||||
"""Start the (escalated) sick day countdown after justification."""
|
||||
@ -228,7 +202,7 @@ class UIFlowsMixin:
|
||||
countdown: int,
|
||||
) -> None:
|
||||
"""Display sick day UI labels and countdown."""
|
||||
self._label("Sick Day Mode", color=self._colors.warning, pady=20)
|
||||
self._label("Sick Day Mode", color="#cc6600", pady=20)
|
||||
self._text(status_text, color=status_color)
|
||||
minutes = countdown // 60
|
||||
self._text(
|
||||
@ -276,7 +250,7 @@ class UIFlowsMixin:
|
||||
self.lockout_label = self._label(
|
||||
f"Go work out!\nLocked for {self.lockout_time} seconds",
|
||||
font_size=48,
|
||||
color=self._colors.danger,
|
||||
color="#ff4444",
|
||||
pady=30,
|
||||
)
|
||||
self.countdown_label = self._label(
|
||||
@ -324,10 +298,10 @@ class UIFlowsMixin:
|
||||
self._label(
|
||||
"Cannot Verify Workout",
|
||||
font_size=36,
|
||||
color=self._colors.warning,
|
||||
color="#ff8800",
|
||||
pady=20,
|
||||
)
|
||||
self._text(message, color=self._colors.warning)
|
||||
self._text(message, color="#ffaa00")
|
||||
self._text(
|
||||
"Connect phone via ADB to skip this wait,\n"
|
||||
"or wait for the penalty timer.\n\n"
|
||||
|
||||
@ -23,7 +23,7 @@ class UIFlowsRelaxedMixin:
|
||||
self._label(
|
||||
"Verifying Workout",
|
||||
font_size=36,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
pady=30,
|
||||
)
|
||||
self._text(
|
||||
@ -59,15 +59,15 @@ class UIFlowsRelaxedMixin:
|
||||
self._label(
|
||||
"✓ Workout Verified!",
|
||||
font_size=42,
|
||||
color=self._colors.success,
|
||||
color="#00cc44",
|
||||
pady=30,
|
||||
)
|
||||
self._text(message, font_size=20, color=self._colors.success)
|
||||
self._text(message, font_size=20, color="#aaffaa")
|
||||
if adjusted:
|
||||
self._text(
|
||||
"Shutdown time moved later!",
|
||||
font_size=20,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
)
|
||||
self.root.after(2000, self.close)
|
||||
else:
|
||||
@ -79,22 +79,22 @@ class UIFlowsRelaxedMixin:
|
||||
self._label(
|
||||
"Workout Not Found",
|
||||
font_size=36,
|
||||
color=self._colors.danger,
|
||||
color="#ff4444",
|
||||
pady=20,
|
||||
)
|
||||
self._text(message, color=self._colors.warning)
|
||||
self._text(message, color="#ffaa00")
|
||||
frame = self._button_row()
|
||||
self._button(
|
||||
frame,
|
||||
"TRY AGAIN",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._start_verify_workout_check,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
self._button(
|
||||
frame,
|
||||
"Close",
|
||||
bg=self._colors.field_bg,
|
||||
bg="#aa0000",
|
||||
command=self.close,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
@ -114,28 +114,28 @@ class UIFlowsRelaxedMixin:
|
||||
self._label(
|
||||
"Optional Day (Tue / Wed / Thu)",
|
||||
font_size=30,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
pady=20,
|
||||
)
|
||||
self._text(
|
||||
f"Weekly workouts: {count} / {WEEKLY_WORKOUT_MINIMUM}\n"
|
||||
"No penalty for skipping today.",
|
||||
font_size=20,
|
||||
color=self._colors.muted,
|
||||
color="#aaaaaa",
|
||||
pady=10,
|
||||
)
|
||||
frame = self._button_row()
|
||||
self._button(
|
||||
frame,
|
||||
"Skip — No Penalty",
|
||||
bg=self._colors.success,
|
||||
bg="#006600",
|
||||
command=self.close,
|
||||
width=18,
|
||||
).pack(side="left", padx=10)
|
||||
self._button(
|
||||
frame,
|
||||
"Log Stronglift Workout",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._start_relaxed_phone_check,
|
||||
width=20,
|
||||
).pack(side="left", padx=10)
|
||||
@ -143,9 +143,7 @@ class UIFlowsRelaxedMixin:
|
||||
def _start_relaxed_phone_check(self) -> None:
|
||||
"""Run Stronglift check in relaxed mode (no screen grab, no sick option)."""
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"Checking phone...", font_size=36, color=self._colors.warning, pady=30
|
||||
)
|
||||
self._label("Checking phone...", font_size=36, color="#ffaa00", pady=30)
|
||||
self._text("Looking for today's workout in StrongLifts...", font_size=18)
|
||||
executor = ThreadPoolExecutor(max_workers=1)
|
||||
self._phone_future = executor.submit(self._verify_phone_workout)
|
||||
@ -177,22 +175,20 @@ class UIFlowsRelaxedMixin:
|
||||
def _show_relaxed_retry(self, message: str, status: str) -> None:
|
||||
"""Show retry and skip-close when workout not found in relaxed mode."""
|
||||
self.clear_container()
|
||||
self._label(
|
||||
"No Workout Found", font_size=36, color=self._colors.danger, pady=20
|
||||
)
|
||||
self._text(f"❌ {message}\n\nReason: {status}", color=self._colors.warning)
|
||||
self._label("No Workout Found", font_size=36, color="#ff4444", pady=20)
|
||||
self._text(f"❌ {message}\n\nReason: {status}", color="#ffaa00")
|
||||
frame = self._button_row()
|
||||
self._button(
|
||||
frame,
|
||||
"TRY AGAIN",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._start_relaxed_phone_check,
|
||||
width=12,
|
||||
).pack(side="left", padx=10)
|
||||
self._button(
|
||||
frame,
|
||||
"Close (Skip)",
|
||||
bg=self._colors.success,
|
||||
bg="#006600",
|
||||
command=self.close,
|
||||
width=14,
|
||||
).pack(side="left", padx=10)
|
||||
|
||||
@ -35,16 +35,16 @@ class UIWidgetsMixin:
|
||||
text: str,
|
||||
*,
|
||||
font_size: int = 36,
|
||||
color: str | None = None,
|
||||
color: str = "white",
|
||||
pady: int = 20,
|
||||
) -> tk.Label:
|
||||
"""Create and pack a bold label in the container."""
|
||||
label = tk.Label(
|
||||
self.container,
|
||||
text=text,
|
||||
font=(self._colors.font_family, font_size, "bold"),
|
||||
fg=color or self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", font_size, "bold"),
|
||||
fg=color,
|
||||
bg="#1a1a1a",
|
||||
)
|
||||
label.pack(pady=pady)
|
||||
return label
|
||||
@ -54,38 +54,20 @@ class UIWidgetsMixin:
|
||||
text: str,
|
||||
*,
|
||||
font_size: int = 18,
|
||||
color: str | None = None,
|
||||
color: str = "white",
|
||||
pady: int = 10,
|
||||
) -> tk.Label:
|
||||
"""Create and pack a non-bold text label in the container."""
|
||||
label = tk.Label(
|
||||
self.container,
|
||||
text=text,
|
||||
font=(self._colors.font_family, font_size),
|
||||
fg=color or self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", font_size),
|
||||
fg=color,
|
||||
bg="#1a1a1a",
|
||||
)
|
||||
label.pack(pady=pady)
|
||||
return label
|
||||
|
||||
def _fg_for(self, bg: str) -> str:
|
||||
"""Return the correct label color for a widget with background `bg`.
|
||||
|
||||
The four filled semantic surfaces (accent/success/warning/danger)
|
||||
all sit in the same mid-light lightness band, so `fg` (near-white,
|
||||
meant for the neutral `bg`/`field_bg` surfaces) under-contrasts on
|
||||
every one of them -- `on_fill` (dark) is required instead. Deriving
|
||||
this from `bg` means a new filled-button call site can't reintroduce
|
||||
the bug by omission.
|
||||
"""
|
||||
fills = {
|
||||
self._colors.accent,
|
||||
self._colors.success,
|
||||
self._colors.warning,
|
||||
self._colors.danger,
|
||||
}
|
||||
return self._colors.on_fill if bg in fills else self._colors.fg
|
||||
|
||||
def _button(
|
||||
self,
|
||||
parent: tk.Widget,
|
||||
@ -95,29 +77,21 @@ class UIWidgetsMixin:
|
||||
command: Callable[[], None],
|
||||
width: int = 10,
|
||||
) -> tk.Button:
|
||||
"""Create a styled button (caller must pack).
|
||||
|
||||
Padding follows the shared 2x horizontal:vertical ratio (rule 22);
|
||||
`relief="flat"` is the one depth technique every button in the app
|
||||
uses now (rule 27), matching what `_heat_skip.py` already did alone.
|
||||
"""
|
||||
"""Create a styled button (caller must pack)."""
|
||||
return tk.Button(
|
||||
parent,
|
||||
text=text,
|
||||
font=(self._colors.font_family, 24, "bold"),
|
||||
font=("Arial", 24, "bold"),
|
||||
bg=bg,
|
||||
fg=self._fg_for(bg),
|
||||
fg="white",
|
||||
width=width,
|
||||
command=command,
|
||||
cursor="hand2" if self.demo_mode else "",
|
||||
relief="flat",
|
||||
padx=24,
|
||||
pady=12,
|
||||
)
|
||||
|
||||
def _button_row(self) -> tk.Frame:
|
||||
"""Create and pack a horizontal button container."""
|
||||
frame = tk.Frame(self.container, bg=self._colors.bg)
|
||||
frame = tk.Frame(self.container, bg="#1a1a1a")
|
||||
frame.pack(pady=20)
|
||||
return frame
|
||||
|
||||
@ -129,24 +103,24 @@ class UIWidgetsMixin:
|
||||
variable: tk.StringVar,
|
||||
) -> None:
|
||||
"""Add a label + single-line entry pair, with paste disabled."""
|
||||
row = tk.Frame(parent, bg=self._colors.bg)
|
||||
row.pack(pady=8, fill="x")
|
||||
row = tk.Frame(parent, bg="#1a1a1a")
|
||||
row.pack(pady=5, fill="x")
|
||||
tk.Label(
|
||||
row,
|
||||
text=label,
|
||||
font=(self._colors.font_family, 14),
|
||||
fg=self._colors.fg,
|
||||
bg=self._colors.bg,
|
||||
font=("Arial", 14),
|
||||
fg="white",
|
||||
bg="#1a1a1a",
|
||||
anchor="w",
|
||||
).pack(side="top", anchor="w")
|
||||
entry = tk.Entry(
|
||||
row,
|
||||
textvariable=variable,
|
||||
width=50,
|
||||
font=(self._colors.font_family, 14),
|
||||
bg=self._colors.field_bg,
|
||||
fg=self._colors.fg,
|
||||
insertbackground=self._colors.fg,
|
||||
font=("Arial", 14),
|
||||
bg="#2a2a2a",
|
||||
fg="white",
|
||||
insertbackground="white",
|
||||
)
|
||||
entry.pack(side="top", anchor="w", pady=4)
|
||||
entry.pack(side="top", anchor="w", pady=2)
|
||||
disable_paste(entry)
|
||||
|
||||
@ -27,7 +27,7 @@ class WindowSetupMixin:
|
||||
def _setup_verify_window(self) -> None:
|
||||
"""Configure window for post-sick-day workout verification."""
|
||||
self.root.geometry("600x400")
|
||||
self.root.configure(bg=self._colors.bg, cursor="arrow")
|
||||
self.root.configure(bg="#1a1a1a", cursor="arrow")
|
||||
self.root.protocol("WM_DELETE_WINDOW", self.close)
|
||||
|
||||
def _setup_demo_close_button(self) -> None:
|
||||
@ -35,9 +35,9 @@ class WindowSetupMixin:
|
||||
close_btn = tk.Button(
|
||||
self.root,
|
||||
text="✕ Close Demo",
|
||||
font=(self._colors.font_family, 12),
|
||||
bg=self._colors.danger,
|
||||
fg=self._colors.on_fill,
|
||||
font=("Arial", 12),
|
||||
bg="#ff4444",
|
||||
fg="white",
|
||||
command=self.close,
|
||||
cursor="hand2",
|
||||
)
|
||||
@ -46,5 +46,5 @@ class WindowSetupMixin:
|
||||
def _setup_relaxed_day_window(self) -> None:
|
||||
"""Configure a small non-locking window for the optional Tue-Thu prompt."""
|
||||
self.root.geometry("700x450")
|
||||
self.root.configure(bg=self._colors.bg, cursor="arrow")
|
||||
self.root.configure(bg="#1a1a1a", cursor="arrow")
|
||||
self.root.protocol("WM_DELETE_WINDOW", self.close)
|
||||
|
||||
@ -140,25 +140,21 @@ class ScreenLocker(
|
||||
self.demo_mode = demo_mode
|
||||
self.lockout_time = 10 if demo_mode else 1800
|
||||
self._lock: LockWindow | None = None
|
||||
# One shared token source for every window/widget this app creates,
|
||||
# lock or not -- see the `unified-design-system` skill. `mode`/`grab`/
|
||||
# `disable_vt` only matter for the fullscreen lock window itself; the
|
||||
# color/font fields apply everywhere, so this is built unconditionally.
|
||||
self._colors = LockConfig(
|
||||
mode="hard",
|
||||
grab="local" if demo_mode else "global",
|
||||
disable_vt=not demo_mode,
|
||||
)
|
||||
if verify_only:
|
||||
self._setup_verify_window()
|
||||
elif self._relaxed_day_mode:
|
||||
self._setup_relaxed_day_window()
|
||||
else:
|
||||
self._lock = LockWindow(self.root, self._colors, hooks=self)
|
||||
config = LockConfig(
|
||||
mode="hard",
|
||||
grab="local" if demo_mode else "global",
|
||||
disable_vt=not demo_mode,
|
||||
)
|
||||
self._lock = LockWindow(self.root, config, hooks=self)
|
||||
self._lock.setup()
|
||||
if demo_mode:
|
||||
self._setup_demo_close_button()
|
||||
self.container = tk.Frame(self.root, bg=self._colors.bg)
|
||||
self.container = tk.Frame(self.root, bg="#1a1a1a")
|
||||
self.container.place(relx=0.5, rely=0.5, anchor="center")
|
||||
self._phone_future: Future[tuple[str, str]] | None = None
|
||||
self._runnerup_future: Future[tuple[str, str]] | None = None
|
||||
@ -315,33 +311,31 @@ class ScreenLocker(
|
||||
credit = self._apply_workout_credit()
|
||||
|
||||
self.clear_container()
|
||||
self._label("Great job! 💪", font_size=48, color=self._colors.success, pady=30)
|
||||
self._label("Great job! 💪", font_size=48, color="#00ff00", pady=30)
|
||||
if credit.shutdown_adjusted:
|
||||
self._text(
|
||||
"Shutdown time +2h later! 🎁",
|
||||
font_size=24,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
)
|
||||
if credit.extra_bonus_delta > 0:
|
||||
self._text(
|
||||
f"Extra workout today! +{credit.extra_bonus_delta}h tonight",
|
||||
font_size=20,
|
||||
color=self._colors.warning,
|
||||
color="#ffaa00",
|
||||
)
|
||||
if credit.new_debt is not None:
|
||||
self._text(
|
||||
f"Workout debt: {credit.new_debt}",
|
||||
font_size=20,
|
||||
color=self._colors.warning
|
||||
if credit.new_debt > 0
|
||||
else self._colors.muted,
|
||||
color="#ffaa00" if credit.new_debt > 0 else "#888888",
|
||||
)
|
||||
streak = current_streak(EXTRA_BENEFITS_FILE)
|
||||
if streak >= 1:
|
||||
self._text(
|
||||
f"🔥 {streak}-week streak (5+ workouts each)",
|
||||
font_size=14,
|
||||
color=self._colors.muted,
|
||||
color="#888888",
|
||||
)
|
||||
self._text("Screen Unlocked!", font_size=36, pady=20)
|
||||
if self.workout_data.get("type") in (
|
||||
|
||||
@ -28,8 +28,6 @@ import sys
|
||||
import tkinter as tk
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from gatelock import LockConfig
|
||||
|
||||
from screen_locker import _manual_workout
|
||||
from screen_locker._manual_workout_dialog import ManualWorkoutDialogMixin
|
||||
from screen_locker._status_data import (
|
||||
@ -58,7 +56,6 @@ if TYPE_CHECKING:
|
||||
from screen_locker.screen_lock import ScreenLocker
|
||||
|
||||
_DEFAULT_LOG_FILE = Path(__file__).resolve().parent / "workout_log.json"
|
||||
_STATUS_COLORS = LockConfig()
|
||||
|
||||
|
||||
class StatusWindow(
|
||||
@ -99,8 +96,7 @@ class StatusWindow(
|
||||
self._temp_future: Future[TemperatureCheck] | None = None
|
||||
self._temp_result: TemperatureCheck | None = None
|
||||
self._last_snapshot = snapshot
|
||||
self._colors = _STATUS_COLORS
|
||||
self.container = tk.Frame(root, bg=self._colors.bg)
|
||||
self.container = tk.Frame(root, bg="#1a1a1a")
|
||||
self.container.pack(fill="both", expand=True)
|
||||
self._start_temperature_check()
|
||||
self.render(snapshot)
|
||||
@ -121,20 +117,15 @@ class StatusWindow(
|
||||
self._section_shutdown(self.container, snapshot.shutdown)
|
||||
if self._phone_check_result is not None:
|
||||
status, message = self._phone_check_result
|
||||
color = (
|
||||
self._colors.success if status == "verified" else self._colors.warning
|
||||
)
|
||||
self._text(f"Phone check ({status}): {message}", font_size=16, color=color)
|
||||
color = "#00cc44" if status == "verified" else "#ff8844"
|
||||
self._text(f"Phone check ({status}): {message}", font_size=13, color=color)
|
||||
if self._credit_message is not None:
|
||||
self._text(self._credit_message, font_size=16, color=self._colors.success)
|
||||
# "Check Phone"/"Log Manual Workout" are the primary write actions
|
||||
# (accent, high contrast per rule 3); "Refresh"/"Close" are secondary
|
||||
# utility actions (muted) -- two tiers instead of four arbitrary hues.
|
||||
self._text(self._credit_message, font_size=13, color="#00cc44")
|
||||
frame = self._button_row()
|
||||
self._button(
|
||||
frame,
|
||||
"Check Phone",
|
||||
bg=self._colors.accent,
|
||||
bg="#0066cc",
|
||||
command=self._on_check_phone_clicked,
|
||||
width=14,
|
||||
).pack(side="left", padx=8)
|
||||
@ -142,23 +133,15 @@ class StatusWindow(
|
||||
self._button(
|
||||
frame,
|
||||
"Log Manual Workout",
|
||||
bg=self._colors.accent,
|
||||
bg="#0088cc",
|
||||
command=self._show_manual_workout_form,
|
||||
width=16,
|
||||
).pack(side="left", padx=8)
|
||||
self._button(
|
||||
frame,
|
||||
"Refresh",
|
||||
bg=self._colors.field_bg,
|
||||
command=self._on_refresh_clicked,
|
||||
width=10,
|
||||
frame, "Refresh", bg="#006600", command=self._on_refresh_clicked, width=10
|
||||
).pack(side="left", padx=8)
|
||||
self._button(
|
||||
frame,
|
||||
"Close",
|
||||
bg=self._colors.field_bg,
|
||||
command=self.root.destroy,
|
||||
width=8,
|
||||
frame, "Close", bg="#aa0000", command=self.root.destroy, width=8
|
||||
).pack(side="left", padx=8)
|
||||
|
||||
def _section_today(self, parent: tk.Widget, day: DayStatus) -> None:
|
||||
@ -171,12 +154,10 @@ class StatusWindow(
|
||||
self._text(
|
||||
f"{mark} Today ({day.label}): {entry_str}",
|
||||
font_size=18,
|
||||
color=self._colors.success if day.counted else self._colors.warning,
|
||||
color="#aaffaa" if day.counted else "#ffaa00",
|
||||
)
|
||||
if day.source:
|
||||
# Secondary provenance note on an already-shown entry -- a
|
||||
# deliberately caption-sized exception to the 16px floor.
|
||||
self._text(day.source, font_size=12, color=self._colors.muted, pady=4)
|
||||
self._text(day.source, font_size=12, color="#888888", pady=2)
|
||||
|
||||
def _section_week(self, parent: tk.Widget, week: WeeklySummary) -> None:
|
||||
"""Render this ISO week's per-day breakdown and totals."""
|
||||
@ -191,21 +172,17 @@ class StatusWindow(
|
||||
)
|
||||
self._text(
|
||||
f"{mark} {day.label}: {entry_str}",
|
||||
font_size=16,
|
||||
color=self._colors.muted,
|
||||
pady=4,
|
||||
font_size=12,
|
||||
color="#cccccc",
|
||||
pady=1,
|
||||
)
|
||||
if week.remaining > 0:
|
||||
self._text(
|
||||
f"Need {week.remaining} more this week.",
|
||||
font_size=16,
|
||||
color=self._colors.warning,
|
||||
f"Need {week.remaining} more this week.", font_size=13, color="#ffaa00"
|
||||
)
|
||||
elif week.extra > 0:
|
||||
self._text(
|
||||
f"{week.extra} above the weekly minimum!",
|
||||
font_size=16,
|
||||
color=self._colors.success,
|
||||
f"{week.extra} above the weekly minimum!", font_size=13, color="#00cc44"
|
||||
)
|
||||
|
||||
def _section_lock_explanation(
|
||||
@ -215,15 +192,13 @@ class StatusWindow(
|
||||
del parent
|
||||
self._label("Why the lock did/didn't fire", font_size=16, pady=8)
|
||||
self._text(
|
||||
expl.reason,
|
||||
font_size=16,
|
||||
color=self._colors.danger if expl.fired else self._colors.success,
|
||||
expl.reason, font_size=13, color="#ff4444" if expl.fired else "#00cc44"
|
||||
)
|
||||
if expl.auto_upgrade.would_attempt:
|
||||
self._text(
|
||||
f"Pending auto-upgrade: {expl.auto_upgrade.reason}",
|
||||
font_size=14,
|
||||
color=self._colors.warning,
|
||||
font_size=11,
|
||||
color="#ffaa00",
|
||||
)
|
||||
|
||||
def _section_sick_budget(self, parent: tk.Widget, sick: SickBudgetStatus) -> None:
|
||||
@ -233,8 +208,8 @@ class StatusWindow(
|
||||
self._text(
|
||||
f"{sick.used_7d}/{sick.budget_7d} week · {sick.used_30d}/{sick.budget_30d} "
|
||||
f"month · {sick.used_90d}/{sick.budget_90d} quarter · debt {sick.debt}",
|
||||
font_size=16,
|
||||
color=self._colors.danger if sick.exhausted else self._colors.muted,
|
||||
font_size=12,
|
||||
color="#ff4444" if sick.exhausted else "#cccccc",
|
||||
)
|
||||
|
||||
def _section_manual_workout_budget(
|
||||
@ -246,8 +221,8 @@ class StatusWindow(
|
||||
self._text(
|
||||
f"{manual.used_7d}/{manual.budget_7d} week · "
|
||||
f"{manual.used_30d}/{manual.budget_30d} month",
|
||||
font_size=16,
|
||||
color=self._colors.danger if manual.exhausted else self._colors.muted,
|
||||
font_size=12,
|
||||
color="#ff4444" if manual.exhausted else "#cccccc",
|
||||
)
|
||||
|
||||
def _section_shutdown(
|
||||
@ -261,31 +236,23 @@ class StatusWindow(
|
||||
self._text(
|
||||
f"Live config — Mon-Wed {mon_wed_hour:02d}:00, "
|
||||
f"Thu-Sun {thu_sun_hour:02d}:00",
|
||||
font_size=16,
|
||||
font_size=12,
|
||||
)
|
||||
else:
|
||||
self._text(
|
||||
"Live shutdown config unavailable.",
|
||||
font_size=16,
|
||||
color=self._colors.warning,
|
||||
"Live shutdown config unavailable.", font_size=12, color="#ff8844"
|
||||
)
|
||||
# Rest-of-week/next-week/explanation are speculative annotations, not
|
||||
# the section's primary content -- a deliberate caption-sized
|
||||
# exception to the 16px floor, all sharing one muted tone instead of
|
||||
# three unrelated ad hoc grays.
|
||||
rest_line = ", ".join(
|
||||
f"{d.label} {d.hour:02d}:00" for d in shutdown.rest_of_week
|
||||
)
|
||||
self._text(f"Rest of week: {rest_line}", font_size=12, color=self._colors.muted)
|
||||
self._text(f"Rest of week: {rest_line}", font_size=10, color="#cccccc")
|
||||
next_line = ", ".join(
|
||||
f"{d.label} {d.hour:02d}:00" for d in shutdown.next_week_preview
|
||||
)
|
||||
self._text(
|
||||
f"Next week (speculative): {next_line}",
|
||||
font_size=12,
|
||||
color=self._colors.muted,
|
||||
f"Next week (speculative): {next_line}", font_size=10, color="#888888"
|
||||
)
|
||||
self._text(shutdown.explanation, font_size=12, color=self._colors.muted)
|
||||
self._text(shutdown.explanation, font_size=10, color="#666666")
|
||||
|
||||
def _on_refresh_clicked(self) -> None:
|
||||
"""Clear any stale phone-check/credit/temperature results, re-check both."""
|
||||
@ -347,7 +314,7 @@ def main(argv: list[str] | None = None) -> None:
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("Workout Status")
|
||||
root.configure(bg=_STATUS_COLORS.bg)
|
||||
root.configure(bg="#1a1a1a")
|
||||
root.minsize(560, 200)
|
||||
|
||||
def refresh() -> None:
|
||||
|
||||
@ -26,25 +26,25 @@ class TestSectionManualWorkoutBudget:
|
||||
snap = _snapshot(
|
||||
manual_workout_budget=_manual_workout_budget(used_7d=2, exhausted=True)
|
||||
)
|
||||
window = _make_window(mock_tk, snap)
|
||||
_make_window(mock_tk, snap)
|
||||
calls = [
|
||||
c
|
||||
for c in mock_tk.Label.call_args_list
|
||||
if "week" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert any(c.kwargs.get("fg") == window._colors.danger for c in calls)
|
||||
assert any(c.kwargs.get("fg") == "#ff4444" for c in calls)
|
||||
|
||||
def test_not_exhausted_uses_normal_color(self, mock_tk: MagicMock) -> None:
|
||||
snap = _snapshot(
|
||||
manual_workout_budget=_manual_workout_budget(used_7d=0, exhausted=False)
|
||||
)
|
||||
window = _make_window(mock_tk, snap)
|
||||
_make_window(mock_tk, snap)
|
||||
calls = [
|
||||
c
|
||||
for c in mock_tk.Label.call_args_list
|
||||
if "week" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert any(c.kwargs.get("fg") == window._colors.muted for c in calls)
|
||||
assert any(c.kwargs.get("fg") == "#cccccc" for c in calls)
|
||||
|
||||
|
||||
class TestManualWorkoutButtonVisibility:
|
||||
|
||||
@ -145,23 +145,23 @@ class TestSectionLockExplanation:
|
||||
class TestSectionSickBudget:
|
||||
def test_exhausted_uses_warning_color(self, mock_tk: MagicMock) -> None:
|
||||
snap = _snapshot(sick_budget=_sick_budget(used_7d=1, exhausted=True))
|
||||
window = _make_window(mock_tk, snap)
|
||||
_make_window(mock_tk, snap)
|
||||
calls = [
|
||||
c
|
||||
for c in mock_tk.Label.call_args_list
|
||||
if "week" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert any(c.kwargs.get("fg") == window._colors.danger for c in calls)
|
||||
assert any(c.kwargs.get("fg") == "#ff4444" for c in calls)
|
||||
|
||||
def test_not_exhausted_uses_normal_color(self, mock_tk: MagicMock) -> None:
|
||||
snap = _snapshot(sick_budget=_sick_budget(used_7d=0, exhausted=False))
|
||||
window = _make_window(mock_tk, snap)
|
||||
_make_window(mock_tk, snap)
|
||||
calls = [
|
||||
c
|
||||
for c in mock_tk.Label.call_args_list
|
||||
if "week" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert any(c.kwargs.get("fg") == window._colors.muted for c in calls)
|
||||
assert any(c.kwargs.get("fg") == "#cccccc" for c in calls)
|
||||
|
||||
|
||||
class TestSectionShutdown:
|
||||
|
||||
@ -46,7 +46,7 @@ class TestPhoneCheckResultRendering:
|
||||
if "Phone check" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert calls
|
||||
assert calls[-1].kwargs.get("fg") == window._colors.success
|
||||
assert calls[-1].kwargs.get("fg") == "#00cc44"
|
||||
|
||||
def test_non_verified_result_shown_in_orange(self, mock_tk: MagicMock) -> None:
|
||||
window = _make_window(mock_tk, _snapshot())
|
||||
@ -58,7 +58,7 @@ class TestPhoneCheckResultRendering:
|
||||
if "Phone check" in c.kwargs.get("text", "")
|
||||
]
|
||||
assert calls
|
||||
assert calls[-1].kwargs.get("fg") == window._colors.warning
|
||||
assert calls[-1].kwargs.get("fg") == "#ff8844"
|
||||
|
||||
|
||||
class TestButtons:
|
||||
|
||||
@ -144,7 +144,7 @@ class TestGetSickDayStatus:
|
||||
)
|
||||
text, color = locker._get_sick_day_status()
|
||||
assert "already adjusted" in text
|
||||
assert color == locker._colors.warning
|
||||
assert color == "#ffaa00"
|
||||
|
||||
def test_adjustment_success(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
@ -159,7 +159,7 @@ class TestGetSickDayStatus:
|
||||
)
|
||||
text, color = locker._get_sick_day_status()
|
||||
assert "earlier" in text
|
||||
assert color == locker._colors.success
|
||||
assert color == "#00aa00"
|
||||
|
||||
def test_adjustment_failure(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
@ -174,7 +174,7 @@ class TestGetSickDayStatus:
|
||||
)
|
||||
text, color = locker._get_sick_day_status()
|
||||
assert "Could not adjust" in text
|
||||
assert color == locker._colors.danger
|
||||
assert color == "#ff4444"
|
||||
|
||||
|
||||
class TestShowRetryAndSick:
|
||||
|
||||
@ -151,7 +151,7 @@ class TestSetupVerifyWindow:
|
||||
)
|
||||
locker.root.geometry.assert_called_with("600x400")
|
||||
locker.root.configure.assert_called_with(
|
||||
bg=locker._colors.bg,
|
||||
bg="#1a1a1a",
|
||||
cursor="arrow",
|
||||
)
|
||||
locker.root.protocol.assert_called_with(
|
||||
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 1012 B After Width: | Height: | Size: 1016 B |
|
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#211D1B</color>
|
||||
<color name="ic_launcher_background">#1B1D21</color>
|
||||
</resources>
|
||||
|
||||
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
@ -1,6 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||
<rect width="1024" height="1024" fill="#211D1B"/>
|
||||
<g fill="none" stroke="#B8862E" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,0)">
|
||||
<rect width="1024" height="1024" fill="#1B1D21"/>
|
||||
<g fill="none" stroke="#FF4444" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,0)">
|
||||
<path d="M 268 512 L 756 512"/>
|
||||
<path d="M 364 356 L 364 668"/>
|
||||
<path d="M 660 356 L 660 668"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 465 B |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.0 KiB |
@ -1,5 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||
<g fill="none" stroke="#B8862E" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,0)">
|
||||
<g fill="none" stroke="#FF4444" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,0)">
|
||||
<path d="M 268 512 L 756 512"/>
|
||||
<path d="M 364 356 L 364 668"/>
|
||||
<path d="M 660 356 L 660 668"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 413 B |
@ -49,7 +49,7 @@ flutter_launcher_icons:
|
||||
android: true
|
||||
ios: false
|
||||
image_path: "assets/icon/icon.png"
|
||||
adaptive_icon_background: "#211D1B"
|
||||
adaptive_icon_background: "#1B1D21"
|
||||
adaptive_icon_foreground: "assets/icon/icon_foreground.png"
|
||||
adaptive_icon_monochrome: "assets/icon/icon_monochrome.png"
|
||||
min_sdk_android: 21
|
||||
|
||||