Commit 7cfec800 authored by Stefan Haslinger's avatar Stefan Haslinger

switching even more activity views to physical quantities

parent 1cc8d0c5
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"macos":[{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-08-18 15:07:55.002751","version":"1.20.1"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"macos":[{"name":"package_info","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.1/","dependencies":[]},{"name":"path_provider_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-08-18 18:23:15.096020","version":"1.20.1"}
\ No newline at end of file
......@@ -26,7 +26,7 @@ class PQText extends StatelessWidget {
case PQ.distance:
return Text(((value as int) / 1000).toStringAsFixed(2) + ' km');
case PQ.power:
return Text((value as double).toStringAsPrecision(3) + ' W');
return Text((value as num).toStringAsPrecision(3) + ' W');
case PQ.pace:
final double totalSeconds = 1000 / (value as double);
final int minutes = (totalSeconds / 60).floor();
......
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/record_list.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/widgets/charts/power_duration_chart.dart';
class ActivityPowerDurationWidget extends StatelessWidget {
class ActivityPowerDurationWidget extends StatefulWidget {
const ActivityPowerDurationWidget({
@required this.activity,
@required this.athlete,
......@@ -13,35 +14,50 @@ class ActivityPowerDurationWidget extends StatelessWidget {
final Activity activity;
final Athlete athlete;
@override
_ActivityPowerDurationWidgetState createState() =>
_ActivityPowerDurationWidgetState();
}
class _ActivityPowerDurationWidgetState
extends State<ActivityPowerDurationWidget> {
bool loading = true;
RecordList<Event> records = RecordList<Event>(<Event>[]);
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder<List<Event>>(
future: activity.records,
builder: (BuildContext context, AsyncSnapshot<List<Event>> snapshot) {
if (snapshot.hasData) {
final List<Event> powerRecords = snapshot.data
.where((Event value) =>
value.power != null && value.power > 100)
.toList();
if (powerRecords.isNotEmpty) {
return SingleChildScrollView(
child: PowerDurationChart(records: powerRecords),
);
} else {
return const Center(
child: Text('No power data available.'),
);
}
} else {
return Container(
height: 100,
child: const Center(
child: Text('Loading'),
),
);
}
},
);
if (records.isNotEmpty) {
final List<Event> powerRecords = records
.where((Event value) => value.power != null && value.power > 100)
.toList();
if (powerRecords.isNotEmpty) {
return SingleChildScrollView(
child: PowerDurationChart(records: powerRecords),
);
} else {
return const Center(
child: Text('No power data available.'),
);
}
} else {
return Container(
height: 100,
child: Center(
child: Text(loading ? 'Loading' : 'No data available'),
),
);
}
}
Future<void> getData() async {
records = RecordList<Event>(await widget.activity.records);
setState(() => loading = false);
}
}
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/record_list.dart';
import 'package:encrateia/utils/PQText.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:encrateia/widgets/charts/activity_charts/activity_power_per_heart_rate_chart.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityPowerPerHeartRateWidget extends StatefulWidget {
......@@ -24,7 +25,7 @@ class ActivityPowerPerHeartRateWidget extends StatefulWidget {
class _ActivityPowerPerHeartRateWidgetState
extends State<ActivityPowerPerHeartRateWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
String avgPowerPerHeartRateString = 'Loading ...';
bool loading = true;
@override
void initState() {
......@@ -60,7 +61,10 @@ class _ActivityPowerPerHeartRateWidgetState
const Divider(),
ListTile(
leading: MyIcon.average,
title: Text(avgPowerPerHeartRateString),
title: PQText(
value: widget.activity.avgPowerPerHeartRate,
pq: PQ.powerPerHeartRate,
),
subtitle: const Text('average power per heart rate'),
),
],
......@@ -72,8 +76,8 @@ class _ActivityPowerPerHeartRateWidgetState
);
}
} else {
return const Center(
child: Text('Loading'),
return Center(
child: Text(loading ? 'Loading' : 'No data available'),
);
}
}
......@@ -81,8 +85,6 @@ class _ActivityPowerPerHeartRateWidgetState
Future<void> getData() async {
final Activity activity = widget.activity;
records = RecordList<Event>(await activity.records);
final double avg = activity.avgPower / activity.avgHeartRate;
avgPowerPerHeartRateString = avg.toStringOrDashes(2) + ' W / bpm';
setState(() {});
setState(() => loading = false);
}
}
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/record_list.dart';
import 'package:encrateia/utils/PQText.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import 'package:encrateia/widgets/charts/activity_charts/activity_power_ratio_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
......@@ -23,8 +24,7 @@ class ActivityPowerRatioWidget extends StatefulWidget {
class _ActivityPowerRatioWidgetState extends State<ActivityPowerRatioWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
String avgPowerRatioString = 'Loading ...';
String sdevPowerRatioString = 'Loading ...';
bool loading = true;
@override
void initState() {
......@@ -62,17 +62,17 @@ class _ActivityPowerRatioWidgetState extends State<ActivityPowerRatioWidget> {
const Divider(),
ListTile(
leading: MyIcon.formPower,
title: Text(avgPowerRatioString),
title: PQText(value: widget.activity.avgPowerRatio, pq: PQ.percentage,),
subtitle: const Text('average power ratio'),
),
ListTile(
leading: MyIcon.standardDeviation,
title: Text(sdevPowerRatioString),
title: PQText(value: widget.activity.sdevPowerRatio, pq: PQ.percentage,),
subtitle: const Text('standard deviation power ratio '),
),
ListTile(
leading: MyIcon.amount,
title: Text(powerRecords.length.toString()),
title: PQText(value: powerRecords.length, pq: PQ.integer),
subtitle: const Text('number of measurements'),
),
],
......@@ -84,8 +84,8 @@ class _ActivityPowerRatioWidgetState extends State<ActivityPowerRatioWidget> {
);
}
} else {
return const Center(
child: Text('Loading'),
return Center(
child: Text(loading ? 'Loading' : 'No data available'),
);
}
}
......@@ -93,9 +93,6 @@ class _ActivityPowerRatioWidgetState extends State<ActivityPowerRatioWidget> {
Future<void> getData() async {
final Activity activity = widget.activity;
records = RecordList<Event>(await activity.records);
avgPowerRatioString = activity.avgPowerRatio.toStringOrDashes(1) + ' %';
sdevPowerRatioString =
activity.sdevPowerRatio.toStringOrDashes(2) + ' %';
setState(() {});
setState(() => loading = false);
}
}
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:encrateia/utils/PQText.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/power_zone.dart';
import 'package:encrateia/models/power_zone_schema.dart';
import 'package:encrateia/models/record_list.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:encrateia/utils/image_utils.dart';
import 'package:encrateia/utils/my_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import 'package:encrateia/widgets/charts/activity_charts/activity_power_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
......@@ -28,11 +28,8 @@ class ActivityPowerWidget extends StatefulWidget {
class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
String avgPowerString = 'Loading ...';
String minPowerString = 'Loading ...';
String maxPowerString = 'Loading ...';
String sdevPowerString = 'Loading ...';
String screenShotButtonText = 'Save Image to Storage';
bool loading = true;
String screenShotButtonText = 'Save Image';
PowerZoneSchema powerZoneSchema;
List<PowerZone> powerZones;
GlobalKey widgetKey = GlobalKey();
......@@ -66,8 +63,11 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
athlete: widget.athlete,
),
),
if (kDebugMode)
Row(children: <Widget>[
Text('${widget.athlete.recordAggregationCount} records are '
'aggregated into one point in the plot. Only records where '
'power > 100 W are shown.'),
const Divider(),
Row(children: <Widget>[
const Spacer(),
MyButton.save(
child: Text(screenShotButtonText),
......@@ -79,40 +79,41 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
),
const SizedBox(width: 20),
]),
Text('${widget.athlete.recordAggregationCount} records are '
'aggregated into one point in the plot. Only records where '
'power > 100 W are shown.'),
const Divider(),
ListTile(
leading: MyIcon.average,
title: Text(avgPowerString),
title: PQText(value: widget.activity.avgPower, pq: PQ.power),
subtitle: const Text('average power'),
),
ListTile(
leading: MyIcon.minimum,
title: Text(minPowerString),
title: PQText(value: widget.activity.minPower, pq: PQ.power),
subtitle: const Text('minimum power'),
),
ListTile(
leading: MyIcon.maximum,
title: Text(maxPowerString),
title: PQText(value: widget.activity.maxPower, pq: PQ.power),
subtitle: const Text('maximum power'),
),
ListTile(
leading: MyIcon.standardDeviation,
title: Text(sdevPowerString),
title: PQText(value: widget.activity.sdevPower, pq: PQ.power),
subtitle: const Text('standard deviation power'),
),
ListTile(
leading: MyIcon.amount,
title: Text(powerRecords.length.toString()),
title: PQText(value: powerRecords.length, pq: PQ.integer),
subtitle: const Text('number of measurements'),
),
ListTile(
leading: const Text('🕵️‍♀️', style: TextStyle(fontSize: 25)),
title: Text(lastRecord.positionLong.semicirclesAsDegrees() +
' / ' +
lastRecord.positionLat.semicirclesAsDegrees()),
title: Row(
children: <Widget>[
PQText(value: lastRecord.positionLong, pq: PQ.longitude),
const Text(' / '),
PQText(value: lastRecord.positionLat, pq: PQ.latitude),
],
),
subtitle: const Text('findYourStryd (last power record)'),
),
],
......@@ -124,8 +125,8 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
);
}
} else {
return const Center(
child: Text('Loading'),
return Center(
child: Text(loading ? 'Loading' : 'No data available'),
);
}
}
......@@ -133,16 +134,12 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
Future<void> getData() async {
final Activity activity = widget.activity;
records = RecordList<Event>(await activity.records);
avgPowerString = activity.avgPower.toStringOrDashes(1) + ' W';
minPowerString = activity.minPower.toString() + ' W';
maxPowerString = activity.maxPower.toString() + ' W';
sdevPowerString = activity.sdevPower.toStringOrDashes(2) + ' W';
powerZoneSchema = await activity.powerZoneSchema;
if (powerZoneSchema != null)
powerZones = await powerZoneSchema.powerZones;
else
powerZones = <PowerZone>[];
setState(() {});
setState(() => loading = false);
}
}
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