Skip to content

Commit

Permalink
Add tab history option and browser history back/forward support (tomg…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gilder authored Oct 6, 2021
1 parent db5115e commit 50896bb
Show file tree
Hide file tree
Showing 36 changed files with 1,280 additions and 318 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# 0.10.0-dev3
# 0.10.0-dev4

**Important:** this release has some major breaking changes with how Routemaster
interacts with the system back button on Android and web.

* Minimum supported Flutter version is now 2.5.0.

* Breaking change: by default, the Android system back button now navigates
backwards chronologically, instead of just popping the navigation stack.

* Breaking change: by default, tabs no longer add an entry to the web history
stack. This means the browser back button will not navigate between tabs.
To use the previous behavior, specify `backBehavior: TabBackBehavior.history` in
the tab page's constructor.

* Added: `history` property on `Routemaster` for chronological history navigation,
for example `Routemaster.of(context).history.back()`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Hello! Routemaster is an easy-to-use router for Flutter, which wraps over Naviga
* Really easy nested navigation support for tabs
* Multiple route maps: for example one for a logged in user, another for logged out
* Observers to easily listen to route changes
* Covered by over 200 unit, widget and integration tests
* Covered by over 250 unit, widget and integration tests

Here's the entire routing setup needed for an app featuring tabs and pushed routes:

Expand Down
2 changes: 1 addition & 1 deletion example/book_store/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
1 change: 0 additions & 1 deletion example/book_store/test/navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:book_store/models.dart';
import 'package:book_store/search_page.dart';
import 'package:book_store/wishlist_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'helpers.dart';

Expand Down
1 change: 1 addition & 0 deletions example/mobile_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ RouteMap _buildRouteMap(AppState appState) {
'/notifications',
'/settings',
],
backBehavior: TabBackBehavior.none,
),
'/feed': (_) => MaterialPage(
name: 'Feed',
Expand Down
8 changes: 4 additions & 4 deletions example/mobile_app/test/feed_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main() {
await tester.pump();
expect(systemUrl.current, '/feed/profile/1/photo');

await invokeSystemBack();
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(systemUrl.current, '/feed/profile/1');

Expand Down Expand Up @@ -112,7 +112,7 @@ void main() {
);

// Goes back to profile
await invokeSystemBack();
await tester.tap(find.byType(BackButton));

await tester.pump();
await tester.pump(Duration(seconds: 1));
Expand All @@ -122,7 +122,7 @@ void main() {
expect(find.byType(PhotoPage), findsNothing);

// Goes back to feed home
await invokeSystemBack();
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(systemUrl.current, '/feed');
});
Expand Down Expand Up @@ -150,7 +150,7 @@ void main() {

expect(find.text('Non-Page route'), findsOneWidget);

await invokeSystemBack();
await tester.tap(find.byType(BackButton));
await tester.pump();
await tester.pump(Duration(seconds: 1));

Expand Down
5 changes: 4 additions & 1 deletion example/mobile_app/test/replace_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile_app/main.dart';
import 'package:mobile_app/pages/feed_page.dart';
import 'helpers.dart';

Future pumpBottomNavigationPage(WidgetTester tester) async {
Expand Down Expand Up @@ -28,9 +30,10 @@ void main() {
await tester.pump(Duration(seconds: 1));
expect(systemUrl.current, '/bottom-navigation-bar/one');

await invokeSystemBack();
await tester.tap(find.byType(BackButton));
await tester.pump();
await tester.pump(Duration(seconds: 1));
expect(find.byType(FeedPage), findsOneWidget);
expect(systemUrl.current, '/feed');
});
});
Expand Down
Loading

0 comments on commit 50896bb

Please sign in to comment.