Commit d7c328f8 authored by Stefan Haslinger's avatar Stefan Haslinger

switch to navigation buttons on activity level, ecor widget (still with power in it, though)

parent e886a571
import 'package:encrateia/utils/my_color.dart';
import 'package:encrateia/widgets/activity_widgets/activity_metadata_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_overview_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_power_ratio_widget.dart';
......@@ -5,6 +6,7 @@ import 'package:encrateia/widgets/activity_widgets/activity_speed_per_heart_rate
import 'package:encrateia/widgets/laps_list_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_heart_rate_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_power_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_ecor_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_power_duration_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_power_per_heart_rate_widget.dart';
import 'package:encrateia/widgets/activity_widgets/activity_ground_time_widget.dart';
......@@ -36,141 +38,152 @@ class ShowActivityScreen extends StatelessWidget {
overflow: TextOverflow.ellipsis,
),
),
body: Table(
children: [
TableRow(
children: [
detailTile(
title: "Overview",
icon: MyIcon.overView,
context: context,
nextWidget: ActivityOverviewWidget(activity: activity),
),
detailTile(
title: 'Laps',
icon: MyIcon.laps,
context: context,
nextWidget: LapsListWidget(activity: activity),
),
],
),
TableRow(children: [
detailTile(
body: new OrientationBuilder(builder: (context, orientation) {
return GridView.count(
padding: EdgeInsets.all(5),
crossAxisCount: orientation == Orientation.portrait ? 2 : 4,
childAspectRatio: 3,
crossAxisSpacing: 3,
mainAxisSpacing: 3,
children: [
navigationButton(
color: MyColor.settings,
title: "Overview",
icon: MyIcon.overView,
context: context,
nextWidget: ActivityOverviewWidget(activity: activity),
),
navigationButton(
title: 'Laps',
color: MyColor.detail,
icon: MyIcon.laps,
context: context,
nextWidget: LapsListWidget(activity: activity),
),
navigationButton(
title: "Heart Rate",
color: MyColor.navigate,
icon: MyIcon.heartRate,
context: context,
nextWidget: ActivityHeartRateWidget(activity: activity),
),
detailTile(
navigationButton(
title: "Power",
color: MyColor.navigate,
icon: MyIcon.power,
context: context,
nextWidget: ActivityPowerWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
title: "Power Duration",
navigationButton(
title: "Power\nDuration",
color: MyColor.navigate,
icon: MyIcon.powerDuration,
context: context,
nextWidget: ActivityPowerDurationWidget(activity: activity),
),
detailTile(
title: "Power / Heart Rate",
navigationButton(
title: "Power /\nHeart Rate",
color: MyColor.navigate,
icon: MyIcon.power,
context: context,
nextWidget: ActivityPowerPerHeartRateWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
title: "Speed / Heart Rate",
navigationButton(
title: "Ecor",
color: MyColor.navigate,
icon: MyIcon.power,
context: context,
nextWidget: ActivityEcorWidget(activity: activity),
),
navigationButton(
title: "Speed /\nHeart Rate",
color: MyColor.navigate,
icon: MyIcon.speed,
context: context,
nextWidget: ActivitySpeedPerHeartRateWidget(activity: activity),
),
detailTile(
navigationButton(
title: "Ground Time",
color: MyColor.navigate,
icon: MyIcon.groundTime,
context: context,
nextWidget: ActivityGroundTimeWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
navigationButton(
title: "Form Power",
color: MyColor.navigate,
icon: MyIcon.formPower,
context: context,
nextWidget: ActivityFormPowerWidget(activity: activity),
),
detailTile(
navigationButton(
title: "Power Ratio",
color: MyColor.navigate,
icon: MyIcon.formPower,
context: context,
nextWidget: ActivityPowerRatioWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
title: "Vertical Oscillation",
navigationButton(
title: "Vertical\nOscillation",
color: MyColor.navigate,
icon: MyIcon.verticalOscillation,
context: context,
nextWidget: ActivityVerticalOscillationWidget(activity: activity),
),
detailTile(
navigationButton(
title: "Stride Ratio",
color: MyColor.navigate,
icon: MyIcon.strideRatio,
context: context,
nextWidget: ActivityStrideRatioWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
navigationButton(
title: "Cadence",
color: MyColor.navigate,
icon: MyIcon.cadence,
context: context,
nextWidget: ActivityStrydCadenceWidget(activity: activity),
),
detailTile(
title: "Leg Spring Stiffness",
navigationButton(
title: "Leg Spring\nStiffness",
color: MyColor.navigate,
icon: MyIcon.legSpringStiffness,
context: context,
nextWidget: ActivityLegSpringStiffnessWidget(activity: activity),
),
]),
TableRow(children: [
detailTile(
navigationButton(
title: "Metadata",
color: MyColor.settings,
icon: MyIcon.metaData,
context: context,
nextWidget: ActivityMetadataWidget(activity: activity),
),
Text(""),
]),
],
),
],
);
}),
);
}
detailTile({
BuildContext context,
Widget nextWidget,
Widget icon,
String title,
navigationButton({
@required BuildContext context,
@required Widget nextWidget,
@required Widget icon,
@required String title,
@required Color color,
Color textColor,
}) {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
child: ListTile(
leading: icon,
title: Text(title),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShowActivityDetailScreen(
activity: activity,
widget: nextWidget,
title: title,
),
return RaisedButton.icon(
color: color ?? MyColor.primary,
textColor: textColor ?? MyColor.black,
icon: icon,
label: Text(title),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShowActivityDetailScreen(
activity: activity,
widget: nextWidget,
title: title,
),
),
),
......
......@@ -153,10 +153,10 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
}
navigationButton({
Widget nextWidget,
Widget icon,
String title,
Color color,
@required Widget nextWidget,
@required Widget icon,
@required String title,
@required Color color,
Color textColor,
}) {
return RaisedButton.icon(
......
import 'package:encrateia/models/power_zone.dart';
import 'package:encrateia/models/power_zone_schema.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/actitvity_charts/activity_power_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:encrateia/utils/date_time_utils.dart';
class ActivityEcorWidget extends StatefulWidget {
final Activity activity;
ActivityEcorWidget({this.activity});
@override
_ActivityEcorWidgetState createState() => _ActivityEcorWidgetState();
}
class _ActivityEcorWidgetState extends State<ActivityEcorWidget> {
List<Event> records = [];
String avgPowerString = "Loading ...";
String minPowerString = "Loading ...";
String maxPowerString = "Loading ...";
String sdevPowerString = "Loading ...";
PowerZoneSchema powerZoneSchema;
List<PowerZone> powerZones;
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(context) {
if (records.length > 0 && powerZones != null) {
var powerRecords = records
.where((value) => value.db.power != null && value.db.power > 100)
.toList();
if (powerRecords.length > 0) {
var lastRecord = powerRecords.last;
return ListTileTheme(
iconColor: Colors.deepOrange,
child: ListView(
padding: EdgeInsets.only(left: 25),
children: <Widget>[
ActivityPowerChart(
records: powerRecords,
activity: widget.activity,
powerZones: powerZones,
),
ListTile(
leading: MyIcon.average,
title: Text(avgPowerString),
subtitle: Text("average power"),
),
ListTile(
leading: MyIcon.minimum,
title: Text(minPowerString),
subtitle: Text("minimum power"),
),
ListTile(
leading: MyIcon.maximum,
title: Text(maxPowerString),
subtitle: Text("maximum power"),
),
ListTile(
leading: MyIcon.standardDeviation,
title: Text(sdevPowerString),
subtitle: Text("standard deviation power"),
),
ListTile(
leading: MyIcon.amount,
title: Text(powerRecords.length.toString()),
subtitle: Text("number of measurements"),
),
ListTile(
leading: Text("🕵️‍♀️", style: TextStyle(fontSize: 25)),
title: Text(lastRecord.db.positionLong.semicirclesAsDegrees() +
" / " +
lastRecord.db.positionLat.semicirclesAsDegrees()),
subtitle: Text("findYourStryd (last power record)"),
),
],
),
);
} else {
return Center(
child: Text("No power data available."),
);
}
} else {
return Center(
child: Text("Loading"),
);
}
}
getData() async {
Activity activity = widget.activity;
records = await activity.records;
avgPowerString = activity.db.avgPower.toStringOrDashes(1) + " W";
minPowerString = activity.db.minPower.toString() + " W";
maxPowerString = activity.db.maxPower.toString() + " W";
sdevPowerString = activity.db.sdevPower.toStringOrDashes(2) + " W";
powerZoneSchema = await activity.getPowerZoneSchema();
if (powerZoneSchema != null)
powerZones = await powerZoneSchema.powerZones;
else
powerZones = [];
setState(() {});
}
}
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