Add touch fallback to open admin for phone testing

This commit is contained in:
dwindown
2026-04-01 22:10:47 +07:00
parent 925189417d
commit c8d33f0ca0

View File

@@ -45,7 +45,9 @@ class _HomeViewState extends ConsumerState<HomeView> {
Timer? _comboResetTimer; Timer? _comboResetTimer;
Timer? _simulationShortcutTimer; Timer? _simulationShortcutTimer;
Timer? _autoRefreshTimer; Timer? _autoRefreshTimer;
Timer? _touchUnlockTimer;
bool _isAutoRefreshRunning = false; bool _isAutoRefreshRunning = false;
int _touchUnlockTapCount = 0;
@override @override
void initState() { void initState() {
@@ -64,6 +66,7 @@ class _HomeViewState extends ConsumerState<HomeView> {
_comboResetTimer?.cancel(); _comboResetTimer?.cancel();
_simulationShortcutTimer?.cancel(); _simulationShortcutTimer?.cancel();
_autoRefreshTimer?.cancel(); _autoRefreshTimer?.cancel();
_touchUnlockTimer?.cancel();
_homeFocusNode.dispose(); _homeFocusNode.dispose();
super.dispose(); super.dispose();
} }
@@ -213,6 +216,30 @@ class _HomeViewState extends ConsumerState<HomeView> {
_simulationShortcutKeys.clear(); _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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Audio trigger listener // Audio trigger listener
@@ -282,6 +309,17 @@ class _HomeViewState extends ConsumerState<HomeView> {
}, },
child: screen, 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),
),
),
], ],
), ),
), ),