Commit e8686fdf authored by Stefan Haslinger's avatar Stefan Haslinger

switching the first activity views to physical quantities

parent 6407f37a
{"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 13:15:56.280863","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 14:11:49.830227","version":"1.20.1"}
\ No newline at end of file
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/weight.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:encrateia/widgets/activity_widgets/activity_bargraph_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_ftp_widget.dart';
......@@ -50,6 +51,7 @@ class ShowActivityScreen extends StatefulWidget {
class _ShowActivityScreenState extends State<ShowActivityScreen> {
Flushbar<Object> flushbar = Flushbar<Object>();
Weight weight;
List<Widget> get tiles {
return <Widget>[
......@@ -516,6 +518,11 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
Future<void> getData() async {
await widget.activity.laps;
weight = await Weight.getBy(
athletesId: widget.athlete.id,
date: widget.activity.timeCreated,
);
widget.activity.weight = weight.value;
setState(() {});
}
}
......@@ -73,6 +73,8 @@ class PQText extends StatelessWidget {
return Text(((value as double) * 3.6).toStringAsFixed(2) + ' km/h');
case PQ.speedPerHeartRate:
return Text((value as double).toStringAsFixed(1) + ' m/h / bpm');
case PQ.weight:
return Text((value as double).toStringAsFixed(1) + ' kg');
}
return const Text('the pq Parameter was not provided.'); // just to silence the dart analyzer
}
......
......@@ -70,4 +70,5 @@ enum PQ {
latitude,
speed,
speedPerHeartRate,
weight,
}
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';
......@@ -21,6 +23,7 @@ class ActivityAltitudeWidget extends StatefulWidget {
class _ActivityAltitudeWidgetState extends State<ActivityAltitudeWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
bool loading = true;
@override
void initState() {
......@@ -51,7 +54,7 @@ class _ActivityAltitudeWidgetState extends State<ActivityAltitudeWidget> {
const Divider(),
ListTile(
leading: MyIcon.amount,
title: Text(records.length.toString()),
title: PQText(value: records.length, pq: PQ.integer),
subtitle: const Text('number of measurements'),
),
],
......@@ -63,8 +66,8 @@ class _ActivityAltitudeWidgetState extends State<ActivityAltitudeWidget> {
);
}
} else {
return const Center(
child: Text('Loading / no records found'),
return Center(
child: Text(loading ? 'Loading' : 'no records found'),
);
}
}
......@@ -72,6 +75,6 @@ class _ActivityAltitudeWidgetState extends State<ActivityAltitudeWidget> {
Future<void> getData() async {
final Activity activity = widget.activity;
records = RecordList<Event>(await activity.records);
setState(() {});
setState(() => loading = false);
}
}
......@@ -31,6 +31,7 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
List<Lap> _laps = <Lap>[];
List<BarZone> _heartRateDistributions = <BarZone>[];
List<BarZone> _powerDistributions = <BarZone>[];
bool loading = true;
@override
void initState() {
......@@ -68,7 +69,9 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
value: widget.activity.avgPower,
powerZones: _powerZones,
),
Text((widget.activity.avgPower > 0) ? widget.activity.avgPower.toStringAsFixed(1) : ''),
Text((widget.activity.avgPower > 0)
? widget.activity.avgPower.toStringAsFixed(1)
: ''),
MyBarChart(
width: 150,
height: 20,
......@@ -86,7 +89,9 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
value: lap.avgPower,
powerZones: _powerZones,
),
Text((lap.avgPower > 0) ? lap.avgPower.toStringAsFixed(1) : ''),
Text((lap.avgPower > 0)
? lap.avgPower.toStringAsFixed(1)
: ''),
MyBarChart(
width: 150,
height: 20,
......@@ -166,7 +171,9 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
),
);
} else {
return const Center(child: Text('Loading'));
return Center(
child: Text(loading ? 'Loading' : 'No data available'),
);
}
}
......@@ -188,6 +195,7 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
_heartRateZoneSchema = await activity.heartRateZoneSchema;
if (_heartRateZoneSchema != null)
_heartRateZones = await _heartRateZoneSchema.heartRateZones;
setState(() {});
setState(() => loading = false);
}
}
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/record_list.dart';
import 'package:encrateia/models/weight.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_ecor_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
......@@ -25,7 +25,7 @@ class ActivityEcorWidget extends StatefulWidget {
class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
Weight weight;
String weightString = 'Loading ...';
bool loading;
@override
void initState() {
......@@ -62,22 +62,17 @@ class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
const Divider(),
ListTile(
leading: MyIcon.power,
title: Text((widget.activity.weight != null)
? (widget.activity.getAttribute(ActivityAttr.ecor)
as double)
.toStringAsFixed(3) +
' kJ / kg / km'
: 'not available'),
title: PQText(value: widget.activity.ecor, pq: PQ.ecor),
subtitle: const Text('ecor (Energy cost of running)'),
),
ListTile(
leading: MyIcon.weight,
title: Text(weightString),
title: PQText(value: widget.activity.weight, pq: PQ.weight),
subtitle: const Text('weight'),
),
ListTile(
leading: MyIcon.amount,
title: Text(ecorRecords.length.toString()),
title: PQText(value: ecorRecords.length, pq: PQ.integer),
subtitle: const Text('number of measurements'),
),
],
......@@ -89,8 +84,8 @@ class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
);
}
} else {
return const Center(
child: Text('Loading'),
return Center(
child: Text(loading ? 'Loading' : 'No data available'),
);
}
}
......@@ -102,7 +97,6 @@ class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
date: widget.activity.timeCreated,
);
widget.activity.weight = weight.value;
weightString = weight.value.toStringOrDashes(2) + ' kg';
setState(() {});
setState(() => loading = false);
}
}
......@@ -20,6 +20,7 @@ class ActivityPathWidget extends StatefulWidget {
class _ActivityPathWidgetState extends State<ActivityPathWidget> {
RecordList<Event> records = RecordList<Event>(<Event>[]);
bool loading = true;
@override
void initState() {
......@@ -48,14 +49,14 @@ class _ActivityPathWidgetState extends State<ActivityPathWidget> {
);
}
} else {
return const Center(
child: Text('Loading / no records found'),
return Center(
child: Text(loading ? 'Loading' : 'no records found'),
);
}
}
Future<void> getData() async {
records = RecordList<Event>(await widget.activity.records);
setState(() {});
setState(() => loading = false);
}
}
......@@ -2,7 +2,6 @@ import 'package:encrateia/utils/PQText.dart';
import 'package:encrateia/utils/enums.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:intl/intl.dart';
import 'package:encrateia/models/lap.dart';
class LapMetadataWidget extends StatelessWidget {
......
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