From 9f7773f72438570e36d5e90d300d4df9a4153a66 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 21 Mar 2025 13:40:11 -0700 Subject: [PATCH] Add functionality to Help buttons for opening URLs. --- android/app/src/main/AndroidManifest.xml | 5 +++++ lib/pages/help.dart | 25 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 112f694..2839cf7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -42,5 +42,10 @@ + + + + + diff --git a/lib/pages/help.dart b/lib/pages/help.dart index 16feec6..9deed13 100644 --- a/lib/pages/help.dart +++ b/lib/pages/help.dart @@ -1,4 +1,21 @@ +// Flutter import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher_string.dart'; + +_launchSite(String url) async { + try { + if (await canLaunchUrlString(url)) { + await launchUrlString( + url, + mode: LaunchMode.externalApplication, + ); + } else { + throw "System does not think it can launch '$url'."; + } + } on Exception catch (e) { + throw e.toString(); + } +} class HelpPage extends StatelessWidget { const HelpPage({ @@ -41,7 +58,9 @@ class HelpPage extends StatelessWidget { color: theme.colorScheme.onPrimary, ), child: TextButton.icon( - onPressed: () {}, + onPressed: () { + _launchSite("https://git.hyperling.com/me"); + }, icon: Icon(Icons.code), label: Text("Code Repository"), ), @@ -57,7 +76,9 @@ class HelpPage extends StatelessWidget { color: theme.colorScheme.onPrimary, ), child: TextButton.icon( - onPressed: () {}, + onPressed: () { + _launchSite("https://hyperling.com"); + }, icon: Icon(Icons.web_asset), label: Text("Personal Website"), ),