diff --git a/lib/Modele/Api/request_api.dart b/lib/Modele/Api/request_api.dart index 6e12901..5fd3783 100644 --- a/lib/Modele/Api/request_api.dart +++ b/lib/Modele/Api/request_api.dart @@ -101,12 +101,22 @@ class RequestApi extends IDataStrategy { @override Future> postUser( String email, String hash, String username) async { - final response = await http.post(Uri.parse('$urlApi/user'), - body: { - "email": email, - "hash": hash, - "username": username - }); + print(email); + print(hash); + print(username); + + print({ + "\"email\"": "\"$email\"", + "\"hash\"": "\"$hash\"", + "\"username\"": "\"$username\"" + }); + + final response = + await http.post(Uri.parse('$urlApi/user'), body: { + "\"email\"": "\"$email\"", + "\"hash\"": "\"$hash\"", + "\"username\"": "\"$username\"" + }); if (response.statusCode == 200) { Map json = jsonDecode(response.body); diff --git a/lib/Modele/utile/login_user.dart b/lib/Modele/utile/login_user.dart index d07ce10..9ea6964 100644 --- a/lib/Modele/utile/login_user.dart +++ b/lib/Modele/utile/login_user.dart @@ -27,6 +27,8 @@ class Login { } void fillUser(BuildContext context, Map map, String token) { + print(map); + context.read().email = map["email"]; context.read().username = map["username"]; context.read().token = token; diff --git a/lib/View/activity/activity.dart b/lib/View/activity/activity.dart index db26c3f..db6d9a7 100644 --- a/lib/View/activity/activity.dart +++ b/lib/View/activity/activity.dart @@ -1,3 +1,8 @@ +import 'package:responsive_builder/responsive_builder.dart'; +import 'package:smartfit_app_mobile/View/home/mobile/mobile_Activity_view.dart'; +import 'package:smartfit_app_mobile/View/home/mobile/mobile_homeview.dart'; +import 'package:smartfit_app_mobile/View/home/web/web_Activity_view.dart'; +import 'package:smartfit_app_mobile/View/home/web/web_homeview.dart'; import 'package:smartfit_app_mobile/common_widget/steps.dart'; import 'package:smartfit_app_mobile/common_widget/graph.dart'; import 'package:smartfit_app_mobile/common_widget/info.dart' hide Stats; @@ -9,19 +14,9 @@ class Activity extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - body: Column( - children: const [ - Divider(height: 80), - Steps(), - Graph(), - Info(), - Divider(height: 30), - Stats(), - SizedBox(height: 30), - ], - ), + return ScreenTypeLayout.builder( + mobile: (_) => const MobileActivity(), + desktop: (_) => const WebActivity(), ); } } diff --git a/lib/View/home/blank_view.dart b/lib/View/home/blank_view.dart deleted file mode 100644 index 427d01a..0000000 --- a/lib/View/home/blank_view.dart +++ /dev/null @@ -1,19 +0,0 @@ - -import 'package:smartfit_app_mobile/common/colo_extension.dart'; -import 'package:flutter/material.dart'; - -class BlankView extends StatefulWidget { - const BlankView({super.key}); - - @override - State createState() => _BlankViewState(); -} - -class _BlankViewState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: TColor.white, - ); - } -} \ No newline at end of file diff --git a/lib/View/home/mobile/mobile_Activity_view.dart b/lib/View/home/mobile/mobile_Activity_view.dart new file mode 100644 index 0000000..c3db6b1 --- /dev/null +++ b/lib/View/home/mobile/mobile_Activity_view.dart @@ -0,0 +1,27 @@ +import 'package:smartfit_app_mobile/common_widget/steps.dart'; +import 'package:smartfit_app_mobile/common_widget/graph.dart'; +import 'package:smartfit_app_mobile/common_widget/info.dart' hide Stats; +import 'package:smartfit_app_mobile/common_widget/stats.dart'; +import 'package:flutter/material.dart'; + +class MobileActivity extends StatelessWidget { + const MobileActivity({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + body: Column( + children: const [ + Divider(height: 80), + Steps(), + Graph(), + Info(), + Divider(height: 30), + Stats(), + SizedBox(height: 30), + ], + ), + ); + } +} diff --git a/lib/View/home/web/web_Activity_view.dart b/lib/View/home/web/web_Activity_view.dart new file mode 100644 index 0000000..9cb40ee --- /dev/null +++ b/lib/View/home/web/web_Activity_view.dart @@ -0,0 +1,27 @@ +import 'package:smartfit_app_mobile/common_widget/steps.dart'; +import 'package:smartfit_app_mobile/common_widget/graph.dart'; +import 'package:smartfit_app_mobile/common_widget/info.dart' hide Stats; +import 'package:smartfit_app_mobile/common_widget/stats.dart'; +import 'package:flutter/material.dart'; + +class WebActivity extends StatelessWidget { + const WebActivity({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + body: Column( + children: const [ + Divider(height: 80), + Steps(), + Graph(), + Info(), + Divider(height: 30), + Stats(), + SizedBox(height: 30), + ], + ), + ); + } +} diff --git a/lib/View/home/web/web_homeview.dart b/lib/View/home/web/web_homeview.dart index 85f360c..bfe29fb 100644 --- a/lib/View/home/web/web_homeview.dart +++ b/lib/View/home/web/web_homeview.dart @@ -100,7 +100,7 @@ class _WebHomeView extends State { style: TextStyle(color: TColor.gray, fontSize: 12), ), Text( - user.email, + user.username, style: TextStyle( color: TColor.black, fontSize: 20, diff --git a/lib/View/login/Mobile/android_login_view.dart b/lib/View/login/Mobile/android_login_view.dart index 38ab17e..371966b 100644 --- a/lib/View/login/Mobile/android_login_view.dart +++ b/lib/View/login/Mobile/android_login_view.dart @@ -20,10 +20,20 @@ class _MobileLoginView extends State { bool _obscureText = true; bool _errorLogin = false; String _msgError = ""; + bool emailValidate = false; + bool passwordValidate = false; final controllerTextEmail = TextEditingController(); final controllerTextPassword = TextEditingController(); + @override + void initState() { + super.initState(); + // Start listening to changes. + controllerTextEmail.addListener(checkEmail); + controllerTextPassword.addListener(checkPassword); + } + // Toggles the password show status void _toggle() { setState(() { @@ -38,6 +48,25 @@ class _MobileLoginView extends State { }); } + void checkEmail() { + if (!controllerTextEmail.text.contains("@") && + !(controllerTextEmail.text.length > 6)) { + emailValidate = false; + // Faire un affichage + return; + } // Enlever l'affichage + emailValidate = true; + } + + void checkPassword() { + if (!(controllerTextEmail.text.length >= 4)) { + passwordValidate = false; + //Faire un affichage + return; + } // Enlever l'affichage + passwordValidate = true; + } + @override Widget build(BuildContext context) { var media = MediaQuery.of(context).size; @@ -118,6 +147,11 @@ class _MobileLoginView extends State { RoundButton( title: "Se connecter", onPressed: () async { + if (!emailValidate || !passwordValidate) { + _printMsgError( + "Les champs renseigné ne sont pas valide"); + return; + } Tuple2 result = await util.checkLoginAndPassword( controllerTextEmail.text, diff --git a/lib/View/login/Mobile/android_signup_view.dart b/lib/View/login/Mobile/android_signup_view.dart index a503692..63be393 100644 --- a/lib/View/login/Mobile/android_signup_view.dart +++ b/lib/View/login/Mobile/android_signup_view.dart @@ -22,10 +22,23 @@ class _MobileSignUpView extends State { bool _isCheck = false; String _msgError = ""; + bool emailValidate = false; + bool passwordValidate = false; + bool usernameValidate = false; + final controllerTextEmail = TextEditingController(); final controllerUsername = TextEditingController(); final controllerTextPassword = TextEditingController(); + @override + void initState() { + super.initState(); + // Start listening to changes. + controllerTextEmail.addListener(checkEmail); + controllerTextPassword.addListener(checkPassword); + controllerUsername.addListener(checkUsername); + } + // Toggles the password show status void _toggle() { setState(() { @@ -46,6 +59,33 @@ class _MobileSignUpView extends State { }); } + void checkEmail() { + if (!controllerTextEmail.text.contains("@") && + !(controllerTextEmail.text.length > 6)) { + emailValidate = false; + // Faire un affichage + return; + } // Enlever l'affichage + emailValidate = true; + } + + void checkPassword() { + if (!(controllerTextEmail.text.length >= 4)) { + passwordValidate = false; + //Faire un affichage + return; + } // Enlever l'affichage + passwordValidate = true; + } + + void checkUsername() { + if (controllerUsername.text.isEmpty) { + usernameValidate = false; + return; + } + usernameValidate = true; + } + @override Widget build(BuildContext context) { var media = MediaQuery.of(context).size; @@ -144,6 +184,14 @@ class _MobileSignUpView extends State { RoundButton( title: "Créer un compte", onPressed: () async { + if (!emailValidate || + !passwordValidate || + !usernameValidate) { + _printMsgError( + "Les champs renseigné ne sont pas valide"); + return; + } + Tuple2 result = await util.createUser( controllerTextEmail.text, controllerUsername.text, diff --git a/lib/View/login/web/web_login_view.dart b/lib/View/login/web/web_login_view.dart index 8ee22cd..442341a 100644 --- a/lib/View/login/web/web_login_view.dart +++ b/lib/View/login/web/web_login_view.dart @@ -21,10 +21,20 @@ class _WebLoginView extends State { bool _obscureText = true; bool _errorLogin = false; String _msgError = ""; + bool emailValidate = false; + bool passwordValidate = false; final controllerTextEmail = TextEditingController(); final controllerTextPassword = TextEditingController(); + @override + void initState() { + super.initState(); + // Start listening to changes. + controllerTextEmail.addListener(checkEmail); + controllerTextPassword.addListener(checkPassword); + } + // Toggles the password show status void _toggle() { setState(() { @@ -39,6 +49,27 @@ class _WebLoginView extends State { }); } + void checkEmail() { + /* + if (!controllerTextEmail.text.contains("@") && + !(controllerTextEmail.text.length > 6)) { + emailValidate = false; + // Faire un affichage + return; + } // Enlever l'affichage*/ + emailValidate = true; + } + + void checkPassword() { + /* + if (!(controllerTextEmail.text.length >= 4)) { + passwordValidate = false; + //Faire un affichage + return; + } // Enlever l'affichage*/ + passwordValidate = true; + } + @override Widget build(BuildContext context) { var media = MediaQuery.of(context).size; @@ -119,6 +150,11 @@ class _WebLoginView extends State { RoundButton( title: "Se connecter", onPressed: () async { + if (!emailValidate || !passwordValidate) { + _printMsgError( + "Les champs renseigné ne sont pas valide"); + return; + } Tuple2 result = await util.checkLoginAndPassword( controllerTextEmail.text, diff --git a/lib/View/login/web/web_signup_view.dart b/lib/View/login/web/web_signup_view.dart index a580fbd..4935318 100644 --- a/lib/View/login/web/web_signup_view.dart +++ b/lib/View/login/web/web_signup_view.dart @@ -21,11 +21,23 @@ class _WebSignUpView extends State { bool _errorCreateUser = false; bool _isCheck = false; String _msgError = ""; + bool emailValidate = false; + bool passwordValidate = false; + bool usernameValidate = false; final controllerTextEmail = TextEditingController(); final controllerUsername = TextEditingController(); final controllerTextPassword = TextEditingController(); + @override + void initState() { + super.initState(); + // Start listening to changes. + controllerTextEmail.addListener(checkEmail); + controllerTextPassword.addListener(checkPassword); + controllerUsername.addListener(checkUsername); + } + // Toggles the password show status void _toggle() { setState(() { @@ -40,6 +52,33 @@ class _WebSignUpView extends State { }); } + void checkEmail() { + if (!controllerTextEmail.text.contains("@") && + !(controllerTextEmail.text.length > 6)) { + emailValidate = false; + // Faire un affichage + return; + } // Enlever l'affichage + emailValidate = true; + } + + void checkPassword() { + if (!(controllerTextEmail.text.length >= 4)) { + passwordValidate = false; + //Faire un affichage + return; + } // Enlever l'affichage + passwordValidate = true; + } + + void checkUsername() { + if (controllerUsername.text.isEmpty) { + usernameValidate = false; + return; + } + usernameValidate = true; + } + void _check() { setState(() { _isCheck = !_isCheck; @@ -144,6 +183,13 @@ class _WebSignUpView extends State { RoundButton( title: "Créer un compte", onPressed: () async { + if (!emailValidate || + !passwordValidate || + !usernameValidate) { + _printMsgError( + "Les champs renseigné ne sont pas valide"); + return; + } Tuple2 result = await util.createUser( controllerTextEmail.text, controllerUsername.text, diff --git a/lib/View/profile/mobile/mobile_profile_view.dart b/lib/View/profile/mobile/mobile_profile_view.dart new file mode 100644 index 0000000..34c5e9d --- /dev/null +++ b/lib/View/profile/mobile/mobile_profile_view.dart @@ -0,0 +1,361 @@ +import 'package:flutter/material.dart'; +import 'package:animated_toggle_switch/animated_toggle_switch.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/common_widget/setting_row.dart'; +import 'package:smartfit_app_mobile/common_widget/title_subtitle_cell.dart'; + +class MobileProfileView extends StatefulWidget { + const MobileProfileView({super.key}); + + @override + State createState() => _MobileProfileView(); +} + +class _MobileProfileView extends State { + bool positive = false; + + List accountArr = [ + { + "image": "assets/img/p_personal.png", + "name": "Données personnelles", + "tag": "1" + }, + ]; + + List otherArr = [ + {"image": "assets/img/p_contact.png", "name": "Nous contacter", "tag": "5"}, + { + "image": "assets/img/p_privacy.png", + "name": "Politique de confidentialité", + "tag": "6" + }, + ]; + @override + Widget build(BuildContext context) { + 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( + "Benjelloun Othmane", + 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] as Map? ?? {}; + return SettingRow( + icon: iObj["image"].toString(), + title: iObj["name"].toString(), + onPressed: () {}, + ); + }, + ) + ], + ), + ), + 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( + "Pop-up Notification", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ), + ), + CustomAnimatedToggleSwitch( + current: positive, + values: [false, true], + spacing: 0.0, + indicatorSize: 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: 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: () {}, + ); + }, + ) + ], + ), + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/View/profile/profile_view.dart b/lib/View/profile/profile_view.dart index ddc0f43..f7c1dfc 100644 --- a/lib/View/profile/profile_view.dart +++ b/lib/View/profile/profile_view.dart @@ -1,10 +1,7 @@ import 'package:flutter/material.dart'; - -import '../../common/colo_extension.dart'; -import '../../common_widget/round_button.dart'; -import '../../common_widget/setting_row.dart'; -import '../../common_widget/title_subtitle_cell.dart'; -import 'package:animated_toggle_switch/animated_toggle_switch.dart'; +import 'package:responsive_builder/responsive_builder.dart'; +import 'package:smartfit_app_mobile/View/profile/mobile/mobile_profile_view.dart'; +import 'package:smartfit_app_mobile/View/profile/web/web_profile_view.dart'; class ProfileView extends StatefulWidget { const ProfileView({super.key}); @@ -14,341 +11,11 @@ class ProfileView extends StatefulWidget { } class _ProfileViewState extends State { - bool positive = false; - - List accountArr = [ - {"image": "assets/img/p_personal.png", "name": "Données personnelles", "tag": "1"}, - - ]; - - List otherArr = [ - {"image": "assets/img/p_contact.png", "name": "Nous contacter", "tag": "5"}, - {"image": "assets/img/p_privacy.png", "name": "Politique de confidentialité", "tag": "6"}, - ]; @override Widget build(BuildContext context) { - 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( - "Benjelloun Othmane", - 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] as Map? ?? {}; - return SettingRow( - icon: iObj["image"].toString(), - title: iObj["name"].toString(), - onPressed: () {}, - ); - }, - ) - ], - ), - ), - 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( - "Pop-up Notification", - style: TextStyle( - color: TColor.black, - fontSize: 12, - ), - ), - ), - CustomAnimatedToggleSwitch( - current: positive, - values: [false, true], - spacing : 0.0, - indicatorSize: 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: 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: () {}, - ); - }, - ) - ], - ), - ) - ], - ), - ), - ), + return ScreenTypeLayout.builder( + mobile: (_) => const MobileProfileView(), + desktop: (_) => const WebProfileView(), ); } -} \ No newline at end of file +} diff --git a/lib/View/profile/web/web_profile_view.dart b/lib/View/profile/web/web_profile_view.dart new file mode 100644 index 0000000..219d6ce --- /dev/null +++ b/lib/View/profile/web/web_profile_view.dart @@ -0,0 +1,361 @@ +import 'package:flutter/material.dart'; +import 'package:animated_toggle_switch/animated_toggle_switch.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/common_widget/setting_row.dart'; +import 'package:smartfit_app_mobile/common_widget/title_subtitle_cell.dart'; + +class WebProfileView extends StatefulWidget { + const WebProfileView({super.key}); + + @override + State createState() => _WebProfileView(); +} + +class _WebProfileView extends State { + bool positive = false; + + List accountArr = [ + { + "image": "assets/img/p_personal.png", + "name": "Données personnelles", + "tag": "1" + }, + ]; + + List otherArr = [ + {"image": "assets/img/p_contact.png", "name": "Nous contacter", "tag": "5"}, + { + "image": "assets/img/p_privacy.png", + "name": "Politique de confidentialité", + "tag": "6" + }, + ]; + @override + Widget build(BuildContext context) { + 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( + "Benjelloun Othmane", + 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] as Map? ?? {}; + return SettingRow( + icon: iObj["image"].toString(), + title: iObj["name"].toString(), + onPressed: () {}, + ); + }, + ) + ], + ), + ), + 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( + "Pop-up Notification", + style: TextStyle( + color: TColor.black, + fontSize: 12, + ), + ), + ), + CustomAnimatedToggleSwitch( + current: positive, + values: [false, true], + spacing: 0.0, + indicatorSize: 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: 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: () {}, + ); + }, + ) + ], + ), + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/common_widget/round_text_field.dart b/lib/common_widget/round_text_field.dart index 894e20d..006ab83 100644 --- a/lib/common_widget/round_text_field.dart +++ b/lib/common_widget/round_text_field.dart @@ -1,3 +1,4 @@ +import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -12,7 +13,15 @@ class RoundTextField extends StatelessWidget { final Widget? rigtIcon; final bool obscureText; final EdgeInsets? margin; - const RoundTextField({super.key, required this.hitText, required this.icon, this.controller, this.margin, this.keyboardType, this.obscureText = false , this.rigtIcon }); + const RoundTextField( + {super.key, + required this.hitText, + required this.icon, + this.controller, + this.margin, + this.keyboardType, + this.obscureText = false, + this.rigtIcon}); @override Widget build(BuildContext context) { @@ -36,7 +45,7 @@ class RoundTextField extends StatelessWidget { width: 20, height: 20, child: SvgPicture.asset( - icon, + icon, width: 20, height: 20, fit: BoxFit.contain, @@ -45,4 +54,4 @@ class RoundTextField extends StatelessWidget { ), ); } -} \ No newline at end of file +}