Login and mobile app registration improvements

This commit is contained in:
estevez-dev 2019-08-16 12:32:36 +03:00
parent 5c31ddd00f
commit 929abea5d3
6 changed files with 45 additions and 47 deletions

View File

@ -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"));

View File

@ -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();

View File

@ -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<MainPage> with WidgetsBindingObserver, Ticker
});
if (event.showButton) {
_showOAuth();
} else {
Navigator.of(context).pop();
}
});
}

View File

@ -233,7 +233,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
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<ConfigPanelWidget> {
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<ConfigPanelWidget> {
}
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

View File

@ -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"

View File

@ -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