Merge pull request 'Enzo' (#2) from Enzo into master
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Reviewed-on: #2profile
commit
a397d5e0c8
@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smartfit_app_mobile/modele/api/request_api.dart';
|
||||
import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart';
|
||||
import 'package:smartfit_app_mobile/modele/user.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class Login {
|
||||
final IDataStrategy api = RequestApi();
|
||||
|
||||
Future<Tuple2<bool, String>> checkLoginAndPassword(
|
||||
String email, String password) async {
|
||||
Tuple2<bool, String> result = await api.connexion(
|
||||
email, sha256.convert(utf8.encode(password)).toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Tuple2<bool, Map<dynamic, dynamic>>> getUserInfo(String token) async {
|
||||
Tuple2 result = await api.getInfoUser(token);
|
||||
if (result.item1 == false) {
|
||||
return const Tuple2(false, <String, String>{"Empty": "Empty"});
|
||||
}
|
||||
return Tuple2(true, result.item2);
|
||||
}
|
||||
|
||||
void fillUser(BuildContext context, Map<String, dynamic> map, String token) {
|
||||
print(map);
|
||||
|
||||
context.read<User>().email = map["email"];
|
||||
context.read<User>().username = map["username"];
|
||||
context.read<User>().token = token;
|
||||
context.read<User>().listActivity = List.empty(growable: true);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:smartfit_app_mobile/modele/api/request_api.dart';
|
||||
import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class SignUp {
|
||||
final IDataStrategy api = RequestApi();
|
||||
|
||||
Future<Tuple2<bool, String>> createUser(
|
||||
String email, String username, String password) async {
|
||||
return await api.postUser(
|
||||
email, sha256.convert(utf8.encode(password)).toString(), username);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,291 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/login_user.dart';
|
||||
import 'package:smartfit_app_mobile/view/main_tab/main_tab_view.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/round_text_field.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class MobileLoginView extends StatefulWidget {
|
||||
const MobileLoginView({super.key});
|
||||
|
||||
@override
|
||||
State<MobileLoginView> createState() => _MobileLoginView();
|
||||
}
|
||||
|
||||
class _MobileLoginView extends State<MobileLoginView> {
|
||||
final Login util = Login();
|
||||
|
||||
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(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
}
|
||||
|
||||
void _printMsgError(String msgError) {
|
||||
setState(() {
|
||||
_msgError = msgError;
|
||||
_errorLogin = true;
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
return Scaffold(
|
||||
backgroundColor: TColor.white,
|
||||
body: SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: media.height * 0.9,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Bienvenue",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
"Se connecter",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Email",
|
||||
icon: "assets/img/email.svg",
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
controller: controllerTextEmail,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
controller: controllerTextPassword,
|
||||
hitText: "Mot de passe",
|
||||
icon: "assets/img/lock.svg",
|
||||
obscureText: _obscureText,
|
||||
rigtIcon: TextButton(
|
||||
onPressed: _toggle,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: SvgPicture.asset(
|
||||
"assets/img/show_password.svg",
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.contain,
|
||||
))),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Mot de passe oublié ?",
|
||||
style: TextStyle(
|
||||
color: TColor.gray,
|
||||
fontSize: 15,
|
||||
decoration: TextDecoration.underline),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Visibility(
|
||||
visible: _errorLogin,
|
||||
child: Text("Error - $_msgError",
|
||||
style: TextStyle(color: TColor.red))),
|
||||
const Spacer(),
|
||||
RoundButton(
|
||||
title: "Se connecter",
|
||||
onPressed: () async {
|
||||
if (!emailValidate || !passwordValidate) {
|
||||
_printMsgError(
|
||||
"Les champs renseigné ne sont pas valide");
|
||||
return;
|
||||
}
|
||||
Tuple2<bool, String> result =
|
||||
await util.checkLoginAndPassword(
|
||||
controllerTextEmail.text,
|
||||
controllerTextPassword.text);
|
||||
|
||||
if (result.item1 == true) {
|
||||
Tuple2 infoUser = await util.getUserInfo(result.item2);
|
||||
|
||||
if (infoUser.item1 == false) {
|
||||
//print("Erreur - Impossible de récupéré les données de l'utilisateur");
|
||||
_printMsgError(
|
||||
"Impossible de récupéré les données de l'utilisateur - {$infoUser.item2}");
|
||||
} else {
|
||||
util.fillUser(context, infoUser.item2, result.item2);
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const MainTabView()));
|
||||
}
|
||||
} else {
|
||||
_printMsgError("Connexion refuser - ${result.item2}");
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
Text(
|
||||
" Or ",
|
||||
style: TextStyle(color: TColor.black, fontSize: 12),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: media.width * 0.04,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/suunto.png",
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Vous n'avez pas toujours pas de compte ? ",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Créer un compte",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,323 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/signup_user.dart';
|
||||
import 'package:smartfit_app_mobile/view/login/login_view.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/round_text_field.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class MobileSignUpView extends StatefulWidget {
|
||||
const MobileSignUpView({super.key});
|
||||
|
||||
@override
|
||||
State<MobileSignUpView> createState() => _MobileSignUpView();
|
||||
}
|
||||
|
||||
class _MobileSignUpView extends State<MobileSignUpView> {
|
||||
final SignUp util = SignUp();
|
||||
|
||||
bool _obscureText = true;
|
||||
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(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
}
|
||||
|
||||
void _printMsgError(String msgError) {
|
||||
setState(() {
|
||||
_msgError = msgError;
|
||||
_errorCreateUser = true;
|
||||
});
|
||||
}
|
||||
|
||||
void _check() {
|
||||
setState(() {
|
||||
_isCheck = !_isCheck;
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
return Scaffold(
|
||||
backgroundColor: TColor.white,
|
||||
body: SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Bienvenue,",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
"Créer un compte",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Prénom",
|
||||
icon: "assets/img/user_text.svg",
|
||||
controller: controllerUsername,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Email",
|
||||
icon: "assets/img/email.svg",
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
controller: controllerTextEmail,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Mot de passe",
|
||||
icon: "assets/img/lock.svg",
|
||||
obscureText: _obscureText,
|
||||
controller: controllerTextPassword,
|
||||
rigtIcon: TextButton(
|
||||
onPressed: _toggle,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: SvgPicture.asset(
|
||||
"assets/img/show_password.svg",
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.contain,
|
||||
))),
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_check();
|
||||
},
|
||||
icon: Icon(
|
||||
_isCheck
|
||||
? Icons.check_box_outlined
|
||||
: Icons.check_box_outline_blank_outlined,
|
||||
color: TColor.gray,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
"En continuant, vous acceptez notre Politique de\nconfidentialité et nos Conditions d'utilisation.",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 10),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
Visibility(
|
||||
visible: _errorCreateUser,
|
||||
child: Text("Error - $_msgError",
|
||||
style: TextStyle(color: TColor.red))),
|
||||
SizedBox(
|
||||
height: media.width * 0.4,
|
||||
),
|
||||
RoundButton(
|
||||
title: "Créer un compte",
|
||||
onPressed: () async {
|
||||
if (!emailValidate ||
|
||||
!passwordValidate ||
|
||||
!usernameValidate) {
|
||||
_printMsgError(
|
||||
"Les champs renseigné ne sont pas valide");
|
||||
return;
|
||||
}
|
||||
|
||||
Tuple2<bool, String> result = await util.createUser(
|
||||
controllerTextEmail.text,
|
||||
controllerUsername.text,
|
||||
controllerTextPassword.text);
|
||||
if (result.item1) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginView()));
|
||||
} else {
|
||||
_printMsgError(result.item2);
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
Text(
|
||||
" Ou ",
|
||||
style: TextStyle(color: TColor.black, fontSize: 12),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: media.width * 0.04,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/suunto.png",
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginView()));
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Vous avez déjà un compte ? ",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Se connecter",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,297 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/login_user.dart';
|
||||
import 'package:smartfit_app_mobile/view/main_tab/main_tab_view.dart';
|
||||
import 'package:provider/provider.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/view/activity/list_activity.dart';
|
||||
import 'package:smartfit_app_mobile/view/page_test.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/round_text_field.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class WebLoginView extends StatefulWidget {
|
||||
const WebLoginView({super.key});
|
||||
|
||||
@override
|
||||
State<WebLoginView> createState() => _WebLoginView();
|
||||
}
|
||||
|
||||
class _WebLoginView extends State<WebLoginView> {
|
||||
final Login util = Login();
|
||||
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(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
}
|
||||
|
||||
void _printMsgError(String msgError) {
|
||||
setState(() {
|
||||
_msgError = msgError;
|
||||
_errorLogin = true;
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
return Scaffold(
|
||||
backgroundColor: TColor.white,
|
||||
body: SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: media.height * 0.9,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Bienvenue",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
"Se connecter",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Email",
|
||||
icon: "assets/img/email.svg",
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
controller: controllerTextEmail,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
controller: controllerTextPassword,
|
||||
hitText: "Mot de passe",
|
||||
icon: "assets/img/lock.svg",
|
||||
obscureText: _obscureText,
|
||||
rigtIcon: TextButton(
|
||||
onPressed: _toggle,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: SvgPicture.asset(
|
||||
"assets/img/show_password.svg",
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.contain,
|
||||
))),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Mot de passe oublié ?",
|
||||
style: TextStyle(
|
||||
color: TColor.gray,
|
||||
fontSize: 15,
|
||||
decoration: TextDecoration.underline),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Visibility(
|
||||
visible: _errorLogin,
|
||||
child: Text("Error - $_msgError",
|
||||
style: TextStyle(color: TColor.red))),
|
||||
const Spacer(),
|
||||
RoundButton(
|
||||
title: "Se connecter",
|
||||
onPressed: () async {
|
||||
if (!emailValidate || !passwordValidate) {
|
||||
_printMsgError(
|
||||
"Les champs renseigné ne sont pas valide");
|
||||
return;
|
||||
}
|
||||
Tuple2<bool, String> result =
|
||||
await util.checkLoginAndPassword(
|
||||
controllerTextEmail.text,
|
||||
controllerTextPassword.text);
|
||||
|
||||
if (result.item1 == true) {
|
||||
Tuple2 infoUser = await util.getUserInfo(result.item2);
|
||||
|
||||
if (infoUser.item1 == false) {
|
||||
//print("Erreur - Impossible de récupéré les données de l'utilisateur");
|
||||
_printMsgError(
|
||||
"Impossible de récupéré les données de l'utilisateur - {$infoUser.item2}");
|
||||
} else {
|
||||
util.fillUser(context, infoUser.item2, result.item2);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const MainTabView()));
|
||||
}
|
||||
} else {
|
||||
_printMsgError("Connexion refuser - ${result.item2}");
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
Text(
|
||||
" Or ",
|
||||
style: TextStyle(color: TColor.black, fontSize: 12),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: media.width * 0.04,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/suunto.png",
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Vous n'avez pas toujours pas de compte ? ",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Créer un compte",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,321 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/signup_user.dart';
|
||||
import 'package:smartfit_app_mobile/view/login/login_view.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/round_text_field.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class WebSignUpView extends StatefulWidget {
|
||||
const WebSignUpView({super.key});
|
||||
|
||||
@override
|
||||
State<WebSignUpView> createState() => _WebSignUpView();
|
||||
}
|
||||
|
||||
class _WebSignUpView extends State<WebSignUpView> {
|
||||
final SignUp util = SignUp();
|
||||
|
||||
bool _obscureText = true;
|
||||
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(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
}
|
||||
|
||||
void _printMsgError(String msgError) {
|
||||
setState(() {
|
||||
_msgError = msgError;
|
||||
_errorCreateUser = true;
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var media = MediaQuery.of(context).size;
|
||||
return Scaffold(
|
||||
backgroundColor: TColor.white,
|
||||
body: SingleChildScrollView(
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Bienvenue,",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
"Créer un compte",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Prénom",
|
||||
icon: "assets/img/user_text.svg",
|
||||
controller: controllerUsername,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Email",
|
||||
icon: "assets/img/email.svg",
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
controller: controllerTextEmail,
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
RoundTextField(
|
||||
hitText: "Mot de passe",
|
||||
icon: "assets/img/lock.svg",
|
||||
obscureText: _obscureText,
|
||||
controller: controllerTextPassword,
|
||||
rigtIcon: TextButton(
|
||||
onPressed: _toggle,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: SvgPicture.asset(
|
||||
"assets/img/show_password.svg",
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.contain,
|
||||
))),
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_check();
|
||||
},
|
||||
icon: Icon(
|
||||
_isCheck
|
||||
? Icons.check_box_outlined
|
||||
: Icons.check_box_outline_blank_outlined,
|
||||
color: TColor.gray,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
"En continuant, vous acceptez notre Politique de\nconfidentialité et nos Conditions d'utilisation.",
|
||||
style: TextStyle(color: TColor.gray, fontSize: 10),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.05,
|
||||
),
|
||||
Visibility(
|
||||
visible: _errorCreateUser,
|
||||
child: Text("Error - $_msgError",
|
||||
style: TextStyle(color: TColor.red))),
|
||||
SizedBox(
|
||||
height: media.width * 0.4,
|
||||
),
|
||||
RoundButton(
|
||||
title: "Créer un compte",
|
||||
onPressed: () async {
|
||||
if (!emailValidate ||
|
||||
!passwordValidate ||
|
||||
!usernameValidate) {
|
||||
_printMsgError(
|
||||
"Les champs renseigné ne sont pas valide");
|
||||
return;
|
||||
}
|
||||
Tuple2<bool, String> result = await util.createUser(
|
||||
controllerTextEmail.text,
|
||||
controllerUsername.text,
|
||||
controllerTextPassword.text);
|
||||
if (result.item1) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginView()));
|
||||
} else {
|
||||
_printMsgError(result.item2);
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
Text(
|
||||
" Ou ",
|
||||
style: TextStyle(color: TColor.black, fontSize: 12),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: TColor.gray.withOpacity(0.5),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: media.width * 0.04,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: TColor.white,
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: TColor.gray.withOpacity(0.4),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/suunto.png",
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginView()));
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Vous avez déjà un compte ? ",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Se connecter",
|
||||
style: TextStyle(
|
||||
color: TColor.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: media.width * 0.04,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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<MobileProfileView> createState() => _MobileProfileView();
|
||||
}
|
||||
|
||||
class _MobileProfileView extends State<MobileProfileView> {
|
||||
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<bool>(
|
||||
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: () {},
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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<WebProfileView> createState() => _WebProfileView();
|
||||
}
|
||||
|
||||
class _WebProfileView extends State<WebProfileView> {
|
||||
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<bool>(
|
||||
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: () {},
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,416 @@
|
||||
/*import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.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';
|
||||
|
||||
// ----------- File --------------- //
|
||||
|
||||
// Dossier de l'application
|
||||
Future<String> get _localPath async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
return directory.path;
|
||||
}
|
||||
|
||||
// Uri du fichier
|
||||
Future<File> get _localFile async {
|
||||
final path = await _localPath;
|
||||
return File('$path/counter.txt');
|
||||
}
|
||||
|
||||
Future<File> writeCounter(int counter) async {
|
||||
final file = await _localFile;
|
||||
// Write the file
|
||||
return file.writeAsString('$counter');
|
||||
}
|
||||
|
||||
Future<int> readCounter() async {
|
||||
try {
|
||||
final file = await _localFile;
|
||||
|
||||
// Read the file
|
||||
final contents = await file.readAsString();
|
||||
|
||||
return int.parse(contents);
|
||||
} catch (e) {
|
||||
// If encountering an error, return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
String getPlatforme() {
|
||||
if (kIsWeb) {
|
||||
return "Web";
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return "Android";
|
||||
}
|
||||
if (Platform.isWindows) {
|
||||
return "Windows";
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return "MacOS";
|
||||
}
|
||||
return "Null";
|
||||
}
|
||||
|
||||
// File picker
|
||||
|
||||
// ------------------------------------------------- //
|
||||
|
||||
class TestPage extends StatefulWidget {
|
||||
const TestPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<TestPage> createState() => _TestPage();
|
||||
}
|
||||
|
||||
class _TestPage extends State<TestPage> {
|
||||
// Lire un fichier avec picker
|
||||
FilePickerResult? result;
|
||||
IDataStrategy strategy = RequestApi();
|
||||
String platforme = getPlatforme();
|
||||
|
||||
//late File x = File(file.path);
|
||||
Future<void> readFile() async {
|
||||
ManagerFile x = ManagerFile();
|
||||
PlatformFile t = result!.files.single;
|
||||
String? y = t.path;
|
||||
if (t.path == null) {
|
||||
print("t");
|
||||
} else {
|
||||
List<dynamic> result = await x.readFitFile(y!);
|
||||
print("test11");
|
||||
print(result);
|
||||
print("test22");
|
||||
print(ActivityOfUser(result).getHeartRateWithTime());
|
||||
print("test33");
|
||||
Provider.of<User>(context, listen: false).addActivity(ActivityOfUser(result));
|
||||
//print(x.getDistanceWithTime(ActivityOfUser(result)));
|
||||
//print(x.getDistance(ActivityOfUser(result)));
|
||||
//print(x.getAltitudeWithTime(ActivityOfUser(result)));
|
||||
//print(x.getSpeedWithTime(ActivityOfUser(result)));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createUser() async {
|
||||
String mds = "1234";
|
||||
var byte = utf8.encode(mds);
|
||||
var digest = sha256.convert(byte);
|
||||
print(digest.toString());
|
||||
print("Appel");
|
||||
Tuple2<bool, String> res =
|
||||
await strategy.postUser("toto@gmail.com", digest.toString(), "toto");
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> login() async {
|
||||
String mds = "1234";
|
||||
var byte = utf8.encode(mds);
|
||||
var digest = sha256.convert(byte);
|
||||
print(digest.toString());
|
||||
print("Appel");
|
||||
Tuple2<bool, String> res =
|
||||
await strategy.connexion("1234", digest.toString());
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> deleteUser() async {
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiYjA3OThmMjAtN2ZiMy0xMWVlLWJhZmQtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA0ODgyNDI3fQ.2_bnvEC7_pwchielF3Kpu9fFtXDv_KabdOU8T07UnWI";
|
||||
print("Appel");
|
||||
Tuple2<bool, String> res = await strategy.deleteUser(token);
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> getFiles() async {
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiOGJiNDdmMDAtODJkNi0xMWVlLTkzMTMtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA1MjI4MTUyfQ.9ADC65f2rNI_llytvhA6tX0NM9_O3-2RlwPXqV0yYcI";
|
||||
print("Appel");
|
||||
Tuple2 res = await strategy.getFiles(token);
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> modifAttribut() async {
|
||||
String nameAtt = "username";
|
||||
String newValue = "toto2";
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiOGUyYWVmMTItN2ZiNC0xMWVlLWJhZmQtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA0ODgzMDM4fQ.umN7LmUDbKUOeIToLcsOUIioQ7u4wsReHggRDB68VPQ";
|
||||
print("Appel");
|
||||
Tuple2 res = await strategy.modifAttribut(token, nameAtt, newValue);
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> uploadFile() async {
|
||||
PlatformFile t = result!.files.single;
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiOGJiNDdmMDAtODJkNi0xMWVlLTkzMTMtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA1MjI4MTUyfQ.9ADC65f2rNI_llytvhA6tX0NM9_O3-2RlwPXqV0yYcI";
|
||||
String? lol = t.path!;
|
||||
print("Appel");
|
||||
Tuple2 res = await strategy.uploadFile(token, File(lol));
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
Future<void> getOneFile() async {
|
||||
String ui = "fc6e234c-7fc6-11ee-bafd-02420a5a001f";
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiOGUyYWVmMTItN2ZiNC0xMWVlLWJhZmQtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA0ODgzOTE3fQ.TUdrGEo7A0auQlUfO5RQm874QWuGXFBSKbJ8qTGPF2M";
|
||||
print("Appel");
|
||||
Tuple2 res = await strategy.getFile(token, ui);
|
||||
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);
|
||||
print(await x.localPath);
|
||||
print("Save");
|
||||
|
||||
print(await x
|
||||
.readFitFile("${await x.localPath}/Walking_2023-11-08T10_57_28.fit"));
|
||||
}
|
||||
|
||||
Future<void> getInfoUser() async {
|
||||
String token =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1dWlkIjoiOGUyYWVmMTItN2ZiNC0xMWVlLWJhZmQtMDI0MjBhNWEwMDFmIiwiZXhwIjoxNzA0ODgzOTE3fQ.TUdrGEo7A0auQlUfO5RQm874QWuGXFBSKbJ8qTGPF2M";
|
||||
Tuple2 res = await strategy.getInfoUser(token);
|
||||
print(res.item1);
|
||||
print(res.item2);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
User w = context.watch<User>();
|
||||
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
const Text('A random AWESOME idea:'),
|
||||
const Text("User"),
|
||||
|
||||
// ↓ Add this.
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
print('button pressed!');
|
||||
},
|
||||
child: Text('Next'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
result = await FilePicker.platform.pickFiles();
|
||||
if (result == null) {
|
||||
print("No file selected");
|
||||
} else {
|
||||
for (var element in result!.files) {
|
||||
print(element.name);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: const Text("File - ")),
|
||||
ElevatedButton(onPressed: login, child: const Text("Connexion")),
|
||||
ElevatedButton(
|
||||
onPressed: createUser, child: const Text("Create User")),
|
||||
ElevatedButton(
|
||||
onPressed: deleteUser, child: const Text("Delete User")),
|
||||
ElevatedButton(
|
||||
onPressed: readFile, child: const Text("ReadFile")),
|
||||
ElevatedButton(onPressed: getFiles, child: const Text("getFiles")),
|
||||
ElevatedButton(
|
||||
onPressed: modifAttribut, child: const Text("modif attribut")),
|
||||
ElevatedButton(
|
||||
onPressed: uploadFile, child: const Text("Upload File")),
|
||||
ElevatedButton(
|
||||
onPressed: getOneFile, child: const Text("Get One File")),
|
||||
ElevatedButton(
|
||||
onPressed: getInfoUser, child: const Text("Get info User")),
|
||||
Text(platforme),
|
||||
Text(w.email),
|
||||
Text(context.watch<User>().username),
|
||||
Text(Provider.of<User>(context).username)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
void _updateText(String text) {
|
||||
setState(() {
|
||||
test = text;
|
||||
});
|
||||
}
|
||||
|
||||
IDataStrategy tmp = RequestApi();
|
||||
//late Future<String> val = tmp.GetFile("x", "x");
|
||||
late Future<String> val = tmp.test();
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
String test = "Null";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// TRY THIS: Try changing the color here to a specific color (to
|
||||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
|
||||
// change color while the other colors stay the same.
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
|
||||
/*
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
//
|
||||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
|
||||
// action in the IDE, or press "p" in the console), to see the
|
||||
// wireframe for each widget.
|
||||
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('TEST'),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
FutureBuilder<String>(
|
||||
future: val,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasData) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[Text(snapshot.data!)],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const Text("FAIL");
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
*/
|
||||
body: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FutureBuilder<String>(
|
||||
future: val,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasData) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(snapshot.data!),
|
||||
Text(test),
|
||||
TextField(
|
||||
controller: _controller,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Enter Title',
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
_updateText(_controller.text);
|
||||
},
|
||||
child: const Text('Update Data'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => const TestPage()));
|
||||
},
|
||||
child: const Text("Changer de page"))
|
||||
],
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text('${snapshot.error}');
|
||||
}
|
||||
}
|
||||
|
||||
return const CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
<<<<<<<< HEAD:lib/view/test/page_test.dart
|
||||
}*/
|
||||
========
|
||||
}
|
||||
*/*/
|
||||
>>>>>>>> origin/master:lib/view/page_test.dart
|
Loading…
Reference in new issue