diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f8bd47..3f4f07e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -98,7 +98,7 @@ repos: - --jobs=4 additional_dependencies: - pytest - - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock + - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync - mcp - pydantic diff --git a/pyproject.toml b/pyproject.toml index b998095..19f66a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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.0#subdirectory=gatelock", + "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock", "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync", ] diff --git a/requirements.txt b/requirements.txt index 02cc9ca..8c51182 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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.0#subdirectory=gatelock +gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock mcp>=1.9 mypy>=1.8.0 pre-commit>=3.6.0 diff --git a/screen_locker/_heat_skip.py b/screen_locker/_heat_skip.py index 650b64c..5b4921d 100644 --- a/screen_locker/_heat_skip.py +++ b/screen_locker/_heat_skip.py @@ -5,15 +5,17 @@ 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__) -_BG = "#1a1a1a" -_FG_MAIN = "#ff9900" -_FG_SUB = "#cccccc" -_BTN_SKIP = "#cc4400" -_BTN_NO = "#333333" +# 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() _FONT = "monospace" @@ -33,22 +35,22 @@ class HeatSkipMixin: # This window is destroyed before the main GateRoot is created. root = tk.Tk() root.title("Extreme Heat") - root.configure(bg=_BG) + root.configure(bg=_COLORS.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=_BG) + outer = tk.Frame(root, bg=_COLORS.bg) outer.place(relx=0.5, rely=0.5, anchor="center") tk.Label( outer, text="☀ Too hot to workout?", font=(_FONT, 18, "bold"), - bg=_BG, - fg=_FG_MAIN, + bg=_COLORS.bg, + fg=_COLORS.warning, ).pack(pady=(0, 10)) tk.Label( @@ -57,20 +59,20 @@ class HeatSkipMixin: f"{HEAT_SKIP_CITY}: {temp:.0f}°C" f" (threshold: {HEAT_SKIP_TEMP_THRESHOLD}°C)" ), - font=(_FONT, 13), - bg=_BG, - fg=_FG_SUB, + font=(_FONT, 16), + bg=_COLORS.bg, + fg=_COLORS.muted, ).pack(pady=6) tk.Label( outer, text="Skip today's workout due to extreme heat?", - font=(_FONT, 12), - bg=_BG, - fg=_FG_SUB, + font=(_FONT, 16), + bg=_COLORS.bg, + fg=_COLORS.muted, ).pack(pady=(6, 0)) - btn_frame = tk.Frame(outer, bg=_BG) + btn_frame = tk.Frame(outer, bg=_COLORS.bg) btn_frame.pack(pady=28) def _on_skip() -> None: @@ -85,12 +87,12 @@ class HeatSkipMixin: btn_frame, text="Skip workout", command=_on_skip, - bg=_BTN_SKIP, - fg="white", - activebackground="#aa3300", - font=(_FONT, 11), - padx=14, - pady=5, + bg=_COLORS.warning, + fg=_COLORS.on_fill, + activebackground=_COLORS.warning, + font=(_FONT, 14), + padx=16, + pady=8, relief="flat", ).pack(side="left", padx=12) @@ -98,12 +100,12 @@ class HeatSkipMixin: btn_frame, text="No, I'll workout", command=_on_no, - bg=_BTN_NO, - fg="white", - activebackground="#444444", - font=(_FONT, 11), - padx=14, - pady=5, + bg=_COLORS.field_bg, + fg=_COLORS.fg, + activebackground=_COLORS.field_bg, + font=(_FONT, 14), + padx=16, + pady=8, relief="flat", ).pack(side="left", padx=12) diff --git a/screen_locker/_ui_widgets.py b/screen_locker/_ui_widgets.py index 48a1241..8e6cad0 100644 --- a/screen_locker/_ui_widgets.py +++ b/screen_locker/_ui_widgets.py @@ -35,16 +35,16 @@ class UIWidgetsMixin: text: str, *, font_size: int = 36, - color: str = "white", + color: str | None = None, pady: int = 20, ) -> tk.Label: """Create and pack a bold label in the container.""" label = tk.Label( self.container, text=text, - font=("Arial", font_size, "bold"), - fg=color, - bg="#1a1a1a", + font=(self._colors.font_family, font_size, "bold"), + fg=color or self._colors.fg, + bg=self._colors.bg, ) label.pack(pady=pady) return label @@ -54,20 +54,38 @@ class UIWidgetsMixin: text: str, *, font_size: int = 18, - color: str = "white", + color: str | None = None, pady: int = 10, ) -> tk.Label: """Create and pack a non-bold text label in the container.""" label = tk.Label( self.container, text=text, - font=("Arial", font_size), - fg=color, - bg="#1a1a1a", + font=(self._colors.font_family, font_size), + fg=color or self._colors.fg, + bg=self._colors.bg, ) 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, @@ -77,21 +95,29 @@ class UIWidgetsMixin: command: Callable[[], None], width: int = 10, ) -> tk.Button: - """Create a styled button (caller must pack).""" + """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. + """ return tk.Button( parent, text=text, - font=("Arial", 24, "bold"), + font=(self._colors.font_family, 24, "bold"), bg=bg, - fg="white", + fg=self._fg_for(bg), 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="#1a1a1a") + frame = tk.Frame(self.container, bg=self._colors.bg) frame.pack(pady=20) return frame @@ -103,24 +129,24 @@ class UIWidgetsMixin: variable: tk.StringVar, ) -> None: """Add a label + single-line entry pair, with paste disabled.""" - row = tk.Frame(parent, bg="#1a1a1a") - row.pack(pady=5, fill="x") + row = tk.Frame(parent, bg=self._colors.bg) + row.pack(pady=8, fill="x") tk.Label( row, text=label, - font=("Arial", 14), - fg="white", - bg="#1a1a1a", + font=(self._colors.font_family, 14), + fg=self._colors.fg, + bg=self._colors.bg, anchor="w", ).pack(side="top", anchor="w") entry = tk.Entry( row, textvariable=variable, width=50, - font=("Arial", 14), - bg="#2a2a2a", - fg="white", - insertbackground="white", + font=(self._colors.font_family, 14), + bg=self._colors.field_bg, + fg=self._colors.fg, + insertbackground=self._colors.fg, ) - entry.pack(side="top", anchor="w", pady=2) + entry.pack(side="top", anchor="w", pady=4) disable_paste(entry) diff --git a/screen_locker/_window_setup.py b/screen_locker/_window_setup.py index c64bfc4..c0c7728 100644 --- a/screen_locker/_window_setup.py +++ b/screen_locker/_window_setup.py @@ -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="#1a1a1a", cursor="arrow") + self.root.configure(bg=self._colors.bg, 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=("Arial", 12), - bg="#ff4444", - fg="white", + font=(self._colors.font_family, 12), + bg=self._colors.danger, + fg=self._colors.on_fill, 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="#1a1a1a", cursor="arrow") + self.root.configure(bg=self._colors.bg, cursor="arrow") self.root.protocol("WM_DELETE_WINDOW", self.close) diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png index 1e4d1f0..82e7a51 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png and b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png index ab95375..5c9bc70 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png and b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png index 0fee410..c65907c 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png and b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png index eaef697..9ec9055 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png and b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png index 6b7ac32..27e40e6 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png and b/stronglift_replacement/workout_app/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 498c0e2..57b2b14 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index 580f2ca..65b4480 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index d545d47..ad36a32 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index c6e0cfb..ddebaa8 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 6e34f72..f32dc92 100644 Binary files a/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/stronglift_replacement/workout_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/stronglift_replacement/workout_app/android/app/src/main/res/values/colors.xml b/stronglift_replacement/workout_app/android/app/src/main/res/values/colors.xml index 89a0cc8..610f420 100644 --- a/stronglift_replacement/workout_app/android/app/src/main/res/values/colors.xml +++ b/stronglift_replacement/workout_app/android/app/src/main/res/values/colors.xml @@ -1,4 +1,4 @@ #1B1D21 - + \ No newline at end of file diff --git a/stronglift_replacement/workout_app/assets/icon/icon.png b/stronglift_replacement/workout_app/assets/icon/icon.png index 145642d..a45bc47 100644 Binary files a/stronglift_replacement/workout_app/assets/icon/icon.png and b/stronglift_replacement/workout_app/assets/icon/icon.png differ diff --git a/stronglift_replacement/workout_app/assets/icon/icon.svg b/stronglift_replacement/workout_app/assets/icon/icon.svg index 548bc73..8f3e5c1 100644 --- a/stronglift_replacement/workout_app/assets/icon/icon.svg +++ b/stronglift_replacement/workout_app/assets/icon/icon.svg @@ -1,6 +1,6 @@ - - + + diff --git a/stronglift_replacement/workout_app/assets/icon/icon_foreground.png b/stronglift_replacement/workout_app/assets/icon/icon_foreground.png index 5d4b2d7..2f779ee 100644 Binary files a/stronglift_replacement/workout_app/assets/icon/icon_foreground.png and b/stronglift_replacement/workout_app/assets/icon/icon_foreground.png differ diff --git a/stronglift_replacement/workout_app/assets/icon/icon_foreground.svg b/stronglift_replacement/workout_app/assets/icon/icon_foreground.svg index aee7cd4..c2ac731 100644 --- a/stronglift_replacement/workout_app/assets/icon/icon_foreground.svg +++ b/stronglift_replacement/workout_app/assets/icon/icon_foreground.svg @@ -1,5 +1,5 @@ - +