Compare commits

...

2 Commits

Author SHA1 Message Date
191fa48b9d phone_app: warm-tint the unified-design-system palette
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Adds theme.dart (dark-only ColorScheme + AppStatusColors
success/warning extension), wired into main.dart, home_screen.dart,
and settings_screen.dart. Fixes DESIGN_AUDIT_TODO violations: raw
Colors.* replaced with theme roles, off-grid spacing, sub-16px text,
and icon-contrast dimming.
2026-07-22 20:10:27 +02:00
870a71665d Route _alarm.py's dismiss-screen colors through gatelock's LockConfig
Replaces ~15 hardcoded hex/named-color literals with the shared
unified-design-system palette (bg/fg/muted/danger/warning/success),
matching diet-guard/screen-locker. Extracts widget construction into
_alarm_view.py to keep _alarm.py under the repo's 500-line cap.
2026-07-22 20:09:26 +02:00
10 changed files with 275 additions and 130 deletions

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wake_alarm_sync/screens/home_screen.dart'; import 'package:wake_alarm_sync/screens/home_screen.dart';
import 'package:wake_alarm_sync/ui/theme.dart';
/// Entry point. /// Entry point.
void main() => runApp(const WakeAlarmSyncApp()); void main() => runApp(const WakeAlarmSyncApp());
@ -14,12 +15,7 @@ class WakeAlarmSyncApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Wake Alarm Sync', title: 'Wake Alarm Sync',
theme: ThemeData.dark(useMaterial3: true).copyWith( theme: buildAppTheme(),
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.orange,
brightness: Brightness.dark,
),
),
home: const HomeScreen(), home: const HomeScreen(),
); );
} }

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:wake_alarm_sync/screens/settings_screen.dart'; import 'package:wake_alarm_sync/screens/settings_screen.dart';
import 'package:wake_alarm_sync/services/alarm_sync_service.dart'; import 'package:wake_alarm_sync/services/alarm_sync_service.dart';
import 'package:wake_alarm_sync/services/sync_settings.dart'; import 'package:wake_alarm_sync/services/sync_settings.dart';
import 'package:wake_alarm_sync/ui/theme.dart';
/// Main screen: displays the current alarm time and syncs it to the PC via /// Main screen: displays the current alarm time and syncs it to the PC via
/// the shared crdt_sync transport. /// the shared crdt_sync transport.
@ -131,7 +132,11 @@ class _HomeScreenState extends State<HomeScreen> {
title: const Text('Wake Alarm Sync'), title: const Text('Wake Alarm Sync'),
actions: [ actions: [
IconButton( IconButton(
icon: const Icon(Icons.settings), icon: Icon(
Icons.settings,
// Dimmed relative to the adjacent title text (rule 28).
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
onPressed: () async { onPressed: () async {
await Navigator.push<void>( await Navigator.push<void>(
context, context,
@ -195,16 +200,22 @@ class _HomeScreenState extends State<HomeScreen> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: _status.contains('Error') color: _status.contains('Error')
? Colors.redAccent ? Theme.of(context).colorScheme.error
: Colors.greenAccent, : Theme.of(
context,
).extension<AppStatusColors>()!.success,
), ),
), ),
if (!_configured) ...[ if (!_configured) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
const Text( Text(
'Open Settings (gear icon) to connect GitHub.', 'Open Settings (gear icon) to connect GitHub.',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color: Colors.orange), style: TextStyle(
color: Theme.of(
context,
).extension<AppStatusColors>()!.warning,
),
), ),
], ],
], ],

View File

@ -6,6 +6,7 @@ import 'package:url_launcher/url_launcher.dart';
import 'package:wake_alarm_sync/services/github_device_auth.dart'; import 'package:wake_alarm_sync/services/github_device_auth.dart';
import 'package:wake_alarm_sync/services/sync_settings.dart'; import 'package:wake_alarm_sync/services/sync_settings.dart';
import 'package:wake_alarm_sync/ui/theme.dart';
/// Settings screen for the GitHub connection used to sync the alarm. /// Settings screen for the GitHub connection used to sync the alarm.
/// ///
@ -108,7 +109,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
: const Icon(Icons.link), : const Icon(Icons.link),
label: const Text('Connect GitHub'), label: const Text('Connect GitHub'),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14), padding: const EdgeInsets.symmetric(vertical: 16),
textStyle: const TextStyle(fontSize: 16), textStyle: const TextStyle(fontSize: 16),
), ),
) )
@ -124,18 +125,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
_status, _status,
style: TextStyle( style: TextStyle(
color: _status.contains('Error') color: _status.contains('Error')
? Colors.redAccent ? Theme.of(context).colorScheme.error
: Colors.greenAccent, : Theme.of(
context,
).extension<AppStatusColors>()!.success,
), ),
), ),
const Divider(height: 32), const Divider(height: 32),
const Text( Text(
'PC config — create this file:\n' 'PC config — create this file:\n'
'~/.config/wake_alarm/sync.json\n\n' '~/.config/wake_alarm/sync.json\n\n'
'{ "token": "<same token>" }\n\n' '{ "token": "<same token>" }\n\n'
'The token needs "repo" scope so the PC can read ' 'The token needs "repo" scope so the PC can read '
'kuhyx/syncs at shutdown.', 'kuhyx/syncs at shutdown.',
style: TextStyle(fontSize: 12, color: Colors.grey), // Was 12px/Colors.grey — below the 16px reading floor (rule
// 20) and off-palette (rule 4); this is real setup
// instructions, not decorative chrome.
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
), ),
], ],
), ),
@ -151,6 +160,8 @@ class _StatusCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final success = Theme.of(context).extension<AppStatusColors>()!.success;
return Card( return Card(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
@ -158,9 +169,11 @@ class _StatusCard extends StatelessWidget {
children: [ children: [
Icon( Icon(
connected ? Icons.check_circle : Icons.cancel, connected ? Icons.check_circle : Icons.cancel,
color: connected ? Colors.greenAccent : Colors.redAccent, // Dimmed relative to the adjacent label text (rule 28).
color: (connected ? success : colorScheme.error)
.withValues(alpha: 0.8),
), ),
const SizedBox(width: 12), const SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
connected ? 'Connected to GitHub' : 'Not connected', connected ? 'Connected to GitHub' : 'Not connected',
@ -242,7 +255,10 @@ class _DeviceCodeDialogState extends State<_DeviceCodeDialog> {
], ],
) )
else else
Text(_error!, style: const TextStyle(color: Colors.red)), Text(
_error!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
], ],
), ),
actions: [ actions: [

View File

@ -0,0 +1,86 @@
/// The app's design tokens: one identical palette shared across every one
/// of kuhy's apps (Flutter, web, Python/Tkinter alike) — see the
/// `unified-design-system` skill (`~/.claude/skills/unified-design-system/`)
/// for the frozen token table this file implements. Built from an explicit
/// `ColorScheme`, not `ColorScheme.fromSeed`, because the shared palette is
/// hand-picked, not algorithmically derived from one seed color.
library;
import 'package:flutter/material.dart';
/// Builds the app's single dark `ThemeData` from the shared token set.
ThemeData buildAppTheme() {
const colorScheme = ColorScheme.dark(
surface: Color(0xFF211D1B), // ink
surfaceContainerHighest: Color(0xFF38312E), // ink-raised-2
surfaceContainerHigh: Color(0xFF2B2624), // ink-raised-1
onSurface: Color(0xFFECEAE9), // text-on-dark
onSurfaceVariant: Color(0xFFAAA09A), // muted-on-dark
outline: Color(0xFF463E3A), // line-dark
primary: Color(0xFFB8862E), // accent
onPrimary: Color(0xFF211D1B), // on-fill — filled surfaces use dark text
// secondary/tertiary mirror primary — the shared palette has one accent,
// not a separate secondary hue. Leaving these undefined lets Flutter
// fall back to stock Material teal on any widget that reaches for
// secondaryContainer (Chip, SegmentedButton, etc.) — confirmed as a
// real, live bug on two other apps sharing this template.
secondary: Color(0xFFB8862E),
onSecondary: Color(0xFF211D1B),
secondaryContainer: Color(0xFF463E3A),
onSecondaryContainer: Color(0xFFB8862E),
tertiary: Color(0xFFB8862E),
onTertiary: Color(0xFF211D1B),
tertiaryContainer: Color(0xFF463E3A),
onTertiaryContainer: Color(0xFFB8862E),
error: Color(0xFFE2585F), // danger
onError: Color(0xFF211D1B), // on-fill
);
return ThemeData(
useMaterial3: true,
colorScheme: colorScheme,
scaffoldBackgroundColor: colorScheme.surface,
extensions: const [AppStatusColors.dark],
// No custom shadow/elevation exists elsewhere in this app — the one
// Card (_StatusCard) is the sole place M3's default elevation would
// otherwise introduce a shadow in an all-dark UI (rule 26).
cardTheme: const CardThemeData(elevation: 0),
);
}
/// Semantic status colors M3's [ColorScheme] has no role for (it only has
/// `error`). Used instead of the ad hoc `Colors.greenAccent`/`Colors.orange`
/// literals previously scattered across both screens.
@immutable
class AppStatusColors extends ThemeExtension<AppStatusColors> {
/// Creates a status-color set.
const AppStatusColors({required this.success, required this.warning});
/// The shared dark-theme instance — success/warning from the unified
/// palette (danger already exists as `colorScheme.error`).
static const dark = AppStatusColors(
success: Color(0xFF8A9A3C),
warning: Color(0xFFE0A63C),
);
/// Positive/connected status (e.g. "Connected to GitHub").
final Color success;
/// Caution/pending status (e.g. "Open Settings to connect GitHub").
final Color warning;
@override
AppStatusColors copyWith({Color? success, Color? warning}) =>
AppStatusColors(
success: success ?? this.success,
warning: warning ?? this.warning,
);
@override
AppStatusColors lerp(AppStatusColors? other, double t) {
if (other is! AppStatusColors) return this;
return AppStatusColors(
success: Color.lerp(success, other.success, t) ?? success,
warning: Color.lerp(warning, other.warning, t) ?? warning,
);
}
}

View File

@ -21,6 +21,7 @@ import tkinter as tk
from gatelock import GateRoot, LockConfig, LockWindow from gatelock import GateRoot, LockConfig, LockWindow
from wake_alarm._alarm_display import _restore_display, _wake_display from wake_alarm._alarm_display import _restore_display, _wake_display
from wake_alarm._alarm_view import _build_alarm_view
from wake_alarm._audio import ( from wake_alarm._audio import (
_beep_loud, _beep_loud,
_beep_medium, _beep_medium,
@ -68,20 +69,6 @@ def _is_alarm_day() -> bool:
return datetime.now(tz=timezone.utc).weekday() in ALARM_DAYS return datetime.now(tz=timezone.utc).weekday() in ALARM_DAYS
@dataclass
class _AlarmView:
"""The Tk widgets that make up the alarm's dismiss-challenge screen."""
container: tk.Frame
title_label: tk.Label
round_label: tk.Label
info_label: tk.Label
code_label: tk.Label
entry: tk.Entry
status_label: tk.Label
timer_label: tk.Label
@dataclass @dataclass
class _AlarmProgress: class _AlarmProgress:
"""Mutable dismiss-challenge progress state.""" """Mutable dismiss-challenge progress state."""
@ -121,11 +108,14 @@ class WakeAlarm:
self.root.title("Wake Alarm" + (" [DEMO]" if demo_mode else "")) self.root.title("Wake Alarm" + (" [DEMO]" if demo_mode else ""))
# mode="soft": no watchdog exists yet for a clean, silent lock # mode="soft": no watchdog exists yet for a clean, silent lock
# failure, so hard-lock (overrideredirect + grab) is deferred. # failure, so hard-lock (overrideredirect + grab) is deferred.
self._lock = LockWindow(self.root, LockConfig(mode="soft"), hooks=self) config = LockConfig(mode="soft")
self._lock = LockWindow(self.root, config, hooks=self)
self._lock.setup() self._lock.setup()
self._progress = _AlarmProgress(current_challenge=_make_challenge()) self._progress = _AlarmProgress(current_challenge=_make_challenge())
self._view = self._build_ui() self._view = _build_alarm_view(
self.root, self._progress.current_challenge, config, self._on_submit
)
self._update_timer() self._update_timer()
if self._progress.current_challenge.kind == "flash": if self._progress.current_challenge.kind == "flash":
self._start_flash_countdown() self._start_flash_countdown()
@ -159,92 +149,6 @@ class WakeAlarm:
_restore_display() _restore_display()
turn_off_plug() turn_off_plug()
def _build_ui(self) -> _AlarmView:
"""Build the dismiss-challenge UI and return its widgets as a view."""
challenge = self._progress.current_challenge
container = tk.Frame(self.root, bg="#1a1a1a")
container.place(relx=0.5, rely=0.5, anchor="center")
title_label = tk.Label(
container,
text="WAKE UP!",
font=("Arial", 48, "bold"),
fg="#ff4444",
bg="#1a1a1a",
)
title_label.pack(pady=20)
round_label = tk.Label(
container,
text=f"Round 1 / {DISMISS_ROUNDS_REQUIRED}",
font=("Arial", 24, "bold"),
fg="#ffaa00",
bg="#1a1a1a",
)
round_label.pack(pady=5)
info_label = tk.Label(
container,
text=challenge.hint,
font=("Arial", 18),
fg="white",
bg="#1a1a1a",
)
info_label.pack(pady=10)
# Non-flash types use a smaller font because their display text is wider.
code_font_size = (
48 if challenge.kind in ("math", "sort", "sequence", "reverse") else 72
)
code_label = tk.Label(
container,
text=challenge.display,
font=("Courier", code_font_size, "bold"),
fg="#00ff00",
bg="#1a1a1a",
)
code_label.pack(pady=30)
entry = tk.Entry(
container,
font=("Courier", 36),
justify="center",
width=12,
)
entry.pack(pady=10)
entry.focus_set()
entry.bind("<Return>", self._on_submit)
status_label = tk.Label(
container,
text="",
font=("Arial", 18),
fg="#ff4444",
bg="#1a1a1a",
)
status_label.pack(pady=10)
timer_label = tk.Label(
container,
text="",
font=("Arial", 14),
fg="#aaaaaa",
bg="#1a1a1a",
)
timer_label.pack(pady=5)
return _AlarmView(
container=container,
title_label=title_label,
round_label=round_label,
info_label=info_label,
code_label=code_label,
entry=entry,
status_label=status_label,
timer_label=timer_label,
)
def _on_submit(self, _event: object = None) -> None: def _on_submit(self, _event: object = None) -> None:
"""Handle challenge submission. """Handle challenge submission.
@ -260,7 +164,7 @@ class WakeAlarm:
if self._progress.current_challenge.kind == "flash": if self._progress.current_challenge.kind == "flash":
self._view.code_label.configure( self._view.code_label.configure(
text=self._progress.current_challenge.display, text=self._progress.current_challenge.display,
fg="#00ff00", fg=self._view.config.success,
) )
self._start_flash_countdown() self._start_flash_countdown()
return return
@ -271,7 +175,7 @@ class WakeAlarm:
self._progress.current_challenge = _make_challenge() self._progress.current_challenge = _make_challenge()
self._view.code_label.configure( self._view.code_label.configure(
text=self._progress.current_challenge.display, text=self._progress.current_challenge.display,
fg="#00ff00", fg=self._view.config.success,
) )
self._view.info_label.configure(text=self._progress.current_challenge.hint) self._view.info_label.configure(text=self._progress.current_challenge.hint)
self._view.entry.delete(0, tk.END) self._view.entry.delete(0, tk.END)
@ -302,7 +206,7 @@ class WakeAlarm:
self.root.after(1000, self._flash_tick) self.root.after(1000, self._flash_tick)
else: else:
hidden = "?" * len(self._progress.current_challenge.display) hidden = "?" * len(self._progress.current_challenge.display)
self._view.code_label.configure(text=hidden, fg="#555555") self._view.code_label.configure(text=hidden, fg=self._view.config.muted)
self._view.status_label.configure(text="Now type the code from memory!") self._view.status_label.configure(text="Now type the code from memory!")
def _dismiss_alarm(self, *, earned_skip: bool) -> None: def _dismiss_alarm(self, *, earned_skip: bool) -> None:
@ -321,14 +225,15 @@ class WakeAlarm:
if earned_skip if earned_skip
else "Alarm dismissed. No workout skip." else "Alarm dismissed. No workout skip."
) )
color = "#00ff00" if earned_skip else "#ffaa00" cfg = self._view.config
color = cfg.success if earned_skip else cfg.warning
tk.Label( tk.Label(
self._view.container, self._view.container,
text=msg, text=msg,
font=("Arial", 36, "bold"), font=("Arial", 36, "bold"),
fg=color, fg=color,
bg="#1a1a1a", bg=cfg.bg,
).pack(pady=30) ).pack(pady=30)
self.root.after(3000, self._lock.close) self.root.after(3000, self._lock.close)
@ -344,7 +249,7 @@ class WakeAlarm:
self._progress.current_challenge = _make_challenge() self._progress.current_challenge = _make_challenge()
self._view.code_label.configure( self._view.code_label.configure(
text=self._progress.current_challenge.display, text=self._progress.current_challenge.display,
fg="#00ff00", fg=self._view.config.success,
) )
self._view.info_label.configure(text=self._progress.current_challenge.hint) self._view.info_label.configure(text=self._progress.current_challenge.hint)
self._view.entry.delete(0, tk.END) self._view.entry.delete(0, tk.END)
@ -406,7 +311,8 @@ class WakeAlarm:
"""Alternate background colour every 750 ms (below seizure-risk 3 Hz).""" """Alternate background colour every 750 ms (below seizure-risk 3 Hz)."""
if not self._active: if not self._active:
return return
self.root.configure(bg="#ff0000" if self._progress.flash_on else "#1a1a1a") cfg = self._view.config
self.root.configure(bg=cfg.danger if self._progress.flash_on else cfg.bg)
self._progress.flash_on = not self._progress.flash_on self._progress.flash_on = not self._progress.flash_on
self.root.after(750, self._flash_step) self.root.after(750, self._flash_step)

122
wake_alarm/_alarm_view.py Normal file
View File

@ -0,0 +1,122 @@
"""Widget construction for the wake alarm's dismiss-challenge screen."""
from __future__ import annotations
from dataclasses import dataclass
import tkinter as tk
from typing import TYPE_CHECKING
from wake_alarm._constants import DISMISS_ROUNDS_REQUIRED
if TYPE_CHECKING:
from collections.abc import Callable
from gatelock import LockConfig
from wake_alarm._challenges import _Challenge
@dataclass
class _AlarmView:
"""The Tk widgets that make up the alarm's dismiss-challenge screen."""
container: tk.Frame
title_label: tk.Label
round_label: tk.Label
info_label: tk.Label
code_label: tk.Label
entry: tk.Entry
status_label: tk.Label
timer_label: tk.Label
config: LockConfig
def _build_alarm_view(
root: tk.Tk,
challenge: _Challenge,
config: LockConfig,
on_submit: Callable[[object], None],
) -> _AlarmView:
"""Build the dismiss-challenge UI and return its widgets as a view."""
container = tk.Frame(root, bg=config.bg)
container.place(relx=0.5, rely=0.5, anchor="center")
title_label = tk.Label(
container,
text="WAKE UP!",
font=("Arial", 48, "bold"),
fg=config.danger,
bg=config.bg,
)
title_label.pack(pady=20)
round_label = tk.Label(
container,
text=f"Round 1 / {DISMISS_ROUNDS_REQUIRED}",
font=("Arial", 24, "bold"),
fg=config.warning,
bg=config.bg,
)
round_label.pack(pady=5)
info_label = tk.Label(
container,
text=challenge.hint,
font=("Arial", 18),
fg=config.fg,
bg=config.bg,
)
info_label.pack(pady=10)
# Non-flash types use a smaller font because their display text is wider.
code_font_size = (
48 if challenge.kind in ("math", "sort", "sequence", "reverse") else 72
)
code_label = tk.Label(
container,
text=challenge.display,
font=("Courier", code_font_size, "bold"),
fg=config.success,
bg=config.bg,
)
code_label.pack(pady=30)
entry = tk.Entry(
container,
font=("Courier", 36),
justify="center",
width=12,
)
entry.pack(pady=10)
entry.focus_set()
entry.bind("<Return>", on_submit)
status_label = tk.Label(
container,
text="",
font=("Arial", 18),
fg=config.danger,
bg=config.bg,
)
status_label.pack(pady=10)
timer_label = tk.Label(
container,
text="",
font=("Arial", 14),
fg=config.muted,
bg=config.bg,
)
timer_label.pack(pady=5)
return _AlarmView(
container=container,
title_label=title_label,
round_label=round_label,
info_label=info_label,
code_label=code_label,
entry=entry,
status_label=status_label,
timer_label=timer_label,
config=config,
)

View File

@ -60,6 +60,7 @@ def _block_real_tk() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,
@ -74,6 +75,7 @@ def mock_tk_module() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,

View File

@ -42,6 +42,7 @@ def _block_real_tk() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,
@ -75,6 +76,7 @@ def mock_tk_module() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,
@ -397,7 +399,7 @@ class TestScreenFlash:
alarm._progress.flash_on = False alarm._progress.flash_on = False
alarm._flash_step() alarm._flash_step()
mock_root.configure.assert_called_once_with(bg="#1a1a1a") mock_root.configure.assert_called_once_with(bg=alarm._view.config.bg)
assert alarm._progress.flash_on is True assert alarm._progress.flash_on is True
mock_root.after.assert_called_with(750, alarm._flash_step) mock_root.after.assert_called_with(750, alarm._flash_step)
alarm._stop_beep.set() alarm._stop_beep.set()
@ -415,7 +417,7 @@ class TestScreenFlash:
alarm._progress.flash_on = True alarm._progress.flash_on = True
alarm._flash_step() alarm._flash_step()
mock_root.configure.assert_called_once_with(bg="#ff0000") mock_root.configure.assert_called_once_with(bg=alarm._view.config.danger)
assert alarm._progress.flash_on is False assert alarm._progress.flash_on is False
mock_root.after.assert_called_with(750, alarm._flash_step) mock_root.after.assert_called_with(750, alarm._flash_step)
alarm._stop_beep.set() alarm._stop_beep.set()

View File

@ -41,6 +41,7 @@ def _block_real_tk() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,
@ -74,6 +75,7 @@ def mock_tk_module() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,

View File

@ -40,6 +40,7 @@ def _block_real_tk() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,
@ -73,6 +74,7 @@ def mock_tk_module() -> Generator[MagicMock]:
mock = _make_mock_tk() mock = _make_mock_tk()
with ( with (
patch("wake_alarm._alarm.tk", mock), patch("wake_alarm._alarm.tk", mock),
patch("wake_alarm._alarm_view.tk", mock),
patch( patch(
"wake_alarm._alarm.GateRoot", "wake_alarm._alarm.GateRoot",
return_value=mock.Tk.return_value, return_value=mock.Tk.return_value,