Commit eca77bf4 authored by Administrator's avatar Administrator

add ecor to activity overview

parent 0da2f8b3
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/weight.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:intl/intl.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityOverviewWidget extends StatelessWidget {
class ActivityOverviewWidget extends StatefulWidget {
final Activity activity;
final Athlete athlete;
......@@ -14,6 +16,17 @@ class ActivityOverviewWidget extends StatelessWidget {
@required this.athlete,
});
@override
_ActivityOverviewWidgetState createState() => _ActivityOverviewWidgetState();
}
class _ActivityOverviewWidgetState extends State<ActivityOverviewWidget> {
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(context) {
return ListTileTheme(
......@@ -23,72 +36,92 @@ class ActivityOverviewWidget extends StatelessWidget {
children: <Widget>[
ListTile(
leading: MyIcon.time,
title:
Text(Duration(seconds: activity.db.movingTime ?? 0).asString()),
title: Text(Duration(seconds: widget.activity.db.movingTime ?? 0)
.asString()),
subtitle: Text('moving time'),
),
ListTile(
leading: MyIcon.speed,
title: Text(activity.db.avgSpeed.toPace() +
title: Text(widget.activity.db.avgSpeed.toPace() +
" / " +
activity.db.maxSpeed.toPace()),
widget.activity.db.maxSpeed.toPace()),
subtitle: Text('avg / max pace'),
),
ListTile(
leading: MyIcon.power,
title: Text((widget.activity.weight != null)
? widget.activity
.get(activityAttr: ActivityAttr.ecor)
.toStringAsFixed(2) +
" W s/kg m"
: "not available"),
subtitle: Text('ecor'),
),
ListTile(
leading: MyIcon.heartRate,
title: Text(
"${activity.db.avgHeartRate} bpm / ${activity.db.maxHeartRate} bpm"),
"${widget.activity.db.avgHeartRate} bpm / ${widget.activity.db.maxHeartRate} bpm"),
subtitle: Text('avg / max heart rate'),
),
ListTile(
leading: MyIcon.power,
title: Text("${activity.db.avgPower.toStringAsFixed(1)} W"),
title: Text("${widget.activity.db.avgPower.toStringAsFixed(1)} W"),
subtitle: Text('avg power'),
),
ListTile(
leading: MyIcon.power,
title: Text(
"${(activity.db.avgPower / activity.db.avgHeartRate).toStringAsFixed(2)} W/bpm"),
"${(widget.activity.db.avgPower / widget.activity.db.avgHeartRate).toStringAsFixed(2)} W/bpm"),
subtitle: Text('power / heart rate'),
),
ListTile(
leading: MyIcon.distance,
title:
Text('${(activity.db.distance / 1000).toStringAsFixed(2)} km'),
title: Text(
'${(widget.activity.db.distance / 1000).toStringAsFixed(2)} km'),
subtitle: Text('distance'),
),
ListTile(
leading: MyIcon.calories,
title: Text('${activity.db.totalCalories} kcal'),
title: Text('${widget.activity.db.totalCalories} kcal'),
subtitle: Text('total calories'),
),
ListTile(
leading: MyIcon.timeStamp,
title: Text(DateFormat("dd MMM yyyy, h:mm:ss")
.format(activity.db.timeCreated)),
.format(widget.activity.db.timeCreated)),
subtitle: Text('time created'),
),
ListTile(
leading: MyIcon.climb,
title: Text(
"${activity.db.totalAscent} m - ${activity.db.totalDescent} m"
" = ${activity.db.totalAscent - activity.db.totalDescent} m"),
"${widget.activity.db.totalAscent} m - ${widget.activity.db.totalDescent} m"
" = ${widget.activity.db.totalAscent - widget.activity.db.totalDescent} m"),
subtitle: Text('total ascent - descent = total climb'),
),
ListTile(
leading: MyIcon.cadence,
title: Text(
"${(activity.db.avgRunningCadence ?? 0 * 2).round()} spm / "
"${activity.db.maxRunningCadence ?? 0 * 2} spm"),
"${(widget.activity.db.avgRunningCadence ?? 0 * 2).round()} spm / "
"${widget.activity.db.maxRunningCadence ?? 0 * 2} spm"),
subtitle: Text('avg / max steps per minute'),
),
ListTile(
leading: MyIcon.trainingEffect,
title: Text(activity.db.totalTrainingEffect.toString()),
title: Text(widget.activity.db.totalTrainingEffect.toString()),
subtitle: Text('total training effect'),
),
],
),
);
}
getData() async {
var weight = await Weight.getBy(
athletesId: widget.athlete.db.id,
date: widget.activity.db.timeCreated,
);
setState(() {
widget.activity.weight = weight.db.value;
});
}
}
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