Skip to content

Commit

Permalink
Tidy up #6
Browse files Browse the repository at this point in the history
Adding header comments to the pages classes and removing unused imports.
  • Loading branch information
DariusIMP committed Mar 24, 2022
1 parent 2414371 commit 2a99e56
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 55 deletions.
2 changes: 2 additions & 0 deletions lib/pages/about_page.dart
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
1 change: 1 addition & 0 deletions lib/pages/ble_data_collection_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 4 additions & 6 deletions lib/pages/ble_devices_connection_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand All @@ -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;

Expand Down
12 changes: 11 additions & 1 deletion lib/pages/bluetooth_device_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
85 changes: 42 additions & 43 deletions lib/pages/data_visualization_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);

Expand Down Expand Up @@ -71,13 +74,11 @@ class _DataVisualizationPageState extends State<DataVisualizationPage> {
))
.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(
Expand Down Expand Up @@ -163,44 +164,42 @@ class _MeasurementsChartState extends State<MeasurementsChart>
@override
Widget build(BuildContext context) {
return SfCartesianChart(
series: <ChartSeries>[
LineSeries<SeriesEntry, double>(
name: sensor.getXLabel(),
dataSource: _measurementsX,
xValueMapper: (SeriesEntry measurement, _) => measurement.x,
yValueMapper: (SeriesEntry measurement, _) => measurement.y,
onRendererCreated: (ChartSeriesController controller) {
_chartSeriesControllerX = controller;
}),
LineSeries<SeriesEntry, double>(
name: sensor.getYLabel(),
dataSource: _measurementsY,
xValueMapper: (SeriesEntry measurement, _) => measurement.x,
yValueMapper: (SeriesEntry measurement, _) => measurement.y,
onRendererCreated: (ChartSeriesController controller) {
_chartSeriesControllerY = controller;
}),
LineSeries<SeriesEntry, double>(
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: <ChartSeries>[
LineSeries<SeriesEntry, double>(
name: sensor.getXLabel(),
dataSource: _measurementsX,
xValueMapper: (SeriesEntry measurement, _) => measurement.x,
yValueMapper: (SeriesEntry measurement, _) => measurement.y,
onRendererCreated: (ChartSeriesController controller) {
_chartSeriesControllerX = controller;
}),
LineSeries<SeriesEntry, double>(
name: sensor.getYLabel(),
dataSource: _measurementsY,
xValueMapper: (SeriesEntry measurement, _) => measurement.x,
yValueMapper: (SeriesEntry measurement, _) => measurement.y,
onRendererCreated: (ChartSeriesController controller) {
_chartSeriesControllerY = controller;
}),
LineSeries<SeriesEntry, double>(
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()));
Expand Down
6 changes: 5 additions & 1 deletion lib/pages/file_content_chart_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ 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';
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';

Expand Down
5 changes: 5 additions & 0 deletions lib/pages/file_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<StatefulWidget> createState() {
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);

Expand Down
4 changes: 1 addition & 3 deletions lib/pages/interpretation_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);

Expand Down

0 comments on commit 2a99e56

Please sign in to comment.