diff --git a/mobile/lib/src/presentation/pages/record_sleep/record_sleep_validate_page.dart b/mobile/lib/src/presentation/pages/record_sleep/record_sleep_validate_page.dart index d345d884..11be9e80 100644 --- a/mobile/lib/src/presentation/pages/record_sleep/record_sleep_validate_page.dart +++ b/mobile/lib/src/presentation/pages/record_sleep/record_sleep_validate_page.dart @@ -24,16 +24,19 @@ class RecordSleepValidatePage extends StatelessWidget { ]), ); else - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RaisedButton( - child: Text("Stop"), - onPressed: () => - BlocProvider.of(context).stopStreaming(), - ), - ]), + return ListView( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RaisedButton( + child: Text("Stop"), + onPressed: () => + BlocProvider.of(context).stopStreaming(), + ), + ]), + SimpleLineChart.withSampleData(), + ], ); }, ), diff --git a/mobile/lib/src/presentation/widgets/simple_line_chart.dart b/mobile/lib/src/presentation/widgets/simple_line_chart.dart new file mode 100644 index 00000000..6255c919 --- /dev/null +++ b/mobile/lib/src/presentation/widgets/simple_line_chart.dart @@ -0,0 +1,52 @@ +/// Example of a simple line chart. +import 'package:charts_flutter/flutter.dart' as charts; +import 'package:flutter/material.dart'; + +class SimpleLineChart extends StatelessWidget { + final List seriesList; + final bool animate; + + SimpleLineChart(this.seriesList, {this.animate}); + + /// Creates a [LineChart] with sample data and no transition. + factory SimpleLineChart.withSampleData() { + return new SimpleLineChart( + _createSampleData(), + // Disable animations for image tests. + animate: false, + ); + } + + @override + Widget build(BuildContext context) { + return new charts.LineChart(seriesList, animate: animate); + } + + /// Create one series with sample hard coded data. + static List> _createSampleData() { + final data = [ + new LinearSales(0, 5), + new LinearSales(1, 25), + new LinearSales(2, 100), + new LinearSales(3, 75), + ]; + + return [ + new charts.Series( + id: 'Sales', + colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, + domainFn: (LinearSales sales, _) => sales.year, + measureFn: (LinearSales sales, _) => sales.sales, + data: data, + ) + ]; + } +} + +/// Sample linear data type. +class LinearSales { + final int year; + final int sales; + + LinearSales(this.year, this.sales); +} diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index d270ba07..f5dd6a6a 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: share: ^0.6.5 uuid: ^2.2.2 usb_serial: ^0.2.4 + charts_flutter: dev_dependencies: flutter_test: