From 8c1ad9c7f94b9e1c03cba623789df7ff9df7d8c9 Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Fri, 5 Apr 2019 14:07:03 +0300 Subject: [PATCH] Fix login button --- lib/auth_manager.class.dart | 6 ++++-- lib/connection.class.dart | 2 ++ lib/main.dart | 8 ++------ lib/utils.class.dart | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/auth_manager.class.dart b/lib/auth_manager.class.dart index d305b14..6f55c88 100644 --- a/lib/auth_manager.class.dart +++ b/lib/auth_manager.class.dart @@ -27,16 +27,18 @@ class AuthManager { String tempToken = json.decode(response)['access_token']; Logger.d("Closing webview..."); flutterWebviewPlugin.close(); + eventBus.fire(StartAuthEvent(oauthUrl, false)); completer.complete(tempToken); }).catchError((e) { flutterWebviewPlugin.close(); - completer.completeError({"errorCode": 61, "errorMessage": "Error getting temp token"}); Logger.e("Error getting temp token: ${e.toString()}"); + eventBus.fire(StartAuthEvent(oauthUrl, false)); + completer.completeError({"errorCode": 61, "errorMessage": "Error getting temp token"}); }); } }); Logger.d("Launching OAuth..."); - eventBus.fire(StartAuthEvent(oauthUrl)); + eventBus.fire(StartAuthEvent(oauthUrl, true)); return completer.future; } diff --git a/lib/connection.class.dart b/lib/connection.class.dart index 3c827c6..ce9aa51 100644 --- a/lib/connection.class.dart +++ b/lib/connection.class.dart @@ -73,6 +73,8 @@ class Connection { Logger.d("Token from AuthManager recived"); _tempToken = token; _doConnect(completer: completer, forceReconnect: forceReconnect); + }).catchError((e) { + completer.completeError(e); }); } else { _doConnect(completer: completer, forceReconnect: forceReconnect); diff --git a/lib/main.dart b/lib/main.dart index e15017b..836d5c1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -284,7 +284,7 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker if (_startAuthSubscription == null) { _startAuthSubscription = eventBus.on().listen((event){ setState(() { - _showLoginButton = true; + _showLoginButton = event.showButton; }); }); } @@ -651,11 +651,7 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker value: "reload", )); List emptyBody = [ - Icon( - MaterialDesignIcons.getIconDataFromIconName("mdi:border-none-variant"), - size: 100.0, - color: Colors.black26, - ), + Text("."), ]; if (Connection().isAuthenticated) { _showLoginButton = false; diff --git a/lib/utils.class.dart b/lib/utils.class.dart index affbc1b..cc0264d 100644 --- a/lib/utils.class.dart +++ b/lib/utils.class.dart @@ -115,8 +115,9 @@ class ReloadUIEvent { class StartAuthEvent { String oauthUrl; + bool showButton; - StartAuthEvent(this.oauthUrl); + StartAuthEvent(this.oauthUrl, this.showButton); } class ServiceCallEvent {