diff --git a/lib/EasyLink.dart b/lib/EasyLink.dart new file mode 100644 index 0000000..5bec561 --- /dev/null +++ b/lib/EasyLink.dart @@ -0,0 +1,13 @@ +import 'package:flutter/widgets.dart'; + +class EasyLink { + final String uri; + final String displayText; + final IconData icon; + + const EasyLink({ + required this.uri, + required this.displayText, + required this.icon, + }); +} diff --git a/lib/EasyLinkWidget.dart b/lib/EasyLinkWidget.dart new file mode 100644 index 0000000..59751ca --- /dev/null +++ b/lib/EasyLinkWidget.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:ything_radio/EasyLink.dart'; + +class EasyLinkWidget extends StatelessWidget { + final EasyLink linkInfo; + + const EasyLinkWidget({super.key, required this.linkInfo}); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + _launchUrl(); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + FittedBox( + child: Center( + child: Icon(linkInfo.icon), + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.only( + left: 8.0, + ), + child: Text(linkInfo.displayText), + ), + ), + ], + ), + ), + ); + } + + Future _launchUrl() async { + if (!await launchUrl(Uri.parse(linkInfo.uri))) { + throw Exception('Could not launch url'); + } + } +} diff --git a/lib/Links.dart b/lib/Links.dart index a9f64b8..b40c38d 100644 --- a/lib/Links.dart +++ b/lib/Links.dart @@ -1,12 +1,52 @@ import 'package:flutter/material.dart'; +import 'package:flutter_tabler_icons/flutter_tabler_icons.dart'; +import 'package:ything_radio/EasyLink.dart'; +import 'package:ything_radio/EasyLinkWidget.dart'; +import 'package:ything_radio/SafeZone.dart'; class Links extends StatelessWidget { const Links({super.key}); + final List links = const [ + EasyLinkWidget( + linkInfo: EasyLink( + uri: "https://github.com/YthingLLC/ything_radio", + displayText: "GitHub - Ything Radio", + icon: TablerIcons.brand_github), + ), + EasyLinkWidget( + linkInfo: EasyLink( + uri: "http://ything.net", + displayText: "Ything Home", + icon: TablerIcons.home, + ), + ), + EasyLinkWidget( + linkInfo: EasyLink( + uri: "http://", + displayText: "Link 3", + icon: TablerIcons.abc, + ), + ), + EasyLinkWidget( + linkInfo: EasyLink( + uri: "https://", + displayText: "Link 4", + icon: TablerIcons.brand_wikipedia), + ), + ]; + @override Widget build(BuildContext context) { - return const Center( - child: Text("Links Page"), + return DefaultTextStyle( + style: Theme.of(context).textTheme.headlineSmall!, + child: SafeZone( + child: Center( + child: Column( + children: links.map((link) => link).toList(), + ), + ), + ), ); } }