diff --git a/.drone.yml b/.drone.yml index e380b6d..5208750 100644 --- a/.drone.yml +++ b/.drone.yml @@ -40,5 +40,5 @@ steps: - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -D sonar.projectKey=SmartFit_Mobile -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar -D sonar.login=$${SONAR_TOKEN} + - sonar-scanner -D sonar.projectKey=SmartFit_Mobile -D sonar.sources=./lib -D sonar.host.url=https://codefirst.iut.uca.fr/sonar -D sonar.login=$${SONAR_TOKEN} depends_on: [ build-apk, build-web ] diff --git a/lib/common_widget/container/list/list_activity.dart b/lib/common_widget/container/list/list_activity.dart new file mode 100644 index 0000000..f04d84b --- /dev/null +++ b/lib/common_widget/container/list/list_activity.dart @@ -0,0 +1,81 @@ +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/modele/user.dart'; +import 'package:smartfit_app_mobile/modele/utile/list_activity/list_activity_utile.dart'; +import 'package:tuple/tuple.dart'; + +class ListActivity extends StatefulWidget { + const ListActivity({Key? key}) : super(key: key); + + @override + State createState() => _ListActivity(); +} + +class _ListActivity extends State { + final ListActivityUtile _utile = ListActivityUtile(); + + @override + Widget build(BuildContext context) { + return Material( + color: Colors.transparent, + child: ListView.builder( + padding: EdgeInsets.zero, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: Provider.of(context, listen: true).listActivity.length, + itemBuilder: (context, index) { + var activityObj = + Provider.of(context, listen: true).listActivity[index]; + var activityMap = activityObj.toMap(); + + 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); + 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/profile/profile_compte.dart b/lib/common_widget/container/profile/profile_compte.dart new file mode 100644 index 0000000..6b80f0f --- /dev/null +++ b/lib/common_widget/container/profile/profile_compte.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/common/colo_extension.dart'; +import 'package:smartfit_app_mobile/common_widget/setting_row.dart'; +import 'package:smartfit_app_mobile/view/profile/change_email.dart'; +import 'package:smartfit_app_mobile/view/profile/change_password.dart'; +import 'package:smartfit_app_mobile/view/profile/change_username.dart'; + +class ProfileCompte extends StatelessWidget { + const ProfileCompte(this.accountArr, {super.key}); + + final List accountArr; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), + decoration: BoxDecoration( + color: TColor.white, + borderRadius: BorderRadius.circular(15), + boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 2)]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Compte", + style: TextStyle( + color: TColor.black, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox( + height: 8, + ), + ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: accountArr.length, + itemBuilder: (context, index) { + var iObj = accountArr[index]; + return SettingRow( + icon: iObj["image"]!, + title: iObj["name"]!, + onPressed: () { + if (iObj["tag"] == "1") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ChangeUsernameView(), + ), + ); + } else if (iObj["tag"] == "2") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ChangePasswordView(), + ), + ); + } else { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ChangeEmailView(), + ), + ); + } + }, + ); + }, + ), + ], + ), + ); + } +} diff --git a/lib/common_widget/container/profile/profile_entete.dart b/lib/common_widget/container/profile/profile_entete.dart new file mode 100644 index 0000000..b95d21e --- /dev/null +++ b/lib/common_widget/container/profile/profile_entete.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/common/colo_extension.dart'; +import 'package:smartfit_app_mobile/common_widget/button/round_button.dart'; + +class ProfileEntete extends StatelessWidget { + const ProfileEntete(this.username, {super.key}); + + final String username; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(30), + child: Image.asset( + "assets/img/u1.png", + width: 50, + height: 50, + fit: BoxFit.cover, + ), + ), + const SizedBox( + width: 15, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + username, + style: TextStyle( + color: TColor.black, + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + Text( + "Course à pied", + style: TextStyle( + color: TColor.gray, + fontSize: 12, + ), + ) + ], + ), + ), + SizedBox( + width: 70, + height: 25, + child: RoundButton( + title: "Editer", + type: RoundButtonType.bgGradient, + fontSize: 12, + fontWeight: FontWeight.w400, + onPressed: () {}, + ), + ) + ], + ); + } +} diff --git a/lib/common_widget/container/profile/profile_info_user.dart b/lib/common_widget/container/profile/profile_info_user.dart new file mode 100644 index 0000000..05f7f9a --- /dev/null +++ b/lib/common_widget/container/profile/profile_info_user.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/common_widget/title_subtitle_cell.dart'; + +class ProfileInfoUser extends StatelessWidget { + const ProfileInfoUser({super.key}); + + @override + Widget build(BuildContext context) { + return const Row( + children: [ + Expanded( + child: TitleSubtitleCell( + title: "??? cm", + subtitle: "Taille", + ), + ), + SizedBox( + width: 15, + ), + Expanded( + child: TitleSubtitleCell( + title: "?? kg", + subtitle: "Poids", + ), + ), + SizedBox( + width: 15, + ), + Expanded( + child: TitleSubtitleCell( + title: "?? ans", + subtitle: "Age", + ), + ), + ], + ); + } +} diff --git a/lib/common_widget/container/profile/profile_notification.dart b/lib/common_widget/container/profile/profile_notification.dart new file mode 100644 index 0000000..b38a700 --- /dev/null +++ b/lib/common_widget/container/profile/profile_notification.dart @@ -0,0 +1,117 @@ +import 'package:animated_toggle_switch/animated_toggle_switch.dart'; +import 'package:flutter/material.dart'; +import 'package:smartfit_app_mobile/common/colo_extension.dart'; + +class ProfileNotification extends StatefulWidget { + const ProfileNotification(this.positive, {Key? key}) : super(key: key); + + final bool positive; + + @override + State createState() => _ProfileNotification(); +} + +class _ProfileNotification extends State { + @override + Widget build(BuildContext context) { + bool check = widget.positive; + return Container( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), + decoration: BoxDecoration( + color: TColor.white, + borderRadius: BorderRadius.circular(15), + boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 2)]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Notification", + style: TextStyle( + color: TColor.black, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox( + height: 8, + ), + SizedBox( + height: 30, + child: + Row(crossAxisAlignment: CrossAxisAlignment.center, children: [ + Image.asset("assets/img/p_notification.png", + height: 15, width: 15, fit: BoxFit.contain), + const SizedBox( + width: 15, + ), + Expanded( + child: Text( + "Push Notifications", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ), + ), + CustomAnimatedToggleSwitch( + current: check, + values: const [false, true], + spacing: 0.0, + indicatorSize: const Size.square(25.0), + animationDuration: const Duration(milliseconds: 200), + animationCurve: Curves.linear, + onChanged: (b) => setState(() => check = b), + iconBuilder: (context, local, global) { + return const SizedBox(); + }, + cursors: const ToggleCursors( + defaultCursor: SystemMouseCursors.click), + onTap: (_) => setState(() => check = !check), + iconsTappable: false, + wrapperBuilder: (context, global, child) { + return Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 10.0, + right: 10.0, + height: 20.0, + child: DecoratedBox( + decoration: BoxDecoration( + gradient: + LinearGradient(colors: TColor.secondaryG), + borderRadius: + const BorderRadius.all(Radius.circular(50.0)), + ), + )), + child, + ], + ); + }, + foregroundIndicatorBuilder: (context, global) { + return SizedBox.fromSize( + size: const Size(5, 5), + child: DecoratedBox( + decoration: BoxDecoration( + color: TColor.white, + borderRadius: + const BorderRadius.all(Radius.circular(50.0)), + boxShadow: const [ + BoxShadow( + color: Colors.black38, + spreadRadius: 0.05, + blurRadius: 1.1, + offset: Offset(0.0, 0.8)) + ], + ), + ), + ); + }, + ), + ]), + ) + ], + ), + ); + } +} diff --git a/lib/common_widget/container/profile/profile_other.dart b/lib/common_widget/container/profile/profile_other.dart new file mode 100644 index 0000000..621ff22 --- /dev/null +++ b/lib/common_widget/container/profile/profile_other.dart @@ -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/setting_row.dart'; +import 'package:smartfit_app_mobile/view/profile/contact_us_view.dart'; +import 'package:smartfit_app_mobile/view/profile/policy_view.dart'; + +class ProfileOther extends StatelessWidget { + const ProfileOther(this.otherArr, {super.key}); + + final List otherArr; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), + decoration: BoxDecoration( + color: TColor.white, + borderRadius: BorderRadius.circular(15), + boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 2)]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Autre", + style: TextStyle( + color: TColor.black, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox( + height: 8, + ), + ListView.builder( + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: otherArr.length, + itemBuilder: (context, index) { + var iObj = otherArr[index] as Map? ?? {}; + return SettingRow( + icon: iObj["image"].toString(), + title: iObj["name"].toString(), + onPressed: () { + if (iObj["tag"] == "6") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const PrivacyPolicyView(), + ), + ); + } else if (iObj["tag"] == "5") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const ContactUsView(), + ), + ); + } else { + // Autre logique si nécessaire pour d'autres éléments de la liste + } + }, + ); + }, + ) + ], + ), + ); + } +} diff --git a/lib/common_widget/graph/altitude_by_time.dart b/lib/common_widget/graph/altitude_by_time.dart index 63a9885..076c86b 100644 --- a/lib/common_widget/graph/altitude_by_time.dart +++ b/lib/common_widget/graph/altitude_by_time.dart @@ -1,11 +1,7 @@ -import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:responsive_builder/responsive_builder.dart'; -import 'package:smartfit_app_mobile/common/colo_extension.dart'; import 'package:smartfit_app_mobile/common_widget/graph/mobile/mobile_altitude_by_time.dart'; import 'package:smartfit_app_mobile/common_widget/graph/web/web_altitude_by_time.dart'; -import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart'; class GraphAltitudeByTime extends StatefulWidget { @@ -20,11 +16,11 @@ class GraphAltitudeByTime extends StatefulWidget { } class _GraphAltitudeByTime extends State { - @override + @override Widget build(BuildContext context) { return ScreenTypeLayout.builder( - mobile: (_) => MobileGraphAltitudeByTime(widget.media, widget.data), - desktop: (_) => WebGraphAltitudeByTime(widget.media, widget.data), + mobile: (_) => MobileGraphAltitudeByTime(widget.media, widget.data), + desktop: (_) => WebGraphAltitudeByTime(widget.media, widget.data), ); } -} \ No newline at end of file +} 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 2232b27..435bb87 100644 --- a/lib/common_widget/graph/bpm_and_speed_by_time.dart +++ b/lib/common_widget/graph/bpm_and_speed_by_time.dart @@ -1,7 +1,6 @@ -import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:responsive_builder/responsive_builder.dart'; -import 'package:smartfit_app_mobile/common/colo_extension.dart'; +import 'package:smartfit_app_mobile/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart'; import 'package:smartfit_app_mobile/common_widget/graph/mobile/mobile_bpm_and_speed_by_time.dart'; import 'package:smartfit_app_mobile/common_widget/graph/web/web_bpm_and_speed_by_time.dart'; import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart'; @@ -18,11 +17,15 @@ class GraphBpmAndSpeedByTime extends StatefulWidget { } class _GraphBpmAndSpeedByTime extends State { - @override + @override Widget build(BuildContext context) { + final FuncBpmAndSpeedByTime func = FuncBpmAndSpeedByTime(widget.data); + return ScreenTypeLayout.builder( - mobile: (_) => MobileGraphBpmAndSpeedByTime(widget.media, widget.data), - desktop: (_) => WebGraphBpmAndSpeedByTime(widget.media, widget.data), + mobile: (_) => + MobileGraphBpmAndSpeedByTime(widget.media, widget.data, func), + desktop: (_) => + WebGraphBpmAndSpeedByTime(widget.media, widget.data, func), ); } -} \ No newline at end of file +} diff --git a/lib/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart b/lib/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart new file mode 100644 index 0000000..ae9f413 --- /dev/null +++ b/lib/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart @@ -0,0 +1,105 @@ +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 FuncBpmAndSpeedByTime { + final DataHomeView data; + + FuncBpmAndSpeedByTime(this.data); + + List showingTooltipOnSpots = [0]; + + SideTitles get rightTitles => SideTitles( + getTitlesWidget: rightTitleWidgets, + showTitles: true, + interval: 20, + reservedSize: 40, + ); + + late final lineBarsData = [ + LineChartBarData( + spots: data.bpmSecondes, + 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: const FlDotData(show: false), + gradient: LinearGradient( + colors: TColor.secondaryG, + ), + ), + ]; + late final tooltipsOnBar = lineBarsData[0]; + + 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); + } + + 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: const FlDotData(show: false), + belowBarData: BarAreaData(show: false), + spots: data.vitesseSecondes, + ); + + 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: const FlDotData(show: false), + belowBarData: BarAreaData( + show: false, + ), + spots: data.bpmSecondes2, + ); +} diff --git a/lib/common_widget/graph/mobile/mobile_bpm_and_speed_by_time.dart b/lib/common_widget/graph/mobile/mobile_bpm_and_speed_by_time.dart index 350db88..a7ad501 100644 --- a/lib/common_widget/graph/mobile/mobile_bpm_and_speed_by_time.dart +++ b/lib/common_widget/graph/mobile/mobile_bpm_and_speed_by_time.dart @@ -1,15 +1,16 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:smartfit_app_mobile/modele/user.dart'; +import 'package:smartfit_app_mobile/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart'; import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart'; class MobileGraphBpmAndSpeedByTime extends StatefulWidget { final Size media; final DataHomeView data; + final FuncBpmAndSpeedByTime func; - const MobileGraphBpmAndSpeedByTime(this.media, this.data, {Key? key}) + const MobileGraphBpmAndSpeedByTime(this.media, this.data, this.func, + {Key? key}) : super(key: key); @override @@ -21,81 +22,6 @@ class _MobileGraphBpmAndSpeedByTime extends State { TextEditingController bpmController = TextEditingController(); - List showingTooltipOnSpots = [0]; - - 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); - } - - 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: const FlDotData(show: false), - belowBarData: BarAreaData(show: false), - spots: widget.data.vitesseSecondes, - ); - - 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: const FlDotData(show: false), - belowBarData: BarAreaData( - show: false, - ), - spots: widget.data.bpmSecondes2, - ); - @override Widget build(BuildContext context) { final double maxY = widget.data.maxBPM + 2; @@ -103,25 +29,6 @@ class _MobileGraphBpmAndSpeedByTime final double maxX = widget.data.bpmSecondes[widget.data.bpmSecondes.length - 1].x; const double minX = 0.0; - final lineBarsData = [ - LineChartBarData( - spots: widget.data.bpmSecondes, - 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: const FlDotData(show: false), - gradient: LinearGradient( - colors: TColor.secondaryG, - ), - ), - ]; - final tooltipsOnBar = lineBarsData[0]; return Container( padding: const EdgeInsets.only(left: 15), @@ -129,12 +36,13 @@ class _MobileGraphBpmAndSpeedByTime width: double.maxFinite, child: LineChart( LineChartData( - showingTooltipIndicators: showingTooltipOnSpots.map((index) { + showingTooltipIndicators: + widget.func.showingTooltipOnSpots.map((index) { return ShowingTooltipIndicators([ LineBarSpot( - tooltipsOnBar, - lineBarsData.indexOf(tooltipsOnBar), - tooltipsOnBar.spots[index], + widget.func.tooltipsOnBar, + widget.func.lineBarsData.indexOf(widget.func.tooltipsOnBar), + widget.func.tooltipsOnBar.spots[index], ), ]); }).toList(), @@ -147,9 +55,9 @@ class _MobileGraphBpmAndSpeedByTime } if (event is FlTapUpEvent) { final spotIndex = response.lineBarSpots!.first.spotIndex; - showingTooltipOnSpots.clear(); + widget.func.showingTooltipOnSpots.clear(); setState(() { - showingTooltipOnSpots.add(spotIndex); + widget.func.showingTooltipOnSpots.add(spotIndex); }); } }, @@ -197,7 +105,7 @@ class _MobileGraphBpmAndSpeedByTime }, ), ), - lineBarsData: lineBarsData1, + lineBarsData: widget.func.lineBarsData1, minY: 0, maxY: 110, titlesData: FlTitlesData( diff --git a/lib/common_widget/graph/mobile/mobile_bpm_by_time.dart b/lib/common_widget/graph/mobile/mobile_bpm_by_time.dart index 070b11c..d14962c 100644 --- a/lib/common_widget/graph/mobile/mobile_bpm_by_time.dart +++ b/lib/common_widget/graph/mobile/mobile_bpm_by_time.dart @@ -1,8 +1,6 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart'; class MobileBpmByTime extends StatefulWidget { diff --git a/lib/common_widget/graph/web/web_bpm_and_speed_by_time.dart b/lib/common_widget/graph/web/web_bpm_and_speed_by_time.dart index 061439c..1b9203d 100644 --- a/lib/common_widget/graph/web/web_bpm_and_speed_by_time.dart +++ b/lib/common_widget/graph/web/web_bpm_and_speed_by_time.dart @@ -1,15 +1,15 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:smartfit_app_mobile/modele/user.dart'; +import 'package:smartfit_app_mobile/common_widget/graph/data_for_graph/func_bpm_and_speed_by_time.dart'; import 'package:smartfit_app_mobile/modele/utile/home_view/data_home_view.dart'; class WebGraphBpmAndSpeedByTime extends StatefulWidget { final Size media; final DataHomeView data; + final FuncBpmAndSpeedByTime func; - const WebGraphBpmAndSpeedByTime(this.media, this.data, {Key? key}) + const WebGraphBpmAndSpeedByTime(this.media, this.data, this.func, {Key? key}) : super(key: key); @override @@ -20,81 +20,6 @@ class WebGraphBpmAndSpeedByTime extends StatefulWidget { class _WebGraphBpmAndSpeedByTime extends State { TextEditingController bpmController = TextEditingController(); - List showingTooltipOnSpots = [0]; - - 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); - } - - 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: const FlDotData(show: false), - belowBarData: BarAreaData(show: false), - spots: widget.data.vitesseSecondes, - ); - - 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: const FlDotData(show: false), - belowBarData: BarAreaData( - show: false, - ), - spots: widget.data.bpmSecondes2, - ); - @override Widget build(BuildContext context) { final double maxY = widget.data.maxBPM + 2; @@ -103,38 +28,19 @@ class _WebGraphBpmAndSpeedByTime extends State { widget.data.bpmSecondes[widget.data.bpmSecondes.length - 1].x; const double minX = 0.0; - final lineBarsData = [ - LineChartBarData( - spots: widget.data.bpmSecondes, - 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: const FlDotData(show: false), - gradient: LinearGradient( - colors: TColor.secondaryG, - ), - ), - ]; - final tooltipsOnBar = lineBarsData[0]; - return Container( padding: const EdgeInsets.only(left: 15), height: widget.media.width * 0.20, width: widget.media.width * 0.35, child: LineChart( LineChartData( - showingTooltipIndicators: showingTooltipOnSpots.map((index) { + showingTooltipIndicators: + widget.func.showingTooltipOnSpots.map((index) { return ShowingTooltipIndicators([ LineBarSpot( - tooltipsOnBar, - lineBarsData.indexOf(tooltipsOnBar), - tooltipsOnBar.spots[index], + widget.func.tooltipsOnBar, + widget.func.lineBarsData.indexOf(widget.func.tooltipsOnBar), + widget.func.tooltipsOnBar.spots[index], ), ]); }).toList(), @@ -147,9 +53,9 @@ class _WebGraphBpmAndSpeedByTime extends State { } if (event is FlTapUpEvent) { final spotIndex = response.lineBarSpots!.first.spotIndex; - showingTooltipOnSpots.clear(); + widget.func.showingTooltipOnSpots.clear(); setState(() { - showingTooltipOnSpots.add(spotIndex); + widget.func.showingTooltipOnSpots.add(spotIndex); }); } }, @@ -197,13 +103,13 @@ class _WebGraphBpmAndSpeedByTime extends State { }, ), ), - lineBarsData: lineBarsData1, + lineBarsData: widget.func.lineBarsData1, minY: 0, maxY: 110, titlesData: FlTitlesData( show: true, leftTitles: AxisTitles( - sideTitles: rightTitles, + sideTitles: widget.func.rightTitles, ), topTitles: const AxisTitles(), bottomTitles: AxisTitles( diff --git a/lib/common_widget/graph/web/web_bpm_by_time.dart b/lib/common_widget/graph/web/web_bpm_by_time.dart index b39cab2..c9d202b 100644 --- a/lib/common_widget/graph/web/web_bpm_by_time.dart +++ b/lib/common_widget/graph/web/web_bpm_by_time.dart @@ -24,7 +24,7 @@ class _WebBpmByTime extends State { context.watch().managerSelectedActivity.getMinBpm() - 2; final double maxX = widget.data.bpmSecondes[widget.data.bpmSecondes.length - 1].x; - final double minX = 0.0; + const double minX = 0.0; final lineBarsData = [ LineChartBarData( spots: widget.data.bpmSecondes, diff --git a/lib/common_widget/info.dart b/lib/common_widget/info.dart index d17ad64..f28d9f1 100644 --- a/lib/common_widget/info.dart +++ b/lib/common_widget/info.dart @@ -22,11 +22,11 @@ class Info extends StatelessWidget { } class Stats extends StatelessWidget { - String value; - String unit; - String label; + final String value; + final String unit; + final String label; - Stats({ + const Stats({ Key? key, required this.value, required this.unit, @@ -50,7 +50,7 @@ class Stats extends StatelessWidget { const TextSpan(text: ' '), TextSpan( text: unit, - style: TextStyle( + style: const TextStyle( fontSize: 10, fontWeight: FontWeight.w500, ), diff --git a/lib/modele/utile/home_view/home_view_util.dart b/lib/modele/utile/home_view/home_view_util.dart index 131f6fd..b1e2a94 100644 --- a/lib/modele/utile/home_view/home_view_util.dart +++ b/lib/modele/utile/home_view/home_view_util.dart @@ -1,9 +1,7 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:smartfit_app_mobile/modele/activity.dart'; import 'package:smartfit_app_mobile/modele/manager_file.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'; diff --git a/lib/modele/utile/list_activity/list_activity_utile.dart b/lib/modele/utile/list_activity/list_activity_utile.dart index 512280e..025b580 100644 --- a/lib/modele/utile/list_activity/list_activity_utile.dart +++ b/lib/modele/utile/list_activity/list_activity_utile.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:typed_data'; import 'package:csv/csv.dart'; import 'package:flutter/material.dart'; @@ -77,4 +78,27 @@ class ListActivityUtile { } return const Tuple2(true, "Yeah"); } + + Future deleteFileOnBDD(String token, String fileUuid) async { + Tuple2 result = await _strategy.deleteFile(token, fileUuid); + if (!result.item1) { + return false; + } + return true; + } + + void addFileMobile( + String path, String token, String filename, BuildContext context) async { + Tuple2 resultAdd = + await addFile(await File(path).readAsBytes(), filename, token); + if (!resultAdd.item1) { + //print("Message error"); + return; + } + Tuple2 resultGet = await getFiles(token, context); + if (!resultGet.item1) { + //print("Message error"); + return; + } + } } diff --git a/lib/modele/utile/maps/maps_utile.dart b/lib/modele/utile/maps/maps_utile.dart index 300c417..173e8ff 100644 --- a/lib/modele/utile/maps/maps_utile.dart +++ b/lib/modele/utile/maps/maps_utile.dart @@ -5,12 +5,12 @@ import 'package:smartfit_app_mobile/modele/user.dart'; class MapUtil { Set initPolines(BuildContext context, int largueur, Color couleur) { - Set _polylines = {}; - _polylines.add(Polyline( + Set polylines = {}; + polylines.add(Polyline( polylineId: const PolylineId("Polyline"), color: couleur, points: context.watch().managerSelectedActivity.getPosition(), width: largueur)); - return _polylines; + return polylines; } } diff --git a/lib/view/activity/mobile/mobile_list_activity.dart b/lib/view/activity/mobile/mobile_list_activity.dart index 61b9709..91edcb0 100644 --- a/lib/view/activity/mobile/mobile_list_activity.dart +++ b/lib/view/activity/mobile/mobile_list_activity.dart @@ -1,14 +1,10 @@ -import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart'; -import 'package:smartfit_app_mobile/modele/api/request_api.dart'; +import 'package:smartfit_app_mobile/common_widget/container/list/list_activity.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; -import 'package:smartfit_app_mobile/common_widget/container/workout_row.dart'; import 'package:smartfit_app_mobile/modele/utile/list_activity/list_activity_utile.dart'; -import 'package:tuple/tuple.dart'; class MobileListActivity extends StatefulWidget { const MobileListActivity({Key? key}) : super(key: key); @@ -19,31 +15,8 @@ class MobileListActivity extends StatefulWidget { class _MobileListActivity extends State { FilePickerResult? result; - final IDataStrategy _strategy = RequestApi(); final ListActivityUtile _utile = ListActivityUtile(); - Future deleteFileOnBDD(String token, String fileUuid) async { - Tuple2 result = await _strategy.deleteFile(token, fileUuid); - if (!result.item1) { - return false; - } - return true; - } - - void addFileMobile(String path, String token, String filename) async { - Tuple2 resultAdd = - await _utile.addFile(await File(path).readAsBytes(), filename, token); - if (!resultAdd.item1) { - //print("Message error"); - return; - } - Tuple2 resultGet = await _utile.getFiles(token, context); - if (!resultGet.item1) { - //print("Message error"); - return; - } - } - @override Widget build(BuildContext context) { var media = MediaQuery.of(context).size; @@ -82,10 +55,12 @@ class _MobileListActivity extends State { FilePickerResult? result = await FilePicker.platform.pickFiles(); if (result != null) { - addFileMobile( + // ignore: use_build_context_synchronously + _utile.addFileMobile( result.files.single.path!, Provider.of(context, listen: false).token, - result.files.single.name); + result.files.single.name, + context); } else { print("Picker"); // msg d'erreur @@ -117,75 +92,7 @@ class _MobileListActivity extends State { ), ) ]) - : Material( - color: Colors.transparent, - child: ListView.builder( - padding: EdgeInsets.zero, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: Provider.of(context, listen: true) - .listActivity - .length, - itemBuilder: (context, index) { - var activityObj = - Provider.of(context, listen: true) - .listActivity[index]; - var activityMap = activityObj.toMap(); - - return InkWell( - onTap: () {}, - child: WorkoutRow( - wObj: activityMap, - onDelete: () async { - // Attention toute modif peut amener à une surchage mémoire !! - if (await 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); - 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), - ), - ); - }, - ), - ), + : const ListActivity(), SizedBox( height: media.width * 0.1, ), diff --git a/lib/view/activity/web/web_list_activity.dart b/lib/view/activity/web/web_list_activity.dart index 9abfca7..9e7efe4 100644 --- a/lib/view/activity/web/web_list_activity.dart +++ b/lib/view/activity/web/web_list_activity.dart @@ -1,6 +1,7 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:smartfit_app_mobile/modele/utile/list_activity/list_activity_utile.dart'; +import 'package:smartfit_app_mobile/view/activity/list_activity.dart'; import 'package:tuple/tuple.dart'; import 'package:universal_html/html.dart' as html; @@ -10,7 +11,6 @@ import 'package:smartfit_app_mobile/common/colo_extension.dart'; import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart'; import 'package:smartfit_app_mobile/modele/api/request_api.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; -import 'package:smartfit_app_mobile/common_widget/container/workout_row.dart'; class WebListActivity extends StatefulWidget { const WebListActivity({super.key}); @@ -23,18 +23,6 @@ class _WebListActivityState extends State { FilePickerResult? result; IDataStrategy strategy = RequestApi(); final ListActivityUtile _utile = ListActivityUtile(); - final IDataStrategy _strategy = RequestApi(); - - Future deleteFileOnBDD(String token, String fileUuid) async { - Tuple2 result = await _strategy.deleteFile(token, fileUuid); - if (!result.item1) { - //print(fileUuid); - //print("msg d'erreur"); - //print(result.item2); - return false; - } - return true; - } void addFileWeb(html.File file, String token) async { final reader = html.FileReader(); @@ -130,58 +118,7 @@ class _WebListActivityState extends State { ), ) ]) - : Material( - color: Colors.transparent, - child: ListView.builder( - padding: EdgeInsets.zero, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: Provider.of(context, listen: true) - .listActivity - .length, - itemBuilder: (context, index) { - var activityObj = - Provider.of(context, listen: true) - .listActivity[index]; - var activityMap = activityObj.toMap(); - return InkWell( - onTap: () { - /* - setState(() { - firstActivityIndex = index; - }); - Provider.of(context, listen: false) - .removeActivity(activityObj); - Provider.of(context, listen: false) - .insertActivity(0, activityObj);*/ - }, - child: WorkoutRow( - wObj: activityMap, - onDelete: () async { - if (await deleteFileOnBDD( - Provider.of(context, listen: false) - .token, - activityObj.fileUuid)) { - Provider.of(context, listen: false) - .removeActivity(activityObj); - } - }, - onClick: () { - Provider.of(context, listen: false) - .removeActivity(activityObj); - Provider.of(context, listen: false) - .insertActivity(0, activityObj); - _utile.getContentActivity( - context, activityObj); - }, - isSelected: Provider.of(context) - .managerSelectedActivity - .fileNotSelected(activityObj.fileUuid), - ), - ); - }, - ), - ), + : const ListActivity(), SizedBox( height: media.width * 0.1, ), diff --git a/lib/view/home/activity_tracker.dart b/lib/view/home/activity_tracker.dart deleted file mode 100644 index ad5abdd..0000000 --- a/lib/view/home/activity_tracker.dart +++ /dev/null @@ -1,430 +0,0 @@ -import 'package:fl_chart/fl_chart.dart'; -import 'package:flutter/material.dart'; - -import '../../common/colo_extension.dart'; -import '../../common_widget/today_target_cell.dart'; - -class ActivityTrackerView extends StatefulWidget { - const ActivityTrackerView({super.key}); - - @override - State createState() => _ActivityTrackerViewState(); -} - -class _ActivityTrackerViewState extends State { - int touchedIndex = -1; - - List latestArr = [ - { - "image": "assets/img/workout1.svg", - "title": "Drinking 300ml Water", - "time": "About 1 minutes ago" - }, - { - "image": "assets/img/workout1.svg", - "title": "Eat Snack (Fitbar)", - "time": "About 3 hours ago" - }, - ]; - - @override - Widget build(BuildContext context) { - var media = MediaQuery.of(context).size; - return Scaffold( - appBar: AppBar( - backgroundColor: TColor.white, - centerTitle: true, - elevation: 0, - leading: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Container( - margin: const EdgeInsets.all(8), - height: 40, - width: 40, - alignment: Alignment.center, - decoration: BoxDecoration( - color: TColor.lightGray, - borderRadius: BorderRadius.circular(10)), - child: Image.asset( - "assets/img/black_btn.png", - width: 15, - height: 15, - fit: BoxFit.contain, - ), - ), - ), - title: Text( - "Suivi d'activité", - style: TextStyle( - color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700), - ), - actions: [ - InkWell( - onTap: () {}, - child: Container( - margin: const EdgeInsets.all(8), - height: 40, - width: 40, - alignment: Alignment.center, - decoration: BoxDecoration( - color: TColor.lightGray, - borderRadius: BorderRadius.circular(10)), - child: Image.asset( - "assets/img/more_btn.png", - width: 15, - height: 15, - fit: BoxFit.contain, - ), - ), - ) - ], - ), - backgroundColor: TColor.white, - body: SingleChildScrollView( - child: Container( - padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 25), - child: Column( - children: [ - Container( - padding: - const EdgeInsets.symmetric(vertical: 15, horizontal: 15), - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - TColor.primaryColor2.withOpacity(0.3), - TColor.primaryColor1.withOpacity(0.3) - ]), - borderRadius: BorderRadius.circular(15), - ), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Objectif d'aujourd'hui", - style: TextStyle( - color: TColor.black, - fontSize: 14, - fontWeight: FontWeight.w700), - ), - SizedBox( - width: 30, - height: 30, - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: TColor.primaryG, - ), - borderRadius: BorderRadius.circular(10), - ), - child: MaterialButton( - onPressed: () {}, - padding: EdgeInsets.zero, - height: 30, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(25)), - textColor: TColor.primaryColor1, - minWidth: double.maxFinite, - elevation: 0, - color: Colors.transparent, - child: const Icon( - Icons.add, - color: Colors.white, - size: 15, - )), - ), - ) - ], - ), - const SizedBox( - height: 15, - ), - const Row( - children: [ - Expanded( - child: TodayTargetCell( - icon: "assets/img/workout1.svg", - value: "800", - title: "Calories", - ), - ), - SizedBox( - width: 15, - ), - Expanded( - child: TodayTargetCell( - icon: "assets/img/workout1.svg", - value: "2400", - title: "Nombre pas", - ), - ), - ], - ) - ], - ), - ), - SizedBox( - height: media.width * 0.1, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Activité journalière", - 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( - height: media.width * 0.5, - padding: - const EdgeInsets.symmetric(vertical: 15, horizontal: 0), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 3) - ]), - child: BarChart(BarChartData( - barTouchData: BarTouchData( - touchTooltipData: BarTouchTooltipData( - tooltipBgColor: Colors.grey, - tooltipHorizontalAlignment: FLHorizontalAlignment.right, - tooltipMargin: 10, - getTooltipItem: (group, groupIndex, rod, rodIndex) { - String weekDay; - switch (group.x) { - case 0: - weekDay = 'Monday'; - break; - case 1: - weekDay = 'Tuesday'; - break; - case 2: - weekDay = 'Wednesday'; - break; - case 3: - weekDay = 'Thursday'; - break; - case 4: - weekDay = 'Friday'; - break; - case 5: - weekDay = 'Saturday'; - break; - case 6: - weekDay = 'Sunday'; - break; - default: - throw Error(); - } - return BarTooltipItem( - '$weekDay\n', - const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 14, - ), - children: [ - TextSpan( - text: (rod.toY - 1).toString(), - style: TextStyle( - color: TColor.white, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ], - ); - }, - ), - touchCallback: (FlTouchEvent event, barTouchResponse) { - setState(() { - if (!event.isInterestedForInteractions || - barTouchResponse == null || - barTouchResponse.spot == null) { - touchedIndex = -1; - return; - } - touchedIndex = - barTouchResponse.spot!.touchedBarGroupIndex; - }); - }, - ), - titlesData: FlTitlesData( - show: true, - rightTitles: AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - topTitles: AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - bottomTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - getTitlesWidget: getTitles, - reservedSize: 38, - ), - ), - leftTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: false, - ), - ), - ), - borderData: FlBorderData( - show: false, - ), - barGroups: showingGroups(), - gridData: FlGridData(show: false), - )), - ), - SizedBox( - height: media.width * 0.05, - ), - SizedBox( - height: media.width * 0.1, - ), - ], - ), - ), - ), - ); - } - - Widget getTitles(double value, TitleMeta meta) { - var style = TextStyle( - color: TColor.gray, - fontWeight: FontWeight.w500, - fontSize: 12, - ); - Widget text; - switch (value.toInt()) { - case 0: - text = Text('Dim', style: style); - break; - case 1: - text = Text('Lun', style: style); - break; - case 2: - text = Text('Mar', style: style); - break; - case 3: - text = Text('Mer', style: style); - break; - case 4: - text = Text('Jeu', style: style); - break; - case 5: - text = Text('Ven', style: style); - break; - case 6: - text = Text('Sam', style: style); - break; - default: - text = Text('', style: style); - break; - } - return SideTitleWidget( - axisSide: meta.axisSide, - space: 16, - child: text, - ); - } - - List showingGroups() => List.generate(7, (i) { - switch (i) { - case 0: - return makeGroupData(0, 5, TColor.primaryG, - isTouched: i == touchedIndex); - case 1: - return makeGroupData(1, 10.5, TColor.secondaryG, - isTouched: i == touchedIndex); - case 2: - return makeGroupData(2, 5, TColor.primaryG, - isTouched: i == touchedIndex); - case 3: - return makeGroupData(3, 7.5, TColor.secondaryG, - isTouched: i == touchedIndex); - case 4: - return makeGroupData(4, 15, TColor.primaryG, - isTouched: i == touchedIndex); - case 5: - return makeGroupData(5, 5.5, TColor.secondaryG, - isTouched: i == touchedIndex); - case 6: - return makeGroupData(6, 8.5, TColor.primaryG, - isTouched: i == touchedIndex); - default: - return throw Error(); - } - }); - - BarChartGroupData makeGroupData( - int x, - double y, - List barColor, { - bool isTouched = false, - double width = 22, - List showTooltips = const [], - }) { - return BarChartGroupData( - x: x, - barRods: [ - BarChartRodData( - toY: isTouched ? y + 1 : y, - gradient: LinearGradient( - colors: barColor, - begin: Alignment.topCenter, - end: Alignment.bottomCenter), - width: width, - borderSide: isTouched - ? const BorderSide(color: Colors.green) - : const BorderSide(color: Colors.white, width: 0), - backDrawRodData: BackgroundBarChartRodData( - show: true, - toY: 20, - color: TColor.lightGray, - ), - ), - ], - showingTooltipIndicators: showTooltips, - ); - } -} diff --git a/lib/view/main_tab/main_tab_view.dart b/lib/view/main_tab/main_tab_view.dart index 1d894c2..feed785 100644 --- a/lib/view/main_tab/main_tab_view.dart +++ b/lib/view/main_tab/main_tab_view.dart @@ -1,14 +1,7 @@ import 'package:responsive_builder/responsive_builder.dart'; -import 'package:smartfit_app_mobile/view/activity/list_activity.dart'; -import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:smartfit_app_mobile/common_widget/button/tab_button.dart'; -import 'package:smartfit_app_mobile/view/activity/activity.dart'; -import 'package:smartfit_app_mobile/view/home/home_view.dart'; import 'package:flutter/material.dart'; import 'package:smartfit_app_mobile/view/main_tab/mobile/mobile_main_tab_view.dart'; import 'package:smartfit_app_mobile/view/main_tab/web/web_main_tab_view.dart'; -import 'package:smartfit_app_mobile/view/map/my_map.dart'; -import 'package:smartfit_app_mobile/view/profile/profile_view.dart'; class MainTabView extends StatefulWidget { const MainTabView({super.key}); @@ -18,11 +11,11 @@ class MainTabView extends StatefulWidget { } class _MainTabViewState extends State { -@override + @override Widget build(BuildContext context) { return ScreenTypeLayout.builder( mobile: (_) => const MobileMainTabView(), desktop: (_) => const WebMainTabView(), ); } -} \ No newline at end of file +} diff --git a/lib/view/main_tab/select_view.dart b/lib/view/main_tab/select_view.dart deleted file mode 100644 index a2786bd..0000000 --- a/lib/view/main_tab/select_view.dart +++ /dev/null @@ -1,60 +0,0 @@ - - -//import '../sleep_tracker/sleep_tracker_view.dart'; -/* -class SelectView extends StatelessWidget { - const SelectView({super.key}); - - @override - Widget build(BuildContext context) { - // var media = MediaQuery.of(context).size; - - return Scaffold( - body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RoundButton( - title: "Workout Tracker", - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const BlankView(), - ), - ); - }), - const SizedBox( - height: 15, - ), - RoundButton( - title: "Meal Planner", - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const BlankView(), - ), - ); - }), - const SizedBox( - height: 15, - ), - RoundButton( - title: "Sleep Tracker", - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const BlankView(), - ), - ); - }) - ], - ), - ), - ); - } -} -*/ \ No newline at end of file diff --git a/lib/view/ne_pas_supprimer/home_view.txt b/lib/view/ne_pas_supprimer/home_view.txt deleted file mode 100644 index 0cb05f6..0000000 --- a/lib/view/ne_pas_supprimer/home_view.txt +++ /dev/null @@ -1,1050 +0,0 @@ -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/colo_extension.dart'; -import 'package:smartfit_app_mobile/common_widget/round_button.dart'; -import 'package:smartfit_app_mobile/view/home/activity_tracker.dart'; -import 'package:smartfit_app_mobile/view/home/notification_view.dart'; - -class MobileHomeView extends StatefulWidget { - const MobileHomeView({super.key}); - - @override - State createState() => _MobileHomeView(); -} - -class _MobileHomeView extends State { - List bpmSecondes = [FlSpot(0, 30)]; - List bpmSecondes2 = []; - double calories = 0.0; - List vitesseSecondes = [FlSpot(0, 30)]; - List altitudeSecondes = [FlSpot(0, 30)]; - - TextEditingController bpmController = TextEditingController(); - - void normaliserDeuxiemeElement(List liste) { - // Trouver le plus grand élément dans la liste - double maxElement = 0.0; - for (var spot in liste) { - if (spot.y > maxElement) { - maxElement = spot.y; - } - } - - // Calculer le facteur de normalisation - double normalisationFactor = maxElement != 0.0 ? 100 / maxElement : 1.0; - - // Mettre à jour tous les éléments de la liste - for (int i = 0; i < liste.length; i++) { - liste[i] = FlSpot(liste[i].x, liste[i].y * normalisationFactor); - } - } - - 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 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"}, - ]; - - @override - Widget build(BuildContext context) { - var media = MediaQuery.of(context).size; - - bpmSecondes = - Provider.of(context).listActivity[0].getHeartRateWithTime(); - vitesseSecondes = - Provider.of(context).listActivity[0].getSpeedWithTime(); - altitudeSecondes = - Provider.of(context).listActivity[0].getAltitudeWithTime(); - calories = double.parse( - Provider.of(context).listActivity[0].getTotalCalorie()); - - normaliserDeuxiemeElement(vitesseSecondes); - normaliserDeuxiemeElement(altitudeSecondes); - //bpmSecondes2 = List.from(bpmSecondes); - normaliserDeuxiemeElement(bpmSecondes); - - final lineBarsData = [ - LineChartBarData( - spots: bpmSecondes, - 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, - ), - ), - ]; - print("test5"); - - final tooltipsOnBar = lineBarsData[0]; - - return Scaffold( - backgroundColor: TColor.white, - body: SingleChildScrollView( - child: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15), - 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( - "Benjelloun Othmane", - 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.w0, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ActivityTrackerView(), - ), - ); - }, - ), - ) - ], - ), - ), - 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.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( - "Rythme cardiaque", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700), - ), - TextField( - controller: bpmController, - readOnly: true, - style: TextStyle( - color: - TColor.primaryColor1.withOpacity(0.8), - fontWeight: FontWeight.w700, - fontSize: 18), - decoration: InputDecoration( - border: InputBorder - .none, // Ajoutez cette ligne pour supprimer la bordure - ), - ), - ], - ), - ), - 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) { - bpmController.text = "${lineBarSpot.y} BPM"; - return LineTooltipItem( - "Seconde ${lineBarSpot.x.toInt() / 10}", - TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.bold, - ), - ); - }).toList(); - }, - ), - ), - lineBarsData: lineBarsData, - minY: 50, - maxY: 250, - titlesData: FlTitlesData( - show: false, - ), - gridData: FlGridData(show: false), - borderData: FlBorderData( - show: true, - border: Border.all( - color: Colors.transparent, - ), - ), - ), - ) - ], - ), - ), - ), - 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( - '${calories.toString()} 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( - '${200 - calories.toInt()} kCal\n restantes', - textAlign: TextAlign.center, - style: TextStyle( - color: TColor.white, - fontSize: 11), - ), - ), - ), - SimpleCircularProgressBar( - progressStrokeWidth: 10, - backStrokeWidth: 10, - progressColors: TColor.primaryG, - backColor: Colors.grey.shade100, - valueNotifier: ValueNotifier( - calories / 200 * 100), - startAngle: -180, - ), - ], - ), - ), - ) - ]), - ), - ], - )) - ], - ), - SizedBox( - height: media.width * 0.1, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Rythme cardique et vitesse", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700), - ), - ], - ), - 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( - "Seconde ${lineBarSpot.x.toInt() / 10} ", - const TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.bold, - ), - ); - }).toList(); - }, - ), - ), - lineBarsData: lineBarsData1, - minY: 0, - maxY: 110, - titlesData: FlTitlesData( - show: true, - leftTitles: AxisTitles(), - topTitles: AxisTitles(), - bottomTitles: AxisTitles(), - 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, - ), - ), - ), - )), - SizedBox( - height: media.width * 0.05, - ), - SizedBox( - height: media.width * 0.1, - ), - ], - ), - ), - ), - ), - ); - } - - 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: vitesseSecondes, - ); - - 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: bpmSecondes2, - ); - - 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: 50, - 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, - ); - } -} diff --git a/lib/view/ne_pas_supprimer/map.txt b/lib/view/ne_pas_supprimer/map.txt deleted file mode 100644 index c1e6fa5..0000000 --- a/lib/view/ne_pas_supprimer/map.txt +++ /dev/null @@ -1,131 +0,0 @@ -import 'dart:async'; -import 'package:flutter/material.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:location/location.dart'; -import 'package:smartfit_app_mobile/common/colo_extension.dart'; - -class MobileMyMaps extends StatefulWidget { - const MobileMyMaps({super.key}); - - @override - State createState() => _MobileMyMaps(); -} - -class _MobileMyMaps extends State { - Completer _googleMapController = Completer(); - CameraPosition? _cameraPosition; - Location? _location; - LocationData? _currentLocation; - List _polylineCoordinates = []; - Set _polylines = {}; - Set _markers = {}; // Add a set to store markers - - @override - void initState() { - _init(); - super.initState(); - } - - _init() async { - _location = Location(); - _cameraPosition = const CameraPosition( - target: LatLng( - 0, 0), // this is just the example lat and lng for initializing - zoom: 20); - _initLocation(); - } - - //function to listen when we move position - _initLocation() { - _location?.getLocation().then((location) { - _currentLocation = location; - }); - - _location?.onLocationChanged.listen((newLocation) { - setState(() { - _currentLocation = newLocation; - _polylineCoordinates.add(LatLng( - _currentLocation?.latitude ?? 0, - _currentLocation?.longitude ?? 0, - )); - _updatePolyline(); - }); - - moveToPosition(LatLng( - _currentLocation?.latitude ?? 0, _currentLocation?.longitude ?? 0)); - }); - } - - _updatePolyline() { - setState(() { - _polylines.clear(); - _polylines.add(Polyline( - polylineId: PolylineId("polyline"), - color: TColor.primaryColor1, - points: _polylineCoordinates, - width: 10, - )); - }); - } - - /* - // Updated _updateMarker to use the custom marker - _updateMarker(LatLng position) async { - final markerId = MarkerId('marker'); - final marker = Marker(markerId: markerId, position: position); - _markers.clear(); - _markers.add(marker); - }*/ - - 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: _getMap(), - ); - } - - Widget _getMarker() { - return Container( - width: 25, - height: 25, - 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) { - if (!_googleMapController.isCompleted) { - _googleMapController.complete(controller); - } - }, - polylines: _polylines, - markers: _markers, - ), - Positioned.fill( - child: Align(alignment: Alignment.center, child: _getMarker())) - ], - ); - } -} diff --git a/lib/view/profile/all_platforme/profile_view_allplatforme.dart b/lib/view/profile/all_platforme/profile_view_allplatforme.dart new file mode 100644 index 0000000..0aab244 --- /dev/null +++ b/lib/view/profile/all_platforme/profile_view_allplatforme.dart @@ -0,0 +1,89 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:smartfit_app_mobile/common/colo_extension.dart'; +import 'package:smartfit_app_mobile/common_widget/container/profile/profile_compte.dart'; +import 'package:smartfit_app_mobile/common_widget/container/profile/profile_entete.dart'; +import 'package:smartfit_app_mobile/common_widget/container/profile/profile_info_user.dart'; +import 'package:smartfit_app_mobile/common_widget/container/profile/profile_notification.dart'; +import 'package:smartfit_app_mobile/common_widget/container/profile/profile_other.dart'; +import 'package:smartfit_app_mobile/modele/user.dart'; + +class ProfileViewAllPlatforme extends StatefulWidget { + const ProfileViewAllPlatforme(this.positive, this.accountArr, this.otherArr, + {super.key}); + final bool positive; + final List accountArr; + final List otherArr; + + @override + State createState() => _ProfileViewAllPlatforme(); +} + +class _ProfileViewAllPlatforme extends State { + @override + Widget build(BuildContext context) { + String username = context.watch().username; + + return Scaffold( + appBar: AppBar( + backgroundColor: TColor.white, + centerTitle: true, + elevation: 0, + leadingWidth: 0, + title: Text( + "Profile", + style: TextStyle( + color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700), + ), + actions: [ + InkWell( + onTap: () {}, + child: Container( + margin: const EdgeInsets.all(8), + height: 20, + width: 20, + alignment: Alignment.center, + decoration: BoxDecoration( + color: TColor.lightGray, + borderRadius: BorderRadius.circular(10)), + child: Image.asset( + "assets/img/more_btn.png", + width: 15, + height: 15, + fit: BoxFit.contain, + ), + ), + ) + ], + ), + backgroundColor: TColor.white, + body: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 25), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ProfileEntete(username), + const SizedBox( + height: 15, + ), + const ProfileInfoUser(), + const SizedBox( + height: 25, + ), + ProfileCompte(widget.accountArr), + const SizedBox( + height: 25, + ), + ProfileNotification(widget.positive), + const SizedBox( + height: 25, + ), + ProfileOther(widget.otherArr) + ], + ), + ), + ), + ); + } +} diff --git a/lib/view/profile/change_password.dart b/lib/view/profile/change_password.dart index 6ff6525..afe2b7f 100644 --- a/lib/view/profile/change_password.dart +++ b/lib/view/profile/change_password.dart @@ -1,13 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:responsive_builder/responsive_builder.dart'; -import 'package:smartfit_app_mobile/common_widget/button/round_button.dart'; -import 'package:smartfit_app_mobile/common_widget/text_field/round_text_field.dart'; import 'package:smartfit_app_mobile/view/profile/mobile/mobile_change_password.dart'; import 'package:smartfit_app_mobile/view/profile/web/web_change_password.dart'; -import '../../common/colo_extension.dart'; - class ChangePasswordView extends StatefulWidget { const ChangePasswordView({super.key}); @@ -16,7 +11,7 @@ class ChangePasswordView extends StatefulWidget { } class _ChangePasswordViewState extends State { - @override + @override Widget build(BuildContext context) { return ScreenTypeLayout.builder( mobile: (_) => const MobileChangePasswordView(), diff --git a/lib/view/profile/change_username.dart b/lib/view/profile/change_username.dart index c7591f6..5978262 100644 --- a/lib/view/profile/change_username.dart +++ b/lib/view/profile/change_username.dart @@ -1,13 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:responsive_builder/responsive_builder.dart'; -import 'package:smartfit_app_mobile/common_widget/button/round_button.dart'; -import 'package:smartfit_app_mobile/common_widget/text_field/round_text_field.dart'; import 'package:smartfit_app_mobile/view/profile/mobile/mobile_change_username.dart'; import 'package:smartfit_app_mobile/view/profile/web/web_change_username.dart'; -import '../../common/colo_extension.dart'; - class ChangeUsernameView extends StatefulWidget { const ChangeUsernameView({super.key}); @@ -16,7 +11,7 @@ class ChangeUsernameView extends StatefulWidget { } class _ChangeUsernameViewState extends State { - @override + @override Widget build(BuildContext context) { return ScreenTypeLayout.builder( mobile: (_) => const MobileChangeUsernameView(), diff --git a/lib/view/profile/mobile/mobile_profile_view.dart b/lib/view/profile/mobile/mobile_profile_view.dart index 97dbbf9..430eab2 100644 --- a/lib/view/profile/mobile/mobile_profile_view.dart +++ b/lib/view/profile/mobile/mobile_profile_view.dart @@ -1,16 +1,5 @@ -import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:flutter/material.dart'; -import 'package:animated_toggle_switch/animated_toggle_switch.dart'; -import 'package:provider/provider.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/common_widget/setting_row.dart'; -import 'package:smartfit_app_mobile/common_widget/title_subtitle_cell.dart'; -import 'package:smartfit_app_mobile/view/profile/change_password.dart'; -import 'package:smartfit_app_mobile/view/profile/change_email.dart'; -import 'package:smartfit_app_mobile/view/profile/change_username.dart'; -import 'package:smartfit_app_mobile/view/profile/contact_us_view.dart'; -import 'package:smartfit_app_mobile/view/profile/policy_view.dart'; +import 'package:smartfit_app_mobile/view/profile/all_platforme/profile_view_allplatforme.dart'; class MobileProfileView extends StatefulWidget { const MobileProfileView({super.key}); @@ -50,375 +39,6 @@ class _MobileProfileView extends State { ]; @override Widget build(BuildContext context) { - String username = context.watch().username; - - return Scaffold( - appBar: AppBar( - backgroundColor: TColor.white, - centerTitle: true, - elevation: 0, - leadingWidth: 0, - title: Text( - "Profile", - style: TextStyle( - color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700), - ), - actions: [ - InkWell( - onTap: () {}, - child: Container( - margin: const EdgeInsets.all(8), - height: 20, - width: 20, - alignment: Alignment.center, - decoration: BoxDecoration( - color: TColor.lightGray, - borderRadius: BorderRadius.circular(10)), - child: Image.asset( - "assets/img/more_btn.png", - width: 15, - height: 15, - fit: BoxFit.contain, - ), - ), - ) - ], - ), - backgroundColor: TColor.white, - body: SingleChildScrollView( - child: Container( - padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 25), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(30), - child: Image.asset( - "assets/img/u1.png", - width: 50, - height: 50, - fit: BoxFit.cover, - ), - ), - const SizedBox( - width: 15, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - username, - style: TextStyle( - color: TColor.black, - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - Text( - "Course à pied", - style: TextStyle( - color: TColor.gray, - fontSize: 12, - ), - ) - ], - ), - ), - SizedBox( - width: 70, - height: 25, - child: RoundButton( - title: "Editer", - type: RoundButtonType.bgGradient, - fontSize: 12, - fontWeight: FontWeight.w400, - onPressed: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => const ActivityTrackerView(), - // ), - // ); - }, - ), - ) - ], - ), - const SizedBox( - height: 15, - ), - const Row( - children: [ - Expanded( - child: TitleSubtitleCell( - title: "??? cm", - subtitle: "Taille", - ), - ), - SizedBox( - width: 15, - ), - Expanded( - child: TitleSubtitleCell( - title: "?? kg", - subtitle: "Poids", - ), - ), - SizedBox( - width: 15, - ), - Expanded( - child: TitleSubtitleCell( - title: "?? ans", - subtitle: "Age", - ), - ), - ], - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Compte", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: accountArr.length, - itemBuilder: (context, index) { - var iObj = accountArr[index]; - return SettingRow( - icon: iObj["image"]!, - title: iObj["name"]!, - onPressed: () { - if (iObj["tag"] == "1") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ChangeUsernameView(), - ), - ); - } else if (iObj["tag"] == "2") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ChangePasswordView(), - ), - ); - } else { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const ChangeEmailView(), - ), - ); - } - }, - ); - }, - ), - ], - ), - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Notification", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - SizedBox( - height: 30, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset("assets/img/p_notification.png", - height: 15, width: 15, fit: BoxFit.contain), - const SizedBox( - width: 15, - ), - Expanded( - child: Text( - "Push Notifications", - style: TextStyle( - color: TColor.black, - fontSize: 12, - ), - ), - ), - CustomAnimatedToggleSwitch( - current: positive, - values: const [false, true], - spacing: 0.0, - indicatorSize: const Size.square(25.0), - animationDuration: - const Duration(milliseconds: 200), - animationCurve: Curves.linear, - onChanged: (b) => setState(() => positive = b), - iconBuilder: (context, local, global) { - return const SizedBox(); - }, - cursors: const ToggleCursors( - defaultCursor: SystemMouseCursors.click), - onTap: (_) => - setState(() => positive = !positive), - iconsTappable: false, - wrapperBuilder: (context, global, child) { - return Stack( - alignment: Alignment.center, - children: [ - Positioned( - left: 10.0, - right: 10.0, - height: 20.0, - child: DecoratedBox( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: TColor.secondaryG), - borderRadius: - const BorderRadius.all( - Radius.circular(50.0)), - ), - )), - child, - ], - ); - }, - foregroundIndicatorBuilder: (context, global) { - return SizedBox.fromSize( - size: const Size(5, 5), - child: DecoratedBox( - decoration: BoxDecoration( - color: TColor.white, - borderRadius: const BorderRadius.all( - Radius.circular(50.0)), - boxShadow: const [ - BoxShadow( - color: Colors.black38, - spreadRadius: 0.05, - blurRadius: 1.1, - offset: Offset(0.0, 0.8)) - ], - ), - ), - ); - }, - ), - ]), - ) - ], - ), - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Autre", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - ListView.builder( - physics: const NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: otherArr.length, - itemBuilder: (context, index) { - var iObj = otherArr[index] as Map? ?? {}; - return SettingRow( - icon: iObj["image"].toString(), - title: iObj["name"].toString(), - onPressed: () { - if (iObj["tag"] == "6") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const PrivacyPolicyView(), - ), - ); - } else if (iObj["tag"] == "5") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const ContactUsView(), - ), - ); - } else { - // Autre logique si nécessaire pour d'autres éléments de la liste - } - }, - ); - }, - ) - ], - ), - ) - ], - ), - ), - ), - ); + return ProfileViewAllPlatforme(positive, accountArr, otherArr); } } diff --git a/lib/view/profile/web/web_profile_view.dart b/lib/view/profile/web/web_profile_view.dart index 9b11d17..bb0b39b 100644 --- a/lib/view/profile/web/web_profile_view.dart +++ b/lib/view/profile/web/web_profile_view.dart @@ -1,16 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:animated_toggle_switch/animated_toggle_switch.dart'; -import 'package:provider/provider.dart'; -import 'package:smartfit_app_mobile/modele/user.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/common_widget/setting_row.dart'; -import 'package:smartfit_app_mobile/common_widget/title_subtitle_cell.dart'; -import 'package:smartfit_app_mobile/view/profile/change_password.dart'; -import 'package:smartfit_app_mobile/view/profile/change_email.dart'; -import 'package:smartfit_app_mobile/view/profile/change_username.dart'; -import 'package:smartfit_app_mobile/view/profile/contact_us_view.dart'; -import 'package:smartfit_app_mobile/view/profile/policy_view.dart'; +import 'package:smartfit_app_mobile/view/profile/all_platforme/profile_view_allplatforme.dart'; class WebProfileView extends StatefulWidget { const WebProfileView({super.key}); @@ -25,23 +14,27 @@ class _WebProfileView extends State { List accountArr = [ { "image": "assets/img/p_personal.png", - "name": "Changer son pseudo", + "name": "Changer son pseudo ", "tag": "1" }, { "image": "assets/img/p_personal.png", - "name": "Changer son email", + "name": "Changer son email ", "tag": "3" }, { "image": "assets/img/p_personal.png", - "name": "Changer son mot de passe", + "name": "Changer son mot de passe ", "tag": "2" }, ]; List otherArr = [ - {"image": "assets/img/p_contact.png", "name": "Nous contacter", "tag": "5"}, + { + "image": "assets/img/p_contact.png", + "name": "Nous contacter !!", + "tag": "5" + }, { "image": "assets/img/p_privacy.png", "name": "Politique de confidentialité", @@ -50,375 +43,6 @@ class _WebProfileView extends State { ]; @override Widget build(BuildContext context) { - String username = context.watch().username; - - return Scaffold( - appBar: AppBar( - backgroundColor: TColor.white, - centerTitle: true, - elevation: 0, - leadingWidth: 0, - title: Text( - "Profile", - style: TextStyle( - color: TColor.black, fontSize: 16, fontWeight: FontWeight.w700), - ), - actions: [ - InkWell( - onTap: () {}, - child: Container( - margin: const EdgeInsets.all(8), - height: 20, - width: 20, - alignment: Alignment.center, - decoration: BoxDecoration( - color: TColor.lightGray, - borderRadius: BorderRadius.circular(10)), - child: Image.asset( - "assets/img/more_btn.png", - width: 15, - height: 15, - fit: BoxFit.contain, - ), - ), - ) - ], - ), - backgroundColor: TColor.white, - body: SingleChildScrollView( - child: Container( - padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 25), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(30), - child: Image.asset( - "assets/img/u1.png", - width: 50, - height: 50, - fit: BoxFit.cover, - ), - ), - const SizedBox( - width: 15, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - username, - style: TextStyle( - color: TColor.black, - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - Text( - "Course à pied", - style: TextStyle( - color: TColor.gray, - fontSize: 12, - ), - ) - ], - ), - ), - SizedBox( - width: 70, - height: 25, - child: RoundButton( - title: "Editer", - type: RoundButtonType.bgGradient, - fontSize: 12, - fontWeight: FontWeight.w400, - onPressed: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => const ActivityTrackerView(), - // ), - // ); - }, - ), - ) - ], - ), - const SizedBox( - height: 15, - ), - const Row( - children: [ - Expanded( - child: TitleSubtitleCell( - title: "??? cm", - subtitle: "Taille", - ), - ), - SizedBox( - width: 15, - ), - Expanded( - child: TitleSubtitleCell( - title: "?? kg", - subtitle: "Poids", - ), - ), - SizedBox( - width: 15, - ), - Expanded( - child: TitleSubtitleCell( - title: "?? ans", - subtitle: "Age", - ), - ), - ], - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Compte", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: accountArr.length, - itemBuilder: (context, index) { - var iObj = accountArr[index]; - return SettingRow( - icon: iObj["image"]!, - title: iObj["name"]!, - onPressed: () { - if (iObj["tag"] == "1") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ChangeUsernameView(), - ), - ); - } else if (iObj["tag"] == "2") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const ChangePasswordView(), - ), - ); - } else { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const ChangeEmailView(), - ), - ); - } - }, - ); - }, - ), - ], - ), - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Notification", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - SizedBox( - height: 30, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset("assets/img/p_notification.png", - height: 15, width: 15, fit: BoxFit.contain), - const SizedBox( - width: 15, - ), - Expanded( - child: Text( - "Push Notifications", - style: TextStyle( - color: TColor.black, - fontSize: 12, - ), - ), - ), - CustomAnimatedToggleSwitch( - current: positive, - values: const [false, true], - spacing: 0.0, - indicatorSize: const Size.square(25.0), - animationDuration: - const Duration(milliseconds: 200), - animationCurve: Curves.linear, - onChanged: (b) => setState(() => positive = b), - iconBuilder: (context, local, global) { - return const SizedBox(); - }, - cursors: const ToggleCursors( - defaultCursor: SystemMouseCursors.click), - onTap: (_) => - setState(() => positive = !positive), - iconsTappable: false, - wrapperBuilder: (context, global, child) { - return Stack( - alignment: Alignment.center, - children: [ - Positioned( - left: 10.0, - right: 10.0, - height: 20.0, - child: DecoratedBox( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: TColor.secondaryG), - borderRadius: - const BorderRadius.all( - Radius.circular(50.0)), - ), - )), - child, - ], - ); - }, - foregroundIndicatorBuilder: (context, global) { - return SizedBox.fromSize( - size: const Size(5, 5), - child: DecoratedBox( - decoration: BoxDecoration( - color: TColor.white, - borderRadius: const BorderRadius.all( - Radius.circular(50.0)), - boxShadow: const [ - BoxShadow( - color: Colors.black38, - spreadRadius: 0.05, - blurRadius: 1.1, - offset: Offset(0.0, 0.8)) - ], - ), - ), - ); - }, - ), - ]), - ) - ], - ), - ), - const SizedBox( - height: 25, - ), - Container( - padding: - const EdgeInsets.symmetric(vertical: 10, horizontal: 15), - decoration: BoxDecoration( - color: TColor.white, - borderRadius: BorderRadius.circular(15), - boxShadow: const [ - BoxShadow(color: Colors.black12, blurRadius: 2) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Autre", - style: TextStyle( - color: TColor.black, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox( - height: 8, - ), - ListView.builder( - physics: const NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: otherArr.length, - itemBuilder: (context, index) { - var iObj = otherArr[index] as Map? ?? {}; - return SettingRow( - icon: iObj["image"].toString(), - title: iObj["name"].toString(), - onPressed: () { - if (iObj["tag"] == "6") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const PrivacyPolicyView(), - ), - ); - } else if (iObj["tag"] == "5") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const ContactUsView(), - ), - ); - } else { - // Autre logique si nécessaire pour d'autres éléments de la liste - } - }, - ); - }, - ) - ], - ), - ) - ], - ), - ), - ), - ); + return ProfileViewAllPlatforme(positive, accountArr, otherArr); } } diff --git a/lib/view/test/page_test.dart b/lib/view/test/page_test.dart index c051ed1..0ccb04c 100644 --- a/lib/view/test/page_test.dart +++ b/lib/view/test/page_test.dart @@ -1,16 +1,13 @@ import 'dart:convert'; import 'package:crypto/crypto.dart'; -import 'package:csv/csv.dart'; import 'package:fit_tool/fit_tool.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:file_picker/file_picker.dart'; import 'package:provider/provider.dart'; import 'dart:io'; import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart'; -import 'package:smartfit_app_mobile/modele/manager_file.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; import 'package:smartfit_app_mobile/modele/api/request_api.dart'; import 'package:tuple/tuple.dart'; @@ -19,8 +16,9 @@ import 'package:tuple/tuple.dart'; // Dossier de l'application Future get _localPath async { - final directory = await getApplicationDocumentsDirectory(); - return directory.path; + //final directory = await getApplicationDocumentsDirectory(); + //return directory.path; + return "PATH"; } // Uri du fichier @@ -81,11 +79,9 @@ class _TestPage extends State { FilePickerResult? result; IDataStrategy strategy = RequestApi(); String platforme = getPlatforme(); - final ManagerFile _managerFile = ManagerFile(); //late File x = File(file.path); Future readFile() async { - ManagerFile x = ManagerFile(); PlatformFile t = result!.files.single; String? y = t.path; if (t.path == null) { @@ -169,7 +165,7 @@ class _TestPage extends State { } csvData.insert(0, enteteCSV); - final csv = const ListToCsvConverter().convert(csvData); + //final csv = const ListToCsvConverter().convert(csvData); //await outFile.writeAsString(csv); // ------- FIN --------------- // @@ -261,7 +257,6 @@ class _TestPage extends State { print(res.item1); print(res.item2); - ManagerFile x = ManagerFile(); //File file = File("${await x.localPath}/Walking_2023-11-08T10_57_28.fit"); //await file.create(); //await file.writeAsBytes(res.item2); @@ -307,9 +302,7 @@ class _TestPage extends State { if (result == null) { print("No file selected"); } else { - for (var element in result!.files) { - readFile(); - } + readFile(); } }, child: const Text("File - ")), diff --git a/web/index.html b/web/index.html index ac02418..9439c9e 100644 --- a/web/index.html +++ b/web/index.html @@ -1,5 +1,5 @@ - + +