Commit 9f151505 authored by Administrator's avatar Administrator

activity show screen started

parent 6dc804e6
......@@ -96,7 +96,7 @@ class Activity extends ChangeNotifier {
case "file_id":
db
..serialNumber = dataMessage.get('serial_number').round()
..serialNumber = dataMessage.get('serial_number')?.round()
..timeCreated =
dateTimeFromStrava(dataMessage.get('time_created'))
..save();
......@@ -132,26 +132,26 @@ class Activity extends ChangeNotifier {
..startTime = dateTimeFromStrava(dataMessage.get('start_time'))
..startPositionLat = dataMessage.get('start_position_lat')
..startPositionLong = dataMessage.get('start_position_long')
..totalElapsedTime = dataMessage.get('total_elapsed_time').round()
..totalTimerTime = dataMessage.get('total_timer_time').round()
..totalDistance = dataMessage.get('total_distance').round()
..totalStrides = dataMessage.get('total_strides').round()
..totalElapsedTime = dataMessage.get('total_elapsed_time')?.round()
..totalTimerTime = dataMessage.get('total_timer_time')?.round()
..totalDistance = dataMessage.get('total_distance')?.round()
..totalStrides = dataMessage.get('total_strides')?.round()
..necLat = dataMessage.get('nec_lat')
..necLong = dataMessage.get('nec_long')
..swcLat = dataMessage.get('swc_lat')
..swcLong = dataMessage.get('swc_long')
..totalCalories = dataMessage.get('total_calories').round()
..totalCalories = dataMessage.get('total_calories')?.round()
..avgSpeed = dataMessage.get('avg_speed')
..maxSpeed = dataMessage.get('max_speed')
..totalAscent = dataMessage.get('total_ascent').round()
..totalDescent = dataMessage.get('total_descent').round()
..totalAscent = dataMessage.get('total_ascent')?.round()
..totalDescent = dataMessage.get('total_descent')?.round()
..maxRunningCadence =
dataMessage.get('max_running_cadence').round()
..firstLapIndex = dataMessage.get('first_lap_index').round()
..numLaps = dataMessage.get('num_laps').round()
..event = dataMessage.get('event').toString()
dataMessage.get('max_running_cadence')?.round()
..firstLapIndex = dataMessage.get('first_lap_index')?.round()
..numLaps = dataMessage.get('num_laps')?.round()
..event = dataMessage.get('event')?.toString()
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..eventGroup = dataMessage.get('event_group')?.round()
..trigger = dataMessage.get('trigger')
..avgVerticalOscillation =
dataMessage.get('avg_vertical_oscillation')
......@@ -160,13 +160,13 @@ class Activity extends ChangeNotifier {
..avgStanceTime = dataMessage.get('avg_stance_time')
..sport = dataMessage.get('sport')
..subSport = dataMessage.get('sub_sport')
..avgHeartRate = dataMessage.get('avg_heart_rate').round()
..maxHeartRate = dataMessage.get('max_heart_rate').round()
..avgHeartRate = dataMessage.get('avg_heart_rate')?.round()
..maxHeartRate = dataMessage.get('max_heart_rate')?.round()
..avgRunningCadence = dataMessage.get('avg_running_cadence')
..totalTrainingEffect =
dataMessage.get('total_training_effect').round()
..avgTemperature = dataMessage.get('avg_temperature').round()
..maxTemperature = dataMessage.get('max_temperature').round()
dataMessage.get('total_training_effect')?.round()
..avgTemperature = dataMessage.get('avg_temperature')?.round()
..maxTemperature = dataMessage.get('max_temperature')?.round()
..avgFractionalCadence = dataMessage.get('avg_fractional_cadence')
..maxFractionalCadence = dataMessage.get('max_fractional_cadence')
..totalFractionalCycles =
......@@ -177,7 +177,7 @@ class Activity extends ChangeNotifier {
case "activity":
db
..numSessions = dataMessage.get('num_sessions').round()
..numSessions = dataMessage.get('num_sessions')?.round()
..localTimestamp =
dateTimeFromStrava(dataMessage.get('local_timestamp'))
..save();
......@@ -193,7 +193,11 @@ class Activity extends ChangeNotifier {
}
}
}
print("All elements of activity ${db.stravaId} persisted.");
db.state = "persisted";
db.save();
notifyListeners();
print("Persisted activity ${db.stravaId} to database.");
}
static queryStrava({Athlete athlete}) async {
......
......@@ -11,7 +11,7 @@ class Event {
Event({DataMessage dataMessage, this.activity}) {
if (dataMessage.any('max_heart_rate')) {
activity.db
..maxHeartRate = dataMessage.get('max_heart_rate').round()
..maxHeartRate = dataMessage.get('max_heart_rate')?.round()
..save();
} else if (dataMessage.values.any((value) =>
value.fieldName == 'event_type' &&
......@@ -20,7 +20,7 @@ class Event {
..activitiesId = activity.db.id
..event = dataMessage.get('event')
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..eventGroup = dataMessage.get('event_group')?.round()
..timerTrigger = dataMessage.get('timer_trigger')
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..save();
......@@ -28,9 +28,9 @@ class Event {
value.fieldName == 'event_type' && ['marker'].contains(value.value))) {
db = DbEvent()
..activitiesId = activity.db.id
..event = dataMessage.get('event').toString()
..event = dataMessage.get('event')?.toString()
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..eventGroup = dataMessage.get('event_group')?.round()
..data = dataMessage.get('data')
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..save();
......@@ -48,14 +48,14 @@ class Event {
..distance = dataMessage.get('distance')
..altitude = dataMessage.get('altitude')
..speed = dataMessage.get('speed')
..heartRate = dataMessage.get('heart_rate').round()
..heartRate = dataMessage.get('heart_rate')?.round()
..cadence = dataMessage.get('cadence')
..fractionalCadence = dataMessage.get('fractional_cadence')
..power = dataMessage.get('Power').round()
..power = dataMessage.get('Power')?.round()
..strydCadence = dataMessage.get('Cadence')
..groundTime = dataMessage.get('Ground Time')
..verticalOscillation = dataMessage.get('Vertical Oscillation')
..formPower = dataMessage.get('Form Power').round()
..formPower = dataMessage.get('Form Power')?.round()
..legSpringStiffness = dataMessage.get('Leg Spring Stiffness')
..save();
}
......@@ -66,13 +66,13 @@ class Event {
..positionLat = dataMessage.get('end_position_lat')
..positionLong = dataMessage.get('end_position_long')
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..event = dataMessage.get('event').toString()
..event = dataMessage.get('event')?.toString()
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..eventGroup = dataMessage.get('event_group')?.round()
..speed = dataMessage.get('avg_speed')
..verticalOscillation = dataMessage.get('avg_vertical_oscillation')
..fractionalCadence = dataMessage.get('avg_fractional_cadence')
..heartRate = dataMessage.get('avg_heart_rate').round()
..heartRate = dataMessage.get('avg_heart_rate')?.round()
..cadence = dataMessage.get('avg_running_cadence')
..timerTrigger = dataMessage.get('lap_trigger')
..distance = dataMessage.get('total_distance')
......
......@@ -17,31 +17,31 @@ class Lap {
..startPositionLong = dataMessage.get('start_position_long')
..endPositionLong = dataMessage.get('end_position_lat')
..startPositionLat = dataMessage.get('end_position_long')
..avgHeartRate = dataMessage.get('avg_heart_rate').round()
..maxHeartRate = dataMessage.get('max_heart_rate').round()
..avgHeartRate = dataMessage.get('avg_heart_rate')?.round()
..maxHeartRate = dataMessage.get('max_heart_rate')?.round()
..avgRunningCadence = dataMessage.get('avg_running_cadence')
..event = dataMessage.get('event')
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..eventGroup = dataMessage.get('event_group')?.round()
..sport = dataMessage.get('sport')
..subSport = dataMessage.get('sub_sport')
..avgVerticalOscillation = dataMessage.get('avg_vertical_oscillation')
..totalElapsedTime = dataMessage.get('total_elapsed_time').round()
..totalTimerTime = dataMessage.get('total_timer_time').round()
..totalDistance = dataMessage.get('total_distance').round()
..totalStrides = dataMessage.get('total_strides').round()
..totalCalories = dataMessage.get('total_calories').round()
..totalElapsedTime = dataMessage.get('total_elapsed_time')?.round()
..totalTimerTime = dataMessage.get('total_timer_time')?.round()
..totalDistance = dataMessage.get('total_distance')?.round()
..totalStrides = dataMessage.get('total_strides')?.round()
..totalCalories = dataMessage.get('total_calories')?.round()
..avgSpeed = dataMessage.get('avg_speed')
..maxSpeed = dataMessage.get('max_speed')
..totalAscent = dataMessage.get('total_ascent').round()
..totalDescent = dataMessage.get('total_descent').round()
..totalAscent = dataMessage.get('total_ascent')?.round()
..totalDescent = dataMessage.get('total_descent')?.round()
..avgStanceTimePercent = dataMessage.get('avg_stance_time_percent')
..avgStanceTime = dataMessage.get('avg_stance_time')
..maxRunningCadence = dataMessage.get('max_running_cadence').round()
..intensity = dataMessage.get('intensity').round()
..maxRunningCadence = dataMessage.get('max_running_cadence')?.round()
..intensity = dataMessage.get('intensity')?.round()
..lapTrigger = dataMessage.get('lap_trigger')
..avgTemperature = dataMessage.get('avg_temperature').round()
..maxTemperature = dataMessage.get('max_temperature').round()
..avgTemperature = dataMessage.get('avg_temperature')?.round()
..maxTemperature = dataMessage.get('max_temperature')?.round()
..avgFractionalCadence = dataMessage.get('avg_fractional_cadence')
..maxFractionalCadence = dataMessage.get('max_fractional_cadence')
..totalFractionalCycles = dataMessage.get('total_fractional_cycles')
......
......@@ -2,6 +2,7 @@ import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'show_activity.dart';
class ListActivitiesScreen extends StatefulWidget {
final Athlete athlete;
......@@ -35,7 +36,7 @@ class _ListActivitiesScreenState extends State<ListActivitiesScreen> {
ListTile(
leading: Icon(Icons.cloud_download),
title: Text("Download Activities from Strava"),
onTap: () => Activity.queryStrava(athlete: athlete),
onTap: () => Activity.queryStrava(athlete: widget.athlete),
),
if (widget.athlete.password == null)
ListTile(
......@@ -96,6 +97,32 @@ class _ListActivitiesScreenState extends State<ListActivitiesScreen> {
],
);
break;
case "persisted":
return Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(Icons.remove_red_eye),
onPressed: () => {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShowActivityScreen(
activity: activity,
),
),
)
},
tooltip: 'Show details',
),
IconButton(
icon: Icon(Icons.details),
onPressed: () => activity.parse(athlete: athlete),
tooltip: 'Parse .fit-file',
),
],
);
break;
default:
return Text(activity.db.state);
}
......
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:intl/intl.dart';
class ShowActivityScreen extends StatelessWidget {
final Activity activity;
const ShowActivityScreen({
Key key,
this.activity,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Activity ${activity.db.name}',
overflow: TextOverflow.ellipsis,
),
),
body: ListView(
children: <Widget>[
ListTile(
leading: Icon(Icons.title),
title: Text(activity.db.name),
),
ListTile(
leading: Icon(Icons.fingerprint),
title: Text(activity.db.stravaId.toString()),
subtitle: Text(activity.db.serialNumber.toString()),
trailing: Text("Strava id \nGarmin id"),
),
ListTile(
leading: Icon(Icons.timer),
title: Text(Duration(seconds: activity.db.movingTime).print()),
trailing: Text('moving time (hh:mm:ss)'),
),
ListTile(
leading: Icon(Icons.directions_bike),
title: Text(activity.db.type),
subtitle: Text(activity.db.sport + '/' + activity.db.subSport),
trailing: Text('activity type \nsport / sub sport'),
),
ListTile(
leading: Icon(Icons.access_time),
title: Text(DateFormat("dd MMM yyyy hh:mm:ss").format(activity.db.timeCreated)),
trailing: Text('time created'),
),
ListTile(
leading: Icon(Icons.redo),
title: Text('${(activity.db.distance / 1000).toStringAsFixed(2)} km'),
trailing: Text('distance'),
),
],
),
);
}
//double startPositionLat;
//double startPositionLong;
//String event;
//String eventType;
//int eventGroup;
//int totalDistance;
//int totalStrides;
//int totalCalories;
//double avgSpeed;
//double maxSpeed;
//int totalAscent;
//int totalDescent;
//int maxRunningCadence;
//String trigger;
//int avgTemperature;
//int maxTemperature;
//double avgFractionalCadence;
//double maxFractionalCadence;
//double totalFractionalCycles;
//double avgStanceTimePercent;
//double avgStanceTime;
//int avgHeartRate;
//int maxHeartRate;
//double avgRunningCadence;
//double avgVerticalOscillation;
//int totalElapsedTime;
//int totalTimerTime;
//int totalTrainingEffect;
//double necLat;
//double necLong;
//double swcLat;
//double swcLong;
//int firstLapIndex;
//int numLaps;
//int numSessions;
//DateTime localTimestamp;
//int athletesId;
}
......@@ -4,3 +4,8 @@ dateTimeFromStrava(double dateTime) {
(dateTime.round() + 631065600) * 1000);
}
extension DurationFormatters on Duration {
String print() {
return "$inHours h ${inMinutes.remainder(60)} min ${inSeconds.remainder(60)} s";
}
}
......@@ -203,7 +203,7 @@ packages:
name: fit_parser
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
version: "0.1.6"
fixnum:
dependency: transitive
description:
......
......@@ -19,7 +19,7 @@ dependencies:
dio_cookie_manager: ^1.0.0
flutter_secure_storage: ^3.3.1+1
provider: ^3.2.0
fit_parser: ^0.1.5
fit_parser: ^0.1.6
dev_dependencies:
flutter_test:
......
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