From c8d33f0ca09b9ce8d1954cb43e594823b8cf9582 Mon Sep 17 00:00:00 2001 From: dwindown Date: Wed, 1 Apr 2026 22:10:47 +0700 Subject: [PATCH] Add touch fallback to open admin for phone testing --- lib/features/home/home_view.dart | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/features/home/home_view.dart b/lib/features/home/home_view.dart index 7c446a0..2a8e951 100644 --- a/lib/features/home/home_view.dart +++ b/lib/features/home/home_view.dart @@ -45,7 +45,9 @@ class _HomeViewState extends ConsumerState { Timer? _comboResetTimer; Timer? _simulationShortcutTimer; Timer? _autoRefreshTimer; + Timer? _touchUnlockTimer; bool _isAutoRefreshRunning = false; + int _touchUnlockTapCount = 0; @override void initState() { @@ -64,6 +66,7 @@ class _HomeViewState extends ConsumerState { _comboResetTimer?.cancel(); _simulationShortcutTimer?.cancel(); _autoRefreshTimer?.cancel(); + _touchUnlockTimer?.cancel(); _homeFocusNode.dispose(); super.dispose(); } @@ -213,6 +216,30 @@ class _HomeViewState extends ConsumerState { _simulationShortcutKeys.clear(); } + void _resetTouchUnlock() { + _touchUnlockTimer?.cancel(); + _touchUnlockTapCount = 0; + } + + void _registerTouchUnlockTap() { + _touchUnlockTimer?.cancel(); + _touchUnlockTimer = Timer(const Duration(seconds: 3), _resetTouchUnlock); + _touchUnlockTapCount += 1; + + if (_touchUnlockTapCount < 5) return; + + _resetTouchUnlock(); + WidgetsBinding.instance.addPostFrameCallback((_) async { + if (!mounted) return; + await Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const AdminScreen()), + ); + if (mounted) { + _homeFocusNode.requestFocus(); + } + }); + } + @override Widget build(BuildContext context) { // Audio trigger listener @@ -282,6 +309,17 @@ class _HomeViewState extends ConsumerState { }, child: screen, ), + // Hidden touch fallback for phones/tablets during testing: + // tap top-left area 5x quickly to open admin. + Positioned( + top: 0, + left: 0, + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: _registerTouchUnlockTap, + child: const SizedBox(width: 110, height: 110), + ), + ), ], ), ),