Browse Source

hide db from Event

master
Stefan Haslinger 3 years ago
parent
commit
0810876501
  1. 0
      _db.swcLong
  2. 11
      lib/models/activity.dart
  3. 42
      lib/models/event.dart
  4. 4
      lib/models/lap.dart
  5. 8
      lib/models/minimum_power_duration.dart
  6. 5
      lib/models/power_duration.dart
  7. 166
      lib/models/record_list.dart
  8. 4
      lib/utils/path_painter.dart
  9. 8
      lib/widgets/activity_widgets/activity_ecor_widget.dart
  10. 6
      lib/widgets/activity_widgets/activity_form_power_widget.dart
  11. 2
      lib/widgets/activity_widgets/activity_ground_time_widget.dart
  12. 2
      lib/widgets/activity_widgets/activity_heart_rate_widget.dart
  13. 4
      lib/widgets/activity_widgets/activity_leg_spring_stiffness_widget.dart
  14. 2
      lib/widgets/activity_widgets/activity_path_widget.dart
  15. 2
      lib/widgets/activity_widgets/activity_power_duration_widget.dart
  16. 8
      lib/widgets/activity_widgets/activity_power_per_heart_rate_widget.dart
  17. 10
      lib/widgets/activity_widgets/activity_power_ratio_widget.dart
  18. 6
      lib/widgets/activity_widgets/activity_power_widget.dart
  19. 6
      lib/widgets/activity_widgets/activity_speed_per_heart_rate_widget.dart
  20. 6
      lib/widgets/activity_widgets/activity_stride_ratio_widget.dart
  21. 2
      lib/widgets/activity_widgets/activity_stryd_cadence_widget.dart
  22. 2
      lib/widgets/activity_widgets/activity_vertical_oscillation_widget.dart
  23. 2
      lib/widgets/charts/activity_charts/activity_ecor_chart.dart
  24. 2
      lib/widgets/charts/activity_charts/activity_form_power_chart.dart
  25. 2
      lib/widgets/charts/activity_charts/activity_ground_time_chart.dart
  26. 2
      lib/widgets/charts/activity_charts/activity_heart_rate_chart.dart
  27. 2
      lib/widgets/charts/activity_charts/activity_leg_spring_stiffness_chart.dart
  28. 2
      lib/widgets/charts/activity_charts/activity_power_chart.dart
  29. 2
      lib/widgets/charts/activity_charts/activity_power_per_heart_rate_chart.dart
  30. 2
      lib/widgets/charts/activity_charts/activity_power_ratio_chart.dart
  31. 2
      lib/widgets/charts/activity_charts/activity_speed_per_heart_rate_chart.dart
  32. 2
      lib/widgets/charts/activity_charts/activity_stride_ratio_chart.dart
  33. 2
      lib/widgets/charts/activity_charts/activity_stryd_cadence_chart.dart
  34. 2
      lib/widgets/charts/activity_charts/activity_vertical_oscillation_chart.dart
  35. 6
      lib/widgets/charts/lap_charts/lap_ecor_chart.dart
  36. 6
      lib/widgets/charts/lap_charts/lap_form_power_chart.dart
  37. 6
      lib/widgets/charts/lap_charts/lap_ground_time_chart.dart
  38. 6
      lib/widgets/charts/lap_charts/lap_heart_rate_chart.dart
  39. 6
      lib/widgets/charts/lap_charts/lap_leg_spring_stiffness_chart.dart
  40. 6
      lib/widgets/charts/lap_charts/lap_power_chart.dart
  41. 6
      lib/widgets/charts/lap_charts/lap_stryd_cadence_chart.dart
  42. 6
      lib/widgets/charts/lap_charts/lap_vertical_oscillation_chart.dart
  43. 8
      lib/widgets/lap_widgets/lap_ecor_widget.dart
  44. 2
      lib/widgets/lap_widgets/lap_form_power_widget.dart
  45. 2
      lib/widgets/lap_widgets/lap_ground_time_widget.dart
  46. 2
      lib/widgets/lap_widgets/lap_heart_rate_widget.dart
  47. 4
      lib/widgets/lap_widgets/lap_leg_spring_stiffness_widget.dart
  48. 2
      lib/widgets/lap_widgets/lap_power_duration_widget.dart
  49. 2
      lib/widgets/lap_widgets/lap_power_widget.dart
  50. 2
      lib/widgets/lap_widgets/lap_stryd_cadence_widget.dart
  51. 4
      lib/widgets/lap_widgets/lap_vertical_oscillation_widget.dart

0
_db.swcLong

11
lib/models/activity.dart

@ -6,7 +6,7 @@ import 'package:encrateia/models/strava_fit_download.dart';
import 'package:fit_parser/src/value.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart'
show DbActivity, DbEvent, DbHeartRateZone, DbPowerZone;
show DbActivity, DbHeartRateZone, DbPowerZone;
import 'package:sqfentity_gen/sqfentity_gen.dart';
import 'package:strava_flutter/strava.dart';
import 'package:encrateia/secrets/secrets.dart';
@ -371,10 +371,7 @@ class Activity {
lap: currentLap,
);
await lap.db.save();
await DbEvent().upsertAll(eventsForCurrentLap
.where((Event event) => event.db != null)
.map((Event event) => event.db)
.toList());
await Event.upsertAll(eventsForCurrentLap);
await resetCurrentLap();
break;
@ -619,7 +616,7 @@ class Activity {
final PowerZoneSchema powerZoneSchema = await this.powerZoneSchema;
final List<Event> records = await this.records;
final List<Event> powerRecords =
records.where((Event record) => record.db.power != null).toList();
records.where((Event record) => record.power != null).toList();
final List<BarZone> powerZoneCounts = await RecordList<Event>(powerRecords)
.powerZoneCounts(powerZoneSchema: powerZoneSchema);
return powerZoneCounts;
@ -630,7 +627,7 @@ class Activity {
await this.heartRateZoneSchema;
final List<Event> records = await this.records;
final List<Event> heartRateRecords =
records.where((Event record) => record.db.heartRate != null).toList();
records.where((Event record) => record.heartRate != null).toList();
final List<BarZone> heartRateZoneCounts =
await RecordList<Event>(heartRateRecords)
.heartRateZoneCounts(heartRateZoneSchema: heartRateZoneSchema);

42
lib/models/event.dart

@ -6,6 +6,7 @@ import 'package:encrateia/models/lap.dart';
// ignore: implementation_imports
import 'package:fit_parser/src/value.dart';
import 'package:flutter/foundation.dart';
import 'package:sqfentity_gen/sqfentity_gen.dart';
class Event {
Event({
@ -19,7 +20,7 @@ class Event {
} else if (dataMessage.values.any((Value value) =>
value.fieldName == 'event_type' &&
<String> ['start', 'stop_all'].contains(value.value))) {
db = DbEvent()
_db = DbEvent()
..activitiesId = activity.db.id
..event = dataMessage.get('event') as String
..eventType = dataMessage.get('event_type') as String
@ -29,7 +30,7 @@ class Event {
dateTimeFromStrava(dataMessage.get('timestamp') as double);
} else if (dataMessage.values.any((Value value) =>
value.fieldName == 'event_type' && <String> ['marker'].contains(value.value))) {
db = DbEvent()
_db = DbEvent()
..activitiesId = activity.db.id
..event = dataMessage.get('event')?.toString()
..eventType = dataMessage.get('event_type') as String
@ -43,14 +44,14 @@ class Event {
}
}
Event.fromDb(this.db);
Event.fromDb(this._db);
Event.fromRecord({
@required DataMessage dataMessage,
@required this.activity,
@required int lapsId,
}) {
db = DbEvent()
_db = DbEvent()
..activitiesId = activity.db.id
..lapsId = lapsId
..event = 'record'
@ -76,7 +77,7 @@ class Event {
@required this.activity,
@required int lapsId,
}) {
db = DbEvent()
_db = DbEvent()
..activitiesId = activity.db.id
..lapsId = lapsId
..positionLat = dataMessage.get('end_position_lat') as double
@ -95,25 +96,41 @@ class Event {
..distance = dataMessage.get('total_distance') as double;
}
DbEvent db;
DbEvent _db;
Activity activity;
Lap lap;
int index;
int get id => _db.id;
String get event => _db.event;
int get power => _db.power;
int get heartRate => _db.heartRate;
double get speed => _db.speed;
DateTime get timeStamp => _db.timeStamp;
double get groundTime => _db.groundTime;
double get strydCadence => _db.strydCadence;
double get legSpringStiffness => _db.legSpringStiffness;
double get verticalOscillation => _db.verticalOscillation;
int get formPower => _db.formPower;
double get distance => _db.distance;
double get positionLong => _db.positionLong;
double get positionLat => _db.positionLat;
set event(String value) => _db.event = value;
@override
String toString() => '< Event | ${db.event} | $index >';
String toString() => '< Event | $event | $index >';
static Future<List<Event>> recordsByLap({Lap lap}) async {
final List<Event> events = await byLap(lap: lap);
final Iterable<Event> records =
events.where((Event event) => event.db.event == 'record');
events.where((Event event) => event.event == 'record');
return records.toList();
}
static Future<List<Event>> recordsByActivity({Activity activity}) async {
final List<Event> events = await by(activity: activity);
final Iterable<Event> records =
events.where((Event event) => event.db.event == 'record');
events.where((Event event) => event.event == 'record');
return records.toList();
}
@ -146,4 +163,11 @@ class Event {
}
return eventList;
}
static Future<BoolCommitResult> upsertAll(List<Event> events) async {
return await DbEvent().upsertAll(events
.where((Event event) => event.id != null)
.map((Event event) => event._db)
.toList());
}
}

4
lib/models/lap.dart

@ -345,7 +345,7 @@ class Lap {
final PowerZoneSchema powerZoneSchema = await this.powerZoneSchema;
final List<Event> records = await this.records;
final List<Event> powerRecords =
records.where((Event record) => record.db.power != null).toList();
records.where((Event record) => record.power != null).toList();
final List<BarZone> powerZoneCounts = await RecordList<Event>(powerRecords)
.powerZoneCounts(powerZoneSchema: powerZoneSchema);
return powerZoneCounts;
@ -356,7 +356,7 @@ class Lap {
await this.heartRateZoneSchema;
final List<Event> records = await this.records;
final List<Event> heartRateRecords =
records.where((Event record) => record.db.heartRate != null).toList();
records.where((Event record) => record.heartRate != null).toList();
final List<BarZone> heartRateZoneCounts =
await RecordList<Event>(heartRateRecords)
.heartRateZoneCounts(heartRateZoneSchema: heartRateZoneSchema);

8
lib/models/minimum_power_duration.dart

@ -5,19 +5,17 @@ import 'package:encrateia/models/plot_point.dart';
class MinimumPowerDuration {
MinimumPowerDuration({List<Event> records}) {
for (int index = 0; index < records.length - 1; index++) {
final int power = records[index].db.power;
final int power = records[index].power;
final DateTime nextLower = records
.sublist(index + 1, records.length)
.firstWhere((Event record) => record.db.power < power,
.firstWhere((Event record) => record.power < power,
orElse: () => records.last)
.db
.timeStamp;
final DateTime recentLower = records
.sublist(0, index)
.lastWhere((Event record) => record.db.power < power,
.lastWhere((Event record) => record.power < power,
orElse: () => records.first)
.db
.timeStamp;
final int persistedFor = nextLower.difference(recentLower).inSeconds;

5
lib/models/power_duration.dart

@ -7,11 +7,10 @@ class PowerDuration {
final Map<int, EnergyPoint> powerSum = <int, EnergyPoint>{};
for (int index = 1; index <= records.length - 1; index++) {
final int power = records[index].db.power;
final int power = records[index].power;
final int duration = records[index]
.db
.timeStamp
.difference(records[index - 1].db.timeStamp)
.difference(records[index - 1].timeStamp)
.inSeconds;
powerSum.forEach((int start, EnergyPoint energyPoint) {

166
lib/models/record_list.dart

@ -19,25 +19,25 @@ class RecordList<E> extends DelegatingList<E> {
final List<Event> _records;
String get sdevHeartRateString => _records
.map((Event record) => record.db.heartRate)
.map((Event record) => record.heartRate)
.nonZeroInts()
.sdev()
.toStringAsFixed(2);
String get minHeartRateString => _records
.map((Event record) => record.db.heartRate)
.map((Event record) => record.heartRate)
.nonZeroInts()
.min()
.toString();
String get avgHeartRateString => _records
.map((Event record) => record.db.heartRate)
.map((Event record) => record.heartRate)
.nonZeroInts()
.mean()
.toStringOrDashes(1);
String get maxHeartRateString => _records
.map((Event record) => record.db.heartRate)
.map((Event record) => record.heartRate)
.nonZeroInts()
.max()
.toString();
@ -45,10 +45,10 @@ class RecordList<E> extends DelegatingList<E> {
double calculateAveragePower() {
final Iterable<int> powers = _records
.where((Event record) =>
record.db.power != null &&
record.db.power > 0 &&
record.db.power < 2000)
.map((Event record) => record.db.power);
record.power != null &&
record.power > 0 &&
record.power < 2000)
.map((Event record) => record.power);
if (powers.isNotEmpty) {
return powers.mean();
@ -58,15 +58,15 @@ class RecordList<E> extends DelegatingList<E> {
double calculateSdevPower() => _records
.where((Event record) =>
record.db.power != null &&
record.db.power > 0 &&
record.db.power < 2000)
.map((Event record) => record.db.power)
record.power != null &&
record.power > 0 &&
record.power < 2000)
.map((Event record) => record.power)
.sdev();
int calculateMinPower() {
final List<int> powers =
_records.map((Event record) => record.db.power).nonZeroInts();
_records.map((Event record) => record.power).nonZeroInts();
if (powers.isNotEmpty)
return powers.min();
else
@ -75,7 +75,7 @@ class RecordList<E> extends DelegatingList<E> {
int calculateMaxPower() {
final List<int> powers =
_records.map((Event record) => record.db.power).nonZeroInts();
_records.map((Event record) => record.power).nonZeroInts();
if (powers.isNotEmpty)
return powers.max();
else
@ -85,10 +85,10 @@ class RecordList<E> extends DelegatingList<E> {
int calculateAverageHeartRate() {
final Iterable<int> heartRates = _records
.where((Event record) =>
record.db.heartRate != null &&
record.db.heartRate > 0 &&
record.db.heartRate < 2000)
.map((Event record) => record.db.heartRate);
record.heartRate != null &&
record.heartRate > 0 &&
record.heartRate < 2000)
.map((Event record) => record.heartRate);
if (heartRates.isNotEmpty) {
return heartRates.mean().round();
@ -98,15 +98,15 @@ class RecordList<E> extends DelegatingList<E> {
double calculateSdevHeartRate() => _records
.where((Event record) =>
record.db.heartRate != null &&
record.db.heartRate > 0 &&
record.db.heartRate < 2000)
.map((Event record) => record.db.heartRate)
record.heartRate != null &&
record.heartRate > 0 &&
record.heartRate < 2000)
.map((Event record) => record.heartRate)
.sdev();
int calculateMinHeartRate() {
final List<int> heartRates =
_records.map((Event record) => record.db.heartRate).nonZeroInts();
_records.map((Event record) => record.heartRate).nonZeroInts();
if (heartRates.isNotEmpty)
return heartRates.min();
@ -116,7 +116,7 @@ class RecordList<E> extends DelegatingList<E> {
int calculateMaxHeartRate() {
final List<int> heartRates =
_records.map((Event record) => record.db.heartRate).nonZeroInts();
_records.map((Event record) => record.heartRate).nonZeroInts();
if (heartRates.isNotEmpty)
return heartRates.max();
@ -126,7 +126,7 @@ class RecordList<E> extends DelegatingList<E> {
double calculateAverageSpeed() {
final List<double> speeds =
_records.map((Event record) => record.db.speed).nonZeroDoubles();
_records.map((Event record) => record.speed).nonZeroDoubles();
if (speeds.isNotEmpty) {
return speeds.mean();
@ -136,7 +136,7 @@ class RecordList<E> extends DelegatingList<E> {
double calculateAverageGroundTime() {
final List<double> groundTimes =
_records.map((Event record) => record.db.groundTime).nonZeroDoubles();
_records.map((Event record) => record.groundTime).nonZeroDoubles();
if (groundTimes.isNotEmpty) {
return groundTimes.mean();
@ -145,13 +145,13 @@ class RecordList<E> extends DelegatingList<E> {
}
double calculateSdevGroundTime() => _records
.map((Event record) => record.db.groundTime)
.map((Event record) => record.groundTime)
.nonZeroDoubles()
.sdev();
double calculateAverageStrydCadence() {
final List<double> strydCadences = _records
.map((Event record) => record.db.strydCadence ?? 0.0 * 2)
.map((Event record) => record.strydCadence ?? 0.0 * 2)
.nonZeroDoubles();
if (strydCadences.isNotEmpty) {
@ -161,13 +161,13 @@ class RecordList<E> extends DelegatingList<E> {
}
double calculateSdevStrydCadence() => _records
.map((Event record) => record.db.strydCadence ?? 0.0 * 2)
.map((Event record) => record.strydCadence ?? 0.0 * 2)
.nonZeroDoubles()
.sdev();
double calculateAverageLegSpringStiffness() {
final List<double> legSpringStiffnesses = _records
.map((Event record) => record.db.legSpringStiffness)
.map((Event record) => record.legSpringStiffness)
.nonZeroDoubles();
if (legSpringStiffnesses.isNotEmpty) {
@ -177,13 +177,13 @@ class RecordList<E> extends DelegatingList<E> {
}
double calculateSdevLegSpringStiffness() => _records
.map((Event record) => record.db.legSpringStiffness)
.map((Event record) => record.legSpringStiffness)
.nonZeroDoubles()
.sdev();
double calculateAverageVerticalOscillation() {
final List<double> verticalOscillation = _records
.map((Event record) => record.db.verticalOscillation)
.map((Event record) => record.verticalOscillation)
.nonZeroDoubles();
if (verticalOscillation.isNotEmpty) {
@ -193,15 +193,15 @@ class RecordList<E> extends DelegatingList<E> {
}
double calculateSdevVerticalOscillation() => _records
.map((Event record) => record.db.verticalOscillation)
.map((Event record) => record.verticalOscillation)
.nonZeroDoubles()
.sdev();
double calculateAverageFormPower() {
final Iterable<int> formPowers = _records
.where((Event record) =>
record.db.formPower != null && record.db.formPower < 200)
.map((Event record) => record.db.formPower);
record.formPower != null && record.formPower < 200)
.map((Event record) => record.formPower);
if (formPowers.isNotEmpty) {
return formPowers.mean();
@ -211,19 +211,19 @@ class RecordList<E> extends DelegatingList<E> {
double calculateSdevFormPower() => _records
.where((Event record) =>
record.db.formPower != null && record.db.formPower < 200)
.map((Event record) => record.db.formPower)
record.formPower != null && record.formPower < 200)
.map((Event record) => record.formPower)
.sdev();
double calculateAveragePowerRatio() {
final Iterable<double> powerRatios = _records
.where((Event record) =>
record.db.power != null &&
record.db.power != 0 &&
record.db.formPower != null &&
record.db.formPower != 0)
record.power != null &&
record.power != 0 &&
record.formPower != null &&
record.formPower != 0)
.map((Event record) =>
(record.db.power - record.db.formPower) / record.db.power * 100);
(record.power - record.formPower) / record.power * 100);
if (powerRatios.isNotEmpty) {
return powerRatios.mean();
@ -233,28 +233,28 @@ class RecordList<E> extends DelegatingList<E> {
double calculateSdevPowerRatio() => _records
.where((Event record) =>
record.db.power != null &&
record.db.power != 0 &&
record.db.formPower != null &&
record.db.formPower != 0)
record.power != null &&
record.power != 0 &&
record.formPower != null &&
record.formPower != 0)
.map((Event record) =>
(record.db.power - record.db.formPower) / record.db.power * 100)
(record.power - record.formPower) / record.power * 100)
.sdev();
double calculateAverageStrideRatio() {
final Iterable<double> powerRatios = _records
.where((Event record) =>
record.db.speed != null &&
record.db.strydCadence != null &&
record.db.strydCadence != 0 &&
record.db.verticalOscillation != null &&
record.db.verticalOscillation != 0)
record.speed != null &&
record.strydCadence != null &&
record.strydCadence != 0 &&
record.verticalOscillation != null &&
record.verticalOscillation != 0)
.map((Event record) =>
10000 /
6 *
record.db.speed /
record.db.strydCadence /
record.db.verticalOscillation);
record.speed /
record.strydCadence /
record.verticalOscillation);
if (powerRatios.isNotEmpty) {
return powerRatios.mean();
@ -264,17 +264,17 @@ class RecordList<E> extends DelegatingList<E> {
double calculateSdevStrideRatio() => _records
.where((Event record) =>
record.db.speed != null &&
record.db.strydCadence != null &&
record.db.strydCadence != 0 &&
record.db.verticalOscillation != null &&
record.db.verticalOscillation != 0)
record.speed != null &&
record.strydCadence != null &&
record.strydCadence != 0 &&
record.verticalOscillation != null &&
record.verticalOscillation != 0)
.map((Event record) =>
10000 /
6 *
record.db.speed /
record.db.strydCadence /
record.db.verticalOscillation)
record.speed /
record.strydCadence /
record.verticalOscillation)
.sdev();
List<IntPlotPoint> toIntDataPoints({
@ -288,18 +288,18 @@ class RecordList<E> extends DelegatingList<E> {
for (final Event record in _records) {
switch (attribute) {
case LapIntAttr.power:
sum = sum + record.db.power;
sum = sum + record.power;
break;
case LapIntAttr.formPower:
sum = sum + record.db.formPower;
sum = sum + record.formPower;
break;
case LapIntAttr.heartRate:
sum = sum + record.db.heartRate;
sum = sum + record.heartRate;
}
if (index++ % amount == amount - 1) {
plotPoints.add(IntPlotPoint(
domain: record.db.distance.round(),
domain: record.distance.round(),
measure: (sum / amount).round(),
));
sum = 0;
@ -321,42 +321,42 @@ class RecordList<E> extends DelegatingList<E> {
for (final Event record in _records) {
switch (attribute) {
case LapDoubleAttr.powerPerHeartRate:
sum = sum + (record.db.power / record.db.heartRate);
sum = sum + (record.power / record.heartRate);
break;
case LapDoubleAttr.speedPerHeartRate:
sum = sum + 100 * (record.db.speed / record.db.heartRate);
sum = sum + 100 * (record.speed / record.heartRate);
break;
case LapDoubleAttr.groundTime:
sum = sum + record.db.groundTime;
sum = sum + record.groundTime;
break;
case LapDoubleAttr.strydCadence:
sum = sum + 2 * record.db.strydCadence;
sum = sum + 2 * record.strydCadence;
break;
case LapDoubleAttr.verticalOscillation:
sum = sum + record.db.verticalOscillation;
sum = sum + record.verticalOscillation;
break;
case LapDoubleAttr.legSpringStiffness:
sum = sum + record.db.legSpringStiffness;
sum = sum + record.legSpringStiffness;
break;
case LapDoubleAttr.powerRatio:
sum = sum +
((record.db.power - record.db.formPower) / record.db.power * 100);
((record.power - record.formPower) / record.power * 100);
break;
case LapDoubleAttr.strideRatio:
sum = sum +
(10000 /
6 *
record.db.speed /
record.db.strydCadence /
record.db.verticalOscillation);
record.speed /
record.strydCadence /
record.verticalOscillation);
break;
case LapDoubleAttr.ecor:
sum = sum + (record.db.power / record.db.speed / weight);
sum = sum + (record.power / record.speed / weight);
}
if (index++ % amount == amount - 1) {
plotPoints.add(DoublePlotPoint(
domain: record.db.distance.round(),
domain: record.distance.round(),
measure: sum / amount,
));
sum = 0;
@ -376,8 +376,8 @@ class RecordList<E> extends DelegatingList<E> {
for (final PowerZone powerZone in powerZones.reversed) {
final int numberInZone = _records
.where((Event event) =>
(event.db.power >= powerZone.lowerLimit) &&
(event.db.power <= powerZone.upperLimit))
(event.power >= powerZone.lowerLimit) &&
(event.power <= powerZone.upperLimit))
.length;
distributions.add(BarZone(
lower: counter,
@ -400,8 +400,8 @@ class RecordList<E> extends DelegatingList<E> {
for (final HeartRateZone heartRateZone in heartRateZones.reversed) {
final int numberInZone = _records
.where((Event event) =>
(event.db.heartRate >= heartRateZone.lowerLimit) &&
(event.db.heartRate <= heartRateZone.upperLimit))
(event.heartRate >= heartRateZone.lowerLimit) &&
(event.heartRate <= heartRateZone.upperLimit))
.length;
distributions.add(BarZone(
lower: counter,

4
lib/utils/path_painter.dart

@ -43,14 +43,14 @@ class PathPainter extends CustomPainter {
(Event record) => Offset(
width / 2 +
scale *
(record.db.positionLong -
(record.positionLong -
activity.db.swcLong / 2 -
activity.db.necLong / 2),
height / 2 +
scale *
(activity.db.necLat / 2 +
activity.db.swcLat / 2 -
record.db.positionLat),
record.positionLat),
),
)
.toList(),

8
lib/widgets/activity_widgets/activity_ecor_widget.dart

@ -38,10 +38,10 @@ class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
if (records.isNotEmpty) {
final List<Event> ecorRecords = records
.where((Event value) =>
value.db.power != null &&
value.db.power > 100 &&
value.db.speed != null &&
value.db.speed >= 1)
value.power != null &&
value.power > 100 &&
value.speed != null &&
value.speed >= 1)
.toList();
if (ecorRecords.isNotEmpty && ecorRecords != null) {

6
lib/widgets/activity_widgets/activity_form_power_widget.dart

@ -37,9 +37,9 @@ class _ActivityFormPowerWidgetState extends State<ActivityFormPowerWidget> {
if (records.isNotEmpty) {
final List<Event> formPowerRecords = records
.where((Event value) =>
value.db.formPower != null &&
value.db.formPower > 0 &&
value.db.formPower < 200)
value.formPower != null &&
value.formPower > 0 &&
value.formPower < 200)
.toList();
if (formPowerRecords.isNotEmpty) {

2
lib/widgets/activity_widgets/activity_ground_time_widget.dart

@ -37,7 +37,7 @@ class _ActivityGroundTimeWidgetState extends State<ActivityGroundTimeWidget> {
if (records.isNotEmpty) {
final List<Event> groundTimeRecords = records
.where((Event value) =>
value.db.groundTime != null && value.db.groundTime > 0)
value.groundTime != null && value.groundTime > 0)
.toList();
if (groundTimeRecords.isNotEmpty) {

2
lib/widgets/activity_widgets/activity_heart_rate_widget.dart

@ -38,7 +38,7 @@ class _ActivityHeartRateWidgetState extends State<ActivityHeartRateWidget> {
if (records.isNotEmpty) {
final List<Event> heartRateRecords = records
.where((Event value) =>
value.db.heartRate != null && value.db.heartRate > 10)
value.heartRate != null && value.heartRate > 10)
.toList();
if (heartRateRecords.isNotEmpty) {

4
lib/widgets/activity_widgets/activity_leg_spring_stiffness_widget.dart

@ -38,8 +38,8 @@ class _ActivityLegSpringStiffnessWidgetState
if (records.isNotEmpty) {
final List<Event> legSpringStiffnessRecords = records
.where((Event value) =>
value.db.legSpringStiffness != null &&
value.db.legSpringStiffness > 0)
value.legSpringStiffness != null &&
value.legSpringStiffness > 0)
.toList();
if (legSpringStiffnessRecords.isNotEmpty) {

2
lib/widgets/activity_widgets/activity_path_widget.dart

@ -32,7 +32,7 @@ class _ActivityPathWidgetState extends State<ActivityPathWidget> {
if (records.isNotEmpty) {
final List<Event> geoRecords = records
.where((Event value) =>
value.db.positionLong != null && value.db.positionLat != null)
value.positionLong != null && value.positionLat != null)
.toList();
if (geoRecords.isNotEmpty && geoRecords != null) {

2
lib/widgets/activity_widgets/activity_power_duration_widget.dart

@ -21,7 +21,7 @@ class ActivityPowerDurationWidget extends StatelessWidget {
if (snapshot.hasData) {
final List<Event> powerRecords = snapshot.data
.where((Event value) =>
value.db.power != null && value.db.power > 100)
value.power != null && value.power > 100)
.toList();
if (powerRecords.isNotEmpty) {

8
lib/widgets/activity_widgets/activity_power_per_heart_rate_widget.dart

@ -37,10 +37,10 @@ class _ActivityPowerPerHeartRateWidgetState
if (records.isNotEmpty) {
final List<Event> powerPerHeartRateRecords = records
.where((Event value) =>
value.db.power != null &&
value.db.power > 100 &&
value.db.heartRate != null &&
value.db.heartRate > 0)
value.power != null &&
value.power > 100 &&
value.heartRate != null &&
value.heartRate > 0)
.toList();
if (powerPerHeartRateRecords.isNotEmpty) {

10
lib/widgets/activity_widgets/activity_power_ratio_widget.dart

@ -37,11 +37,11 @@ class _ActivityPowerRatioWidgetState extends State<ActivityPowerRatioWidget> {
if (records.isNotEmpty) {
final List<Event> powerRecords = records
.where((Event value) =>
value.db.power != null &&
value.db.power > 100 &&
value.db.formPower != null &&
value.db.formPower > 0 &&
value.db.formPower < 200)
value.power != null &&
value.power > 100 &&
value.formPower != null &&
value.formPower > 0 &&
value.formPower < 200)
.toList();
if (powerRecords.isNotEmpty) {

6
lib/widgets/activity_widgets/activity_power_widget.dart

@ -42,7 +42,7 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
Widget build(BuildContext context) {
if (records.isNotEmpty && powerZones != null) {
final List<Event> powerRecords = records
.where((Event value) => value.db.power != null && value.db.power > 100)
.where((Event value) => value.power != null && value.power > 100)
.toList();
if (powerRecords.isNotEmpty) {
@ -89,9 +89,9 @@ class _ActivityPowerWidgetState extends State<ActivityPowerWidget> {
),
ListTile(
leading: const Text('🕵', style: TextStyle(fontSize: 25)),
title: Text(lastRecord.db.positionLong.semicirclesAsDegrees() +
title: Text(lastRecord.positionLong.semicirclesAsDegrees() +
' / ' +
lastRecord.db.positionLat.semicirclesAsDegrees()),
lastRecord.positionLat.semicirclesAsDegrees()),
subtitle: const Text('findYourStryd (last power record)'),
),
],

6
lib/widgets/activity_widgets/activity_speed_per_heart_rate_widget.dart

@ -37,9 +37,9 @@ class _ActivitySpeedPerHeartRateWidgetState
if (records.isNotEmpty) {
final List<Event> speedPerHeartRateRecords = records
.where((Event value) =>
value.db.speed != null &&
value.db.heartRate != null &&
value.db.heartRate > 0)
value.speed != null &&
value.heartRate != null &&
value.heartRate > 0)
.toList();
if (speedPerHeartRateRecords.isNotEmpty) {

6
lib/widgets/activity_widgets/activity_stride_ratio_widget.dart

@ -37,9 +37,9 @@ class _ActivityStrideRatioWidgetState extends State<ActivityStrideRatioWidget> {
if (records.isNotEmpty) {
final List<Event> strideRatioRecords = records
.where((Event value) =>
value.db.strydCadence != null &&
value.db.verticalOscillation != null &&
value.db.verticalOscillation != 0)
value.strydCadence != null &&
value.verticalOscillation != null &&
value.verticalOscillation != 0)
.toList();
if (strideRatioRecords.isNotEmpty) {

2
lib/widgets/activity_widgets/activity_stryd_cadence_widget.dart

@ -38,7 +38,7 @@ class _ActivityStrydCadenceWidgetState
if (records.isNotEmpty) {
final List<Event> powerRecords = records
.where((Event value) =>
value.db.strydCadence != null && value.db.strydCadence > 0)
value.strydCadence != null && value.strydCadence > 0)
.toList();
if (powerRecords.isNotEmpty) {

2
lib/widgets/activity_widgets/activity_vertical_oscillation_widget.dart

@ -37,7 +37,7 @@ class _ActivityVerticalOscillationWidgetState
Widget build(BuildContext context) {
if (records.isNotEmpty) {
final List<Event> powerRecords = records
.where((Event value) => value.db.verticalOscillation != null)
.where((Event value) => value.verticalOscillation != null)
.toList();
if (powerRecords.isNotEmpty) {

2
lib/widgets/charts/activity_charts/activity_ecor_chart.dart

@ -52,7 +52,7 @@ class ActivityEcorChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Ecor (W s/kg m)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_form_power_chart.dart

@ -47,7 +47,7 @@ class ActivityFormPowerChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Form Power (W)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_ground_time_chart.dart

@ -47,7 +47,7 @@ class ActivityGroundTimeChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Ground Time (ms)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_heart_rate_chart.dart

@ -50,7 +50,7 @@ class ActivityHeartRateChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
heartRateZones: heartRateZones,
domainTitle: 'Heart Rate (bpm)',

2
lib/widgets/charts/activity_charts/activity_leg_spring_stiffness_chart.dart

@ -48,7 +48,7 @@ class ActivityLegSpringStiffnessChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Leg Spring Stiffness (kN/m)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_power_chart.dart

@ -51,7 +51,7 @@ class ActivityPowerChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
powerZones: powerZones,
domainTitle: 'Power (W)',

2
lib/widgets/charts/activity_charts/activity_power_per_heart_rate_chart.dart

@ -48,7 +48,7 @@ class ActivityPowerPerHeartRateChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Power per Heart Rate (W/bpm)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_power_ratio_chart.dart

@ -48,7 +48,7 @@ class ActivityPowerRatioChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Power Ratio (%)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_speed_per_heart_rate_chart.dart

@ -47,7 +47,7 @@ class ActivitySpeedPerHeartRateChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Speed per Heart Rate (km/h / 100 bpm)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_stride_ratio_chart.dart

@ -48,7 +48,7 @@ class ActivityStrideRatioChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Stride Ratio (multiple)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_stryd_cadence_chart.dart

@ -47,7 +47,7 @@ class ActivityStrydCadenceChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Cadence (s/min)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

2
lib/widgets/charts/activity_charts/activity_vertical_oscillation_chart.dart

@ -48,7 +48,7 @@ class ActivityVerticalOscillationChart extends StatelessWidget {
height: 300,
child: MyLineChart(
data: data,
maxDomain: records.last.db.distance,
maxDomain: records.last.distance,
laps: laps,
domainTitle: 'Vertical Oscillation (cm)',
measureTickProviderSpec: const BasicNumericTickProviderSpec(

6
lib/widgets/charts/lap_charts/lap_ecor_chart.dart

@ -14,15 +14,15 @@ class LapEcorChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Ecor',
colorFn: (_, __) => MaterialPalette.gray.shade700,
domainFn: (Event record, _) => record.db.distance.round() - offset,
domainFn: (Event record, _) => record.distance.round() - offset,
measureFn: (Event record, _) =>
record.db.power / record.db.speed / weight,
record.power / record.speed / weight,
data: records,
)
];

6
lib/widgets/charts/lap_charts/lap_form_power_chart.dart

@ -11,14 +11,14 @@ class LapFormPowerChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Form Power',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (Event record, _) => record.db.distance.round() - offset,
measureFn: (Event record, _) => record.db.formPower,
domainFn: (Event record, _) => record.distance.round() - offset,
measureFn: (Event record, _) => record.formPower,
data: records,
)
];

6
lib/widgets/charts/lap_charts/lap_ground_time_chart.dart

@ -11,14 +11,14 @@ class LapGroundTimeChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Ground Time',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (Event record, _) => record.db.distance.round() - offset,
measureFn: (Event record, _) => record.db.groundTime,
domainFn: (Event record, _) => record.distance.round() - offset,
measureFn: (Event record, _) => record.groundTime,
data: records,
)
];

6
lib/widgets/charts/lap_charts/lap_heart_rate_chart.dart

@ -21,14 +21,14 @@ class LapHeartRateChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Heart Rate',
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
domainFn: (Event record, _) => record.db.distance.round() - offset,
measureFn: (Event record, _) => record.db.heartRate,
domainFn: (Event record, _) => record.distance.round() - offset,
measureFn: (Event record, _) => record.heartRate,
data: records,
)
];

6
lib/widgets/charts/lap_charts/lap_leg_spring_stiffness_chart.dart

@ -11,14 +11,14 @@ class LapLegSpringStiffnessChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Leg Spring Stiffness',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (Event record, _) => record.db.distance.round() - offset,
measureFn: (Event record, _) => record.db.groundTime,
domainFn: (Event record, _) => record.distance.round() - offset,
measureFn: (Event record, _) => record.groundTime,
data: records,
)
];

6
lib/widgets/charts/lap_charts/lap_power_chart.dart

@ -21,14 +21,14 @@ class LapPowerChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int offset = records.first.db.distance.round();
final int offset = records.first.distance.round();
final List<Series<Event, int>> data = <Series<Event, int>>[
Series<Event, int>(
id: 'Power',
colorFn: (_, __) =&