Skip to content

Commit

Permalink
Add source code and about URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
TechAurelian committed Oct 31, 2024
1 parent eac7668 commit 5292367
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 5 deletions.
4 changes: 3 additions & 1 deletion recursive_routing/lib/common/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
11 changes: 11 additions & 0 deletions recursive_routing/lib/common/urls.dart
Original file line number Diff line number Diff line change
@@ -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/';
32 changes: 29 additions & 3 deletions recursive_routing/lib/screens/recursive_routing_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -64,14 +67,22 @@ class _RecursiveRoutingScreenState extends State<RecursiveRoutingScreen> {
/// 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;
}
}

Expand Down Expand Up @@ -132,6 +143,8 @@ class _RecursiveRoutingScreenState extends State<RecursiveRoutingScreen> {
enum _AppBarActions {
incrementCounter,
goHome,
viewSource,
about,
}

/// The app bar of the recursive routing screen.
Expand Down Expand Up @@ -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),
),
],
),
Expand Down
87 changes: 86 additions & 1 deletion recursive_routing/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"
1 change: 1 addition & 0 deletions recursive_routing/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5292367

Please sign in to comment.