From 43a28bb48e12206d1f73f6824b55b6716515d2ef Mon Sep 17 00:00:00 2001 From: Yugesh-Kumar-S Date: Fri, 23 May 2025 00:16:01 +0530 Subject: [PATCH 1/5] Added FAQ page --- lib/main.dart | 3 +- lib/view/faq_screen.dart | 171 +++++++++++++++++++++++- lib/view/widgets/navigation_drawer.dart | 11 +- 3 files changed, 178 insertions(+), 7 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 2b1e007ee..ce43d6296 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,7 +9,6 @@ import 'package:pslab/view/oscilloscope_screen.dart'; import 'package:pslab/view/settings_screen.dart'; import 'package:pslab/view/about_us_screen.dart'; import 'package:pslab/view/software_licenses_screen.dart'; - import 'constants.dart'; void main() { @@ -45,7 +44,7 @@ class MyApp extends StatelessWidget { '/': (context) => const InstrumentsScreen(), '/oscilloscope': (context) => const OscilloscopeScreen(), '/connectDevice': (context) => const ConnectDeviceScreen(), - '/faq': (context) => const FAQScreen(), + '/faq': (context) => const FAQScreen(), '/settings': (context) => const SettingsScreen(), '/aboutUs': (context) => const AboutUsScreen(), '/softwareLicenses': (context) => const SoftwareLicensesScreen(), diff --git a/lib/view/faq_screen.dart b/lib/view/faq_screen.dart index dabf30b2c..93c0a502f 100644 --- a/lib/view/faq_screen.dart +++ b/lib/view/faq_screen.dart @@ -1,11 +1,174 @@ -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:pslab/colors.dart'; +import 'package:pslab/constants.dart'; +import 'package:pslab/view/widgets/main_scaffold_widget.dart'; +import 'package:url_launcher/url_launcher.dart'; class FAQScreen extends StatelessWidget { - const FAQScreen({super.key}); + static const List faqs = [ + FAQItem( + question: "What is Pocket Science Lab? What can I do with it?", + answer: "Pocket Science Lab (PSLab) is a small USB powered hardware board that can be used for measurements and experiments. It works as an extension for Android phones or PCs. PSLab comes with a built-in Oscilloscope, Multimeter, Wave Generator, Logic Analyzer, Power Source, and many more instruments. It can also be used as a robotics control app. And, we are constantly adding more digital instruments. PSLab is many devices in one. Simply connect two wires to the relevant pins (description is on the back of the PSLab board) and start measuring. You can use our Open Source Android or desktop app to view and collect the data. You can also plug in hundreds of compatible I²C standard sensors to the PSLab pin slots. It works without the need for programming. So, what experiments you do is just limited to your imagination!", + ), + FAQItem( + question: "Where can I buy a Pocket Science Lab?", + answer: "There is an overview page for shops where you can buy a Pocket Science Lab device in different regions on the website at ", + linkText: "https://pslab.io/shop/", + linkUrl: "https://pslab.io/shop/", + ), + FAQItem( + question: "Where can I download the Android App for Pocket Science Lab?", + answer: "The app can be downloaded from F-Droid or Play Store. Simply click on the links to be directed over!", + linkText: "Playstore", + linkUrl: "https://play.google.com/store/apps/details?id=io.pslab&hl=en_IN" + ), + FAQItem( + question: "Where can I download the desktop app for Pocket Science Lab for Windows, Linux and Mac?", + answer: "We are developing a desktop app for Windows, Linux and Mac in our desktop Git repository. You can find it in the install branch of the project here. The app is still under development. We are using technologies like Electron and Python, that work on all platforms. However, to make the final installer work everywhere requires some tweaks and improvements here and there. So, please expect some glitches. You can use the tracker in the repository to submit issues, bugs and feature requests.", + ), + FAQItem( + question: "How can I connect to the device? What kind of USB cable do I need? What is an OTG USB cable?", + answer: "To connect to the device you need an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. USB cables that are not OTG compatible will NOT work. It is also possible to extend the PSLab with an ESP WiFi chip or a Bluetooth chip and communicate through these gateways using the Android app. You can refer to the hardware developer documentation and code on GitHub for more details here.", + ), + FAQItem( + question: "I found a bug in one of your apps or hardware. What to do? Where should I report it?", + answer: "We have issue trackers in all our projects. They are currently hosted on GitHub. In order to submit a bug or feature request you need to login to the service.", + linkText: "A list of our PSLab repositories is here", + linkUrl: "https://github.com/fossasia" + ), + FAQItem( + question: "Can I record or save data in the apps and export or import it?", + answer: "Yes, we have implemented a record and play function or a way to save and open configurations in the instruments on the Android and desktop app. Data you record can be imported into the apps and viewed. This feature is still under heavy development, but works well in most places. You can find it in the top bar of the apps. There are buttons to record, play, save and open data.", + ), + FAQItem( + question: "My Android phone already has some sensors, can I use them with the PSLab app as well?", + answer: "Yes, absolutely. You can install the PSLab Android app (Play Store, Fdroid) on your phone and use it with devices such as Luxmeter or Compass. We are adding support for more built-in sensors step by step.", + ), + FAQItem( + question: "Which external sensors can I use with a PSLab device and the apps? Which ones are compatible?", + answer: "In our apps we use the industry standard I²C (Wikipedia). You can get the data from sensors that are connected to the device through the USB port using an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. For the transfer we use UART (universal asynchronous receiver-transmitter, Wikipedia). Many sensors can be used with specific instruments, e.g. Barometer, Thermometer, Gyroscope etc. You can access the configuration for sensors in the instrument settings on the top right burger menu of each instrument. All sensors using the I²C standard are compatible with the device. There are connection pins for analogue and digital sensors. You find the description of the pins on the back of the device. Even if there is no specific instrument in one of our apps yet, you can still view and store the raw data using the Oscilloscope instrument component. There is a page with a list of recommended sensors on the website.", + ), + ]; + + const FAQScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - // TODO: implement build - throw UnimplementedError(); + return MainScaffold( + title: 'FAQs', + index: 6, + body: ListView.separated( + padding: const EdgeInsets.symmetric(vertical: 8), + itemCount: faqs.length, + separatorBuilder: (context, index) => const Divider(height: 1), + itemBuilder: (context, index) => _buildFAQItem(faqs[index]), + ), + ); + } + + Widget _buildFAQItem(FAQItem faq) { + return Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), + child: ExpansionTile( + tilePadding: EdgeInsets.zero, + shape: Border(), + collapsedShape: Border(), + title: Padding( + padding: const EdgeInsets.only(bottom: 0), + child: Row( + + children: [ + Text('Q:', + style: TextStyle( + color: primaryRed, + ), + ), + SizedBox(width: 10,), + Flexible( + child: Text( + '${faq.question}', + style: TextStyle( + color: primaryRed, + + ), + ), + ), + ] + + ), + ), + childrenPadding: const EdgeInsets.fromLTRB(5, 0, 16, 16), + expandedCrossAxisAlignment: CrossAxisAlignment.start, + trailing: const SizedBox(), + children: [ + Padding( + + padding: const EdgeInsets.only(top: 0), // Space before answer + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('A:', + style: TextStyle( + color: Colors.black, + ), + ), + SizedBox(width: 10,), + Flexible( + child: Text( + '${faq.answer}', + style: TextStyle( + color: Colors.black, + + ), + ), + ), + ] + + ), + ), + if (faq.linkText != null && faq.linkUrl != null) + Padding( + padding: const EdgeInsets.only(top: 8), + child: GestureDetector( + onTap: () => _launchURL(faq.linkUrl!), + child: Row( + children: [ + SizedBox(width: 25,), + Text( + faq.linkText!, + style: TextStyle( + color: primaryRed, + decoration: TextDecoration.underline, + ), + ), + ], + ), + ), + ), + ], + ), + ); + } + + Future _launchURL(String url) async { + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } } } + +class FAQItem { + final String question; + final String answer; + final String? linkText; + final String? linkUrl; + + const FAQItem({ + required this.question, + required this.answer, + this.linkText, + this.linkUrl, + }); +} \ No newline at end of file diff --git a/lib/view/widgets/navigation_drawer.dart b/lib/view/widgets/navigation_drawer.dart index ec6ded2ba..890c971f5 100644 --- a/lib/view/widgets/navigation_drawer.dart +++ b/lib/view/widgets/navigation_drawer.dart @@ -286,7 +286,16 @@ class _NavDrawerState extends State { ), ), onTap: () { - /**/ + if (Navigator.canPop(context) && + ModalRoute.of(context)?.settings.name == '/faq') { + Navigator.popUntil(context, ModalRoute.withName('/faq')); + } else { + Navigator.pushNamedAndRemoveUntil( + context, + '/faq', + (route) => route.isFirst, + ); + } }, ), ListTile( From 70f821deee5a589b590db6ae607e1449b8f6df21 Mon Sep 17 00:00:00 2001 From: Yugesh-Kumar-S Date: Fri, 23 May 2025 12:35:14 +0530 Subject: [PATCH 2/5] Fix code formatting issues --- lib/main.dart | 2 +- lib/view/faq_screen.dart | 154 +++++++++++++----------- lib/view/widgets/navigation_drawer.dart | 2 +- 3 files changed, 85 insertions(+), 73 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index ce43d6296..c5df876ef 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -44,7 +44,7 @@ class MyApp extends StatelessWidget { '/': (context) => const InstrumentsScreen(), '/oscilloscope': (context) => const OscilloscopeScreen(), '/connectDevice': (context) => const ConnectDeviceScreen(), - '/faq': (context) => const FAQScreen(), + '/faq': (context) => const FAQScreen(), '/settings': (context) => const SettingsScreen(), '/aboutUs': (context) => const AboutUsScreen(), '/softwareLicenses': (context) => const SoftwareLicensesScreen(), diff --git a/lib/view/faq_screen.dart b/lib/view/faq_screen.dart index 93c0a502f..c15bcc794 100644 --- a/lib/view/faq_screen.dart +++ b/lib/view/faq_screen.dart @@ -6,47 +6,62 @@ import 'package:url_launcher/url_launcher.dart'; class FAQScreen extends StatelessWidget { static const List faqs = [ - FAQItem( + FAQItem( question: "What is Pocket Science Lab? What can I do with it?", - answer: "Pocket Science Lab (PSLab) is a small USB powered hardware board that can be used for measurements and experiments. It works as an extension for Android phones or PCs. PSLab comes with a built-in Oscilloscope, Multimeter, Wave Generator, Logic Analyzer, Power Source, and many more instruments. It can also be used as a robotics control app. And, we are constantly adding more digital instruments. PSLab is many devices in one. Simply connect two wires to the relevant pins (description is on the back of the PSLab board) and start measuring. You can use our Open Source Android or desktop app to view and collect the data. You can also plug in hundreds of compatible I²C standard sensors to the PSLab pin slots. It works without the need for programming. So, what experiments you do is just limited to your imagination!", + answer: + "Pocket Science Lab (PSLab) is a small USB powered hardware board that can be used for measurements and experiments. It works as an extension for Android phones or PCs. PSLab comes with a built-in Oscilloscope, Multimeter, Wave Generator, Logic Analyzer, Power Source, and many more instruments. It can also be used as a robotics control app. And, we are constantly adding more digital instruments. PSLab is many devices in one. Simply connect two wires to the relevant pins (description is on the back of the PSLab board) and start measuring. You can use our Open Source Android or desktop app to view and collect the data. You can also plug in hundreds of compatible I²C standard sensors to the PSLab pin slots. It works without the need for programming. So, what experiments you do is just limited to your imagination!", ), - FAQItem( + FAQItem( question: "Where can I buy a Pocket Science Lab?", - answer: "There is an overview page for shops where you can buy a Pocket Science Lab device in different regions on the website at ", + answer: + "There is an overview page for shops where you can buy a Pocket Science Lab device in different regions on the website at ", linkText: "https://pslab.io/shop/", linkUrl: "https://pslab.io/shop/", ), - FAQItem( - question: "Where can I download the Android App for Pocket Science Lab?", - answer: "The app can be downloaded from F-Droid or Play Store. Simply click on the links to be directed over!", - linkText: "Playstore", - linkUrl: "https://play.google.com/store/apps/details?id=io.pslab&hl=en_IN" + FAQItem( + question: + "Where can I download the Android App for Pocket Science Lab?", + answer: + "The app can be downloaded from F-Droid or Play Store. Simply click on the links to be directed over!", + linkText: "Playstore", + linkUrl: + "https://play.google.com/store/apps/details?id=io.pslab&hl=en_IN"), + FAQItem( + question: + "Where can I download the desktop app for Pocket Science Lab for Windows, Linux and Mac?", + answer: + "We are developing a desktop app for Windows, Linux and Mac in our desktop Git repository. You can find it in the install branch of the project here. The app is still under development. We are using technologies like Electron and Python, that work on all platforms. However, to make the final installer work everywhere requires some tweaks and improvements here and there. So, please expect some glitches. You can use the tracker in the repository to submit issues, bugs and feature requests.", ), - FAQItem( - question: "Where can I download the desktop app for Pocket Science Lab for Windows, Linux and Mac?", - answer: "We are developing a desktop app for Windows, Linux and Mac in our desktop Git repository. You can find it in the install branch of the project here. The app is still under development. We are using technologies like Electron and Python, that work on all platforms. However, to make the final installer work everywhere requires some tweaks and improvements here and there. So, please expect some glitches. You can use the tracker in the repository to submit issues, bugs and feature requests.", + FAQItem( + question: + "How can I connect to the device? What kind of USB cable do I need? What is an OTG USB cable?", + answer: + "To connect to the device you need an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. USB cables that are not OTG compatible will NOT work. It is also possible to extend the PSLab with an ESP WiFi chip or a Bluetooth chip and communicate through these gateways using the Android app. You can refer to the hardware developer documentation and code on GitHub for more details here.", ), - FAQItem( - question: "How can I connect to the device? What kind of USB cable do I need? What is an OTG USB cable?", - answer: "To connect to the device you need an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. USB cables that are not OTG compatible will NOT work. It is also possible to extend the PSLab with an ESP WiFi chip or a Bluetooth chip and communicate through these gateways using the Android app. You can refer to the hardware developer documentation and code on GitHub for more details here.", + FAQItem( + question: + "I found a bug in one of your apps or hardware. What to do? Where should I report it?", + answer: + "We have issue trackers in all our projects. They are currently hosted on GitHub. In order to submit a bug or feature request you need to login to the service.", + linkText: "A list of our PSLab repositories is here", + linkUrl: "https://github.com/fossasia"), + FAQItem( + question: + "Can I record or save data in the apps and export or import it?", + answer: + "Yes, we have implemented a record and play function or a way to save and open configurations in the instruments on the Android and desktop app. Data you record can be imported into the apps and viewed. This feature is still under heavy development, but works well in most places. You can find it in the top bar of the apps. There are buttons to record, play, save and open data.", ), - FAQItem( - question: "I found a bug in one of your apps or hardware. What to do? Where should I report it?", - answer: "We have issue trackers in all our projects. They are currently hosted on GitHub. In order to submit a bug or feature request you need to login to the service.", - linkText: "A list of our PSLab repositories is here", - linkUrl: "https://github.com/fossasia" + FAQItem( + question: + "My Android phone already has some sensors, can I use them with the PSLab app as well?", + answer: + "Yes, absolutely. You can install the PSLab Android app (Play Store, Fdroid) on your phone and use it with devices such as Luxmeter or Compass. We are adding support for more built-in sensors step by step.", ), - FAQItem( - question: "Can I record or save data in the apps and export or import it?", - answer: "Yes, we have implemented a record and play function or a way to save and open configurations in the instruments on the Android and desktop app. Data you record can be imported into the apps and viewed. This feature is still under heavy development, but works well in most places. You can find it in the top bar of the apps. There are buttons to record, play, save and open data.", - ), - FAQItem( - question: "My Android phone already has some sensors, can I use them with the PSLab app as well?", - answer: "Yes, absolutely. You can install the PSLab Android app (Play Store, Fdroid) on your phone and use it with devices such as Luxmeter or Compass. We are adding support for more built-in sensors step by step.", - ), - FAQItem( - question: "Which external sensors can I use with a PSLab device and the apps? Which ones are compatible?", - answer: "In our apps we use the industry standard I²C (Wikipedia). You can get the data from sensors that are connected to the device through the USB port using an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. For the transfer we use UART (universal asynchronous receiver-transmitter, Wikipedia). Many sensors can be used with specific instruments, e.g. Barometer, Thermometer, Gyroscope etc. You can access the configuration for sensors in the instrument settings on the top right burger menu of each instrument. All sensors using the I²C standard are compatible with the device. There are connection pins for analogue and digital sensors. You find the description of the pins on the back of the device. Even if there is no specific instrument in one of our apps yet, you can still view and store the raw data using the Oscilloscope instrument component. There is a page with a list of recommended sensors on the website.", + FAQItem( + question: + "Which external sensors can I use with a PSLab device and the apps? Which ones are compatible?", + answer: + "In our apps we use the industry standard I²C (Wikipedia). You can get the data from sensors that are connected to the device through the USB port using an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. For the transfer we use UART (universal asynchronous receiver-transmitter, Wikipedia). Many sensors can be used with specific instruments, e.g. Barometer, Thermometer, Gyroscope etc. You can access the configuration for sensors in the instrument settings on the top right burger menu of each instrument. All sensors using the I²C standard are compatible with the device. There are connection pins for analogue and digital sensors. You find the description of the pins on the back of the device. Even if there is no specific instrument in one of our apps yet, you can still view and store the raw data using the Oscilloscope instrument component. There is a page with a list of recommended sensors on the website.", ), ]; @@ -75,56 +90,51 @@ class FAQScreen extends StatelessWidget { collapsedShape: Border(), title: Padding( padding: const EdgeInsets.only(bottom: 0), - child: Row( - - children: [ - Text('Q:', + child: Row(children: [ + Text( + 'Q:', + style: TextStyle( + color: primaryRed, + ), + ), + SizedBox( + width: 10, + ), + Flexible( + child: Text( + '${faq.question}', style: TextStyle( color: primaryRed, ), ), - SizedBox(width: 10,), - Flexible( - child: Text( - '${faq.question}', - style: TextStyle( - color: primaryRed, - - ), - ), - ), - ] - - ), + ), + ]), ), childrenPadding: const EdgeInsets.fromLTRB(5, 0, 16, 16), expandedCrossAxisAlignment: CrossAxisAlignment.start, trailing: const SizedBox(), children: [ Padding( - padding: const EdgeInsets.only(top: 0), // Space before answer - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('A:', - style: TextStyle( - color: Colors.black, - ), - ), - SizedBox(width: 10,), - Flexible( - child: Text( - '${faq.answer}', - style: TextStyle( - color: Colors.black, - - ), - ), + child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + 'A:', + style: TextStyle( + color: Colors.black, + ), + ), + SizedBox( + width: 10, + ), + Flexible( + child: Text( + '${faq.answer}', + style: TextStyle( + color: Colors.black, ), - ] - - ), + ), + ), + ]), ), if (faq.linkText != null && faq.linkUrl != null) Padding( @@ -133,7 +143,9 @@ class FAQScreen extends StatelessWidget { onTap: () => _launchURL(faq.linkUrl!), child: Row( children: [ - SizedBox(width: 25,), + SizedBox( + width: 25, + ), Text( faq.linkText!, style: TextStyle( @@ -171,4 +183,4 @@ class FAQItem { this.linkText, this.linkUrl, }); -} \ No newline at end of file +} diff --git a/lib/view/widgets/navigation_drawer.dart b/lib/view/widgets/navigation_drawer.dart index 890c971f5..8ee8d57ff 100644 --- a/lib/view/widgets/navigation_drawer.dart +++ b/lib/view/widgets/navigation_drawer.dart @@ -293,7 +293,7 @@ class _NavDrawerState extends State { Navigator.pushNamedAndRemoveUntil( context, '/faq', - (route) => route.isFirst, + (route) => route.isFirst, ); } }, From a711679ceea8b476edb4758c13660309082c2b7c Mon Sep 17 00:00:00 2001 From: Yugesh-Kumar-S Date: Fri, 23 May 2025 12:52:59 +0530 Subject: [PATCH 3/5] fixed _launchURL method --- lib/view/faq_screen.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/view/faq_screen.dart b/lib/view/faq_screen.dart index c15bcc794..e035284df 100644 --- a/lib/view/faq_screen.dart +++ b/lib/view/faq_screen.dart @@ -163,8 +163,9 @@ class FAQScreen extends StatelessWidget { } Future _launchURL(String url) async { - if (await canLaunch(url)) { - await launch(url); + final Uri uri = Uri.parse(url); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); } else { throw 'Could not launch $url'; } From bdf294d43900676d979648fc8ce05563a009363e Mon Sep 17 00:00:00 2001 From: Yugesh-Kumar-S Date: Sun, 25 May 2025 18:13:22 +0530 Subject: [PATCH 4/5] changes to constructor --- lib/view/faq_screen.dart | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/view/faq_screen.dart b/lib/view/faq_screen.dart index e035284df..017ad7f29 100644 --- a/lib/view/faq_screen.dart +++ b/lib/view/faq_screen.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:pslab/colors.dart'; -import 'package:pslab/constants.dart'; import 'package:pslab/view/widgets/main_scaffold_widget.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -65,7 +64,7 @@ class FAQScreen extends StatelessWidget { ), ]; - const FAQScreen({Key? key}) : super(key: key); + const FAQScreen({super.key}); @override Widget build(BuildContext context) { @@ -86,8 +85,8 @@ class FAQScreen extends StatelessWidget { padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), child: ExpansionTile( tilePadding: EdgeInsets.zero, - shape: Border(), - collapsedShape: Border(), + shape: const Border(), + collapsedShape: const Border(), title: Padding( padding: const EdgeInsets.only(bottom: 0), child: Row(children: [ @@ -97,12 +96,12 @@ class FAQScreen extends StatelessWidget { color: primaryRed, ), ), - SizedBox( + const SizedBox( width: 10, ), Flexible( child: Text( - '${faq.question}', + faq.question, style: TextStyle( color: primaryRed, ), @@ -117,19 +116,19 @@ class FAQScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 0), // Space before answer child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( + const Text( 'A:', style: TextStyle( color: Colors.black, ), ), - SizedBox( + const SizedBox( width: 10, ), Flexible( child: Text( - '${faq.answer}', - style: TextStyle( + faq.answer, + style: const TextStyle( color: Colors.black, ), ), @@ -143,7 +142,7 @@ class FAQScreen extends StatelessWidget { onTap: () => _launchURL(faq.linkUrl!), child: Row( children: [ - SizedBox( + const SizedBox( width: 25, ), Text( From ec4fa23c4964bf614d823f4b75b19fc7792d0380 Mon Sep 17 00:00:00 2001 From: Yugesh-Kumar-S Date: Sat, 31 May 2025 14:04:33 +0530 Subject: [PATCH 5/5] Removed hardcoded strings --- lib/constants.dart | 59 +++++++++++++++++++++++++++++ lib/view/faq_screen.dart | 81 ++++++++++++++++------------------------ 2 files changed, 92 insertions(+), 48 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index cca96fde6..f66fe477c 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -133,3 +133,62 @@ List connectWithUs = [ 'Developers' ]; String softwareLicenses = 'Software Licenses'; +String faqTitle = 'FAQs'; +String launchError = 'Could not launch'; +String Q = 'Q:'; +String A = 'A:'; + +class FAQConstants { + static const String whatIsPslab = + "What is Pocket Science Lab? What can I do with it?"; + static const String whereToBuy = "Where can I buy a Pocket Science Lab?"; + static const String downloadAndroidApp = + "Where can I download the Android App for Pocket Science Lab?"; + static const String downloadDesktopApp = + "Where can I download the desktop app for Pocket Science Lab for Windows, Linux and Mac?"; + static const String howToConnect = + "How can I connect to the device? What kind of USB cable do I need? What is an OTG USB cable?"; + static const String reportBug = + "I found a bug in one of your apps or hardware. What to do? Where should I report it?"; + static const String recordData = + "Can I record or save data in the apps and export or import it?"; + static const String usePhoneSensors = + "My Android phone already has some sensors, can I use them with the PSLab app as well?"; + static const String compatibleSensors = + "Which external sensors can I use with a PSLab device and the apps? Which ones are compatible?"; + + static const String whatIsPslabAnswer = + "Pocket Science Lab (PSLab) is a small USB powered hardware board that can be used for measurements and experiments. It works as an extension for Android phones or PCs. PSLab comes with a built-in Oscilloscope, Multimeter, Wave Generator, Logic Analyzer, Power Source, and many more instruments. It can also be used as a robotics control app. And, we are constantly adding more digital instruments. PSLab is many devices in one. Simply connect two wires to the relevant pins (description is on the back of the PSLab board) and start measuring. You can use our Open Source Android or desktop app to view and collect the data. You can also plug in hundreds of compatible I²C standard sensors to the PSLab pin slots. It works without the need for programming. So, what experiments you do is just limited to your imagination!"; + + static const String whereToBuyAnswer = + "There is an overview page for shops where you can buy a Pocket Science Lab device in different regions on the website at "; + static const String whereToBuyLinkText = "https://pslab.io/shop/"; + static const String whereToBuyLinkUrl = "https://pslab.io/shop/"; + + static const String downloadAndroidAppAnswer = + "The app can be downloaded from F-Droid or Play Store. Simply click on the links to be directed over!"; + static const String downloadAndroidAppLinkText = "Playstore"; + static const String downloadAndroidAppLinkUrl = + "https://play.google.com/store/apps/details?id=io.pslab&hl=en_IN"; + + static const String downloadDesktopAppAnswer = + "We are developing a desktop app for Windows, Linux and Mac in our desktop Git repository. You can find it in the install branch of the project here. The app is still under development. We are using technologies like Electron and Python, that work on all platforms. However, to make the final installer work everywhere requires some tweaks and improvements here and there. So, please expect some glitches. You can use the tracker in the repository to submit issues, bugs and feature requests."; + + static const String howToConnectAnswer = + "To connect to the device you need an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. USB cables that are not OTG compatible will NOT work. It is also possible to extend the PSLab with an ESP WiFi chip or a Bluetooth chip and communicate through these gateways using the Android app. You can refer to the hardware developer documentation and code on GitHub for more details here."; + + static const String reportBugAnswer = + "We have issue trackers in all our projects. They are currently hosted on GitHub. In order to submit a bug or feature request you need to login to the service."; + static const String reportBugLinkText = + "A list of our PSLab repositories is here"; + static const String reportBugLinkUrl = "https://github.com/fossasia"; + + static const String recordDataAnswer = + "Yes, we have implemented a record and play function or a way to save and open configurations in the instruments on the Android and desktop app. Data you record can be imported into the apps and viewed. This feature is still under heavy development, but works well in most places. You can find it in the top bar of the apps. There are buttons to record, play, save and open data."; + + static const String usePhoneSensorsAnswer = + "Yes, absolutely. You can install the PSLab Android app (Play Store, Fdroid) on your phone and use it with devices such as Luxmeter or Compass. We are adding support for more built-in sensors step by step."; + + static const String compatibleSensorsAnswer = + "In our apps we use the industry standard I²C (Wikipedia). You can get the data from sensors that are connected to the device through the USB port using an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. For the transfer we use UART (universal asynchronous receiver-transmitter, Wikipedia). Many sensors can be used with specific instruments, e.g. Barometer, Thermometer, Gyroscope etc. You can access the configuration for sensors in the instrument settings on the top right burger menu of each instrument. All sensors using the I²C standard are compatible with the device. There are connection pins for analogue and digital sensors. You find the description of the pins on the back of the device. Even if there is no specific instrument in one of our apps yet, you can still view and store the raw data using the Oscilloscope instrument component. There is a page with a list of recommended sensors on the website."; +} diff --git a/lib/view/faq_screen.dart b/lib/view/faq_screen.dart index 017ad7f29..c94958f43 100644 --- a/lib/view/faq_screen.dart +++ b/lib/view/faq_screen.dart @@ -2,65 +2,50 @@ import 'package:flutter/material.dart'; import 'package:pslab/colors.dart'; import 'package:pslab/view/widgets/main_scaffold_widget.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:pslab/constants.dart'; class FAQScreen extends StatelessWidget { static const List faqs = [ FAQItem( - question: "What is Pocket Science Lab? What can I do with it?", - answer: - "Pocket Science Lab (PSLab) is a small USB powered hardware board that can be used for measurements and experiments. It works as an extension for Android phones or PCs. PSLab comes with a built-in Oscilloscope, Multimeter, Wave Generator, Logic Analyzer, Power Source, and many more instruments. It can also be used as a robotics control app. And, we are constantly adding more digital instruments. PSLab is many devices in one. Simply connect two wires to the relevant pins (description is on the back of the PSLab board) and start measuring. You can use our Open Source Android or desktop app to view and collect the data. You can also plug in hundreds of compatible I²C standard sensors to the PSLab pin slots. It works without the need for programming. So, what experiments you do is just limited to your imagination!", + question: FAQConstants.whatIsPslab, + answer: FAQConstants.whatIsPslabAnswer, ), FAQItem( - question: "Where can I buy a Pocket Science Lab?", - answer: - "There is an overview page for shops where you can buy a Pocket Science Lab device in different regions on the website at ", - linkText: "https://pslab.io/shop/", - linkUrl: "https://pslab.io/shop/", + question: FAQConstants.whereToBuy, + answer: FAQConstants.whereToBuyAnswer, + linkText: FAQConstants.whereToBuyLinkText, + linkUrl: FAQConstants.whereToBuyLinkUrl, ), FAQItem( - question: - "Where can I download the Android App for Pocket Science Lab?", - answer: - "The app can be downloaded from F-Droid or Play Store. Simply click on the links to be directed over!", - linkText: "Playstore", - linkUrl: - "https://play.google.com/store/apps/details?id=io.pslab&hl=en_IN"), + question: FAQConstants.downloadAndroidApp, + answer: FAQConstants.downloadAndroidAppAnswer, + linkText: FAQConstants.downloadAndroidAppLinkText, + linkUrl: FAQConstants.downloadAndroidAppLinkUrl, + ), FAQItem( - question: - "Where can I download the desktop app for Pocket Science Lab for Windows, Linux and Mac?", - answer: - "We are developing a desktop app for Windows, Linux and Mac in our desktop Git repository. You can find it in the install branch of the project here. The app is still under development. We are using technologies like Electron and Python, that work on all platforms. However, to make the final installer work everywhere requires some tweaks and improvements here and there. So, please expect some glitches. You can use the tracker in the repository to submit issues, bugs and feature requests.", + question: FAQConstants.downloadDesktopApp, + answer: FAQConstants.downloadDesktopAppAnswer, ), FAQItem( - question: - "How can I connect to the device? What kind of USB cable do I need? What is an OTG USB cable?", - answer: - "To connect to the device you need an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. USB cables that are not OTG compatible will NOT work. It is also possible to extend the PSLab with an ESP WiFi chip or a Bluetooth chip and communicate through these gateways using the Android app. You can refer to the hardware developer documentation and code on GitHub for more details here.", + question: FAQConstants.howToConnect, + answer: FAQConstants.howToConnectAnswer, ), FAQItem( - question: - "I found a bug in one of your apps or hardware. What to do? Where should I report it?", - answer: - "We have issue trackers in all our projects. They are currently hosted on GitHub. In order to submit a bug or feature request you need to login to the service.", - linkText: "A list of our PSLab repositories is here", - linkUrl: "https://github.com/fossasia"), + question: FAQConstants.reportBug, + answer: FAQConstants.reportBugAnswer, + linkText: FAQConstants.reportBugLinkText, + linkUrl: FAQConstants.reportBugLinkUrl), FAQItem( - question: - "Can I record or save data in the apps and export or import it?", - answer: - "Yes, we have implemented a record and play function or a way to save and open configurations in the instruments on the Android and desktop app. Data you record can be imported into the apps and viewed. This feature is still under heavy development, but works well in most places. You can find it in the top bar of the apps. There are buttons to record, play, save and open data.", + question: FAQConstants.recordData, + answer: FAQConstants.recordDataAnswer, ), FAQItem( - question: - "My Android phone already has some sensors, can I use them with the PSLab app as well?", - answer: - "Yes, absolutely. You can install the PSLab Android app (Play Store, Fdroid) on your phone and use it with devices such as Luxmeter or Compass. We are adding support for more built-in sensors step by step.", + question: FAQConstants.usePhoneSensors, + answer: FAQConstants.usePhoneSensorsAnswer, ), FAQItem( - question: - "Which external sensors can I use with a PSLab device and the apps? Which ones are compatible?", - answer: - "In our apps we use the industry standard I²C (Wikipedia). You can get the data from sensors that are connected to the device through the USB port using an OTG USB cable (OTG = On the go) which is a USB cable that allows connected devices to switch back and forth between the roles of host and device. For the transfer we use UART (universal asynchronous receiver-transmitter, Wikipedia). Many sensors can be used with specific instruments, e.g. Barometer, Thermometer, Gyroscope etc. You can access the configuration for sensors in the instrument settings on the top right burger menu of each instrument. All sensors using the I²C standard are compatible with the device. There are connection pins for analogue and digital sensors. You find the description of the pins on the back of the device. Even if there is no specific instrument in one of our apps yet, you can still view and store the raw data using the Oscilloscope instrument component. There is a page with a list of recommended sensors on the website.", + question: FAQConstants.compatibleSensors, + answer: FAQConstants.compatibleSensorsAnswer, ), ]; @@ -69,7 +54,7 @@ class FAQScreen extends StatelessWidget { @override Widget build(BuildContext context) { return MainScaffold( - title: 'FAQs', + title: faqTitle, index: 6, body: ListView.separated( padding: const EdgeInsets.symmetric(vertical: 8), @@ -91,7 +76,7 @@ class FAQScreen extends StatelessWidget { padding: const EdgeInsets.only(bottom: 0), child: Row(children: [ Text( - 'Q:', + Q, style: TextStyle( color: primaryRed, ), @@ -114,11 +99,11 @@ class FAQScreen extends StatelessWidget { trailing: const SizedBox(), children: [ Padding( - padding: const EdgeInsets.only(top: 0), // Space before answer + padding: const EdgeInsets.only(top: 0), child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - 'A:', - style: TextStyle( + Text( + A, + style: const TextStyle( color: Colors.black, ), ), @@ -166,7 +151,7 @@ class FAQScreen extends StatelessWidget { if (await canLaunchUrl(uri)) { await launchUrl(uri); } else { - throw 'Could not launch $url'; + throw '$launchError $url'; } } }