From b3d33b05d56c628da0803ba553d06ef6f99bf45e Mon Sep 17 00:00:00 2001 From: jdz Date: Wed, 28 Oct 2026 22:56:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=8E=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E8=BF=94=E5=9B=9E=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 4 +++- test/back_navigation_test.dart | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 41ffecb8..bc7c39d6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -405,8 +405,10 @@ class _TechPieAppState extends State with WidgetsBindingObserver { } if (release == null || !mounted) return; + final dialogContext = _navigatorKey.currentState?.overlay?.context; + if (dialogContext == null || !dialogContext.mounted) return; _promptedThisLaunch = true; - await showUpdateAvailableDialog(context, release); + await showUpdateAvailableDialog(dialogContext, release); } Future _openEcardPayCode() async { diff --git a/test/back_navigation_test.dart b/test/back_navigation_test.dart index 9fd4d890..9e046c9c 100644 --- a/test/back_navigation_test.dart +++ b/test/back_navigation_test.dart @@ -1,8 +1,10 @@ import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:techpie/main.dart'; import 'package:techpie/pages/debug_log_page.dart'; +import 'package:techpie/pages/settings_page.dart'; import 'package:techpie/services/assignment_service.dart'; import 'package:techpie/services/auth_service.dart'; import 'package:techpie/services/campus_card_service.dart'; @@ -26,9 +28,7 @@ void main() { testWidgets('the system back leaves a settings subpage rather than the app', ( WidgetTester tester, ) async { - // Wide enough for the non-compact layout, and tall enough that the debug - // tiles at the bottom of the settings list are not under the navigation bar — - // a tap on an obscured tile does nothing, silently. + // Keep the wide layout so the settings subpage uses its nested navigator. tester.view.physicalSize = const Size(1200, 1400); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -90,8 +90,19 @@ void main() { await tester.tap(find.text('Settings').first); await tester.pumpAndSettle(); - // Only the debug section is reachable without an account; the window above is - // tall enough for it to be on screen. + // Settings can grow as options are added. Scroll the actual settings list + // until the entry can receive taps, including above the bottom navigation. + await tester.scrollUntilVisible( + find.text('View Logs').hitTestable(), + 200, + scrollable: find + .descendant( + of: find.byType(SettingsPage), + matching: find.byType(Scrollable), + ) + .first, + ); + await tester.pumpAndSettle(); await tester.tap(find.text('View Logs')); await tester.pumpAndSettle(); expect(find.byType(DebugLogPage), findsOneWidget); @@ -102,7 +113,8 @@ void main() { expect( platformCalls, isNot(contains('SystemNavigator.pop')), - reason: 'the back gesture left the subpage, so the app must not be asked to close', + reason: + 'the back gesture left the subpage, so the app must not be asked to close', ); expect(find.byType(DebugLogPage), findsNothing); });