From 218179b9df1d820ba7a5b81999287beef239caca Mon Sep 17 00:00:00 2001 From: Enzo Date: Wed, 13 Dec 2023 15:00:50 +0100 Subject: [PATCH] commencement de logOff et deleteUser --- lib/view/home/prediction_view.dart | 5 +- .../profile_view_allplatforme.dart | 58 ++++++++++++++++++- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/lib/view/home/prediction_view.dart b/lib/view/home/prediction_view.dart index 60a8ef5..10790d6 100644 --- a/lib/view/home/prediction_view.dart +++ b/lib/view/home/prediction_view.dart @@ -45,7 +45,6 @@ class _PredictionState extends State { @override Widget build(BuildContext context) { - var media = MediaQuery.of(context).size; List listCategory = [_managerFile.marche, _managerFile.velo]; void prediction() async { @@ -54,7 +53,7 @@ class _PredictionState extends State { /* if (selectedCategory != _managerFile.marche || selectedCategory != _managerFile.velo) return;*/ - + Tuple2 resultat = await Provider.of(context, listen: false) .predictActivity(DateTime.now(), selectedCategory, tmp); @@ -164,7 +163,7 @@ class _PredictionState extends State { shrinkWrap: true, itemCount: lastWorkoutArr.length, itemBuilder: (context, index) { - var wObj = lastWorkoutArr[index] as Map ?? {}; + var wObj = lastWorkoutArr[index]; return InkWell( child: WorkoutRow(wObj: wObj), ); diff --git a/lib/view/profile/all_platforme/profile_view_allplatforme.dart b/lib/view/profile/all_platforme/profile_view_allplatforme.dart index 4406961..2f02f59 100644 --- a/lib/view/profile/all_platforme/profile_view_allplatforme.dart +++ b/lib/view/profile/all_platforme/profile_view_allplatforme.dart @@ -7,7 +7,11 @@ import 'package:smartfit_app_mobile/common_widget/container/profile/profile_comp 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_other.dart'; +import 'package:smartfit_app_mobile/modele/api/api_wrapper.dart'; import 'package:smartfit_app_mobile/modele/user.dart'; +import 'package:smartfit_app_mobile/modele/utile/info_message.dart'; +import 'package:smartfit_app_mobile/view/login/signup_view.dart'; +import 'package:tuple/tuple.dart'; class ProfileViewAllPlatforme extends StatefulWidget { final bool offlineSave; @@ -26,7 +30,25 @@ class _ProfileViewAllPlatforme extends State { @override Widget build(BuildContext context) { + ApiWrapper wrapper = ApiWrapper(); String username = context.watch().username; + InfoMessage infoManager = InfoMessage(); + + void logOff() { + // TODO + } + + void deleteUser() async { + // Ne marche pas !! + Tuple2 result = await wrapper.deleteUser( + Provider.of(context, listen: false).token, infoManager); + if (!result.item1) { + // Affiché erreur + } else { + Navigator.push(context, + MaterialPageRoute(builder: (context) => const SignUpView())); + } + } return Scaffold( appBar: AppBar( @@ -59,8 +81,6 @@ class _ProfileViewAllPlatforme extends State { const SizedBox( height: 25, ), - // TODO: Download/Delete (local) all users files on toggle ? - // TODO: Display size of download in Mo Visibility( visible: isNative, child: const Column( @@ -72,7 +92,39 @@ class _ProfileViewAllPlatforme extends State { ) ], )), - ProfileOther(widget.otherArr) + ProfileOther(widget.otherArr), + const SizedBox( + height: 25, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + style: TextButton.styleFrom( + backgroundColor: TColor.primaryColor1, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8))), + onPressed: logOff, + child: const Text('Déconnexion', + style: TextStyle(color: Colors.black)), + ), + const SizedBox( + width: 25, + ), + TextButton( + style: TextButton.styleFrom( + backgroundColor: TColor.primaryColor1, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8))), + onPressed: deleteUser, + child: const Text('Suprimé son compte', + style: TextStyle(color: Colors.black)), + ), + ], + ), + const SizedBox( + height: 25, + ) ], ), ),