diff --git a/lib/common_widget/container/list/list_activity_widget.dart b/lib/common_widget/container/list/list_activity_widget.dart index bcaaba8..8d85253 100644 --- a/lib/common_widget/container/list/list_activity_widget.dart +++ b/lib/common_widget/container/list/list_activity_widget.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:smartfit_app_mobile/common_widget/container/workout_row.dart'; +import 'package:smartfit_app_mobile/common_widget/container/workout_row/workout_row_generic.dart'; +import 'package:smartfit_app_mobile/common_widget/container/workout_row/workout_row_walking.dart'; import 'package:smartfit_app_mobile/modele/activity.dart'; import 'package:smartfit_app_mobile/modele/manager_file.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; @@ -20,6 +21,48 @@ class _ListActivityWidget extends State { @override Widget build(BuildContext context) { + void onClick(ActivityOfUser activityObj) async { + if (!Provider.of(context, listen: false) + .managerSelectedActivity + .fileNotSelected(activityObj.fileUuid)) { + Provider.of(context, listen: false) + .managerSelectedActivity + .removeSelectedActivity(activityObj.fileUuid); + setState(() {}); + return; + } + + Tuple2 result = + await _utile.getContentActivity(context, activityObj); + if (!result.item1) { + return; + } + + Provider.of(context, listen: false).removeActivity(activityObj); + Provider.of(context, listen: false).insertActivity(0, activityObj); + } + + void onDelete(ActivityOfUser activityObj) async { + if (await _utile.deleteFileOnBDD( + Provider.of(context, listen: false).token, + activityObj.fileUuid)) { + if (!Provider.of(context, listen: false) + .managerSelectedActivity + .fileNotSelected(activityObj.fileUuid)) { + Provider.of(context, listen: false) + .managerSelectedActivity + .removeSelectedActivity(activityObj.fileUuid); + } + Provider.of(context, listen: false).removeActivity(activityObj); + } + } + + bool isSelected(ActivityOfUser activityObj) { + return !Provider.of(context) + .managerSelectedActivity + .fileNotSelected(activityObj.fileUuid); + } + return Material( color: Colors.transparent, child: ListView.builder( @@ -34,57 +77,28 @@ class _ListActivityWidget extends State { // -- Si categorie == marche if (activityObj.category == managerFile.marche) { activityMap = activityObj.toMapWalking(); + return InkWell( + onTap: () {}, + child: WorkoutRowWalking( + wObj: activityMap, + onDelete: () => onDelete(activityObj), + onClick: () => onClick(activityObj), + isSelected: isSelected(activityObj), + ), + ); } else { // -- Default -- // activityMap = activityObj.toMapGeneric(); + return InkWell( + onTap: () {}, + child: WorkoutRowGeneric( + wObj: activityMap, + onDelete: () => onDelete(activityObj), + onClick: () => onClick(activityObj), + isSelected: isSelected(activityObj), + ), + ); } - - return InkWell( - onTap: () {}, - child: WorkoutRow( - wObj: activityMap, - onDelete: () async { - if (await _utile.deleteFileOnBDD( - Provider.of(context, listen: false).token, - activityObj.fileUuid)) { - if (!Provider.of(context, listen: false) - .managerSelectedActivity - .fileNotSelected(activityObj.fileUuid)) { - Provider.of(context, listen: false) - .managerSelectedActivity - .removeSelectedActivity(activityObj.fileUuid); - } - Provider.of(context, listen: false) - .removeActivity(activityObj); - } - }, - onClick: () async { - if (!Provider.of(context, listen: false) - .managerSelectedActivity - .fileNotSelected(activityObj.fileUuid)) { - Provider.of(context, listen: false) - .managerSelectedActivity - .removeSelectedActivity(activityObj.fileUuid); - setState(() {}); - return; - } - - Tuple2 result = - await _utile.getContentActivity(context, activityObj); - if (!result.item1) { - return; - } - - Provider.of(context, listen: false) - .removeActivity(activityObj); - Provider.of(context, listen: false) - .insertActivity(0, activityObj); - }, - isSelected: !Provider.of(context) - .managerSelectedActivity - .fileNotSelected(activityObj.fileUuid), - ), - ); }, ), ); diff --git a/lib/common_widget/container/workout_row/workout_row_generic.dart b/lib/common_widget/container/workout_row/workout_row_generic.dart new file mode 100644 index 0000000..fa733a9 --- /dev/null +++ b/lib/common_widget/container/workout_row/workout_row_generic.dart @@ -0,0 +1,118 @@ +import 'package:flutter_svg/svg.dart'; +import 'package:smartfit_app_mobile/common/colo_extension.dart'; +import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/modele/convertisseur.dart'; + +class WorkoutRowGeneric extends StatelessWidget { + final Map wObj; + final bool isSelected; + final VoidCallback onDelete; + final VoidCallback onClick; + + const WorkoutRowGeneric({ + Key? key, + required this.wObj, + required this.onDelete, + required this.onClick, + required this.isSelected, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onClick, + child: Container( + margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 2), + decoration: BoxDecoration( + border: Border.all( + color: isSelected + ? const Color.fromARGB(255, 144, 252, 148) + : Colors.transparent, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), + ), + child: Material( + color: isSelected + ? const Color.fromARGB(255, 240, 255, 240) + : Colors.transparent, + child: InkWell( + borderRadius: + BorderRadius.circular(10), // Utiliser le même borderRadius + splashColor: const Color.fromARGB(255, 42, 94, 44) + .withOpacity(0.3), // Couleur du fond au survol + onTap: onClick, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(10), + child: SvgPicture.asset( + wObj["image"].toString(), + width: 60, + height: 60, + fit: BoxFit.cover, + ), + ), + const SizedBox(width: 15), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Type : ${wObj["categorie"].toString()}", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ), + Text( + "Date : ${wObj["date"].toString()}", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ), + Text( + "Temps : ${Convertisseur.secondeIntoMinute(wObj["time"]).toStringAsFixed(2)} m", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ) + ], + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + IconButton( + onPressed: onClick, + icon: Image.asset( + "assets/img/next_icon.png", + width: 30, + height: 30, + fit: BoxFit.contain, + ), + ), + IconButton( + onPressed: onDelete, + icon: Image.asset( + "assets/img/corbeille.png", + width: 30, + height: 30, + fit: BoxFit.contain, + ), + ), + ], + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/common_widget/container/workout_row.dart b/lib/common_widget/container/workout_row/workout_row_walking.dart similarity index 91% rename from lib/common_widget/container/workout_row.dart rename to lib/common_widget/container/workout_row/workout_row_walking.dart index d4d499a..1f6b5fd 100644 --- a/lib/common_widget/container/workout_row.dart +++ b/lib/common_widget/container/workout_row/workout_row_walking.dart @@ -1,14 +1,15 @@ import 'package:flutter_svg/svg.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/modele/convertisseur.dart'; -class WorkoutRow extends StatelessWidget { +class WorkoutRowWalking extends StatelessWidget { final Map wObj; final bool isSelected; final VoidCallback onDelete; final VoidCallback onClick; - const WorkoutRow({ + const WorkoutRowWalking({ Key? key, required this.wObj, required this.onDelete, @@ -74,14 +75,14 @@ class WorkoutRow extends StatelessWidget { ), ), Text( - "Temps : ${wObj["time"].toString()}", + "Temps : ${Convertisseur.secondeIntoMinute(wObj["time"]).toStringAsFixed(2)} m", style: TextStyle( color: TColor.black, fontSize: 12, ), ), Text( - "Dénivelé positif : ${wObj["DenivelePositif"].toString()}", + "Vitesse moyenne : ${Convertisseur.msIntoKmh(wObj["VitesseAvg"]).toStringAsFixed(2)} km/h", style: TextStyle( color: TColor.black, fontSize: 12, diff --git a/lib/common_widget/info.dart b/lib/common_widget/info.dart index f28d9f1..c75c775 100644 --- a/lib/common_widget/info.dart +++ b/lib/common_widget/info.dart @@ -9,7 +9,7 @@ class Info extends StatelessWidget { Widget build(BuildContext context) { String distance = Provider.of(context, listen: false) .managerSelectedActivity - .getTotalDistance() + .getDistanceAllActivitySelected() .toString(); return Row( diff --git a/lib/common_widget/stats.dart b/lib/common_widget/stats.dart index 9d15654..affbc98 100644 --- a/lib/common_widget/stats.dart +++ b/lib/common_widget/stats.dart @@ -10,7 +10,7 @@ class Stats extends StatelessWidget { Widget build(BuildContext context) { String calories = Provider.of(context, listen: false) .managerSelectedActivity - .getCalorie() + .getCalorieAllActivitySelected() .toString(); String heartrate = Provider.of(context, listen: false) .managerSelectedActivity @@ -21,7 +21,7 @@ class Stats extends StatelessWidget { .toString(); String time = Provider.of(context, listen: false) .managerSelectedActivity - .getTotalTime() + .getTimeAllActivitySelected() .toString(); return Column( children: [ diff --git a/lib/common_widget/steps.dart b/lib/common_widget/steps.dart index 6bcb530..03acc68 100644 --- a/lib/common_widget/steps.dart +++ b/lib/common_widget/steps.dart @@ -9,7 +9,7 @@ class Steps extends StatelessWidget { Widget build(BuildContext context) { String steps = Provider.of(context, listen: false) .managerSelectedActivity - .getTotalSteps() + .getTimeAllActivitySelected() .toString(); return Padding( diff --git a/lib/modele/activity.dart b/lib/modele/activity.dart index 57b36f1..5637d1c 100644 --- a/lib/modele/activity.dart +++ b/lib/modele/activity.dart @@ -3,7 +3,7 @@ import 'package:smartfit_app_mobile/modele/activity_info/activity_info.dart'; class ActivityOfUser { final ActivityInfo _activityInfo; // A afficher - final String _categorie; + final String _category; final String _fileUuid; final String _nameFile; // ------------ // @@ -14,7 +14,7 @@ class ActivityOfUser { String get fileUuid => _fileUuid; String get nameFile => _nameFile; - String get category => _categorie; + String get category => _category; ActivityInfo get activityInfo => _activityInfo; Map get enteteCSV => _enteteCSV; @@ -29,9 +29,9 @@ class ActivityOfUser { } ActivityOfUser( - this._activityInfo, this._categorie, this._fileUuid, this._nameFile) { + this._activityInfo, this._category, this._fileUuid, this._nameFile) { // Mettre dans une fonction appart - if (_categorie == "Walking") { + if (_category == "Walking") { _imageName = "assets/img/workout1.svg"; } else { // Mettre des conditions pour d'autre type d'activité @@ -43,7 +43,7 @@ class ActivityOfUser { Map toMapGeneric() { Map map = { - 'categorie': _categorie, + 'categorie': _category, 'image': _imageName, 'date': _activityInfo.startTime, 'time': _activityInfo.timeOfActivity, diff --git a/lib/modele/activity_info/activity_info.dart b/lib/modele/activity_info/activity_info.dart index 2c0f38b..92ba698 100644 --- a/lib/modele/activity_info/activity_info.dart +++ b/lib/modele/activity_info/activity_info.dart @@ -7,13 +7,16 @@ class ActivityInfo { ActivityInfo(); // -- Time -- // Ne pas calculer (Ligne session) - String startTime = "2000-01-01"; + DateTime startTime = DateTime.now(); double timeOfActivity = 0.0; - + double distance = 0.0; + int calories = 0; + int steps = 0; // ----------- BPM ------------ // int bpmMax = 0; int bpmMin = 300; int bpmAvg = 0; + bool bpmNotZero = false; // ----------- Denivelé ------------ // double denivelePositif = 0.0; double deniveleNegatif = 0.0; @@ -21,11 +24,22 @@ class ActivityInfo { double altitudeMax = 0.0; double altitudeMin = 30000.0; double altitudeAvg = 0.0; + bool altitudeNotZero = false; + // ----------- Température --------- // + int temperatureMax = 0; + int temperatureMin = 3000; + int temperatureAvg = 0; + bool temperatureNotZero = false; + // ----------- Vitesse ------------- // + double vitesseMax = 0.0; + double vitesseMin = 999999.0; + double vitesseAvg = 0.0; + bool vitesseNotZero = false; // ---------------------------------------------------------------------- // // -- Fonction pour lire le csv et remplir la classe -- // - ActivityInfo getData(List> csv) { + ActivityInfo getDataWalking(List> csv) { // - Entete - // Map enteteCSV = getEntete(csv.first); // ------------- Var tmp ---------- // @@ -37,6 +51,12 @@ class ActivityInfo { // -- Altitude -- // double altitudeSomme = 0; int alititudeNb = 0; + // -- Température -- // + int temperatureSomme = 0; + int temperatureNb = 0; + // -- Vitesse -- // + double vitesseSomme = 0.0; + int vitesseNb = 0; // --- Boucle -- // for (int i = 1; i < csv.length; i++) { @@ -47,6 +67,7 @@ class ActivityInfo { int.parse(csv[i][enteteCSV["Value_${managerFile.fielBPM}"]!]); bpmSomme += value; bpmNb += 1; + bpmNotZero = true; if (value > bpmMax) { bpmMax = value; } @@ -75,13 +96,204 @@ class ActivityInfo { } altitudeSomme += value; alititudeNb += 1; + altitudeNotZero = true; + } + + // ------------------------ Température ----------------------- // + if (!isNull( + enteteCSV["Value_${managerFile.fieldTemperature}"]!, csv[i])) { + int value = int.parse( + csv[i][enteteCSV["Value_${managerFile.fieldTemperature}"]!]); + temperatureSomme += value; + temperatureNb += 1; + temperatureNotZero = true; + if (value > temperatureMax) { + temperatureMax = value; + } + if (value < temperatureMin) { + temperatureMin = value; + } + } + + // ------------------------ Vitesse -----------------------------// + if (!isNull(enteteCSV["Value_${managerFile.fieldSpeed}"]!, csv[i])) { + double value = + double.parse(csv[i][enteteCSV["Value_${managerFile.fieldSpeed}"]!]); + vitesseSomme += value; + vitesseNb += 1; + vitesseNotZero = true; + if (value > vitesseMax) { + vitesseMax = value; + } + if (value < vitesseMin) { + vitesseMin = value; + } } } // -- BPM -- // - bpmAvg = bpmSomme ~/ bpmNb; + if (bpmNotZero) { + bpmAvg = bpmSomme ~/ bpmNb; + } // -- Atitude -- // - altitudeAvg = altitudeSomme / alititudeNb; + if (altitudeNotZero) { + altitudeAvg = altitudeSomme / alititudeNb; + } + // -- Température -- // + if (temperatureNotZero) { + temperatureAvg = temperatureSomme ~/ temperatureNb; + } + // -- Vitesse -- // + if (vitesseNotZero) { + vitesseAvg = vitesseSomme / vitesseNb; + } + return this; + } + + // -- Fonction pour lire le csv et remplir la classe -- // + ActivityInfo getDataCycling(List> csv) { + // - Entete - // + Map enteteCSV = getEntete(csv.first); + // ------------- Var tmp ---------- // + // -- BPM -- // + int bpmSomme = 0; + int bpmNb = 0; + // -- Denivelé -- // + double lastDenivele = 0.0; + // -- Altitude -- // + double altitudeSomme = 0; + int alititudeNb = 0; + // -- Température -- // + int temperatureSomme = 0; + int temperatureNb = 0; + // -- Vitesse -- // + double vitesseSomme = 0.0; + int vitesseNb = 0; + + // --- Boucle -- // + for (int i = 1; i < csv.length; i++) { + // + // ---------------------- BPM ---------------------- // + if (!isNull(enteteCSV["Value_${managerFile.fielBPM}"]!, csv[i])) { + int value = + int.parse(csv[i][enteteCSV["Value_${managerFile.fielBPM}"]!]); + bpmSomme += value; + bpmNb += 1; + bpmNotZero = true; + if (value > bpmMax) { + bpmMax = value; + } + if (value < bpmMin) { + bpmMin = value; + } + } + + /// ------------------ Denivele et Altitude --------------- // + if (!isNull(enteteCSV["Value_${managerFile.fieldAltitude}"]!, csv[i])) { + double value = double.parse( + csv[i][enteteCSV["Value_${managerFile.fieldAltitude}"]!]); + // -- Denivelé -- // + if (value > lastDenivele) { + denivelePositif += value - lastDenivele; + } else { + deniveleNegatif += (value - lastDenivele) * -1; + } + lastDenivele = value; + // -- Altitude -- // + if (value > altitudeMax) { + altitudeMax = value; + } + if (value < altitudeMin) { + altitudeMin = value; + } + altitudeSomme += value; + alititudeNb += 1; + altitudeNotZero = true; + } + + // ------------------------ Température ----------------------- // + if (!isNull( + enteteCSV["Value_${managerFile.fieldTemperature}"]!, csv[i])) { + int value = int.parse( + csv[i][enteteCSV["Value_${managerFile.fieldTemperature}"]!]); + temperatureSomme += value; + temperatureNb += 1; + vitesseNotZero = true; + if (value > temperatureMax) { + temperatureMax = value; + } + if (value < temperatureMin) { + temperatureMin = value; + } + } + + // ------------------------ Vitesse -----------------------------// + if (!isNull(enteteCSV["Value_${managerFile.fieldSpeed}"]!, csv[i])) { + double value = + double.parse(csv[i][enteteCSV["Value_${managerFile.fieldSpeed}"]!]); + vitesseSomme += value; + vitesseNb += 1; + vitesseNotZero = true; + if (value > vitesseMax) { + vitesseMax = value; + } + if (value < vitesseMin) { + vitesseMin = value; + } + } + } + + // -- BPM -- // + if (bpmNotZero) { + bpmAvg = bpmSomme ~/ bpmNb; + } + // -- Atitude -- // + if (altitudeNotZero) { + altitudeAvg = altitudeSomme / alititudeNb; + } + // -- Température -- // + if (temperatureNotZero) { + temperatureAvg = temperatureSomme ~/ temperatureNb; + } + // -- Vitesse -- // + if (vitesseNotZero) { + vitesseAvg = vitesseSomme / vitesseNb; + } + return this; + } + +// -- Fonction pour lire le csv et remplir la classe -- // + ActivityInfo getDataGeneric(List> csv) { + // - Entete - // + Map enteteCSV = getEntete(csv.first); + // ------------- Var tmp ---------- // + // -- BPM -- // + int bpmSomme = 0; + int bpmNb = 0; + bool bpmNotZero = false; + // --- Boucle -- // + for (int i = 1; i < csv.length; i++) { + // + // ---------------------- BPM ---------------------- // + if (!isNull(enteteCSV["Value_${managerFile.fielBPM}"]!, csv[i])) { + int value = + int.parse(csv[i][enteteCSV["Value_${managerFile.fielBPM}"]!]); + bpmSomme += value; + bpmNb += 1; + bpmNotZero = true; + if (value > bpmMax) { + bpmMax = value; + } + if (value < bpmMin) { + bpmMin = value; + } + } + } + + // -- BPM -- // + if (bpmNotZero) { + bpmAvg = bpmSomme ~/ bpmNb; + } return this; } @@ -107,7 +319,9 @@ class ActivityInfo { // -- Altitude -- // "AltitudeMax": altitudeMax, "AltitudeMin": altitudeMin, - "AltitudeAvg": altitudeAvg + "AltitudeAvg": altitudeAvg, + // -- Vitesse -- // + "VitesseAvg": vitesseAvg }; } @@ -118,19 +332,106 @@ class ActivityInfo { return; } // -- Ligne session -- // - startTime = map["startTime"]; - timeOfActivity = map["timeOfActivity"].toDouble(); + try { + startTime = DateTime.parse(map["startTime"]); + } catch (e) { + print("Impossible de recup -> startTime"); + } + try { + timeOfActivity = map["timeOfActivity"]; + } catch (e) { + print("Impossible de recup -> timeOfActivity"); + } + try { + distance = map["distance"].toDouble(); + } catch (e) { + print("Impossible de recup -> distance"); + } + try { + calories = map["calories"]; + } catch (e) { + print("Impossible de recup -> calories"); + } + try { + steps = map["steps"]; + } catch (e) { + print("Impossible de recup -> steps"); + } // -- BPM -- // - bpmAvg = map["bpmAvg"]; - bpmMax = map["bpmMax"]; - bpmMin = map["bpmMin"]; + try { + bpmAvg = map["bpmAvg"]; + } catch (e) { + print("Impossible de recup -> "); + } + try { + bpmMax = map["bpmMax"]; + } catch (e) { + print("Impossible de recup -> "); + } + try { + bpmMin = map["bpmMin"]; + } catch (e) { + print("Impossible de recup -> "); + } // -- Denivelé -- // - deniveleNegatif = map["deniveleNegatif"].toDouble(); - denivelePositif = map["denivelePositif"].toDouble(); + try { + deniveleNegatif = map["deniveleNegatif"]; + } catch (e) { + print("Impossible de recup -> deniveleNegatif"); + } + try { + denivelePositif = map["denivelePositif"]; + } catch (e) { + print("Impossible de recup -> denivelePositif"); + } // -- Altitude -- // - altitudeMax = map["altitudeMax"].toDouble(); - altitudeMin = map["altitudeMin"].toDouble(); - altitudeAvg = map["altitudeAvg"].toDouble(); + try { + altitudeMax = map["altitudeMax"]; + } catch (e) { + print("Impossible de recup -> altitudeMax"); + } + try { + altitudeMin = map["altitudeMin"]; + } catch (e) { + print("Impossible de recup -> altitudeMin"); + } + try { + altitudeAvg = map["altitudeAvg"]; + } catch (e) { + print("Impossible de recup -> altitudeAvg"); + } + // -- Température -- // + try { + temperatureMax = map["temperatureMax"]; + } catch (e) { + print("Impossible de recup -> temperatureMax"); + } + try { + temperatureMin = map["temperatureMin"]; + } catch (e) { + print("Impossible de recup -> temperatureMin"); + } + try { + temperatureAvg = map["temperatureAvg"]; + } catch (e) { + print("Impossible de recup -> temperatureAvg"); + } + // -- Vitesse -- // + try { + vitesseMax = map["vitesseMax"].toDouble(); + } catch (e) { + print("Impossible de recup -> vitesseMax"); + } + try { + vitesseMin = map["vitesseMin"].toDouble(); + } catch (e) { + print("Impossible de recup -> vitesseMin"); + } + try { + vitesseAvg = map["vitesseAvg"].toDouble(); + } catch (e) { + print("Impossible de recup -> vitesseAvg"); + } } // -- Ecriture -- // @@ -147,9 +448,20 @@ class ActivityInfo { 'altitudeMax': altitudeMax, 'altitudeMin': altitudeMin, 'altitudeAvg': altitudeAvg, + // -- Température -- // + 'temperatureMax': temperatureMax, + 'temperatureMin': temperatureMin, + 'temperatureAvg': temperatureAvg, + // -- Vitesse -- // + 'vitesseMax': vitesseMax, + 'vitesseMin': vitesseMin, + 'vitesseAvg': vitesseAvg, // Ligne session - 'startTime': startTime, + 'startTime': startTime.toIso8601String(), 'timeOfActivity': timeOfActivity, + 'distance': distance, + 'calories': calories, + 'steps': steps }; return jsonEncode(jsonMap); } diff --git a/lib/modele/api/i_data_strategy.dart b/lib/modele/api/i_data_strategy.dart index 299e8eb..e4f1f51 100644 --- a/lib/modele/api/i_data_strategy.dart +++ b/lib/modele/api/i_data_strategy.dart @@ -25,7 +25,7 @@ abstract class IDataStrategy { Uint8List contentFile, String nameFile, String category, - String date, + DateTime date, ActivityInfo activityInfo); // Get one file by id diff --git a/lib/modele/api/request_api.dart b/lib/modele/api/request_api.dart index 9a3330c..eb5b9fc 100644 --- a/lib/modele/api/request_api.dart +++ b/lib/modele/api/request_api.dart @@ -192,7 +192,7 @@ class RequestApi implements IDataStrategy { Uint8List contentFile, String nameFile, String category, - String date, + DateTime date, ActivityInfo activityInfo) async { final uri = Uri.parse('$urlApi/user/files'); Map headers = {'Authorization': token}; @@ -206,7 +206,7 @@ class RequestApi implements IDataStrategy { request.files.add(httpImage); request.headers.addAll(headers); request.fields["SmartFit_Category"] = category; - request.fields["SmartFit_Date"] = date; + request.fields["SmartFit_Date"] = date.toString(); request.fields["info"] = activityInfo.toJson(); final response = await request.send(); diff --git a/lib/modele/convertisseur.dart b/lib/modele/convertisseur.dart new file mode 100644 index 0000000..89e3ebc --- /dev/null +++ b/lib/modele/convertisseur.dart @@ -0,0 +1,11 @@ +class Convertisseur { + // Mettre que des trucs static + + static double secondeIntoMinute(double seconde) { + return seconde / 60; + } + + static double msIntoKmh(double metreSeconde) { + return metreSeconde * 3.6; + } +} diff --git a/lib/modele/manager_file.dart b/lib/modele/manager_file.dart index 937dc96..efb9959 100644 --- a/lib/modele/manager_file.dart +++ b/lib/modele/manager_file.dart @@ -15,15 +15,16 @@ class ManagerFile { final String _fieldBPM = "heart_rate"; final String _fieldSpeed = "speed"; final String _fieldAltitude = "altitude"; - final String _fieldTotalStep = "total_strides"; - final String _fieldTotalCalorie = "total_calories"; final String _fieldTemperature = "temperature"; - // -- Not in CSV -- // + // -- Not in CSV (Ligne session) -- // static const String _session = "session"; static const String _startTime = "start_time"; static const String _sport = "sport"; static const String _timeActivity = "total_elapsed_time"; + static const String _totalDistance = "total_distance"; + static const String _totalCalories = "total_calories"; + static const String _totalStep = "total_strides"; // -- Getter field String get fieldTimeStamp => _fieldTimestamp; @@ -33,8 +34,6 @@ class ManagerFile { String get fielBPM => _fieldBPM; String get fieldSpeed => _fieldSpeed; String get fieldAltitude => _fieldAltitude; - String get fieldTotalStep => _fieldTotalStep; - String get fieldTotalCalories => _fieldTotalCalorie; String get fieldTemperature => _fieldTemperature; // -- Categorie -- // @@ -59,8 +58,6 @@ class ManagerFile { _fieldBPM, _fieldSpeed, _fieldAltitude, - _fieldTotalStep, - _fieldTotalCalorie, _fieldTemperature ]; @@ -74,7 +71,6 @@ class ManagerFile { _fieldBPM, _fieldSpeed, _fieldAltitude, - _fieldTotalCalorie, _fieldTemperature ]; } @@ -117,7 +113,7 @@ class ManagerFile { categorie = _getCategoryById(int.parse(_getXfromListe(_sport, ligneSession))); - // -- Si la catégorie est pas prévu est est généric -- // + // -- Si la catégorie est pas prévu == généric -- // switch (categorie) { case (_marche): fieldAllowed = allowedFieldWalking; @@ -140,13 +136,25 @@ class ManagerFile { // ------ Remplir info avec la ligne session --------- // info.startTime = DateTime.fromMillisecondsSinceEpoch( - int.parse(_getXfromListe(_startTime, ligneSession))) - .toIso8601String(); + int.parse(_getXfromListe(_startTime, ligneSession))); info.timeOfActivity = double.parse(_getXfromListe(_timeActivity, ligneSession)); + info.distance = double.parse(_getXfromListe(_totalDistance, ligneSession)); + info.calories = int.parse(_getXfromListe(_totalCalories, ligneSession)); + info.steps = int.parse(_getXfromListe(_totalStep, ligneSession)); // ----------------------------------------------------- // + // -- Extraire les données en fonction de la catégorie -- // + switch (categorie) { + case (_marche): + info.getDataWalking(csvData); + case (_velo): + info.getDataCycling(csvData); + default: + info.getDataGeneric(csvData); + } - return Tuple4(true, csvData, info.getData(csvData), categorie); + //print("Fin : ManagerFile -> convertBytesFitFileIntoCSVListAndGetInfo "); + return Tuple4(true, csvData, info, categorie); } List _getLigneSession(List listRecord) { @@ -165,7 +173,7 @@ class ManagerFile { return liste[i + 1].toString(); } } - return "null"; + return "0"; } List>> getDataOfListeOfRecord( diff --git a/lib/modele/manager_selected_activity.dart b/lib/modele/manager_selected_activity.dart index a0ed413..6aa944a 100644 --- a/lib/modele/manager_selected_activity.dart +++ b/lib/modele/manager_selected_activity.dart @@ -79,27 +79,9 @@ class ManagerSelectedActivity { return result; } -// ----------------- BPM ------------------ // - /* - // Retourne le BPM Max (Fichier CSV) - int getMaxBpm() { - int max = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull(c, i, - activitySelected[c].enteteCSV["Value_${_managerFile.fielBPM}"]!)) { - int valueTmp = activitySelected[c].contentActivity[i] - [activitySelected[c].enteteCSV["Value_${_managerFile.fielBPM}"]!]; - if (valueTmp > max) { - max = valueTmp; - } - } - } - } - - return max; - }*/ +//-------------------------------------------------------------------------------------------// +// ----------------- BPM ------------------ // int getBpmMaxAllActivitieSelected() { int max = 0; for (ActivityOfUser activityOfUser in activitySelected) { @@ -111,7 +93,7 @@ class ManagerSelectedActivity { } int getBpmMinAllActivitieSelected() { - int min = 0; + int min = 999; for (ActivityOfUser activityOfUser in activitySelected) { if (activityOfUser.activityInfo.bpmMax < min) { min = activityOfUser.activityInfo.bpmMin; @@ -119,308 +101,119 @@ class ManagerSelectedActivity { } return min; } - /* -// Retourne le BPM Min (Fichier CSV) - int getMinBpm() { - int min = 300; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull(c, i, - activitySelected[c].enteteCSV["Value_${_managerFile.fielBPM}"]!)) { - int valueTmp = activitySelected[c].contentActivity[i] - [activitySelected[c].enteteCSV["Value_${_managerFile.fielBPM}"]!]; - if (valueTmp < min) { - min = valueTmp; - } - } - } + int getBpmAvgAllActivitieSelected() { + int somme = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.bpmAvg; } - return min; + return somme ~/ activitySelected.length; } - - // Retourne le BPM avg (Fichier CSV) - int getAvgBpm() { - int somme = 0; - int nb = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull(c, i, - activitySelected[c].enteteCSV["Value_${_managerFile.fielBPM}"]!)) { - somme += activitySelected[c].contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fielBPM}"]!] as int; - nb++; - } + // ------------------ Fin BPM ------------------- // + // ------------------ Altitude ------------------ // + double getMaxAltitudeAllActivitySelected() { + double max = 0.0; + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.altitudeMax > max) { + max = activityOfUser.activityInfo.altitudeMax; } } - return somme ~/ nb; - }*/ - /* - double getAvgAltitude() { - double somme = 0; - int nb = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!)) { - somme += activitySelected[c].contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!]; - nb++; - } + return max; + } + + double getMinAltitudeAllActivitySelected() { + double min = 99999.0; + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.altitudeMax < min) { + min = activityOfUser.activityInfo.altitudeMin; } } - double average = somme / nb; - return double.parse(average.toStringAsFixed(2)); - }*/ + return min; + } - double getAvgTemperature() { + double getAvgAltitudeAllActivitySelected() { double somme = 0; - int nb = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!)) { - somme += activitySelected[c].contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!]; - nb++; - } - } + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.altitudeAvg; } - double average = somme / nb; - return double.parse(average.toStringAsFixed(2)); + return somme / activitySelected.length; } + // ------------------ Fin Altitude ------------------- // - double getMaxTemperature() { - double max = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!] - .toDouble(); - if (valueTmp > max) { - max = valueTmp; - } - } - } + // ------------------ Température -------------------- // + int getAvgTemperatureAllActivitySelected() { + int somme = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.temperatureAvg; } + return somme ~/ activitySelected.length; + } + int getMaxTemperatureAllActivitySelected() { + int max = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.temperatureMax > max) { + max = activityOfUser.activityInfo.temperatureMax; + } + } return max; } - double getMinTemperature() { - double min = 5000; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTemperature}"]!] - .toDouble(); - if (valueTmp < min) { - min = valueTmp; - } - } + int getMinTemperatureAllActivitySelected() { + int min = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.temperatureMin > min) { + min = activityOfUser.activityInfo.temperatureMin; } } return min; } - - // -------------------------- FIN BPM ---------------------- // + // -------------------------- FIN Température ---------------------- // // ---------------------- Distance ---------------------- // - double getTotalDistance() { - double max = 0; - - for (int c = 0; c < activitySelected.length; c++) { - for (int i = activitySelected[c].contentActivity.length - 1; - i != 0; - i--) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldDistance}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldDistance}"]!] - .toDouble(); - if (valueTmp > max) { - max = valueTmp; - } - } - } + double getDistanceAllActivitySelected() { + double somme = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.distance; } - - return max; + return somme; } // ---------------------- FIN Distance ---------------------- // // ---------------------- Calories ---------------------- // - int getCalorie() { - for (int c = 0; c < activitySelected.length; c++) { - for (int i = activitySelected[c].contentActivity.length - 1; - i != 0; - i--) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTotalCalories}"]!)) { - return activitySelected[c].contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTotalCalories}"]!] as int; - } - } + int getCalorieAllActivitySelected() { + int somme = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.calories; } - return 0; + return somme; } // ---------------------- FIN Calories ---------------------- // // ---------------------- Step ------------------------------// - int getTotalSteps() { - for (int c = 0; c < activitySelected.length; c++) { - for (int i = activitySelected[c].contentActivity.length - 1; - i != 0; - i--) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTotalStep}"]!)) { - return activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldTotalStep}"]!] - .toInt(); - } - } + int getStepsAllActivitySelected() { + int somme = 0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.steps; } - return 0; + return somme; } // ----------------------- FIN Step ------------------------ // // ------------------------- Time ----------------------------- // - double getTotalTime() { - int timestampMax = 0; - int timestampMin = 0; - - for (int i = 0; i < activitySelected[0].contentActivity.length; i++) { - if (_notNull( - 0, - i, - activitySelected[0] - .enteteCSV["Value_${_managerFile.fieldTimeStamp}"]!)) { - timestampMin = activitySelected[0].contentActivity[i][ - activitySelected[0] - .enteteCSV["Value_${_managerFile.fieldTimeStamp}"]!]; - break; - } - } - - for (int i = activitySelected[0].contentActivity.length - 1; i != 0; i--) { - if (_notNull( - 0, - i, - activitySelected[0] - .enteteCSV["Value_${_managerFile.fieldTimeStamp}"]!)) { - timestampMax = activitySelected[0].contentActivity[i][ - activitySelected[0] - .enteteCSV["Value_${_managerFile.fieldTimeStamp}"]!]; - break; - } - } - return (timestampMax - timestampMin) / 1000; - } - // ---------------------------- FIN time -------------------- // - - // ---------------------------------------- Altitude -------------------- // - /* - // --- Fichier CSV --- // - double getMaxAltitude() { - double max = 0; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!] - .toDouble(); - if (valueTmp > max) { - max = valueTmp; - } - } - } - } - return max; - }*/ - - double getMaxAltitudeAllActivitySelected() { - double max = 0.0; - for (ActivityOfUser activityOfUser in activitySelected) { - if (activityOfUser.activityInfo.altitudeMax > max) { - max = activityOfUser.activityInfo.altitudeMax; - } - } - return max; - } - - double getMinAltitudeAllActivitySelected() { - double min = 0.0; + double getTimeAllActivitySelected() { + double somme = 0; for (ActivityOfUser activityOfUser in activitySelected) { - if (activityOfUser.activityInfo.altitudeMax < min) { - min = activityOfUser.activityInfo.altitudeMin; - } + somme += activityOfUser.activityInfo.timeOfActivity; } - return min; + return somme; } - /* - // --- Fichier CSV --- // - double getMinAltitude() { - double min = 5000; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldAltitude}"]!] - .toDouble(); - if (valueTmp < min) { - min = valueTmp; - } - } - } - } - return min; - }*/ - - // -------------------------- FIN altitude ---------------------- // + // ---------------------------- FIN time -------------------- // // -------------------------- Speed ---------------------- // @@ -463,73 +256,32 @@ class ManagerSelectedActivity { return result; } - // Retourne la Speed Max (Fichier CSV) - double getMaxSpeed() { + double getMaxSpeedAllActivitySelected() { double max = 0.00; - - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!] - .toDouble(); - if (valueTmp > max) { - max = valueTmp; - } - } + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.vitesseMax > max) { + max = activityOfUser.activityInfo.vitesseMax; } } return max; } - double getMinSpeed() { - double min = 5000; - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!)) { - double valueTmp = activitySelected[c] - .contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!] - .toDouble(); - if (valueTmp < min) { - min = valueTmp; - } - } + double getMinSpeedAllActivitySelected() { + double min = 99999.9; + for (ActivityOfUser activityOfUser in activitySelected) { + if (activityOfUser.activityInfo.vitesseMin < min) { + min = activityOfUser.activityInfo.vitesseMin; } } return min; } - // Retourne avg Max (Fichier CSV) - double getAvgSpeed() { - double somme = 0; - int nb = 0; - - for (int c = 0; c < activitySelected.length; c++) { - for (int i = 0; i < activitySelected[c].contentActivity.length; i++) { - if (_notNull( - c, - i, - activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!)) { - somme += activitySelected[c].contentActivity[i][activitySelected[c] - .enteteCSV["Value_${_managerFile.fieldSpeed}"]!]; - nb++; - } - } + double getAvgSpeedAllActivitySelected() { + double somme = 0.0; + for (ActivityOfUser activityOfUser in activitySelected) { + somme += activityOfUser.activityInfo.vitesseAvg; } - - double average = somme / nb; - return double.parse(average.toStringAsFixed(2)); + return somme / activitySelected.length; } // -------------------------- FIN Speed ---------------------- // diff --git a/lib/modele/user.dart b/lib/modele/user.dart index 5320f97..59a4b72 100644 --- a/lib/modele/user.dart +++ b/lib/modele/user.dart @@ -37,7 +37,7 @@ class User extends ChangeNotifier { // ------------ Walking -------------- // // ---- Denivelé ---- // - double getTotalDenivelePositif() { + double getTotalDenivelePositifAllActivity() { double totalDevPos = 0.0; for (ActivityOfUser activity in listActivity) { totalDevPos += activity.activityInfo.denivelePositif; @@ -45,7 +45,7 @@ class User extends ChangeNotifier { return totalDevPos; } - double getTotalDeniveleNegatif() { + double getTotalDeniveleNegatifAllActivity() { double totalDevNeg = 0.0; for (ActivityOfUser activity in listActivity) { totalDevNeg += activity.activityInfo.deniveleNegatif; diff --git a/lib/modele/utile/list_activity/list_activity_utile.dart b/lib/modele/utile/list_activity/list_activity_utile.dart index 7deadc9..1f9ef4f 100644 --- a/lib/modele/utile/list_activity/list_activity_utile.dart +++ b/lib/modele/utile/list_activity/list_activity_utile.dart @@ -58,10 +58,6 @@ class ListActivityUtile { element["uuid"].toString(), element["filename"].toString())); } - /* - if (notZero) { - await getContentActivity(context); - }*/ return const Tuple2(true, "Yeah"); } @@ -85,6 +81,8 @@ class ListActivityUtile { resultData.item4, resultData.item3.startTime, resultData.item3); + // resultData.item4 == category + // resultData.item3 == ActivityInfo if (result.item1 == false) { return Tuple2(false, result.item2); } diff --git a/lib/view/home/stats_activities_view.dart b/lib/view/home/stats_activities_view.dart index ad4df11..a0c5d0a 100644 --- a/lib/view/home/stats_activities_view.dart +++ b/lib/view/home/stats_activities_view.dart @@ -29,36 +29,65 @@ class _StatAtivities extends State { // -- BPM -- // int maxBpm = managerSelectedActivity.getBpmMaxAllActivitieSelected(); int minBpm = managerSelectedActivity.getBpmMinAllActivitieSelected(); - int avgBpm = (minBpm + maxBpm) ~/ 2; + int avgBpm = managerSelectedActivity.getBpmAvgAllActivitieSelected(); // -- Altitude -- // double maxAltitude = managerSelectedActivity.getMaxAltitudeAllActivitySelected(); double minAltitude = managerSelectedActivity.getMinAltitudeAllActivitySelected(); - double avgAltitude = (minAltitude + maxAltitude) / 2; + double avgAltitude = + managerSelectedActivity.getAvgAltitudeAllActivitySelected(); - double getTotalDistance = - context.watch().managerSelectedActivity.getTotalDistance(); - int totalSteps = - context.watch().managerSelectedActivity.getTotalSteps(); - double totalTime = - context.watch().managerSelectedActivity.getTotalTime(); - int totalCalories = - context.watch().managerSelectedActivity.getCalorie(); - double avgSpeed = - context.watch().managerSelectedActivity.getAvgSpeed(); + // -- Température -- // + double avgTemperature = context + .watch() + .managerSelectedActivity + .getAvgTemperatureAllActivitySelected() + .toDouble(); + double maxTemperature = context + .watch() + .managerSelectedActivity + .getMaxTemperatureAllActivitySelected() + .toDouble(); + double minTemperature = context + .watch() + .managerSelectedActivity + .getMinTemperatureAllActivitySelected() + .toDouble(); + // ----- Distance ---- // + double getTotalDistance = context + .watch() + .managerSelectedActivity + .getDistanceAllActivitySelected(); + // ---- Calories --- // + int totalCalories = context + .watch() + .managerSelectedActivity + .getCalorieAllActivitySelected(); + // --- Steps --- // + int totalSteps = context + .watch() + .managerSelectedActivity + .getStepsAllActivitySelected(); + // -- Time -- // + double totalTime = context + .watch() + .managerSelectedActivity + .getTimeAllActivitySelected(); - double avgTemperature = - context.watch().managerSelectedActivity.getAvgTemperature(); - double maxTemperature = - context.watch().managerSelectedActivity.getMaxTemperature(); - - double maxSpeed = - context.watch().managerSelectedActivity.getMaxSpeed(); - double minSpeed = - context.watch().managerSelectedActivity.getMinSpeed(); - double minTemperature = - context.watch().managerSelectedActivity.getMinTemperature(); + // -- Speed -- // + double avgSpeed = context + .watch() + .managerSelectedActivity + .getAvgSpeedAllActivitySelected(); + double maxSpeed = context + .watch() + .managerSelectedActivity + .getMaxAltitudeAllActivitySelected(); + double minSpeed = context + .watch() + .managerSelectedActivity + .getMinAltitudeAllActivitySelected(); return Scaffold( backgroundColor: TColor.white, diff --git a/lib/view/home/web/web_homeview.dart b/lib/view/home/web/web_homeview.dart index 7ec0374..2498fd0 100644 --- a/lib/view/home/web/web_homeview.dart +++ b/lib/view/home/web/web_homeview.dart @@ -43,16 +43,23 @@ class _WebHomeView extends State { double avgAltitude = managerSelectedActivity.activitySelected.first.activityInfo.altitudeAvg; // -- Speed -- // - double maxSpeed = - context.watch().managerSelectedActivity.getMaxSpeed(); - double avgSpeed = - context.watch().managerSelectedActivity.getAvgSpeed(); + double maxSpeed = context + .watch() + .managerSelectedActivity + .getMaxSpeedAllActivitySelected(); + double avgSpeed = context + .watch() + .managerSelectedActivity + .getAvgSpeedAllActivitySelected(); data = HomeViewUtil().initData(context); data.maxBPM = maxBpm; data.minBPM = minBpm; data.maxSpeed = maxSpeed; - data.time = context.watch().managerSelectedActivity.getTotalTime(); + data.time = context + .watch() + .managerSelectedActivity + .getTimeAllActivitySelected(); return Scaffold( backgroundColor: TColor.white, body: SingleChildScrollView( diff --git a/pubspec.yaml b/pubspec.yaml index 7bafd6c..0b436fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,6 +58,7 @@ dependencies: responsive_builder: ^0.7.0 flutter_map: ^5.0.0 latlong2: ^0.9.0 + units_converter: ^2.1.1 dev_dependencies: flutter_test: