Merge branch 'master' into othmane6
continuous-integration/drone/push Build is failing Details

pull/8/head^2
Othmane BENJELLOUN 2 years ago
commit c58bebb010

@ -10,10 +10,14 @@ trigger:
steps:
- name: build-apk
image: ghcr.io/cirruslabs/flutter:3.13.9
image: ghcr.io/cirruslabs/flutter:3.16.3
commands:
- flutter clean
- dart run build_runner build
- flutter pub cache repair
- flutter pub get
- ls /drone/src/.dart_tool/
- dart run build_runner clean
- dart run build_runner build --delete-conflicting-outputs
- 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
@ -21,7 +25,7 @@ steps:
- cat upload.json | cut -d '"' -f 12
- name: build-web
image: ghcr.io/cirruslabs/flutter:3.13.9
image: ghcr.io/cirruslabs/flutter:3.16.3
environment:
FIREBASE_TOKEN:
from_secret: firebase_token

@ -34,8 +34,7 @@ class MyApp extends StatelessWidget {
Widget viewToDisplay = const SignUpView();
// Skip sign-up + fill provider if user already connected
if (!kIsWeb) {
if (localDB.hasUser()) {
if (!kIsWeb && localDB.hasUser()) {
final User user = localDB.getUser();
final userActivities = localDB.getAllActivities();
@ -51,7 +50,6 @@ class MyApp extends StatelessWidget {
viewToDisplay = const MainTabView();
}
}
return MaterialApp(
title: 'SmartFit',

@ -1,5 +1,3 @@
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:smartfit_app_mobile/modele/activity_info/activity_info.dart';
import 'package:smartfit_app_mobile/modele/api/i_data_strategy.dart';
@ -9,9 +7,10 @@ import 'package:smartfit_app_mobile/modele/utile/info_message.dart';
import 'package:email_validator/email_validator.dart';
import 'package:tuple/tuple.dart';
import 'dart:convert';
import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:smartfit_app_mobile/main.dart';
import 'dart:io';
import 'package:http/http.dart' as http;
class ApiWrapper {
late IDataStrategy api;
@ -22,15 +21,15 @@ class ApiWrapper {
// TODO: Change check online for flutterWeb
Future<bool> isOnline() async {
try {
final result = await InternetAddress.lookup('example.com')
.timeout(const Duration(seconds: 2));
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
final http.Response res = await http
.head(Uri.https("example.com"))
.timeout(const Duration(seconds: 5));
if (res.statusCode == 200) {
return true;
}
} on SocketException catch (_) {
} catch (_) {
return false;
} on UnsupportedError catch (_) {
return true;
}
return true;
}
@ -43,13 +42,10 @@ class ApiWrapper {
}
if (await isOnline()) {
stdout.write("(API) ");
api = RequestApi();
} else if (!kIsWeb && localDB.getSaveLocally()) {
stdout.write("(LOCAL) ");
api = RequestLocal();
} else {
stdout.write("(API OFFLINE) ");
api = RequestApi();
}
}
@ -67,7 +63,6 @@ class ApiWrapper {
await init();
Tuple2 res = await api.getInfoUser(token);
stdout.write("getUserInfo: ${res.item1}\n");
return res;
}
@ -80,7 +75,6 @@ class ApiWrapper {
infoManager.displayMessage(noConnectionMessage, true);
}
stdout.write("getFile: ${res.item1}\n");
return res;
}
@ -92,7 +86,6 @@ class ApiWrapper {
infoManager.displayMessage(noConnectionMessage, true);
}
stdout.write("getFiles: ${res.item1}\n");
return res;
}
@ -108,7 +101,6 @@ class ApiWrapper {
Tuple2<bool, String> res =
await api.modifAttribut(token, infoToModify, value);
stdout.write("updateUserInfo: ${res.item1}\n");
if (res.item1) {
infoManager.displayMessage(
"${infoToModify.capitalize()} modified succesfully !", false);
@ -133,7 +125,6 @@ class ApiWrapper {
String hash = sha256.convert(utf8.encode(password)).toString();
Tuple2<bool, String> res = await api.connexion(email, hash);
stdout.write("login: ${res.item1}\n");
if (res.item1) {
return Tuple2(true, res.item2);
} else {
@ -151,7 +142,6 @@ class ApiWrapper {
Tuple2<bool, String> res = await api.deleteUser(token);
stdout.write("deleteUser: ${res.item1}\n");
return res;
}
@ -162,7 +152,6 @@ class ApiWrapper {
Tuple2<bool, String> res = await api.postUser(email, hash, username);
stdout.write("createUser: ${res.item1}\n");
return res;
}
@ -172,7 +161,6 @@ class ApiWrapper {
if (handleOffline(infoManager)) return const Tuple2(false, "offline");
Tuple2<bool, String> res = await api.uploadFile(token, file);
stdout.write("uploadFile: ${res.item1}\n");
return res;
}
@ -191,7 +179,7 @@ class ApiWrapper {
token, contentFile, filename, category, date, activityInfo);
if (!res.item1) infoManager.displayMessage(noConnectionMessage, true);
stdout.write("uploadFileByte: ${res.item1}\n");
//stdout.write("uploadFileByte: ${res.item1}\n");
return res;
}
@ -203,7 +191,6 @@ class ApiWrapper {
bool res = await api.deleteFile(token, fileUuid);
if (!res) infoManager.displayMessage(noConnectionMessage, true);
stdout.write("deleteFile: $res\n");
return res;
}
}

@ -44,7 +44,6 @@ class ObjectBox implements DbImpl {
@override
User getUser() {
db.User userRes = userBox.get(1);
return User.create(userRes.username, userRes.email, userRes.token);
}
@ -82,8 +81,7 @@ class ObjectBox implements DbImpl {
// ===== Activity =====
@override
void addActivity(String uuid, String filename, String category, String info) {
db.Activity act =
db.Activity(0, uuid, filename, category, jsonEncode(info));
db.Activity act = db.Activity(0, uuid, filename, category, info);
try {
activityBox.put(act);
@ -124,6 +122,7 @@ class ObjectBox implements DbImpl {
for (db.Activity act in activityDBList) {
ActivityInfo actInfo = ActivityInfo.fromJson(jsonDecode(act.info));
userActivityList
.add(ActivityOfUser(actInfo, act.category, act.uuid, act.filename));
}

@ -41,7 +41,7 @@ class RequestLocal implements IDataStrategy {
jsonList.add(json);
}
return Tuple2(true, jsonEncode(activities));
return Tuple2(true, jsonList);
}
@override

@ -11,7 +11,7 @@ class User extends ChangeNotifier {
User();
User.create(String username, String email, String token);
User.create(this.username, this.email, this.token);
void addActivity(ActivityOfUser activity) {
listActivity.add(activity);

@ -74,10 +74,11 @@ class ListActivityUtile {
element["filename"].toString()));
// Save to local db
if (!kIsWeb)
if (!kIsWeb) {
localDB.addActivity(element["uuid"], element["filename"],
element["category"], jsonEncode(element["info"]));
}
}
return const Tuple2(true, "Yeah");
}

@ -63,12 +63,15 @@ class _ProfileViewAllPlatforme extends State<ProfileViewAllPlatforme> {
// TODO: Display size of download in Mo
Visibility(
visible: isNative,
child: const ProfileSwitch("Offline mode",
"Save your files locally", "local_save.png"),
),
const SizedBox(
child: const Column(
children: [
ProfileSwitch("Offline mode", "Save your files locally",
"local_save.png"),
SizedBox(
height: 25,
),
)
],
)),
ProfileOther(widget.otherArr)
],
),

Loading…
Cancel
Save