Commit 86cf3c96 authored by Administrator's avatar Administrator

power and heart rate widget on activity level

parent 07deb0ad
......@@ -98,6 +98,12 @@ class Event {
return records.toList();
}
static Future<List<Event>> recordsByActivity({Activity activity}) async {
var events = await by(activity: activity);
var records = events.where((event) => event.db.event == "record");
return records.toList();
}
static Future<List<Event>> by({Activity activity}) async {
int counter = 1;
......
import 'package:encrateia/widgets/activity_metadata_widget.dart';
import 'package:encrateia/widgets/activity_overview_widget.dart';
import 'package:encrateia/widgets/laps_list_widget.dart';
import 'package:encrateia/widgets/activity_heart_rate_widget.dart';
import 'package:encrateia/widgets/activity_power_widget.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
......@@ -15,10 +17,11 @@ class ShowActivityScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
length: 5,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
isScrollable: true,
tabs: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
......@@ -27,6 +30,20 @@ class ShowActivityScreen extends StatelessWidget {
Text(" Overview"),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Tab(icon: Icon(Icons.spa)),
Text(" Heart Rate"),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Tab(icon: Icon(Icons.ev_station)),
Text(" Power"),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
......@@ -50,6 +67,8 @@ class ShowActivityScreen extends StatelessWidget {
),
body: TabBarView(children: [
ActivityOverviewWidget(activity: activity),
ActivityHeartRateWidget(activity: activity),
ActivityPowerWidget(activity: activity),
LapsListWidget(activity: activity),
ActivityMetadataWidget(activity: activity),
]),
......
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/models/lap.dart';
class ActivityHeartRateWidget extends StatelessWidget {
final Activity activity;
ActivityHeartRateWidget({this.activity});
@override
Widget build(context) {
return FutureBuilder<List<Event>>(
future: Event.recordsByActivity(activity: activity),
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
if (snapshot.hasData) {
var records = snapshot.data;
return ListTileTheme(
iconColor: Colors.lightGreen,
child: ListView(
padding: EdgeInsets.only(left: 25),
children: <Widget>[
ListTile(
leading: Icon(Icons.playlist_add),
title: Text(records.length.toString()),
subtitle: Text("number of measurements"),
),
ListTile(
leading: Icon(Icons.pets),
title: Text(Lap.averageHeartRate(records: records)),
subtitle: Text("average heart rate"),
),
ListTile(
leading: Icon(Icons.expand_less),
title: Text(Lap.minHeartRate(records: records)),
subtitle: Text("minimum heart rate"),
),
ListTile(
leading: Icon(Icons.expand_more),
title: Text(Lap.maxHeartRate(records: records)),
subtitle: Text("maximum heart rate"),
),
ListTile(
leading: Icon(Icons.unfold_more),
title: Text(Lap.sdevHeartRate(records: records)),
subtitle: Text("standard deviation heart rate"),
),
],
),
);
} else {
return Center(
child: Text("Loading"),
);
}
},
);
}
}
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
class ActivityPowerWidget extends StatelessWidget {
final Activity activity;
ActivityPowerWidget({this.activity});
@override
Widget build(context) {
return FutureBuilder<List<Event>>(
future: Event.recordsByActivity(activity: activity),
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
if (snapshot.hasData) {
var records = snapshot.data;
return ListTileTheme(
iconColor: Colors.lightGreen,
child: ListView(
padding: EdgeInsets.only(left: 25),
children: <Widget>[
ListTile(
leading: Icon(Icons.playlist_add),
title: Text(records.length.toString()),
subtitle: Text("number of measurements"),
),
ListTile(
leading: Icon(Icons.ev_station),
title: Text(Lap.averagePower(records: records) + " W"),
subtitle: Text("average power"),
),
ListTile(
leading: Icon(Icons.expand_less),
title: Text(Lap.minPower(records: records) + " W"),
subtitle: Text("minimum power"),
),
ListTile(
leading: Icon(Icons.expand_more),
title: Text(Lap.maxPower(records: records) + " W"),
subtitle: Text("maximum power"),
),
ListTile(
leading: Icon(Icons.unfold_more),
title: Text(Lap.sdevPower(records: records) + " W"),
subtitle: Text("standard deviation power"),
),
],
),
);
} else {
return Center(
child: Text("Loading"),
);
}
},
);
}
}
......@@ -25,7 +25,7 @@ class LapPowerWidget extends StatelessWidget {
subtitle: Text("number of measurements"),
),
ListTile(
leading: Icon(Icons.pets),
leading: Icon(Icons.ev_station),
title: Text(Lap.averagePower(records: records) + " W"),
subtitle: Text("average power"),
),
......
......@@ -84,7 +84,6 @@ class LapsListWidget extends StatelessWidget {
child: Text("Loading"),
);
}
;
},
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment