Commit 8a99595d authored by Administrator's avatar Administrator

switch lap detail screen from tabview to gridview, ecor on lap level

parent 524f429a
import 'package:encrateia/models/lap.dart';
import 'package:flutter/material.dart';
class ShowLapDetailScreen extends StatelessWidget {
final Lap lap;
final Widget widget;
final String title;
const ShowLapDetailScreen({
Key key,
@required this.lap,
this.widget,
this.title,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Lap ${lap.index.toString()}: $title',
overflow: TextOverflow.ellipsis,
),
),
body: widget,
);
}
}
import 'package:encrateia/screens/show_lap_detail_screen.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:encrateia/widgets/lap_widgets/lap_metadata_widget.dart';
import 'package:encrateia/widgets/lap_widgets/lap_overview_widget.dart';
import 'package:encrateia/widgets/lap_widgets/lap_heart_rate_widget.dart';
......@@ -22,73 +24,120 @@ class ShowLapScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 10,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
bottom: TabBar(
isScrollable: true,
tabs: [
Tab(
icon: MyIcon.overView,
text: "Overview",
),
Tab(
icon: MyIcon.heartRate,
text: "HR",
),
Tab(
icon: MyIcon.power,
text: "Power",
),
Tab(
icon: MyIcon.powerDuration,
text: "Power Duration",
),
Tab(
icon: MyIcon.groundTime,
text: "Ground Time",
),
Tab(
icon: MyIcon.legSpringStiffness,
text: "Leg spr.stiff.",
),
Tab(
icon: MyIcon.formPower,
text: "Form Power",
),
Tab(
icon: MyIcon.cadence,
text: "Cadence",
),
Tab(
icon: MyIcon.verticalOscillation,
text: "Vertical Oscillation",
),
Tab(
icon: MyIcon.metaData,
text: "Metadata",
),
],
),
title: Text(
'Lap ${lap.index}',
overflow: TextOverflow.ellipsis,
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title: Text(
'Lap ${lap.index}',
overflow: TextOverflow.ellipsis,
),
),
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(
title: "Overview",
color: MyColor.navigate,
icon: MyIcon.metaData,
context: context,
nextWidget: LapOverviewWidget(lap: lap),
),
navigationButton(
title: "Heart Rate",
color: MyColor.navigate,
icon: MyIcon.heartRate,
context: context,
nextWidget: LapHeartRateWidget(lap: lap),
),
navigationButton(
title: "Power",
color: MyColor.navigate,
icon: MyIcon.power,
context: context,
nextWidget: LapPowerWidget(lap: lap),
),
navigationButton(
title: "Power Duration",
color: MyColor.navigate,
icon: MyIcon.powerDuration,
context: context,
nextWidget: LapPowerDurationWidget(lap: lap),
),
navigationButton(
title: "Ground Time",
color: MyColor.navigate,
icon: MyIcon.groundTime,
context: context,
nextWidget: LapGroundTimeWidget(lap: lap),
),
navigationButton(
title: "Leg Spring Stiffness",
color: MyColor.navigate,
icon: MyIcon.legSpringStiffness,
context: context,
nextWidget: LapLegSpringStiffnessWidget(lap: lap),
),
navigationButton(
title: "Form Power",
color: MyColor.navigate,
icon: MyIcon.formPower,
context: context,
nextWidget: LapFormPowerWidget(lap: lap),
),
navigationButton(
title: "Cadence",
color: MyColor.navigate,
icon: MyIcon.cadence,
context: context,
nextWidget: LapStrydCadenceWidget(lap: lap),
),
navigationButton(
title: "Vertical Oscillation",
color: MyColor.navigate,
icon: MyIcon.verticalOscillation,
context: context,
nextWidget: LapVerticalOscillationWidget(lap: lap),
),
navigationButton(
title: "Metadata",
color: MyColor.navigate,
icon: MyIcon.metaData,
context: context,
nextWidget: LapMetadataWidget(lap: lap),
),
],
);
}),
);
}
navigationButton({
@required BuildContext context,
@required Widget nextWidget,
@required Widget icon,
@required String title,
@required Color color,
Color textColor,
}) {
return RaisedButton.icon(
color: color ?? MyColor.primary,
textColor: textColor ?? MyColor.black,
icon: icon,
label: Text(title),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShowLapDetailScreen(
lap: lap,
widget: nextWidget,
title: title,
),
),
body: TabBarView(children: [
LapOverviewWidget(lap: lap),
LapHeartRateWidget(lap: lap),
LapPowerWidget(lap: lap),
LapPowerDurationWidget(lap: lap),
LapGroundTimeWidget(lap: lap),
LapLegSpringStiffnessWidget(lap: lap),
LapFormPowerWidget(lap: lap),
LapStrydCadenceWidget(lap: lap),
LapVerticalOscillationWidget(lap: lap),
LapMetadataWidget(lap: lap),
]),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
class LapEcorChart extends StatelessWidget {
final List<Event> records;
final double weight;
LapEcorChart({
this.records,
@required this.weight,
});
@override
Widget build(BuildContext context) {
var offset = records.first.db.distance.round();
List<Series<dynamic, num>> data = [
Series<Event, int>(
id: 'Ecor',
colorFn: (_, __) => MaterialPalette.gray.shade700,
domainFn: (Event record, _) => record.db.distance.round() - offset,
measureFn: (Event record, _) =>
record.db.power / record.db.speed / weight,
data: records,
)
];
return Container(
height: 300,
child: LineChart(
data,
primaryMeasureAxis: NumericAxisSpec(
tickProviderSpec: BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: true,
desiredTickCount: 6),
),
animate: false,
behaviors: [
ChartTitle(
"Ecor (W s/kg m)",
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
),
);
}
}
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/weight.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_ecor_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:encrateia/utils/num_utils.dart';
class LapEcorWidget extends StatefulWidget {
final Lap lap;
final Athlete athlete;
LapEcorWidget({
@required this.lap,
@required this.athlete,
});
@override
_LapEcorWidgetState createState() => _LapEcorWidgetState();
}
class _LapEcorWidgetState extends State<LapEcorWidget> {
List<Event> records = [];
Weight weight;
String weightString;
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(context) {
if (records.length > 0) {
var powerRecords = records
.where((value) =>
value.db.power != null &&
value.db.power > 100 &&
value.db.speed != null &&
value.db.speed >= 1)
.toList();
if (powerRecords.length > 0) {
return ListTileTheme(
iconColor: Colors.lightGreen,
child: ListView(
padding: EdgeInsets.only(left: 25),
children: <Widget>[
LapEcorChart(
records: powerRecords,
weight: weight.db.value,
),
Text('${widget.athlete.db.recordAggregationCount} records are '
'aggregated into one point in the plot. Only records where '
'power > 0 W and speed > 1 m/s are shown.'),
Divider(),
ListTile(
leading: MyIcon.weight,
title: Text(weightString),
subtitle: Text("weight"),
),
ListTile(
leading: MyIcon.amount,
title: Text(powerRecords.length.toString()),
subtitle: Text("number of measurements"),
),
],
),
);
} else {
return Center(
child: Text("No power data available."),
);
}
} else {
return Center(
child: Text("Loading"),
);
}
}
getData() async {
records = await widget.lap.records;
weight = await Weight.getBy(
athletesId: widget.athlete.db.id,
date: widget.lap.db.startTime,
);
weightString = weight.db.value.toStringOrDashes(2) + " kg";
setState(() {});
}
}
......@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_power_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_power_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapPowerWidget extends StatefulWidget {
......
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