Commit 72b98c48 authored by Stefan Haslinger's avatar Stefan Haslinger

heart rate on athlete level

parent cc10dea9
......@@ -164,6 +164,8 @@ class Activity {
return 10000 / 6 * avgSpeed / avgStrydCadence / avgVerticalOscillation;
case ActivityAttr.avgPace:
return 50 / 3 / avgSpeed;
case ActivityAttr.avgHeartRate:
return avgHeartRate.toDouble();
}
}
......
......@@ -2,6 +2,7 @@ import 'package:encrateia/actions/analyse_activities.dart';
import 'package:encrateia/actions/import_activities_locally.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:encrateia/widgets/activities_list_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_heart_rate_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_pace_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_power_ratio_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_power_zone_schema_widget.dart';
......@@ -84,6 +85,12 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
icon: MyIcon.speed,
nextWidget: AthletePaceWidget(athlete: widget.athlete),
),
navigationButton(
color: MyColor.navigate,
title: 'Heart Rate',
icon: MyIcon.heartRate,
nextWidget: AthleteHeartRateWidget(athlete: widget.athlete),
),
navigationButton(
color: MyColor.navigate,
title: 'Ecor',
......
......@@ -25,4 +25,5 @@ enum ActivityAttr {
avgStrideRatio,
ecor,
avgPace,
avgHeartRate,
}
import 'package:encrateia/models/activity_list.dart';
import 'package:encrateia/models/tag_group.dart';
import 'package:encrateia/utils/athlete_time_series_chart.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
import 'athlete_filter_widget.dart';
class AthleteHeartRateWidget extends StatefulWidget {
const AthleteHeartRateWidget({this.athlete});
final Athlete athlete;
@override
_AthleteHeartRateWidgetState createState() =>
_AthleteHeartRateWidgetState();
}
class _AthleteHeartRateWidgetState extends State<AthleteHeartRateWidget> {
ActivityList<Activity> activities = ActivityList<Activity>(<Activity>[]);
List<TagGroup> tagGroups = <TagGroup>[];
String loadingStatus = 'Loading ...';
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(BuildContext context) {
if (activities.isNotEmpty) {
final List<Activity> heartRateActivities = activities
.where((Activity activity) =>
activity.avgSpeed != null && activity.avgSpeed > 0)
.toList();
if (heartRateActivities.isNotEmpty) {
return ListTileTheme(
iconColor: Colors.deepOrange,
child: ListView(
padding: const EdgeInsets.only(left: 25),
children: <Widget>[
AthleteTimeSeriesChart(
activities: heartRateActivities,
activityAttr: ActivityAttr.avgHeartRate,
chartTitleText: 'Heart Rate',
athlete: widget.athlete,
),
AthleteFilterWidget(
athlete: widget.athlete,
tagGroups: tagGroups,
callBackFunction: getData,
),
],
),
);
} else {
return const Center(
child: Text('No heart rate data available.'),
);
}
} else {
return ListView(children: <Widget>[
const SizedBox(
height: 50,
),
Center(
child: Text(loadingStatus),
),
const SizedBox(
height: 50,
),
AthleteFilterWidget(
athlete: widget.athlete,
tagGroups: tagGroups,
callBackFunction: getData,
)
]);
}
}
Future<void> getData() async {
final Athlete athlete = widget.athlete;
final List<Activity> unfilteredActivities = await athlete.activities;
tagGroups = await widget.athlete.tagGroups;
activities = await ActivityList<Activity>(unfilteredActivities).applyFilter(
athlete: widget.athlete,
tagGroups: tagGroups,
);
loadingStatus = activities.length.toString() + ' activities found';
setState(() {});
}
}
......@@ -32,19 +32,19 @@ class _AthletePaceWidgetState extends State<AthletePaceWidget> {
@override
Widget build(BuildContext context) {
if (activities.isNotEmpty) {
final List<Activity> strideRatioActivities = activities
final List<Activity> paceActivities = activities
.where((Activity activity) =>
activity.avgSpeed != null && activity.avgSpeed > 0)
.toList();
if (strideRatioActivities.isNotEmpty) {
if (paceActivities.isNotEmpty) {
return ListTileTheme(
iconColor: Colors.deepOrange,
child: ListView(
padding: const EdgeInsets.only(left: 25),
children: <Widget>[
AthleteTimeSeriesChart(
activities: strideRatioActivities,
activities: paceActivities,
activityAttr: ActivityAttr.avgPace,
chartTitleText: 'Pace',
athlete: widget.athlete,
......
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