Commit 3c8cf9d6 authored by Stefan Haslinger's avatar Stefan Haslinger

cleanup of - - - Strings, cleanup of pace helper functions

parent f76870bc
......@@ -7,8 +7,7 @@ import 'package:encrateia/utils/my_button.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:intl/intl.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'PQText.dart';
class AthleteTimeSeriesChart extends StatefulWidget {
const AthleteTimeSeriesChart({
......@@ -192,31 +191,41 @@ class _AthleteTimeSeriesChartState extends State<AthleteTimeSeriesChart> {
),
),
ListTile(
title: Text(DateFormat('dd MMM yyyy, h:mm:ss')
.format(selectedActivity.timeCreated)),
title: PQText(
value: selectedActivity.timeCreated,
pq: PQ.dateTime,
format: DateTimeFormat.longDateTime,
),
subtitle: const Text('Time created'),
),
ListTile(
title: Text(selectedActivity.distance.toString() + ' m'),
title: PQText(
value: selectedActivity.distance,
pq: PQ.distance,
),
subtitle: const Text('Distance'),
),
ListTile(
title: Text(selectedActivity.avgSpeed.toPace() + ' min/km'),
title: PQText(
value: selectedActivity.avgSpeed,
pq: PQ.paceFromSpeed,
),
subtitle: const Text('Average speed'),
),
ListTile(
title:
Text(selectedActivity.avgPower.toStringAsFixed(1) + ' W'),
title: PQText(value: selectedActivity.avgPower, pq: PQ.power),
subtitle: const Text('Average power'),
),
if (selectedActivity.ftp != null)
ListTile(
title: Text(selectedActivity.ftp.toStringAsFixed(1) + ' W'),
title: PQText(value: selectedActivity.ftp, pq: PQ.power),
subtitle: const Text('FTP'),
),
ListTile(
title:
Text(selectedActivity.avgHeartRate.toString() + ' bpm'),
title: PQText(
value: selectedActivity.avgHeartRate,
pq: PQ.heartRate,
),
subtitle: const Text('Average heart rate')),
],
),
......
......@@ -27,22 +27,4 @@ extension DegreeFormatters on double {
return '$degrees° $minutes\' ${seconds.toStringAsFixed(2)}"';
}
String toPace() {
if (this != null) {
final double totalSeconds = 1000 / this;
final int minutes = (totalSeconds / 60).floor();
final String seconds =
(totalSeconds - minutes * 60).round().toString().padLeft(2, '0');
return '$minutes:$seconds';
} else {
return '- - - ';
}
}
double toPaceDouble() {
if (this != null)
return 1000 / this;
return 0;
}
}
......@@ -10,7 +10,6 @@ import 'package:encrateia/utils/enums.dart';
import 'package:encrateia/utils/my_bar_chart.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/utils/date_time_utils.dart';
class ActivityBarGraphWidget extends StatefulWidget {
const ActivityBarGraphWidget({
......@@ -153,7 +152,7 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
const Text('Activity'),
MyBarChart(
height: 20,
value: widget.activity.avgSpeed.toPaceDouble(),
value: widget.activity.avgPace,
maximum: 700,
),
PQText(value: widget.activity.avgSpeed, pq: PQ.paceFromSpeed),
......@@ -163,7 +162,7 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
Text('Lap ' + lap.index.toString()),
MyBarChart(
height: 20,
value: lap.avgSpeed.toPaceDouble(),
value: lap.avgPace,
maximum: 700,
),
PQText(value: lap.avgSpeed, pq: PQ.paceFromSpeed),
......
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