diff --git a/recursive_routing/lib/common/strings.dart b/recursive_routing/lib/common/strings.dart index 24292ac..0686b15 100644 --- a/recursive_routing/lib/common/strings.dart +++ b/recursive_routing/lib/common/strings.dart @@ -9,7 +9,9 @@ library; const String appName = 'Flutter Recursive Routing'; const String recursiveRoutingScreenTitle = 'Recursive Routing'; String recursiveLevel(int level) => 'Level $level'; -const String goHomeTitle = 'Go back to the first level'; const String goUpTooltip = 'Go up to the previous level'; const String goDownTooltip = 'Go down to the next level'; const String addTooltip = 'Increment counter to check state keeping'; +const String goHomeMenuItem = 'Go back to the first level'; +const String viewSourceMenuItem = 'View source code'; +const String aboutMenuItem = 'About these experiments'; diff --git a/recursive_routing/lib/common/urls.dart b/recursive_routing/lib/common/urls.dart new file mode 100644 index 0000000..15dc407 --- /dev/null +++ b/recursive_routing/lib/common/urls.dart @@ -0,0 +1,11 @@ +// Copyright 2020-2024 Hellogramming. All rights reserved. +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file or at +// https://hellogramming.com/flutter_experiments/license/. + +/// URL constants used in the app. +library; + +const String viewSourceUrl = 'https://github.com/Hellogramming/flutter_experiments'; + +const String aboutUrl = 'https://hellogramming.com/flutterexperiments/'; diff --git a/recursive_routing/lib/screens/recursive_routing_screen.dart b/recursive_routing/lib/screens/recursive_routing_screen.dart index b879e34..3a23c5d 100644 --- a/recursive_routing/lib/screens/recursive_routing_screen.dart +++ b/recursive_routing/lib/screens/recursive_routing_screen.dart @@ -5,7 +5,10 @@ import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + import '../common/strings.dart' as strings; +import '../common/urls.dart' as urls; import '../utils/color_utils.dart' as color_utils; /// The list of accent colors for the recursive routing screens. @@ -64,14 +67,22 @@ class _RecursiveRoutingScreenState extends State { /// Performs the tasks of the app bar actions. void _onAppBarAction(_AppBarActions action) { switch (action) { + // Increment the counter case _AppBarActions.incrementCounter: - // Increment the counter setState(() => _counter++); break; + // Go back to the first level of the recursive routing case _AppBarActions.goHome: - // Go back to the first level of the recursive routing Navigator.popUntil(context, (route) => route.isFirst); break; + // Open the source code of the experiments in the browser + case _AppBarActions.viewSource: + launchUrl(Uri.parse(urls.viewSourceUrl)); + break; + // Open the about page of the experiments in the browser + case _AppBarActions.about: + launchUrl(Uri.parse(urls.aboutUrl)); + break; } } @@ -132,6 +143,8 @@ class _RecursiveRoutingScreenState extends State { enum _AppBarActions { incrementCounter, goHome, + viewSource, + about, } /// The app bar of the recursive routing screen. @@ -178,7 +191,20 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget { itemBuilder: (_) => [ const PopupMenuItem( value: _AppBarActions.goHome, - child: Text(strings.goHomeTitle), + child: Text(strings.goHomeMenuItem), + ), + + // Add a divider between the menu items + const PopupMenuDivider(), + + const PopupMenuItem( + value: _AppBarActions.viewSource, + child: Text(strings.viewSourceMenuItem), + ), + + const PopupMenuItem( + value: _AppBarActions.about, + child: Text(strings.aboutMenuItem), ), ], ), diff --git a/recursive_routing/pubspec.lock b/recursive_routing/pubspec.lock index cbb6965..516fee4 100644 --- a/recursive_routing/pubspec.lock +++ b/recursive_routing/pubspec.lock @@ -75,6 +75,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" leak_tracker: dependency: transitive description: @@ -139,6 +144,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" sky_engine: dependency: transitive description: flutter @@ -192,6 +205,70 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603" + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "0dea215895a4d254401730ca0ba8204b29109a34a99fb06ae559a2b60988d2de" + url: "https://pub.dev" + source: hosted + version: "6.3.13" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af + url: "https://pub.dev" + source: hosted + version: "3.2.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e" + url: "https://pub.dev" + source: hosted + version: "2.3.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4" + url: "https://pub.dev" + source: hosted + version: "3.1.3" vector_math: dependency: transitive description: @@ -208,6 +285,14 @@ packages: url: "https://pub.dev" source: hosted version: "14.2.5" + web: + dependency: transitive + description: + name: web + sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + url: "https://pub.dev" + source: hosted + version: "1.1.0" sdks: dart: ">=3.5.4 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" + flutter: ">=3.24.0" diff --git a/recursive_routing/pubspec.yaml b/recursive_routing/pubspec.yaml index 15314d1..aeee8db 100644 --- a/recursive_routing/pubspec.yaml +++ b/recursive_routing/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: flutter: sdk: flutter + url_launcher: ^6.3.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.