Skip to content

Commit

Permalink
make website link clickable
Browse files Browse the repository at this point in the history
This should work on all supported platforms (web/android).

Fixes mwageringel#7
  • Loading branch information
mwageringel committed Aug 13, 2022
1 parent f4d93e0 commit 91ed785
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixed
- an issue in which level 1 did not unlock
(Workaround for version 1.1.2: Solve the very first question again or change the theme.)
- the website URL is now clickable

## [1.1.2] - 2022-07-22
### Added
Expand Down
45 changes: 31 additions & 14 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:sqflite/sqflite.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:everest/game.dart';
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:url_launcher/link.dart';
import 'package:url_launcher/url_launcher.dart';

const appName = 'Everest';
const String themeModeKey = 'settings:themeMode';
Expand Down Expand Up @@ -382,13 +384,38 @@ class ThemeModeLabel extends StatelessWidget {
}
}

class MoreInfoMessage extends StatelessWidget {
const MoreInfoMessage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle textStyle = theme.textTheme.bodyText2!;
final Uri url = Uri.parse('https://mwageringel.github.io/everest/');
return Text.rich( // important for vertical alignment
TextSpan(
children: <InlineSpan>[
TextSpan(style: textStyle, text: AppLocalizations.of(context)!.moreInfo),
WidgetSpan(
child: Link(
uri: url,
builder: (context, followLink) => InkWell(
// opens new tab in web (in contrast to `followLink`) and external browser on android
onTap: () => launchUrl(url, mode: LaunchMode.externalApplication),
child: Text(url.toString(), style: textStyle.copyWith(color: theme.colorScheme.primary)),
),
),
),
],
),
);
}
}

class SettingsScreen extends StatelessWidget {
const SettingsScreen({ Key? key }) : super(key: key);

@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle textStyle = theme.textTheme.bodyText2!;
return ListView(
padding: listPadding,
children: [
Expand Down Expand Up @@ -438,18 +465,8 @@ class SettingsScreen extends StatelessWidget {
AboutListTile(
icon: const Icon(Icons.info_outline),
applicationVersion: "${AppLocalizations.of(context)!.version} ${Provider.of<World>(context).appInfo.version}",
aboutBoxChildren: [
SelectableText.rich(
TextSpan(
children: <TextSpan>[
TextSpan(style: textStyle, text: AppLocalizations.of(context)!.moreInfo),
TextSpan(
style: textStyle.copyWith(color: theme.colorScheme.primary),
text: 'https://mwageringel.github.io/everest/'), // TODO make hyperlink clickable or copy to clipboard
TextSpan(style: textStyle, text: '.'),
],
),
),
aboutBoxChildren: const [
MoreInfoMessage(),
],
),
const MyDivider(),
Expand Down
56 changes: 56 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.5"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
vector_math:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
provider: ^6.0.2
package_info_plus: ^1.4.2
flex_color_scheme: ^5.1.0
url_launcher: ^6.1.5
# scrollable_positioned_list: ^0.2.3

dev_dependencies:
Expand Down

0 comments on commit 91ed785

Please sign in to comment.