From b1858227defbdd6ef61280da85d88967d6d0abb8 Mon Sep 17 00:00:00 2001 From: Werner Fleischer <70745309+wfleischer@users.noreply.github.com> Date: Mon, 2 Dec 2024 00:20:05 +0100 Subject: [PATCH] schedules: use primary color for section buttons (#138) --- .../presentations/section_widget.dart | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/src/schedules/presentations/section_widget.dart b/lib/src/schedules/presentations/section_widget.dart index c6c7992..7f5a7ff 100644 --- a/lib/src/schedules/presentations/section_widget.dart +++ b/lib/src/schedules/presentations/section_widget.dart @@ -79,11 +79,19 @@ class SectionWidget extends ConsumerWidget { child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ TextButton( - onPressed: () => _launchUrl(Uri.parse( - 'https://www.jw.org/finder?srcid=jwlshare&wtlocale=${bibleLanguage?.wtCode}&prefer=lang&bible=${section.url}')), + onPressed: () async { + final url = Uri.parse( + 'https://www.jw.org/finder?srcid=jwlshare&wtlocale=${bibleLanguage?.wtCode}&prefer=lang&bible=${section.url}'); + + if (await canLaunchUrl(url)) { + await launchUrl(url); + } + }, child: Text( '${bibleLanguage?.books[section.bookIndex].name} ${section.ref}', - style: const TextStyle(color: Color(0xff007bff)))), + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ))), if (plan.showEvents) ...section.events .map((eventKey) => events?.events[eventKey] != null @@ -101,9 +109,3 @@ class SectionWidget extends ConsumerWidget { ); } } - -Future _launchUrl(Uri url) async { - if (!await launchUrl(url)) { - throw Exception('Could not launch $url'); - } -}