From 8fe91016003593ffa1093e37a839fc4511844eda Mon Sep 17 00:00:00 2001 From: otbenjello Date: Mon, 20 Nov 2023 08:23:06 +0100 Subject: [PATCH] branche pour responsive web --- .../container/ligne_container_stats.dart | 6 +- .../graph/bpm_and_speed_by_time.dart | 2 +- lib/common_widget/graph/bpm_by_time.dart | 2 +- lib/modele/manager_file.dart | 6 +- .../utile/home_view/home_view_util.dart | 2 +- lib/view/activity/web/web_list_activity.dart | 76 +- lib/view/home/web/web_homeview.dart | 1021 +---------------- 7 files changed, 80 insertions(+), 1035 deletions(-) diff --git a/lib/common_widget/container/ligne_container_stats.dart b/lib/common_widget/container/ligne_container_stats.dart index 359272d..96e35e8 100644 --- a/lib/common_widget/container/ligne_container_stats.dart +++ b/lib/common_widget/container/ligne_container_stats.dart @@ -19,11 +19,11 @@ class LigneContainerStats extends StatelessWidget { Widget build(BuildContext context) { return Row( children: [ - const SizedBox(height: 10), + const SizedBox(width: 20), ContainerStats(value1, designation1), - const SizedBox(height: 10), + const SizedBox(width: 20), ContainerStats(value2, designation2), - const SizedBox(height: 10), + const SizedBox(width: 20), ContainerStats(value3, designation3), ], ); diff --git a/lib/common_widget/graph/bpm_and_speed_by_time.dart b/lib/common_widget/graph/bpm_and_speed_by_time.dart index 0c9dc00..8b2c717 100644 --- a/lib/common_widget/graph/bpm_and_speed_by_time.dart +++ b/lib/common_widget/graph/bpm_and_speed_by_time.dart @@ -116,7 +116,7 @@ class _GraphBpmAndSpeedByTime extends State { return Container( padding: const EdgeInsets.only(left: 15), - height: widget.media.width * 0.5, + height: widget.media.width * 0.3, width: double.maxFinite, child: LineChart( LineChartData( diff --git a/lib/common_widget/graph/bpm_by_time.dart b/lib/common_widget/graph/bpm_by_time.dart index aaa580c..928f67b 100644 --- a/lib/common_widget/graph/bpm_by_time.dart +++ b/lib/common_widget/graph/bpm_by_time.dart @@ -80,7 +80,7 @@ class _GraphBpmByTime extends State { return ClipRRect( borderRadius: BorderRadius.circular(25), child: Container( - height: media.width * 0.4, + height: media.width * 0.2, width: double.maxFinite, decoration: BoxDecoration( color: TColor.primaryColor2.withOpacity(0.3), diff --git a/lib/modele/manager_file.dart b/lib/modele/manager_file.dart index f07ffd5..0b453bd 100644 --- a/lib/modele/manager_file.dart +++ b/lib/modele/manager_file.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'dart:typed_data'; import 'package:csv/csv.dart'; import 'package:fit_tool/fit_tool.dart'; import 'package:path_provider/path_provider.dart'; @@ -26,7 +27,10 @@ class ManagerFile { return fitFile.toRows(); } - + List readFitFileWeb(Uint8List bytes) { + final fitFile = FitFile.fromBytes(bytes); + return fitFile.toRows(); + } // ------------- Get The path of application --- // Future get localPath async { final directory = await getApplicationDocumentsDirectory(); diff --git a/lib/modele/utile/home_view/home_view_util.dart b/lib/modele/utile/home_view/home_view_util.dart index abed685..44cbe8c 100644 --- a/lib/modele/utile/home_view/home_view_util.dart +++ b/lib/modele/utile/home_view/home_view_util.dart @@ -13,7 +13,7 @@ class HomeViewUtil { List bpmSecondes2 = List.from(bpmSecondes); return DataHomeView( - normaliserDeuxiemeElement(bpmSecondes), + bpmSecondes, normaliserDeuxiemeElement(bpmSecondes2), normaliserDeuxiemeElement(vitesseSecondes)); } diff --git a/lib/view/activity/web/web_list_activity.dart b/lib/view/activity/web/web_list_activity.dart index 4e9e7f6..f6d2530 100644 --- a/lib/view/activity/web/web_list_activity.dart +++ b/lib/view/activity/web/web_list_activity.dart @@ -1,3 +1,10 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; +import 'dart:html' as html; // Importation des fonctionnalités HTML + +import 'package:crypto/crypto.dart'; import 'package:file_picker/file_picker.dart'; import 'package:provider/provider.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; @@ -8,40 +15,45 @@ import 'package:smartfit_app_mobile/modele/manager_file.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:smartfit_app_mobile/common_widget/container/workout_row.dart'; import 'package:flutter/material.dart'; +import 'package:tuple/tuple.dart'; class WebListActivity extends StatefulWidget { const WebListActivity({super.key}); @override - State createState() => _WebListActivity(); + State createState() => _WebListActivityState(); } -class _WebListActivity extends State { +class _WebListActivityState extends State { FilePickerResult? result; IDataStrategy strategy = RequestApi(); - Future readFile(String nom) async { - ManagerFile x = ManagerFile(); - PlatformFile t = result!.files.single; - String? y = t.path; - if (t.path == null) { - print("t"); - } else { - List result = await x.readFitFile(y!); - print("test11"); - print(result); - print("test22"); - print(ActivityOfUser(nom, result).getHeartRateWithTime()); - print("test33"); - Provider.of(context, listen: false) - .addActivity(ActivityOfUser(nom, result)); - //print(x.getDistanceWithTime(ActivityOfUser(result))); - //print(x.getDistance(ActivityOfUser(result))); - //print(x.getAltitudeWithTime(ActivityOfUser(result))); - //print(x.getSpeedWithTime(ActivityOfUser(result))); + //late File x = File(file.path); + List parseFile(Uint8List bytes) { + String csvString = utf8.decode(bytes); // Convertit les bytes en chaîne UTF-8 + List lines = LineSplitter.split(csvString).toList(); // Sépare les lignes + + for (String line in lines) { + print(line); // Affiche chaque ligne du fichier } + + return lines; // Ou retournez les lignes du fichier } + void readFile(html.File file) async { + ManagerFile x = ManagerFile(); + final reader = html.FileReader(); + reader.readAsArrayBuffer(file); + reader.onLoadEnd.listen((event) { + if (reader.readyState == html.FileReader.DONE) { + Uint8List bytes = reader.result as Uint8List; + List result = x.readFitFileWeb(bytes) ; + Provider.of(context, listen: false) + .addActivity(ActivityOfUser(file.name, result )); + } + }); + } + List lastWorkoutArr = []; @override @@ -70,15 +82,15 @@ class _WebListActivity extends State { ), TextButton( onPressed: () async { - result = await FilePicker.platform.pickFiles(); - if (result == null) { - print("No file selected"); - } else { - for (var element in result!.files) { - readFile(element.name); - print(element.name); + html.FileUploadInputElement uploadInput = html.FileUploadInputElement(); + uploadInput.click(); + + uploadInput.onChange.listen((e) { + final files = uploadInput.files; + if (files != null && files.isNotEmpty) { + readFile(files[0]); // Lecture du fichier sélectionné } - } + }); }, child: Text( "Ajouter", @@ -147,5 +159,7 @@ class _WebListActivity extends State { ), ), ); - } -} + } + + +} \ No newline at end of file diff --git a/lib/view/home/web/web_homeview.dart b/lib/view/home/web/web_homeview.dart index f95605c..7c04521 100644 --- a/lib/view/home/web/web_homeview.dart +++ b/lib/view/home/web/web_homeview.dart @@ -1,14 +1,12 @@ -import 'package:dotted_dashed_line/dotted_dashed_line.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:simple_animation_progress_bar/simple_animation_progress_bar.dart'; -import 'package:simple_circular_progress_bar/simple_circular_progress_bar.dart'; -import 'package:smartfit_app_mobile/modele/user.dart'; +import 'package:smartfit_app_mobile/common_widget/container/ligne_container_stats.dart'; +import 'package:smartfit_app_mobile/common_widget/graph/bpm_and_speed_by_time.dart'; +import 'package:smartfit_app_mobile/common_widget/graph/bpm_by_time.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/common_widget/button/round_button.dart'; -import 'package:smartfit_app_mobile/view/home/activity_tracker.dart'; -import 'package:smartfit_app_mobile/view/home/notification_view.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 WebHomeView extends StatefulWidget { const WebHomeView({super.key}); @@ -18,230 +16,28 @@ class WebHomeView extends StatefulWidget { } class _WebHomeView extends State { - List lastWorkoutArr = [ - { - "name": "Full Body Workout", - "image": "assets/img/Workout1.png", - "kcal": "180", - "time": "20", - "progress": 0.3 - }, - { - "name": "Lower Body Workout", - "image": "assets/img/Workout2.png", - "kcal": "200", - "time": "30", - "progress": 0.4 - }, - { - "name": "Ab Workout", - "image": "assets/img/Workout3.png", - "kcal": "300", - "time": "40", - "progress": 0.7 - }, - ]; - List showingTooltipOnSpots = [0]; - - List allSpots = [FlSpot(0, 20)]; - - List waterArr = [ - {"title": "6am - 8am", "subtitle": "600ml"}, - {"title": "9am - 11am", "subtitle": "500ml"}, - {"title": "11am - 2pm", "subtitle": "1000ml"}, - {"title": "2pm - 4pm", "subtitle": "700ml"}, - {"title": "4pm - now", "subtitle": "900ml"}, - ]; + late DataHomeView data; + TextEditingController bpmController = TextEditingController(); @override Widget build(BuildContext context) { var media = MediaQuery.of(context).size; - User user = context.watch(); - final lineBarsData = [ - LineChartBarData( - showingIndicators: showingTooltipOnSpots, - spots: allSpots, - isCurved: false, - barWidth: 2, - belowBarData: BarAreaData( - show: true, - gradient: LinearGradient(colors: [ - TColor.secondaryColor1.withOpacity(0.4), - TColor.secondaryColor2.withOpacity(0.1), - ], begin: Alignment.topCenter, end: Alignment.bottomCenter), - ), - dotData: FlDotData(show: false), - gradient: LinearGradient( - colors: TColor.secondaryG, - ), - ), - ]; - - final tooltipsOnBar = lineBarsData[0]; + data = HomeViewUtil().initData(context); return Scaffold( backgroundColor: TColor.white, body: SingleChildScrollView( child: SafeArea( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15), + padding: const EdgeInsets.symmetric(horizontal: 200), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Bienvenue,", - style: TextStyle(color: TColor.gray, fontSize: 12), - ), - Text( - user.username, - style: TextStyle( - color: TColor.black, - fontSize: 20, - fontWeight: FontWeight.w700), - ), - ], - ), - IconButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const NotificationView(), - ), - ); - }, - icon: Image.asset( - "assets/img/notification_active.png", - width: 25, - height: 25, - fit: BoxFit.fitHeight, - )) - ], - ), - SizedBox( - height: media.width * 0.05, - ), - Container( - height: media.width * 0.4, - decoration: BoxDecoration( - gradient: LinearGradient(colors: TColor.primaryG), - borderRadius: BorderRadius.circular(media.width * 0.075)), - child: Stack(alignment: Alignment.center, children: [ - Image.asset( - "assets/img/bg_dots.png", - height: media.width * 0.4, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Padding( - padding: const EdgeInsets.symmetric( - vertical: 25, horizontal: 25), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Graph 1", - style: TextStyle( - color: TColor.white, - fontSize: 14, - fontWeight: FontWeight.w700), - ), - Text( - "Sous titre 1", - style: TextStyle( - color: TColor.white.withOpacity(0.7), - fontSize: 12), - ), - SizedBox( - height: media.width * 0.05, - ), - SizedBox( - width: 120, - height: 35, - child: RoundButton( - title: "Voir plus", - type: RoundButtonType.bgSGradient, - fontSize: 12, - fontWeight: FontWeight.w400, - onPressed: () {})) - ], - ), - AspectRatio( - aspectRatio: 1, - child: PieChart( - PieChartData( - pieTouchData: PieTouchData( - touchCallback: - (FlTouchEvent event, pieTouchResponse) {}, - ), - startDegreeOffset: 250, - borderData: FlBorderData( - show: false, - ), - sectionsSpace: 1, - centerSpaceRadius: 0, - sections: showingSections(), - ), - ), - ), - ], - ), - ) - ]), - ), SizedBox( - height: media.width * 0.05, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 15, horizontal: 15), - decoration: BoxDecoration( - color: TColor.primaryColor2.withOpacity(0.3), - borderRadius: BorderRadius.circular(15), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Suivi d'activité", - style: TextStyle( - color: TColor.black, - fontSize: 14, - fontWeight: FontWeight.w700), - ), - SizedBox( - width: 70, - height: 25, - child: RoundButton( - title: "Voir", - type: RoundButtonType.bgGradient, - fontSize: 12, - fontWeight: FontWeight.w400, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ActivityTrackerView(), - ), - ); - }, - ), - ) - ], - ), + height: media.width * 0.03, ), + const EnteteHomeView(), SizedBox( height: media.width * 0.05, ), @@ -255,625 +51,42 @@ class _WebHomeView extends State { SizedBox( height: media.width * 0.02, ), - ClipRRect( - borderRadius: BorderRadius.circular(25), - child: Container( - height: media.width * 0.4, - width: double.maxFinite, - decoration: BoxDecoration( - color: TColor.primaryColor2.withOpacity(0.3), - borderRadius: BorderRadius.circular(25), - ), - child: Stack( - alignment: Alignment.topLeft, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Graph 2 ( rhythme cardiaque )", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700), - ), - ShaderMask( - blendMode: BlendMode.srcIn, - shaderCallback: (bounds) { - return LinearGradient( - colors: TColor.primaryG, - begin: Alignment.centerLeft, - end: Alignment.centerRight) - .createShader(Rect.fromLTRB( - 0, 0, bounds.width, bounds.height)); - }, - child: Text( - "78 BPM", - style: TextStyle( - color: - TColor.primaryColor1.withOpacity(0.7), - fontWeight: FontWeight.w700, - fontSize: 18), - ), - ), - ], - ), - ), - LineChart( - LineChartData( - showingTooltipIndicators: - showingTooltipOnSpots.map((index) { - return ShowingTooltipIndicators([ - LineBarSpot( - tooltipsOnBar, - lineBarsData.indexOf(tooltipsOnBar), - tooltipsOnBar.spots[index], - ), - ]); - }).toList(), - lineTouchData: LineTouchData( - enabled: true, - handleBuiltInTouches: false, - touchCallback: (FlTouchEvent event, - LineTouchResponse? response) { - if (response == null || - response.lineBarSpots == null) { - return; - } - if (event is FlTapUpEvent) { - final spotIndex = - response.lineBarSpots!.first.spotIndex; - showingTooltipOnSpots.clear(); - setState(() { - showingTooltipOnSpots.add(spotIndex); - }); - } - }, - mouseCursorResolver: (FlTouchEvent event, - LineTouchResponse? response) { - if (response == null || - response.lineBarSpots == null) { - return SystemMouseCursors.basic; - } - return SystemMouseCursors.click; - }, - getTouchedSpotIndicator: - (LineChartBarData barData, - List spotIndexes) { - return spotIndexes.map((index) { - return TouchedSpotIndicatorData( - FlLine( - color: TColor.secondaryColor1, - ), - FlDotData( - show: true, - getDotPainter: - (spot, percent, barData, index) => - FlDotCirclePainter( - radius: 3, - color: Colors.white, - strokeWidth: 3, - strokeColor: TColor.secondaryColor1, - ), - ), - ); - }).toList(); - }, - touchTooltipData: LineTouchTooltipData( - tooltipBgColor: TColor.secondaryColor1, - tooltipRoundedRadius: 20, - getTooltipItems: - (List lineBarsSpot) { - return lineBarsSpot.map((lineBarSpot) { - return LineTooltipItem( - "il y a ${lineBarSpot.x.toInt()} minutes", - const TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.bold, - ), - ); - }).toList(); - }, - ), - ), - lineBarsData: lineBarsData, - minY: 0, - maxY: 130, - titlesData: FlTitlesData( - show: false, - ), - gridData: FlGridData(show: false), - borderData: FlBorderData( - show: true, - border: Border.all( - color: Colors.transparent, - ), - ), - ), - ) - ], - ), - ), - ), + GraphBpmByTime(media, data), SizedBox( height: media.width * 0.05, ), - Row( - children: [ - Expanded( - child: Container( - height: media.width * 0.95, - padding: const EdgeInsets.symmetric( - vertical: 25, horizontal: 20), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(25), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Row( - children: [ - SimpleAnimationProgressBar( - height: media.width * 0.85, - width: media.width * 0.07, - backgroundColor: Colors.grey.shade100, - foregrondColor: Colors.purple, - ratio: 0.5, - direction: Axis.vertical, - curve: Curves.fastLinearToSlowEaseIn, - duration: const Duration(seconds: 3), - borderRadius: BorderRadius.circular(15), - gradientColor: LinearGradient( - colors: TColor.primaryG, - begin: Alignment.bottomCenter, - end: Alignment.topCenter), - ), - const SizedBox( - width: 10, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Graph 3", - style: TextStyle( - color: TColor.black, - fontSize: 12, - fontWeight: FontWeight.w700), - ), - ShaderMask( - blendMode: BlendMode.srcIn, - shaderCallback: (bounds) { - return LinearGradient( - colors: TColor.primaryG, - begin: Alignment.centerLeft, - end: Alignment.centerRight) - .createShader(Rect.fromLTRB( - 0, 0, bounds.width, bounds.height)); - }, - child: Text( - "ex : objectif", - style: TextStyle( - color: TColor.white.withOpacity(0.7), - fontWeight: FontWeight.w700, - fontSize: 14), - ), - ), - const SizedBox( - height: 10, - ), - Text( - "Mis à jour en temps réel", - style: TextStyle( - color: TColor.gray, - fontSize: 12, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: waterArr.map((wObj) { - var isLast = wObj == waterArr.last; - return Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Container( - margin: - const EdgeInsets.symmetric( - vertical: 4), - width: 10, - height: 10, - decoration: BoxDecoration( - color: TColor.secondaryColor1 - .withOpacity(0.5), - borderRadius: - BorderRadius.circular(5), - ), - ), - if (!isLast) - DottedDashedLine( - height: media.width * 0.078, - width: 0, - dashColor: TColor - .secondaryColor1 - .withOpacity(0.5), - axis: Axis.vertical) - ], - ), - const SizedBox( - width: 10, - ), - Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - wObj["title"].toString(), - style: TextStyle( - color: TColor.gray, - fontSize: 10, - ), - ), - ShaderMask( - blendMode: BlendMode.srcIn, - shaderCallback: (bounds) { - return LinearGradient( - colors: - TColor.secondaryG, - begin: Alignment - .centerLeft, - end: Alignment - .centerRight) - .createShader(Rect.fromLTRB( - 0, - 0, - bounds.width, - bounds.height)); - }, - child: Text( - wObj["subtitle"].toString(), - style: TextStyle( - color: TColor.white - .withOpacity(0.7), - fontSize: 12), - ), - ), - ], - ) - ], - ); - }).toList(), - ) - ], - )) - ], - ), - ), - ), - SizedBox( - width: media.width * 0.05, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: double.maxFinite, - height: media.width * 0.45, - padding: const EdgeInsets.symmetric( - vertical: 25, horizontal: 20), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(25), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Graph 4", - style: TextStyle( - color: TColor.black, - fontSize: 12, - fontWeight: FontWeight.w700), - ), - ShaderMask( - blendMode: BlendMode.srcIn, - shaderCallback: (bounds) { - return LinearGradient( - colors: TColor.primaryG, - begin: Alignment.centerLeft, - end: Alignment.centerRight) - .createShader(Rect.fromLTRB( - 0, 0, bounds.width, bounds.height)); - }, - child: Text( - "durée", - style: TextStyle( - color: TColor.white.withOpacity(0.7), - fontWeight: FontWeight.w700, - fontSize: 14), - ), - ), - const Spacer(), - Image.asset("assets/img/sleep_graph.png", - width: double.maxFinite, - height: 80, - fit: BoxFit.fitWidth) - ]), - ), - SizedBox( - height: media.width * 0.05, - ), - Container( - width: double.maxFinite, - height: media.width * 0.45, - padding: const EdgeInsets.symmetric( - vertical: 25, horizontal: 20), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(25), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Calories", - style: TextStyle( - color: TColor.black, - fontSize: 12, - fontWeight: FontWeight.w700), - ), - ShaderMask( - blendMode: BlendMode.srcIn, - shaderCallback: (bounds) { - return LinearGradient( - colors: TColor.primaryG, - begin: Alignment.centerLeft, - end: Alignment.centerRight) - .createShader(Rect.fromLTRB( - 0, 0, bounds.width, bounds.height)); - }, - child: Text( - "760 kCal", - style: TextStyle( - color: TColor.white.withOpacity(0.7), - fontWeight: FontWeight.w700, - fontSize: 14), - ), - ), - const Spacer(), - Container( - alignment: Alignment.center, - child: SizedBox( - width: media.width * 0.2, - height: media.width * 0.2, - child: Stack( - alignment: Alignment.center, - children: [ - Container( - width: media.width * 0.15, - height: media.width * 0.15, - alignment: Alignment.center, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: TColor.primaryG), - borderRadius: BorderRadius.circular( - media.width * 0.075), - ), - child: FittedBox( - child: Text( - "230kCal\nrestantes", - textAlign: TextAlign.center, - style: TextStyle( - color: TColor.white, - fontSize: 11), - ), - ), - ), - SimpleCircularProgressBar( - progressStrokeWidth: 10, - backStrokeWidth: 10, - progressColors: TColor.primaryG, - backColor: Colors.grey.shade100, - valueNotifier: ValueNotifier(50), - startAngle: -180, - ), - ], - ), - ), - ) - ]), - ), - ], - )) - ], - ), + const LigneContainerStats("1", "2", "3", "s", "s", "s"), SizedBox( - height: media.width * 0.1, + height: media.width * 0.05, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "graph 5", + "Rythme cardique et vitesse", style: TextStyle( color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700), ), - Container( - height: 30, - padding: const EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - gradient: LinearGradient(colors: TColor.primaryG), - borderRadius: BorderRadius.circular(15), - ), - child: DropdownButtonHideUnderline( - child: DropdownButton( - items: ["Semaine", "Mois"] - .map((name) => DropdownMenuItem( - value: name, - child: Text( - name, - style: TextStyle( - color: TColor.gray, fontSize: 14), - ), - )) - .toList(), - onChanged: (value) {}, - icon: Icon(Icons.expand_more, color: TColor.white), - hint: Text( - "Semaine", - textAlign: TextAlign.center, - style: - TextStyle(color: TColor.white, fontSize: 12), - ), - ), - )), ], ), SizedBox( height: media.width * 0.05, ), - Container( - padding: const EdgeInsets.only(left: 15), - height: media.width * 0.5, - width: double.maxFinite, - child: LineChart( - LineChartData( - showingTooltipIndicators: - showingTooltipOnSpots.map((index) { - return ShowingTooltipIndicators([ - LineBarSpot( - tooltipsOnBar, - lineBarsData.indexOf(tooltipsOnBar), - tooltipsOnBar.spots[index], - ), - ]); - }).toList(), - lineTouchData: LineTouchData( - enabled: true, - handleBuiltInTouches: false, - touchCallback: (FlTouchEvent event, - LineTouchResponse? response) { - if (response == null || - response.lineBarSpots == null) { - return; - } - if (event is FlTapUpEvent) { - final spotIndex = - response.lineBarSpots!.first.spotIndex; - showingTooltipOnSpots.clear(); - setState(() { - showingTooltipOnSpots.add(spotIndex); - }); - } - }, - mouseCursorResolver: (FlTouchEvent event, - LineTouchResponse? response) { - if (response == null || - response.lineBarSpots == null) { - return SystemMouseCursors.basic; - } - return SystemMouseCursors.click; - }, - getTouchedSpotIndicator: (LineChartBarData barData, - List spotIndexes) { - return spotIndexes.map((index) { - return TouchedSpotIndicatorData( - FlLine( - color: Colors.transparent, - ), - FlDotData( - show: true, - getDotPainter: - (spot, percent, barData, index) => - FlDotCirclePainter( - radius: 3, - color: Colors.white, - strokeWidth: 3, - strokeColor: TColor.secondaryColor1, - ), - ), - ); - }).toList(); - }, - touchTooltipData: LineTouchTooltipData( - tooltipBgColor: TColor.secondaryColor1, - tooltipRoundedRadius: 20, - getTooltipItems: (List lineBarsSpot) { - return lineBarsSpot.map((lineBarSpot) { - return LineTooltipItem( - "il y a ${lineBarSpot.x.toInt()} minutes", - const TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.bold, - ), - ); - }).toList(); - }, - ), - ), - lineBarsData: lineBarsData1, - minY: -0.5, - maxY: 110, - titlesData: FlTitlesData( - show: true, - leftTitles: AxisTitles(), - topTitles: AxisTitles(), - bottomTitles: AxisTitles( - sideTitles: bottomTitles, - ), - rightTitles: AxisTitles( - sideTitles: rightTitles, - )), - gridData: FlGridData( - show: true, - drawHorizontalLine: true, - horizontalInterval: 25, - drawVerticalLine: false, - getDrawingHorizontalLine: (value) { - return FlLine( - color: TColor.gray.withOpacity(0.15), - strokeWidth: 2, - ); - }, - ), - borderData: FlBorderData( - show: true, - border: Border.all( - color: Colors.transparent, - ), - ), - ), - )), + GraphBpmAndSpeedByTime(media, data), SizedBox( height: media.width * 0.05, ), + const LigneContainerStats("1", "2", "3", "s", "s", "s"), SizedBox( - height: media.width * 0.1, + height: media.width * 0.05, ), + Container( + padding: const EdgeInsets.only(left: 15), + height: media.width * 0.5, + width: double.maxFinite, + child: LineChart(LineChartData())) ], ), ), @@ -881,190 +94,4 @@ class _WebHomeView extends State { ), ); } - - void updateChartData(List newData) { - setState(() { - allSpots = newData; - }); - } - - List showingSections() { - return List.generate( - 2, - (i) { - var color0 = TColor.secondaryColor1; - - switch (i) { - case 0: - return PieChartSectionData( - color: color0, - value: 33, - title: '', - radius: 55, - titlePositionPercentageOffset: 0.55, - badgeWidget: const Text( - "20,1", - style: TextStyle( - color: Colors.white, - fontSize: 12, - fontWeight: FontWeight.w700), - )); - case 1: - return PieChartSectionData( - color: Colors.white, - value: 75, - title: '', - radius: 45, - titlePositionPercentageOffset: 0.55, - ); - - default: - throw Error(); - } - }, - ); - } - - LineTouchData get lineTouchData1 => LineTouchData( - handleBuiltInTouches: true, - touchTooltipData: LineTouchTooltipData( - tooltipBgColor: Colors.blueGrey.withOpacity(0.8), - ), - ); - - List get lineBarsData1 => [ - lineChartBarData1_1, - lineChartBarData1_2, - ]; - - LineChartBarData get lineChartBarData1_1 => LineChartBarData( - isCurved: true, - gradient: LinearGradient(colors: [ - TColor.primaryColor2.withOpacity(0.5), - TColor.primaryColor1.withOpacity(0.5), - ]), - barWidth: 4, - isStrokeCapRound: true, - dotData: FlDotData(show: false), - belowBarData: BarAreaData(show: false), - spots: const [ - FlSpot(1, 35), - FlSpot(2, 70), - FlSpot(3, 40), - FlSpot(4, 80), - FlSpot(5, 25), - FlSpot(6, 70), - FlSpot(7, 35), - ], - ); - - LineChartBarData get lineChartBarData1_2 => LineChartBarData( - isCurved: true, - gradient: LinearGradient(colors: [ - TColor.secondaryColor2.withOpacity(0.5), - TColor.secondaryColor1.withOpacity(0.5), - ]), - barWidth: 2, - isStrokeCapRound: true, - dotData: FlDotData(show: false), - belowBarData: BarAreaData( - show: false, - ), - spots: const [ - FlSpot(1, 80), - FlSpot(2, 50), - FlSpot(3, 90), - FlSpot(4, 40), - FlSpot(5, 80), - FlSpot(6, 35), - FlSpot(7, 60), - ], - ); - - SideTitles get rightTitles => SideTitles( - getTitlesWidget: rightTitleWidgets, - showTitles: true, - interval: 20, - reservedSize: 40, - ); - - Widget rightTitleWidgets(double value, TitleMeta meta) { - String text; - switch (value.toInt()) { - case 0: - text = '0%'; - break; - case 20: - text = '20%'; - break; - case 40: - text = '40%'; - break; - case 60: - text = '60%'; - break; - case 80: - text = '80%'; - break; - case 100: - text = '100%'; - break; - default: - return Container(); - } - - return Text(text, - style: TextStyle( - color: TColor.gray, - fontSize: 12, - ), - textAlign: TextAlign.center); - } - - SideTitles get bottomTitles => SideTitles( - showTitles: true, - reservedSize: 32, - interval: 1, - getTitlesWidget: bottomTitleWidgets, - ); - - Widget bottomTitleWidgets(double value, TitleMeta meta) { - var style = TextStyle( - color: TColor.gray, - fontSize: 12, - ); - Widget text; - switch (value.toInt()) { - case 1: - text = Text('Dim', style: style); - break; - case 2: - text = Text('Lun', style: style); - break; - case 3: - text = Text('Mar', style: style); - break; - case 4: - text = Text('Mer', style: style); - break; - case 5: - text = Text('Jeu', style: style); - break; - case 6: - text = Text('Ven', style: style); - break; - case 7: - text = Text('Sam', style: style); - break; - default: - text = Text('', style: style); - break; - } - - return SideTitleWidget( - axisSide: meta.axisSide, - space: 10, - child: text, - ); - } }