commit
425bc391a2
After Width: | Height: | Size: 974 B |
@ -0,0 +1,25 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/container/mobile/mobile_container_stats_activities.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/container/web/web_container_stats_activities.dart';
|
||||||
|
|
||||||
|
class ContainerStatsActivities extends StatelessWidget {
|
||||||
|
const ContainerStatsActivities(
|
||||||
|
this.value,
|
||||||
|
this.designation,
|
||||||
|
this.icon, {
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
final String designation;
|
||||||
|
final IconData icon;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ScreenTypeLayout.builder(
|
||||||
|
mobile: (_) => MobileContainerStatsActivities(value, designation, icon),
|
||||||
|
desktop: (_) => WebContainerStatsActivities(value, designation, icon),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/stats.dart';
|
||||||
|
|
||||||
|
class MobileContainerStatsActivities extends StatelessWidget {
|
||||||
|
const MobileContainerStatsActivities(
|
||||||
|
this.value,
|
||||||
|
this.designation,
|
||||||
|
this.icon, {
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
final String designation;
|
||||||
|
final IconData icon;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var media = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
height: media.width * 0.4,
|
||||||
|
width: media.width * 0.27,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
border: Border.all(
|
||||||
|
color: const Color(0xffe1e1e1),
|
||||||
|
),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black12,
|
||||||
|
offset: Offset(3, 3),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center, // Centrer horizontalement
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
StatIcon(
|
||||||
|
icon: icon,
|
||||||
|
iconColor: TColor.white,
|
||||||
|
iconBackground: TColor.secondaryColor1,
|
||||||
|
sizeIcon: 30.0,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20), // Espacement entre l'icône et le texte
|
||||||
|
Text(
|
||||||
|
designation,
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/stats.dart';
|
||||||
|
|
||||||
|
class WebContainerStatsActivities extends StatelessWidget {
|
||||||
|
const WebContainerStatsActivities(
|
||||||
|
this.value,
|
||||||
|
this.designation,
|
||||||
|
this.icon, {
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
final String designation;
|
||||||
|
final IconData icon;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var media = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
height: media.width * 0.2,
|
||||||
|
width: media.width * 0.3,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
border: Border.all(
|
||||||
|
color: const Color(0xffe1e1e1),
|
||||||
|
),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black12,
|
||||||
|
offset: Offset(3, 3),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center, // Centrer horizontalement
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
StatIcon(
|
||||||
|
icon: icon,
|
||||||
|
iconColor: TColor.white,
|
||||||
|
iconBackground: TColor.secondaryColor1,
|
||||||
|
sizeIcon: 40.0,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 40), // Espacement entre l'icône et le texte
|
||||||
|
Text(
|
||||||
|
designation,
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart';
|
||||||
|
|
||||||
|
class FuncBpmByTime {
|
||||||
|
final DataHomeView data;
|
||||||
|
|
||||||
|
FuncBpmByTime(this.data);
|
||||||
|
|
||||||
|
SideTitles get rightTitles => SideTitles(
|
||||||
|
getTitlesWidget: rightTitleWidgets,
|
||||||
|
showTitles: true,
|
||||||
|
interval: 20,
|
||||||
|
reservedSize: 40,
|
||||||
|
);
|
||||||
|
|
||||||
|
SideTitles get bottomTitles => SideTitles(
|
||||||
|
getTitlesWidget: bottomTitleWidgets,
|
||||||
|
showTitles: true,
|
||||||
|
interval: 20,
|
||||||
|
reservedSize: 20,
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget rightTitleWidgets(double value, TitleMeta meta) {
|
||||||
|
int minBpm = data.minBPM;
|
||||||
|
int maxBpm = data.maxBPM;
|
||||||
|
double interval = (maxBpm - minBpm) / 5;
|
||||||
|
|
||||||
|
String text;
|
||||||
|
switch (value.toInt()) {
|
||||||
|
case 0:
|
||||||
|
text = "${(minBpm).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
text = "${(minBpm + interval).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
case 40:
|
||||||
|
text = "${(minBpm + interval * 2).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
case 60:
|
||||||
|
text = "${(minBpm + interval * 3).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
case 80:
|
||||||
|
text = "${(minBpm + interval * 4).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
case 100:
|
||||||
|
text = "${(maxBpm).toStringAsFixed(2)} BPM";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text(text,
|
||||||
|
style: TextStyle(
|
||||||
|
color: TColor.gray,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget bottomTitleWidgets(double value, TitleMeta meta) {
|
||||||
|
double interval = data.time / 5;
|
||||||
|
String text;
|
||||||
|
switch (value) {
|
||||||
|
case 0:
|
||||||
|
text = '0 s';
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
text = "${(interval).toStringAsFixed(2)} s";
|
||||||
|
break;
|
||||||
|
case 40:
|
||||||
|
text = "${(interval * 2).toStringAsFixed(2)} s";
|
||||||
|
break;
|
||||||
|
case 60:
|
||||||
|
text = "${(interval * 3).toStringAsFixed(2)} s";
|
||||||
|
break;
|
||||||
|
case 80:
|
||||||
|
text = "${(interval * 4).toStringAsFixed(2)} s";
|
||||||
|
break;
|
||||||
|
case 100:
|
||||||
|
text = "${(interval * 5).toStringAsFixed(2)} s";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text(text,
|
||||||
|
style: TextStyle(
|
||||||
|
color: TColor.gray,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,227 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:smartfit_app_mobile/modele/manager_file.dart';
|
||||||
|
|
||||||
|
class ActivityInfo {
|
||||||
|
ManagerFile managerFile = ManagerFile();
|
||||||
|
ActivityInfo();
|
||||||
|
|
||||||
|
// -- Time -- // Ne pas calculer (Ligne session)
|
||||||
|
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;
|
||||||
|
// ----------- Denivelé ------------ //
|
||||||
|
double denivelePositif = 0.0;
|
||||||
|
double deniveleNegatif = 0.0;
|
||||||
|
// ----------- Altitude ------------ //
|
||||||
|
double altitudeMax = 0.0;
|
||||||
|
double altitudeMin = 30000.0;
|
||||||
|
double altitudeAvg = 0.0;
|
||||||
|
// ----------- Température --------- //
|
||||||
|
int temperatureMax = 0;
|
||||||
|
int temperatureMin = 3000;
|
||||||
|
int temperatureAvg = 0;
|
||||||
|
// ----------- Vitesse ------------- //
|
||||||
|
double vitesseMax = 0.0;
|
||||||
|
double vitesseMin = 999999.0;
|
||||||
|
double vitesseAvg = 0.0;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
// -- Fonction pour lire le csv et remplir la classe -- //
|
||||||
|
ActivityInfo getData(List<List<String>> csv) {
|
||||||
|
// - Entete - //
|
||||||
|
Map<String, int> 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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------ Température ----------------------- //
|
||||||
|
if (!isNull(
|
||||||
|
enteteCSV["Value_${managerFile.fieldTemperature}"]!, csv[i])) {
|
||||||
|
int value = int.parse(
|
||||||
|
csv[i][enteteCSV["Value_${managerFile.fieldTemperature}"]!]);
|
||||||
|
temperatureSomme += value;
|
||||||
|
temperatureNb += 1;
|
||||||
|
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;
|
||||||
|
if (value > vitesseMax) {
|
||||||
|
vitesseMax = value;
|
||||||
|
}
|
||||||
|
if (value < vitesseMin) {
|
||||||
|
vitesseMin = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- BPM -- //
|
||||||
|
bpmAvg = bpmSomme ~/ bpmNb;
|
||||||
|
// -- Atitude -- //
|
||||||
|
altitudeAvg = altitudeSomme / alititudeNb;
|
||||||
|
// -- Température -- //
|
||||||
|
temperatureAvg = temperatureSomme ~/ temperatureNb;
|
||||||
|
// -- Vitesse -- //
|
||||||
|
vitesseAvg = vitesseSomme / vitesseNb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------ Fonction utile ------------------- //
|
||||||
|
Map<String, int> getEntete(List<dynamic> content) {
|
||||||
|
Map<String, int> enteteCSV = {};
|
||||||
|
for (int i = 0; i < content.length; i++) {
|
||||||
|
enteteCSV.addAll({content[i]: i});
|
||||||
|
}
|
||||||
|
return enteteCSV;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNull(int colonne, List<dynamic> ligne) {
|
||||||
|
return ligne[colonne] == "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------- Pour print ----------------- //
|
||||||
|
Map<String, dynamic> toMapWalking() {
|
||||||
|
return {
|
||||||
|
// -- Denivelé -- //
|
||||||
|
"DenivelePositif": denivelePositif,
|
||||||
|
"DeniveleNegatif": denivelePositif,
|
||||||
|
// -- Altitude -- //
|
||||||
|
"AltitudeMax": altitudeMax,
|
||||||
|
"AltitudeMin": altitudeMin,
|
||||||
|
"AltitudeAvg": altitudeAvg
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------- JSON --------- //
|
||||||
|
// -- Lecture -- //
|
||||||
|
ActivityInfo.fromJson(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// -- Ligne session -- //
|
||||||
|
startTime = DateTime.parse(map["startTime"]);
|
||||||
|
timeOfActivity = map["timeOfActivity"].toDouble();
|
||||||
|
distance = map["distance"].toDouble();
|
||||||
|
calories = map["calories"].toInt();
|
||||||
|
steps = map["steps"].toInt();
|
||||||
|
// -- BPM -- //
|
||||||
|
bpmAvg = map["bpmAvg"];
|
||||||
|
bpmMax = map["bpmMax"];
|
||||||
|
bpmMin = map["bpmMin"];
|
||||||
|
// -- Denivelé -- //
|
||||||
|
deniveleNegatif = map["deniveleNegatif"].toDouble();
|
||||||
|
denivelePositif = map["denivelePositif"].toDouble();
|
||||||
|
// -- Altitude -- //
|
||||||
|
altitudeMax = map["altitudeMax"].toDouble();
|
||||||
|
altitudeMin = map["altitudeMin"].toDouble();
|
||||||
|
altitudeAvg = map["altitudeAvg"].toDouble();
|
||||||
|
// -- Température -- //
|
||||||
|
temperatureMax = map["temperatureMax"].toInt();
|
||||||
|
temperatureMin = map["temperatureMin"].toInt();
|
||||||
|
temperatureAvg = map["temperatureAvg"].toInt();
|
||||||
|
// -- Vitesse -- //
|
||||||
|
vitesseMax = map["vitesseMax"].toDouble();
|
||||||
|
vitesseMin = map["vitesseMin"].toDouble();
|
||||||
|
vitesseAvg = map["vitesseAvg"].toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Ecriture -- //
|
||||||
|
String toJson() {
|
||||||
|
Map<String, dynamic> jsonMap = {
|
||||||
|
// -- BPM -- //
|
||||||
|
'bpmAvg': bpmAvg,
|
||||||
|
'bpmMax': bpmMax,
|
||||||
|
'bpmMin': bpmMin,
|
||||||
|
// -- Denivelé -- //
|
||||||
|
'denivelePositif': denivelePositif,
|
||||||
|
'deniveleNegatif': deniveleNegatif,
|
||||||
|
// -- Altitude -- //
|
||||||
|
'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.toString(),
|
||||||
|
'timeOfActivity': timeOfActivity,
|
||||||
|
'distance': distance,
|
||||||
|
'calories': calories,
|
||||||
|
'steps': steps
|
||||||
|
};
|
||||||
|
return jsonEncode(jsonMap);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,235 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/container/container_stats_activities.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common_widget/other/entete_home_view.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/manager_selected_activity.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/user.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/utile/home_view/home_view_util.dart';
|
||||||
|
|
||||||
|
class StatAtivities extends StatefulWidget {
|
||||||
|
const StatAtivities({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatAtivities> createState() => _StatAtivities();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StatAtivities extends State<StatAtivities> {
|
||||||
|
late DataHomeView data;
|
||||||
|
TextEditingController bpmController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var media = MediaQuery.of(context).size;
|
||||||
|
data = HomeViewUtil().initData(context);
|
||||||
|
ManagerSelectedActivity managerSelectedActivity =
|
||||||
|
context.watch<User>().managerSelectedActivity;
|
||||||
|
|
||||||
|
// -- BPM -- //
|
||||||
|
int maxBpm = managerSelectedActivity.getBpmMaxAllActivitieSelected();
|
||||||
|
int minBpm = managerSelectedActivity.getBpmMinAllActivitieSelected();
|
||||||
|
int avgBpm = managerSelectedActivity.getBpmAvgAllActivitieSelected();
|
||||||
|
// -- Altitude -- //
|
||||||
|
double maxAltitude =
|
||||||
|
managerSelectedActivity.getMaxAltitudeAllActivitySelected();
|
||||||
|
double minAltitude =
|
||||||
|
managerSelectedActivity.getMinAltitudeAllActivitySelected();
|
||||||
|
double avgAltitude =
|
||||||
|
managerSelectedActivity.getAvgAltitudeAllActivitySelected();
|
||||||
|
|
||||||
|
// -- Température -- //
|
||||||
|
double avgTemperature = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getAvgTemperatureAllActivitySelected()
|
||||||
|
.toDouble();
|
||||||
|
double maxTemperature = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getMaxTemperatureAllActivitySelected()
|
||||||
|
.toDouble();
|
||||||
|
double minTemperature = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getMinTemperatureAllActivitySelected()
|
||||||
|
.toDouble();
|
||||||
|
// ----- Distance ---- //
|
||||||
|
double getTotalDistance = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getDistanceAllActivitySelected();
|
||||||
|
// ---- Calories --- //
|
||||||
|
int totalCalories = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getCalorieAllActivitySelected();
|
||||||
|
// --- Steps --- //
|
||||||
|
int totalSteps = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getStepsAllActivitySelected();
|
||||||
|
// -- Time -- //
|
||||||
|
double totalTime = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getTimeAllActivitySelected();
|
||||||
|
|
||||||
|
// -- Speed -- //
|
||||||
|
double avgSpeed = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getAvgSpeedAllActivitySelected();
|
||||||
|
double maxSpeed = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getMaxAltitudeAllActivitySelected();
|
||||||
|
double minSpeed = context
|
||||||
|
.watch<User>()
|
||||||
|
.managerSelectedActivity
|
||||||
|
.getMinAltitudeAllActivitySelected();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: TColor.white,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
const EnteteHomeView(),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.05,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Status d'activité",
|
||||||
|
style: TextStyle(
|
||||||
|
color: TColor.black,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$avgBpm BPM", "Moyenne Bpm", Icons.favorite),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$maxBpm BPM", "Maximum Bpm", Icons.trending_up),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$minBpm BPM", "Minimum Bpm", Icons.trending_down)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$avgSpeed m/s", "Moyenne vitesse", Icons.bolt),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$maxSpeed m/s", "Maximum vitesse", Icons.trending_up),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$minSpeed m/s", "Minimum vitesse", Icons.trending_down)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities("$avgTemperature °C",
|
||||||
|
"Moyenne Temperature", Icons.thermostat),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities("$maxTemperature °C",
|
||||||
|
"Maximum Temperature", Icons.trending_up),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities("$minTemperature °C",
|
||||||
|
"Minimum Temperature", Icons.trending_down)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$avgAltitude m", "Moyenne Altitude", Icons.landscape),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities("$maxAltitude m",
|
||||||
|
"Maximum Altitude", Icons.trending_up),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities("$minAltitude m",
|
||||||
|
"Minimum Altitude", Icons.trending_down)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities("$getTotalDistance m",
|
||||||
|
"Distance Totale", Icons.double_arrow),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$totalSteps", "Total Pas", Icons.do_not_step_rounded),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ContainerStatsActivities(
|
||||||
|
"$totalTime s", "Temps Total", Icons.timer),
|
||||||
|
SizedBox(
|
||||||
|
width: media.width * 0.03,
|
||||||
|
),
|
||||||
|
ContainerStatsActivities("$totalCalories kCal",
|
||||||
|
"Calories Dépensées", Icons.local_fire_department),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: media.width * 0.03,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/view/map/mobile/mobile_my_map.dart';
|
||||||
|
import 'package:smartfit_app_mobile/view/map/my_map_osm.dart';
|
||||||
|
|
||||||
|
class ChoseMap extends StatefulWidget {
|
||||||
|
const ChoseMap({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChoseMap> createState() => _ChoseMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChoseMap extends State<ChoseMap> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: TColor.white,
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const MobileMyMaps()));
|
||||||
|
},
|
||||||
|
child: const Text("Use map with google map")),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder: (context) => const MyMapOSM()));
|
||||||
|
},
|
||||||
|
child: const Text("Use map with Open Street Map")),
|
||||||
|
const Text(
|
||||||
|
"Mettre une image la en mode une personne avec des jumelles")
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
|
import 'package:latlong2/latlong.dart' as osm;
|
||||||
|
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||||
|
import 'package:smartfit_app_mobile/modele/user.dart';
|
||||||
|
|
||||||
|
class MyMapOSM extends StatefulWidget {
|
||||||
|
const MyMapOSM({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MyMapOSM> createState() => _MyMapOSM();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyMapOSM extends State<MyMapOSM> {
|
||||||
|
final controller = MapController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<osm.LatLng> listPolynines =
|
||||||
|
context.watch<User>().managerSelectedActivity.getPositionOSM();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text("Carte Open Street Map "),
|
||||||
|
backgroundColor: TColor.primaryColor1,
|
||||||
|
),
|
||||||
|
body: FlutterMap(
|
||||||
|
options: MapOptions(center: listPolynines.first),
|
||||||
|
children: [
|
||||||
|
TileLayer(
|
||||||
|
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
),
|
||||||
|
PolylineLayer(
|
||||||
|
polylines: [
|
||||||
|
Polyline(
|
||||||
|
points: listPolynines,
|
||||||
|
color: TColor.primaryColor1,
|
||||||
|
strokeWidth: 5.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,117 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
||||||
import 'package:location/location.dart';
|
|
||||||
|
|
||||||
class MyMap extends StatefulWidget {
|
|
||||||
const MyMap({ Key? key }) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyMap> createState() => _MyMapState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyMapState extends State<MyMap> {
|
|
||||||
|
|
||||||
Completer<GoogleMapController> _googleMapController = Completer();
|
|
||||||
CameraPosition? _cameraPosition;
|
|
||||||
Location? _location;
|
|
||||||
LocationData? _currentLocation;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_init();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
_init() async {
|
|
||||||
_location = Location();
|
|
||||||
_cameraPosition = CameraPosition(
|
|
||||||
target: LatLng(0, 0), // this is just the example lat and lng for initializing
|
|
||||||
zoom: 15
|
|
||||||
);
|
|
||||||
_initLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
//function to listen when we move position
|
|
||||||
_initLocation() {
|
|
||||||
//use this to go to current location instead
|
|
||||||
_location?.getLocation().then((location) {
|
|
||||||
_currentLocation = location;
|
|
||||||
});
|
|
||||||
_location?.onLocationChanged.listen((newLocation) {
|
|
||||||
_currentLocation = newLocation;
|
|
||||||
moveToPosition(LatLng(_currentLocation?.latitude ?? 0, _currentLocation?.longitude ?? 0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
moveToPosition(LatLng latLng) async {
|
|
||||||
GoogleMapController mapController = await _googleMapController.future;
|
|
||||||
mapController.animateCamera(
|
|
||||||
CameraUpdate.newCameraPosition(
|
|
||||||
CameraPosition(
|
|
||||||
target: latLng,
|
|
||||||
zoom: 15
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: _buildBody(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBody() {
|
|
||||||
return _getMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getMarker() {
|
|
||||||
return Container(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
padding: EdgeInsets.all(2),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(100),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey,
|
|
||||||
offset: Offset(0,3),
|
|
||||||
spreadRadius: 4,
|
|
||||||
blurRadius: 6
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
child: ClipOval(child: Image.asset("assets/img/u1.png")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getMap() {
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
GoogleMap(
|
|
||||||
initialCameraPosition: _cameraPosition!,
|
|
||||||
mapType: MapType.normal,
|
|
||||||
onMapCreated: (GoogleMapController controller) {
|
|
||||||
// now we need a variable to get the controller of google map
|
|
||||||
if (!_googleMapController.isCompleted) {
|
|
||||||
_googleMapController.complete(controller);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
Positioned.fill(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: _getMarker()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue