From c00000f964d4856127936d3b331d851179c41f8d Mon Sep 17 00:00:00 2001 From: anima-regem Date: Mon, 16 Dec 2024 02:14:59 +0530 Subject: [PATCH] adds a settings page --- lib/screens/settings_screen.dart | 81 ++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index ea195c2..c5582d9 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -4,14 +4,49 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:vyajan/services/helpers.dart'; class SettingsScreen extends StatelessWidget { + const SettingsScreen({super.key}); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Settings'), + title: const Text('Settings'), ), body: Column( children: [ + ListTile( + leading: const Icon(HugeIcons.strokeRoundedReload), + title: const Text( + 'Check for updates', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + onTap: () { + getLatestVersion().then( + (latestVersion) { + if (latestVersion != null) { + if (latestVersion == getVersion()) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'You are using the latest version $latestVersion'), + ), + ); + } else { + final downloadURL = Uri.parse( + 'https://github.com/anima-regem/Vyajan/releases'); + launchUrl(downloadURL); + } + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Failed to check for updates'), + ), + ); + } + }, + ); + }, + ), ListTile( leading: const Icon(HugeIcons.strokeRoundedGithub), title: const Text( @@ -26,12 +61,48 @@ class SettingsScreen extends StatelessWidget { }, ), ListTile( - leading: const Icon(HugeIcons.strokeRoundedReload), + leading: const Icon(HugeIcons.strokeRoundedMail01), + title: const Text( + 'Email', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + subtitle: const Text('Send feedback to the developer)'), + onTap: () { + final Uri email = Uri.parse('mailto:vichukartha@gmail.com'); + launchUrl(email); + }), + ListTile( + leading: const Icon(HugeIcons.strokeRoundedCoffee01), + title: const Text( + 'Buy me a coffee', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + subtitle: const Text('I love coffee! (Just UPI, hehe)'), + onTap: () { + final Uri upi = + Uri.parse('https://buymeacoffee.com/vichukartha'); + launchUrl(upi); + }), + ListTile( + leading: const Icon(HugeIcons.strokeRoundedInformationCircle), title: const Text( - 'Check for updates', + 'Version', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), - subtitle: Text('Current Version : ${getVersion()}'), - ) + subtitle: Text('Current version: ${getVersion()}'), + ), + ListTile( + leading: const Icon(HugeIcons.strokeRoundedNews), + title: const Text( + 'Wiki', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + subtitle: const Text('Read more about the app'), + onTap: () { + final Uri wiki = + Uri.parse('https://github.com/anima-regem/Vyajan/wiki'); + launchUrl(wiki); + }), ], ), );