From b8725c6a9ff86abe4ea5afae2c5937711bb806fd Mon Sep 17 00:00:00 2001 From: TechnicJelle <22576047+TechnicJelle@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:43:44 +0200 Subject: [PATCH] Added link to download Java in the settings screen --- lib/main_menu/settings/setting_heading.dart | 38 +++++++++++++++++++++ lib/main_menu/settings/settings_screen.dart | 15 +++++--- pubspec.lock | 16 +++++++++ pubspec.yaml | 1 + 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 lib/main_menu/settings/setting_heading.dart diff --git a/lib/main_menu/settings/setting_heading.dart b/lib/main_menu/settings/setting_heading.dart new file mode 100644 index 0000000..e7ec0b4 --- /dev/null +++ b/lib/main_menu/settings/setting_heading.dart @@ -0,0 +1,38 @@ +import "package:flutter/material.dart"; +import "package:flutter_markdown/flutter_markdown.dart"; +import "package:url_launcher/url_launcher_string.dart"; + +class SettingHeading extends StatelessWidget { + final String text; + + const SettingHeading(this.text, {super.key}); + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + final TextStyle? titleStyle = textTheme.headlineSmall; + final TextStyle? labelStyle = textTheme.labelMedium?.copyWith(color: Colors.grey); + return Padding( + padding: const EdgeInsets.only(left: 16, bottom: 8, top: 16), + child: Padding( + padding: const EdgeInsets.only(top: 4), + child: MarkdownBody( + data: text, + onTapLink: (String text, String? href, String title) { + if (href != null) { + launchUrlString(href); + } + }, + styleSheet: MarkdownStyleSheet( + h1: titleStyle, + p: labelStyle, + a: labelStyle?.copyWith( + color: Colors.blue, + decoration: TextDecoration.underline, + ), + ), + ), + ), + ); + } +} diff --git a/lib/main_menu/settings/settings_screen.dart b/lib/main_menu/settings/settings_screen.dart index 35cf507..d783294 100644 --- a/lib/main_menu/settings/settings_screen.dart +++ b/lib/main_menu/settings/settings_screen.dart @@ -1,16 +1,21 @@ import "package:flutter/material.dart"; import "java/java_picker.dart"; +import "setting_heading.dart"; class SettingsScreen extends StatelessWidget { const SettingsScreen({super.key}); @override Widget build(BuildContext context) { - return ListView(children: const [ - Text("Java Executable"), //TODO: Add link to download Java - SizedBox(height: 4), - JavaPicker(), - ]); + return ListView( + children: const [ + SettingHeading( + "# Java Executable\n" + "You can download Java [here](https://adoptium.net/temurin/releases/)", + ), + JavaPicker(), + ], + ); } } diff --git a/pubspec.lock b/pubspec.lock index a91a4ff..490cc70 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -219,6 +219,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_markdown: + dependency: "direct main" + description: + name: flutter_markdown + sha256: bd9c475d9aae256369edacafc29d1e74c81f78a10cdcdacbbbc9e3c43d009e4a + url: "https://pub.dev" + source: hosted + version: "0.7.4" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -341,6 +349,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.2-main.4" + markdown: + dependency: transitive + description: + name: markdown + sha256: ef2a1298144e3f985cc736b22e0ccdaf188b5b3970648f2d9dc13efd1d9df051 + url: "https://pub.dev" + source: hosted + version: "7.2.2" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 31a2ee2..fea1ca7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: file_picker: ^8.1.2 flutter: sdk: flutter + flutter_markdown: ^0.7.4 flutter_riverpod: ^2.5.1 meta: ^1.15.0 path: ^1.9.0