notify user when error when linking spotify account
continuous-integration/drone/push Build is passing Details

#MSG01/chat_firebase
Lucas DELANIER 2 years ago
parent 4395bfe519
commit e444f6cdea

@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import '../exceptions/api_exception.dart'; import '../exceptions/api_exception.dart';
import '../main.dart'; import '../main.dart';
@ -24,13 +25,16 @@ class MyInAppBrowser extends InAppBrowser {
@override @override
Future onLoadStart(url) async { Future onLoadStart(url) async {
bool isError = false;
if (url!.origin + url.path == MyApp.api.redirectUri) { if (url!.origin + url.path == MyApp.api.redirectUri) {
try { try {
await MyApp.api.requestUserAuthorization(url); await MyApp.api.requestUserAuthorization(url);
} on ApiException { } on ApiException {
// TODO : add notification to show that an error occured notify(5, MyApp.controller.navigatorKey);
isError = true;
} finally { } finally {
close(); close();
if (!isError) notify(2, MyApp.controller.navigatorKey, isError: false);
} }
} }
} }

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../persistence/database_loader.dart'; import '../persistence/database_loader.dart';
import '../persistence/database_saver.dart'; import '../persistence/database_saver.dart';
@ -13,6 +14,8 @@ class Controller {
static Loader loader = DatabaseLoader(); static Loader loader = DatabaseLoader();
static final Searcher _searcher = DatabaseSearcher(); static final Searcher _searcher = DatabaseSearcher();
late BuildContext navigatorKey;
late User currentUser; late User currentUser;
Controller() { Controller() {

@ -468,6 +468,12 @@ Object notify(int index, context, {bool isError = true}) {
message = "Mot de passe incorrect ! Veuillez réessayer."; message = "Mot de passe incorrect ! Veuillez réessayer.";
break; break;
} }
case 5:
{
message =
"Une erreur est survenue lors de la liaison de votre compte. Veuillez réessayer.";
break;
}
default: default:
message = message =
"Une erreur est survenue pendant l'inscription. Veuillez réessayer."; "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"; message = "Vous avez changer votre mot de passe avec succès";
break; break;
} }
case 2:
{
message = "Vous avez relié votre compte Spotify avec succès";
break;
}
default: default:
message = "L'opération a bien été éxécutée"; message = "L'opération a bien été éxécutée";
break; break;

@ -225,6 +225,7 @@ class _SignUpPageState extends State<SignUpPage> {
), // background// foreground ), // background// foreground
), ),
onPressed: () { onPressed: () {
MyApp.controller.navigatorKey = context;
MyInAppBrowser(); MyInAppBrowser();
}, },
child: Row( child: Row(

Loading…
Cancel
Save