Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,10 @@ class _TechPieAppState extends State<TechPieApp> 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<void> _openEcardPayCode() async {
Expand Down
24 changes: 18 additions & 6 deletions test/back_navigation_test.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
Expand Down