From 2a99e56822a64696164fac20ddf4b8e692f2dbe3 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Thu, 24 Mar 2022 14:28:40 -0300 Subject: [PATCH] Tidy up #6 Adding header comments to the pages classes and removing unused imports. --- lib/pages/about_page.dart | 2 + lib/pages/ble_data_collection_page.dart | 1 + lib/pages/ble_devices_connection_page.dart | 10 +-- lib/pages/bluetooth_device_page.dart | 12 ++- lib/pages/data_visualization_page.dart | 85 +++++++++++----------- lib/pages/file_content_chart_page.dart | 6 +- lib/pages/file_manager_page.dart | 5 ++ lib/pages/home_page.dart | 3 +- lib/pages/interpretation_page.dart | 4 +- 9 files changed, 73 insertions(+), 55 deletions(-) diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dart index f32fbc5..3e891dc 100644 --- a/lib/pages/about_page.dart +++ b/lib/pages/about_page.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:lsa_gloves/navigation/navigation_drawer.dart'; +/// Page containing a brief description of the application and the project per +/// se, as well as contact information. class AboutPage extends StatefulWidget { const AboutPage({Key? key}) : super(key: key); diff --git a/lib/pages/ble_data_collection_page.dart b/lib/pages/ble_data_collection_page.dart index 4669a4c..3855e94 100644 --- a/lib/pages/ble_data_collection_page.dart +++ b/lib/pages/ble_data_collection_page.dart @@ -13,6 +13,7 @@ import 'package:provider/provider.dart'; import 'package:simple_timer/simple_timer.dart'; import 'dart:developer' as developer; +/// Page to run data collections. class BleDataCollectionPage extends StatefulWidget { const BleDataCollectionPage({Key? key}) : super(key: key); diff --git a/lib/pages/ble_devices_connection_page.dart b/lib/pages/ble_devices_connection_page.dart index 4912798..210116b 100644 --- a/lib/pages/ble_devices_connection_page.dart +++ b/lib/pages/ble_devices_connection_page.dart @@ -1,6 +1,3 @@ -import 'dart:async'; - -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_blue/flutter_blue.dart'; import 'package:lsa_gloves/connection/ble/bluetooth_backend.dart'; @@ -10,6 +7,7 @@ import 'package:provider/provider.dart'; import 'bluetooth_device_page.dart'; import 'dart:developer' as developer; +/// Page to let the user connect the app to one or more devices. class BleGloveConnectionPage extends StatelessWidget { static const routeName = '/bleGloveConnectionPage'; @@ -23,13 +21,13 @@ class BleGloveConnectionPage extends StatelessWidget { if (state == BluetoothState.on) { return FindDevicesScreen(); } - return BluetoothOffScreen(state: state); + return BluetoothDisabledWarningPage(state: state); }); } } -class BluetoothOffScreen extends StatelessWidget { - const BluetoothOffScreen({Key? key, this.state}) : super(key: key); +class BluetoothDisabledWarningPage extends StatelessWidget { + const BluetoothDisabledWarningPage({Key? key, this.state}) : super(key: key); final BluetoothState? state; diff --git a/lib/pages/bluetooth_device_page.dart b/lib/pages/bluetooth_device_page.dart index 5b85a74..5641748 100644 --- a/lib/pages/bluetooth_device_page.dart +++ b/lib/pages/bluetooth_device_page.dart @@ -5,8 +5,18 @@ import 'package:lsa_gloves/connection/ble/bluetooth_specification.dart'; import 'package:provider/provider.dart'; +/// Page to set the configuration of a glove. +/// +/// The user can either: +/// - connect the app to the device +/// - update the mtu to 512 bytes +/// - calibrate the glove. +/// +/// This page is accessible when clicking the configuration icon of a device +/// in the BluetoothDevicesConnectionPage. class BluetoothDevicePage extends StatefulWidget { - const BluetoothDevicePage({Key? key, required this.device, required this.isEnabled}) + const BluetoothDevicePage( + {Key? key, required this.device, required this.isEnabled}) : super(key: key); final BluetoothDevice device; final bool isEnabled; diff --git a/lib/pages/data_visualization_page.dart b/lib/pages/data_visualization_page.dart index a24d87a..96254a4 100644 --- a/lib/pages/data_visualization_page.dart +++ b/lib/pages/data_visualization_page.dart @@ -1,6 +1,3 @@ -import 'dart:async'; -import 'dart:collection'; - import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:lsa_gloves/connection/ble/bluetooth_backend.dart'; @@ -13,8 +10,14 @@ import 'package:lsa_gloves/model/vector3.dart'; import 'package:lsa_gloves/navigation/navigation_drawer.dart'; import 'package:provider/provider.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; -import 'dart:developer' as developer; +/// Page to plot real time sensors data. +/// +/// The user can select the sensor from which finger to be plotted. +/// +/// The received data is not recorded, the purpose of this page is to simply +/// provide the user with a debugging tool to assess if the received data +/// from the sensors makes sense. class DataVisualizationPage extends StatefulWidget { const DataVisualizationPage({Key? key}) : super(key: key); @@ -71,13 +74,11 @@ class _DataVisualizationPageState extends State { )) .toList()), Expanded( - child:MeasurementsChart( - key: Key("$_finger-$_sensor"), - measurementsCollector: _measurementsCollector, - finger: _finger, - sensor: _sensor) - ) - + child: MeasurementsChart( + key: Key("$_finger-$_sensor"), + measurementsCollector: _measurementsCollector, + finger: _finger, + sensor: _sensor)) ], )), floatingActionButton: FloatingActionButton( @@ -163,44 +164,42 @@ class _MeasurementsChartState extends State @override Widget build(BuildContext context) { return SfCartesianChart( - series: [ - LineSeries( - name: sensor.getXLabel(), - dataSource: _measurementsX, - xValueMapper: (SeriesEntry measurement, _) => measurement.x, - yValueMapper: (SeriesEntry measurement, _) => measurement.y, - onRendererCreated: (ChartSeriesController controller) { - _chartSeriesControllerX = controller; - }), - LineSeries( - name: sensor.getYLabel(), - dataSource: _measurementsY, - xValueMapper: (SeriesEntry measurement, _) => measurement.x, - yValueMapper: (SeriesEntry measurement, _) => measurement.y, - onRendererCreated: (ChartSeriesController controller) { - _chartSeriesControllerY = controller; - }), - LineSeries( - name: sensor.getZLabel(), - dataSource: _measurementsZ, - xValueMapper: (SeriesEntry measurement, _) => measurement.x, - yValueMapper: (SeriesEntry measurement, _) => measurement.y, - onRendererCreated: (ChartSeriesController controller) { - _chartSeriesControllerZ = controller; - }), - ], - legend: Legend(isVisible: true, position: LegendPosition.bottom), - primaryXAxis: NumericAxis( - numberFormat: NumberFormat("##,###s") - ) - ); + series: [ + LineSeries( + name: sensor.getXLabel(), + dataSource: _measurementsX, + xValueMapper: (SeriesEntry measurement, _) => measurement.x, + yValueMapper: (SeriesEntry measurement, _) => measurement.y, + onRendererCreated: (ChartSeriesController controller) { + _chartSeriesControllerX = controller; + }), + LineSeries( + name: sensor.getYLabel(), + dataSource: _measurementsY, + xValueMapper: (SeriesEntry measurement, _) => measurement.x, + yValueMapper: (SeriesEntry measurement, _) => measurement.y, + onRendererCreated: (ChartSeriesController controller) { + _chartSeriesControllerY = controller; + }), + LineSeries( + name: sensor.getZLabel(), + dataSource: _measurementsZ, + xValueMapper: (SeriesEntry measurement, _) => measurement.x, + yValueMapper: (SeriesEntry measurement, _) => measurement.y, + onRendererCreated: (ChartSeriesController controller) { + _chartSeriesControllerZ = controller; + }), + ], + legend: Legend(isVisible: true, position: LegendPosition.bottom), + primaryXAxis: NumericAxis(numberFormat: NumberFormat("##,###s"))); } @override void onMeasurement(GloveMeasurement measurement) { measurementsBuffer.add(measurement); lastTimestampMs += measurement.timestampMillis; - Vector3 sensorValues = measurement.getFinger(finger).getSensorValues(sensor); + Vector3 sensorValues = + measurement.getFinger(finger).getSensorValues(sensor); _measurementsX.add(SeriesEntry(lastTimestampMs, sensorValues.getX())); _measurementsY.add(SeriesEntry(lastTimestampMs, sensorValues.getY())); _measurementsZ.add(SeriesEntry(lastTimestampMs, sensorValues.getZ())); diff --git a/lib/pages/file_content_chart_page.dart b/lib/pages/file_content_chart_page.dart index 40d878f..9875c51 100644 --- a/lib/pages/file_content_chart_page.dart +++ b/lib/pages/file_content_chart_page.dart @@ -4,7 +4,6 @@ import 'package:lsa_gloves/connection/ble/bluetooth_backend.dart'; import 'package:lsa_gloves/datacollection/storage.dart'; import 'package:lsa_gloves/model/acceleration.dart'; import 'package:lsa_gloves/model/finger.dart'; -import 'package:lsa_gloves/model/glove_measurement.dart'; import 'package:lsa_gloves/model/gyro.dart'; import 'package:lsa_gloves/model/sensor_value.dart'; import 'package:lsa_gloves/model/vector3.dart'; @@ -12,6 +11,11 @@ import 'package:lsa_gloves/navigation/navigation_drawer.dart'; import 'package:provider/provider.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; +/// Page to plot the stored sensor values from a data collection. +/// +/// Two charts are displayed, one for the accelerometer and the other for the +/// gyroscope sensor. The user can select the finger associated with the sensor +/// they want to plot. class FileContentChartPage extends StatefulWidget { static const routeName = '/fileContentChart'; diff --git a/lib/pages/file_manager_page.dart b/lib/pages/file_manager_page.dart index 49bef06..1a450fc 100644 --- a/lib/pages/file_manager_page.dart +++ b/lib/pages/file_manager_page.dart @@ -7,6 +7,11 @@ import 'package:lsa_gloves/datacollection/storage.dart'; import 'file_content_chart_page.dart'; +/// Page to manage the stored files from data collections that haven't been yet +/// uploaded. +/// +/// This page displays the list of files, with its name, letting the user the +/// possibility to visualize the data and to upload or to delete the file. class FileManagerPage extends StatefulWidget { @override State createState() { diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 5802786..295e85b 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import '../navigation/navigation_drawer.dart'; @@ -9,6 +8,8 @@ import 'data_visualization_page.dart'; import 'file_manager_page.dart'; import 'interpretation_page.dart'; +/// Home page with navigation buttons to let the user access the multiple +/// pages of the application. class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); diff --git a/lib/pages/interpretation_page.dart b/lib/pages/interpretation_page.dart index a61593b..0dd04f7 100644 --- a/lib/pages/interpretation_page.dart +++ b/lib/pages/interpretation_page.dart @@ -1,8 +1,5 @@ -import 'dart:collection'; - import 'package:assets_audio_player/assets_audio_player.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_blue/flutter_blue.dart'; import 'package:lsa_gloves/connection/ble/bluetooth_backend.dart'; import 'package:lsa_gloves/navigation/navigation_drawer.dart'; @@ -11,6 +8,7 @@ import 'dart:developer' as developer; import 'package:provider/provider.dart'; +/// Page to display the interpretations from the glove. class InterpretationPage extends StatefulWidget { const InterpretationPage({Key? key}) : super(key: key);