From 929abea5d32c75d9697e6e92314a30a29fb6377a Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Fri, 16 Aug 2019 12:32:36 +0300 Subject: [PATCH] Login and mobile app registration improvements --- lib/auth_manager.class.dart | 4 +- lib/home_assistant.class.dart | 3 +- lib/main.dart | 4 +- lib/ui_widgets/config_panel_widget.dart | 20 ++++++++- pubspec.lock | 59 ++++++++----------------- pubspec.yaml | 2 +- 6 files changed, 45 insertions(+), 47 deletions(-) diff --git a/lib/auth_manager.class.dart b/lib/auth_manager.class.dart index a938877..3bbfb3b 100644 --- a/lib/auth_manager.class.dart +++ b/lib/auth_manager.class.dart @@ -27,11 +27,11 @@ class AuthManager { Logger.d("Gottemp token"); String tempToken = json.decode(response)['access_token']; Logger.d("Closing webview..."); - flutterWebviewPlugin.close(); + //flutterWebviewPlugin.close(); eventBus.fire(StartAuthEvent(oauthUrl, false)); completer.complete(tempToken); }).catchError((e) { - flutterWebviewPlugin.close(); + //flutterWebviewPlugin.close(); Logger.e("Error getting temp token: ${e.toString()}"); eventBus.fire(StartAuthEvent(oauthUrl, false)); completer.completeError(HAError("Error getting temp token")); diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index 32711df..dca6526 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -152,7 +152,8 @@ class HomeAssistant { eventBus.fire(ShowDialogEvent( title: "All good", body: "HA Client integration with your Home Assistant server works fine", - positiveText: "Nice!" + positiveText: "Nice!", + negativeText: "Ok" )); } completer.complete(); diff --git a/lib/main.dart b/lib/main.dart index 208ae81..368fea4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,7 +15,7 @@ import 'package:http/http.dart' as http; import 'package:charts_flutter/flutter.dart' as charts; import 'package:progress_indicators/progress_indicators.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; -import 'package:flutter_svg/flutter_svg.dart'; +//import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; @@ -352,6 +352,8 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker }); if (event.showButton) { _showOAuth(); + } else { + Navigator.of(context).pop(); } }); } diff --git a/lib/ui_widgets/config_panel_widget.dart b/lib/ui_widgets/config_panel_widget.dart index 51d0a91..ddfe63c 100644 --- a/lib/ui_widgets/config_panel_widget.dart +++ b/lib/ui_widgets/config_panel_widget.dart @@ -233,7 +233,7 @@ class _ConfigPanelWidgetState extends State { Container(height: Sizes.rowPadding,), Text("${HomeAssistant().userName}'s ${Device().model}, ${Device().osName} ${Device().osVersion}"), Container(height: 6.0,), - Text("Here you can manually check if HA Client integration with your Home Assistant works fine."), + Text("Here you can manually check if HA Client integration with your Home Assistant works fine. As mobileApp integration in Home Assistant is still in development, this is not 100% correct check."), Divider(), Row( mainAxisSize: MainAxisSize.min, @@ -241,6 +241,10 @@ class _ConfigPanelWidgetState extends State { FlatButton( onPressed: () => updateRegistration(), child: Text("Check registration", style: TextStyle(color: Colors.blue)) + ), + FlatButton( + onPressed: () => resetRegistration(), + child: Text("Reset registration", style: TextStyle(color: Colors.red)) ) ], ) @@ -276,7 +280,19 @@ class _ConfigPanelWidgetState extends State { } updateRegistration() { - HomeAssistant().checkAppRegistration(); + HomeAssistant().checkAppRegistration(showOkDialog: true); + } + + resetRegistration() { + eventBus.fire(ShowDialogEvent( + title: "Waaaait", + body: "If you don't whant to have duplicate integrations and entities in your HA for your current device, first you need to remove MobileApp integration from Integration settings in HA and restart server.", + positiveText: "Done it already", + negativeText: "Ok, I will", + onPositive: () { + HomeAssistant().checkAppRegistration(showOkDialog: true, forceRegister: true); + }, + )); } @override diff --git a/pubspec.lock b/pubspec.lock index eba3d04..8fb45c7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: archive: dependency: transitive @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" boolean_selector: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: cached_network_image url: "https://pub.dartlang.org" source: hosted - version: "0.8.0" + version: "1.1.1" charcode: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.1+1" date_format: dependency: "direct main" description: @@ -117,7 +117,7 @@ packages: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted - version: "0.3.2" + version: "1.1.1" flutter_custom_tabs: dependency: "direct main" description: @@ -131,7 +131,7 @@ packages: name: flutter_launcher_icons url: "https://pub.dartlang.org" source: hosted - version: "0.7.2" + version: "0.7.2+1" flutter_local_notifications: dependency: "direct main" description: @@ -153,13 +153,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.1+1" - flutter_svg: - dependency: "direct main" - description: - name: flutter_svg - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.4" flutter_test: dependency: "direct dev" description: flutter @@ -171,7 +164,7 @@ packages: name: flutter_webview_plugin url: "https://pub.dartlang.org" source: hosted - version: "0.3.5" + version: "0.3.7" http: dependency: transitive description: @@ -235,69 +228,55 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.2" - path_drawing: - dependency: transitive - description: - name: path_drawing - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.1" - path_parsing: - dependency: transitive - description: - name: path_parsing - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.4" path_provider: dependency: transitive description: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "0.5.0+1" + version: "1.2.0" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.7.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.4.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.2.1" progress_indicators: dependency: "direct main" description: name: progress_indicators url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.4" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.3+1" + version: "0.5.3+4" sky_engine: dependency: transitive description: flutter @@ -316,7 +295,7 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "1.1.5" + version: "1.1.6+3" stack_trace: dependency: transitive description: @@ -358,7 +337,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "0.2.5" typed_data: dependency: transitive description: @@ -372,7 +351,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.0.3" + version: "5.1.2" uuid: dependency: transitive description: @@ -393,7 +372,7 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.0.13" + version: "1.0.15" xml: dependency: transitive description: @@ -409,5 +388,5 @@ packages: source: hosted version: "2.1.16" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.4.0 <3.0.0" flutter: ">=1.5.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5b7feef..fbeb663 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: date_format: any charts_flutter: any flutter_markdown: any - flutter_svg: ^0.10.3 +# flutter_svg: ^0.10.3 flutter_custom_tabs: ^0.6.0 firebase_messaging: ^4.0.0+1 flutter_webview_plugin: ^0.3.1