Merge branch 'master' into othmane2

profile
Othmane BENJELLOUN 2 years ago
commit 07dbf953cc

@ -0,0 +1,34 @@
kind: pipeline
type: docker
name: SmartFit_Mobile
trigger:
event:
- push
branch:
- master
steps:
- name: build-apk
image: ghcr.io/cirruslabs/flutter:3.13.9
commands:
- flutter build apk
- sfm_apk=sfm_$(date +"%Y_%m_%d_%H_%M_%S").apk
- cp ./build/app/outputs/flutter-apk/app-release.apk $sfm_apk
- curl -F "file=@$sfm_apk" https://anonfiles.me/api/v1/upload > upload.json
- cat upload.json | cut -d '"' -f 12
- name: code-analysis
image: ghcr.io/cirruslabs/flutter:3.13.9
environment:
SONAR_TOKEN:
from_secret: sonar_token
commands:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -D sonar.projectKey=SmartFit_Mobile -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar -D sonar.login=$${SONAR_TOKEN}
depends_on: [ build-apk ]

@ -0,0 +1,7 @@
enzo
enzo@gmail.com
1234
toto
toto@gmail.com
1234

@ -47,7 +47,8 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
//minSdkVersion flutter.minSdkVersion
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
//# minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
minSdkVersion = 21
//minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion flutter.targetSdkVersion
//argetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()

@ -93,7 +93,7 @@ class RequestApi extends IDataStrategy {
return const Tuple2<bool, String>(false, "UNAUTHORIZED");
}
if (response.statusCode == 404) {
return const Tuple2<bool, String>(false, "Not found");
return const Tuple2<bool, String>(false, "Not found the email");
}
return const Tuple2(false, "Fail");
}

@ -2,9 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:csv/csv.dart';
import 'package:fit_tool/fit_tool.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:path_provider/path_provider.dart';
import 'package:smartfit_app_mobile/Modele/activity.dart';
class ManagerFile {
// ----- Read csv File ------- //

@ -1,5 +1,4 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
@ -22,7 +21,9 @@ class LoginView extends StatefulWidget {
}
class _LoginViewState extends State<LoginView> {
bool isCheck = false;
bool _obscureText = true;
String _msgError = "";
bool _errorLogin = false;
IDataStrategy api = RequestApi();
final controllerTextEmail = TextEditingController();
@ -34,19 +35,27 @@ class _LoginViewState extends State<LoginView> {
return result;
}
Future<Tuple2<bool, Map<String, String>>> getUserInfo(String token) async {
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 as Map<String, String>);
return Tuple2(true, result.item2);
}
void fillUser(BuildContext context, Map<String, String> map, String token) {
void fillUser(BuildContext context, Map<String, dynamic> map, String token) {
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);
print(context.read<User>());
}
// Toggles the password show status
void _toggle() {
setState(() {
_obscureText = !_obscureText;
});
}
@override
@ -92,9 +101,9 @@ class _LoginViewState extends State<LoginView> {
controller: controllerTextPassword,
hitText: "Mot de passe",
icon: "assets/img/lock.svg",
obscureText: true,
obscureText: _obscureText,
rigtIcon: TextButton(
onPressed: () {},
onPressed: _toggle,
child: Container(
alignment: Alignment.center,
width: 20,
@ -118,6 +127,10 @@ class _LoginViewState extends State<LoginView> {
),
],
),
Visibility(
visible: _errorLogin,
child: Text("Error - $_msgError",
style: TextStyle(color: TColor.red))),
const Spacer(),
RoundButton(
title: "Se connecter",
@ -129,9 +142,12 @@ class _LoginViewState extends State<LoginView> {
Tuple2 infoUser = await getUserInfo(result.item2);
if (infoUser.item1 == false) {
print(
"Erreur - Impossible de récupéré les données de l'utilisateur");
// Afficher pop-up
//print("Erreur - Impossible de récupéré les données de l'utilisateur");
setState(() {
_msgError =
"Impossible de récupéré les données de l'utilisateur - {$infoUser.item2}";
_errorLogin = true;
});
} else {
fillUser(context, infoUser.item2, result.item2);
@ -141,8 +157,10 @@ class _LoginViewState extends State<LoginView> {
builder: (context) => const ListActivity()));
}
} else {
print("Connection refuser");
//Afficher une pop-up
setState(() {
_msgError = "Connexion refuser - ${result.item2}";
_errorLogin = true;
});
}
}),
SizedBox(

@ -1,10 +1,14 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:flutter_svg/svg.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/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:smartfit_app_mobile/view/login/complete_profile_view.dart';
import 'package:flutter/material.dart';
import 'package:smartfit_app_mobile/view/main_tab/main_tab_view.dart';
import 'package:tuple/tuple.dart';
class SignUpView extends StatefulWidget {
const SignUpView({super.key});
@ -14,12 +18,30 @@ class SignUpView extends StatefulWidget {
}
class _SignUpViewState extends State<SignUpView> {
bool _obscureText = true;
bool _errorCreateUser = false;
bool isCheck = false;
String _msgError = "";
IDataStrategy api = RequestApi();
final controllerTextEmail = TextEditingController();
final controllerTextUsername = TextEditingController();
final controllerTextPassword = TextEditingController();
Future<Tuple2<bool, String>> createUser() async {
return await api.postUser(
controllerTextEmail.text,
sha256.convert(utf8.encode(controllerTextPassword.text)).toString(),
controllerTextUsername.text);
}
// Toggles the password show status
void _toggle() {
setState(() {
_obscureText = !_obscureText;
});
}
@override
Widget build(BuildContext context) {
var media = MediaQuery.of(context).size;
@ -53,13 +75,6 @@ class _SignUpViewState extends State<SignUpView> {
SizedBox(
height: media.width * 0.04,
),
const RoundTextField(
hitText: "Nom",
icon: "assets/img/user_text.svg",
),
SizedBox(
height: media.width * 0.04,
),
RoundTextField(
hitText: "Email",
icon: "assets/img/email.svg",
@ -72,10 +87,10 @@ class _SignUpViewState extends State<SignUpView> {
RoundTextField(
hitText: "Mot de passe",
icon: "assets/img/lock.svg",
obscureText: true,
obscureText: _obscureText,
controller: controllerTextPassword,
rigtIcon: TextButton(
onPressed: () {},
onPressed: _toggle,
child: Container(
alignment: Alignment.center,
width: 20,
@ -113,10 +128,29 @@ class _SignUpViewState extends State<SignUpView> {
)
],
),
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: () {}),
RoundButton(
title: "Créer un compte",
onPressed: () async {
Tuple2<bool, String> result = await createUser();
if (result.item1) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginView()));
} else {
setState(() {
_errorCreateUser = true;
_msgError = result.item2;
});
}
}),
SizedBox(
height: media.width * 0.04,
),
@ -200,7 +234,7 @@ class _SignUpViewState extends State<SignUpView> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MainTabView()));
builder: (context) => const LoginView()));
},
child: Row(
mainAxisSize: MainAxisSize.min,

@ -7,12 +7,12 @@ class TColor {
static Color get secondaryColor1 => Color(0xff6131AD);
static Color get secondaryColor2 => Color(0xffD4B9FF);
static List<Color> get primaryG => [ primaryColor2, primaryColor1 ];
static List<Color> get primaryG => [primaryColor2, primaryColor1];
static List<Color> get secondaryG => [secondaryColor2, secondaryColor1];
static Color get black => const Color(0xff1D1617);
static Color get gray => const Color(0xff786F72);
static Color get white => Colors.white;
static Color get lightGray => const Color(0xffF7F8F8);
}
static Color get red => const Color.fromARGB(255, 255, 0, 0);
}

@ -4,8 +4,6 @@ import 'package:smartfit_app_mobile/Modele/user.dart';
import 'package:smartfit_app_mobile/View/activity/list_activity.dart';
import 'package:smartfit_app_mobile/View/login/login_view.dart';
import 'package:smartfit_app_mobile/View/login/signup_view.dart';
import 'package:smartfit_app_mobile/View/on_boarding/started_view.dart';
import 'package:smartfit_app_mobile/View/page_test.dart';
import 'package:smartfit_app_mobile/common/colo_extension.dart';
void main() {

Loading…
Cancel
Save