diff --git a/Sources/dafl_project_flutter/lib/api/in_app_browser.dart b/Sources/dafl_project_flutter/lib/api/in_app_browser.dart index a474e46..3223763 100644 --- a/Sources/dafl_project_flutter/lib/api/in_app_browser.dart +++ b/Sources/dafl_project_flutter/lib/api/in_app_browser.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'package:flutter/cupertino.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import '../exceptions/api_exception.dart'; import '../main.dart'; @@ -24,13 +25,16 @@ class MyInAppBrowser extends InAppBrowser { @override Future onLoadStart(url) async { + bool isError = false; if (url!.origin + url.path == MyApp.api.redirectUri) { try { await MyApp.api.requestUserAuthorization(url); } on ApiException { - // TODO : add notification to show that an error occured + notify(5, MyApp.controller.navigatorKey); + isError = true; } finally { close(); + if (!isError) notify(2, MyApp.controller.navigatorKey, isError: false); } } } diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart index a98b2fc..a0da747 100644 --- a/Sources/dafl_project_flutter/lib/controller/controller.dart +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import '../persistence/database_loader.dart'; import '../persistence/database_saver.dart'; @@ -13,6 +14,8 @@ class Controller { static Loader loader = DatabaseLoader(); static final Searcher _searcher = DatabaseSearcher(); + late BuildContext navigatorKey; + late User currentUser; Controller() { diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 4d751b0..6f6c3fd 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -468,6 +468,12 @@ Object notify(int index, context, {bool isError = true}) { message = "Mot de passe incorrect ! Veuillez réessayer."; break; } + case 5: + { + message = + "Une erreur est survenue lors de la liaison de votre compte. Veuillez réessayer."; + break; + } default: message = "Une erreur est survenue pendant l'inscription. Veuillez réessayer."; @@ -544,6 +550,11 @@ Object notify(int index, context, {bool isError = true}) { message = "Vous avez changer votre mot de passe avec succès"; break; } + case 2: + { + message = "Vous avez relié votre compte Spotify avec succès"; + break; + } default: message = "L'opération a bien été éxécutée"; break; diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart index c81d824..7672c5d 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart @@ -225,6 +225,7 @@ class _SignUpPageState extends State { ), // background// foreground ), onPressed: () { + MyApp.controller.navigatorKey = context; MyInAppBrowser(); }, child: Row(