diff --git a/assets/images/logo.png b/assets/images/logo.png new file mode 100644 index 000000000..effdfbab9 Binary files /dev/null and b/assets/images/logo.png differ diff --git a/lib/constants.dart b/lib/constants.dart index 27214df0b..917caec31 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -100,3 +100,27 @@ String bluetooth = 'BLUETOOTH'; String wifi = 'WIFI'; String whatisPslab = 'What is PSLab Device?'; String pslabUrl = 'https://pslab.io'; + +String aboutUs = 'About Us'; +String pslabDescription = + 'The goal of PSLab is to create an Open Source hardware device (open on all layers) that can be used for experiments by teachers, students and citizen scientists. Our tiny pocket lab provides an array of sensors for doing science and engineering experiments. It provides functions of numerous measurement devices including an oscilloscope, a waveform generator, a frequency generator, a frequency counter, a programmable voltage, current source and as a data logger.'; +String feedbackNBugs = 'Feedback & Bugs'; +String feedbackForm = 'https://goo.gl/forms/sHlmRAPFmzcGQ27u2'; +String website = 'https://pslab.io/'; +String github = 'https://github.com/fossasia/'; +String facebook = 'https://www.facebook.com/pslabio/'; +String x = 'https://x.com/pslabio/'; +String youtube = 'https://www.youtube.com/channel/UCQprMsG-raCIMlBudm20iLQ/'; +String mail = 'pslab-fossasia@googlegroups.com'; +String developers = + 'https://github.com/fossasia/pslab-android/graphs/contributors'; +List connectWithUs = [ + 'Connect with us', + 'Contact us', + 'Visit our website', + 'Fork us on GitHub', + 'Like us on Facebook', + 'Follow us on X', + 'Watch us on Youtube', + 'Developers' +]; diff --git a/lib/main.dart b/lib/main.dart index 02db3a084..09be5b76f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'package:pslab/view/connect_device_screen.dart'; import 'package:pslab/view/faq_screen.dart'; import 'package:pslab/view/instruments_screen.dart'; import 'package:pslab/view/oscilloscope_screen.dart'; +import 'package:pslab/view/about_us_screen.dart'; import 'constants.dart'; @@ -43,6 +44,7 @@ class MyApp extends StatelessWidget { '/oscilloscope': (context) => const OscilloscopeScreen(), '/connectDevice': (context) => const ConnectDeviceScreen(), '/faq': (context) => const FAQScreen(), + '/aboutUs': (context) => const AboutUsScreen(), }, ); } diff --git a/lib/view/about_us_screen.dart b/lib/view/about_us_screen.dart new file mode 100644 index 000000000..1086897fa --- /dev/null +++ b/lib/view/about_us_screen.dart @@ -0,0 +1,171 @@ +import 'package:flutter/material.dart'; +import 'package:pslab/constants.dart'; +import 'package:pslab/view/widgets/main_scaffold_widget.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +class AboutUsScreen extends StatefulWidget { + const AboutUsScreen({super.key}); + + @override + State createState() => _AboutUsScreenState(); +} + +Widget buildContactList(List> items) { + return ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: items.length, + separatorBuilder: (_, __) => const Divider(thickness: 0.5, height: 1), + itemBuilder: (context, index) { + final item = items[index]; + return ListTile( + leading: item['icon'] as Icon, + title: Text( + item['title'], + style: const TextStyle(fontSize: 15), + ), + onTap: () async { + final uri = Uri.parse(item['url']); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); + } else { + debugPrint('Could not launch ${item['url']}'); + } + }, + ); + }, + ); +} + +class _AboutUsScreenState extends State { + String get iconAboutUs => 'assets/images/logo.png'; + final List> contactItems = [ + { + 'icon': const Icon(Icons.mail), + 'title': connectWithUs[1], + 'url': 'mailto:$mail' + }, + {'icon': const Icon(Icons.link), 'title': connectWithUs[2], 'url': website}, + { + 'icon': const Icon(FontAwesomeIcons.github, size: 20), + 'title': connectWithUs[3], + 'url': github + }, + { + 'icon': const Icon(Icons.facebook_sharp), + 'title': connectWithUs[4], + 'url': facebook + }, + { + 'icon': const Icon(FontAwesomeIcons.xTwitter, size: 20), + 'title': connectWithUs[5], + 'url': x + }, + { + 'icon': const Icon(FontAwesomeIcons.youtube, size: 20), + 'title': connectWithUs[6], + 'url': youtube + }, + { + 'icon': const Icon(Icons.person), + 'title': connectWithUs[7], + 'url': developers + }, + ]; + + @override + Widget build(BuildContext context) { + return MainScaffold( + title: aboutUs, + index: 5, + body: SafeArea( + child: Center( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const SizedBox( + height: 30, + ), + Center( + child: Image.asset( + iconAboutUs, + width: 250, + height: 250, + ), + ), + Center( + child: Container( + margin: const EdgeInsets.all(20), + child: Text( + pslabDescription, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 15, + ), + ), + ), + ), + ListView( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + children: [ + ListTile( + leading: const Icon(Icons.link), + title: Text(feedbackNBugs, + style: const TextStyle( + fontSize: 15, + )), + onTap: () async { + await launchUrl(Uri.parse(feedbackForm)); + }, + ), + const Divider( + thickness: 0.5, + height: 1, + ), + ListTile( + leading: const Icon(Icons.widgets), + title: FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (BuildContext context, + AsyncSnapshot snapshot) { + if (snapshot.hasData) { + return Text( + snapshot.data!.version, + style: const TextStyle( + fontSize: 15, + ), + ); + } else { + return const Text( + 'Loading...', + style: TextStyle( + fontSize: 15, + ), + ); + } + }), + ) + ], + ), + Container( + margin: const EdgeInsets.only(left: 15, top: 10, bottom: 10), + alignment: Alignment.centerLeft, + child: Text( + connectWithUs[0], + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w300, + ), + ), + ), + buildContactList(contactItems) + ], + ), + ))), + ); + } +} diff --git a/lib/view/widgets/navigation_drawer.dart b/lib/view/widgets/navigation_drawer.dart index e58d17e3a..079fca8fd 100644 --- a/lib/view/widgets/navigation_drawer.dart +++ b/lib/view/widgets/navigation_drawer.dart @@ -191,7 +191,16 @@ class _NavDrawerState extends State { ), ), onTap: () { - /**/ + if (Navigator.canPop(context) && + ModalRoute.of(context)?.settings.name == '/aboutUs') { + Navigator.popUntil(context, ModalRoute.withName('/aboutUs')); + } else { + Navigator.pushNamedAndRemoveUntil( + context, + '/aboutUs', + (route) => route.isFirst, + ); + } }, ), ListTile( diff --git a/pubspec.yaml b/pubspec.yaml index 7eabd3641..32d2a1cb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,6 +52,9 @@ dependencies: permission_handler: ^11.3.1 logger: ^2.5.0 url_launcher: ^6.3.1 + font_awesome_flutter: ^10.8.0 + package_info_plus: ^8.3.0 + dev_dependencies: flutter_test: