Commit ff13fdbd authored by Administrator's avatar Administrator

show at least 40 activities on athlete level

parent 75868466
...@@ -24,16 +24,26 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> { ...@@ -24,16 +24,26 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
@override @override
Widget build(context) { Widget build(context) {
if (activities.length > 0) { if (activities.length == 0) {
return Center(
child: Text("Loading"),
);
} else {
var ecorActivities = activities var ecorActivities = activities
.where((activity) => .where((activity) =>
activity.db.avgPower != null && activity.db.avgPower != null &&
activity.db.avgPower > 0 && activity.db.avgPower > 0 &&
activity.db.avgSpeed != null && activity.db.avgSpeed != null)
activity.weight != null)
.toList(); .toList();
if (ecorActivities.length == 0) {
if (ecorActivities.length > 0) { return Center(
child: Text("No ecor data available."),
);
} else if (ecorActivities.first.weight == null) {
return Center(
child: Text("Please enter your (historical) weight in the settings."),
);
} else {
return ListTileTheme( return ListTileTheme(
iconColor: Colors.orange, iconColor: Colors.orange,
child: ListView( child: ListView(
...@@ -43,15 +53,7 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> { ...@@ -43,15 +53,7 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
], ],
), ),
); );
} else {
return Center(
child: Text("No Ecor available."),
);
} }
} else {
return Center(
child: Text("Loading"),
);
} }
} }
...@@ -64,7 +66,7 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> { ...@@ -64,7 +66,7 @@ class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
athletesId: activity.db.athletesId, athletesId: activity.db.athletesId,
date: activity.db.timeCreated, date: activity.db.timeCreated,
); );
activity.weight = weight.db.value; activity.weight = weight?.db?.value;
} }
setState(() {}); setState(() {});
} }
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:encrateia/models/activity_list.dart'; import 'package:encrateia/models/activity_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -23,6 +25,10 @@ class AthleteEcorChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthleteEcorChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:encrateia/models/activity_list.dart'; import 'package:encrateia/models/activity_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -23,6 +25,10 @@ class AthletePowerChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthletePowerChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart'; import 'package:encrateia/models/activity.dart';
...@@ -23,6 +25,10 @@ class AthletePowerPerHeartRateChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthletePowerPerHeartRateChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart'; import 'package:encrateia/models/activity.dart';
...@@ -23,6 +25,10 @@ class AthletePowerRatioChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthletePowerRatioChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart'; import 'package:encrateia/models/activity.dart';
...@@ -23,6 +25,10 @@ class AthleteSpeedPerHeartRateChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthleteSpeedPerHeartRateChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
import 'dart:math';
import 'package:charts_flutter/flutter.dart'; import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart'; import 'package:encrateia/models/activity.dart';
...@@ -23,6 +25,10 @@ class AthleteStrideRatioChart extends StatelessWidget { ...@@ -23,6 +25,10 @@ class AthleteStrideRatioChart extends StatelessWidget {
DateTime.now().difference(activity.db.timeCreated).inDays < DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays) xAxesDays)
.toList(); .toList();
if (recentActivities.length < 40) {
int amount = min(activities.length, 40);
recentActivities = activities.sublist(0, amount);
}
var data = [ var data = [
Series<Activity, DateTime>( Series<Activity, DateTime>(
......
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