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