initial links page
This commit is contained in:
13
lib/EasyLink.dart
Normal file
13
lib/EasyLink.dart
Normal file
@@ -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,
|
||||
});
|
||||
}
|
||||
44
lib/EasyLinkWidget.dart
Normal file
44
lib/EasyLinkWidget.dart
Normal file
@@ -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<void> _launchUrl() async {
|
||||
if (!await launchUrl(Uri.parse(linkInfo.uri))) {
|
||||
throw Exception('Could not launch url');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<EasyLinkWidget> 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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user