Fix token login popup show
This commit is contained in:
parent
8aa0e03187
commit
cc60dc2b21
@ -238,7 +238,7 @@ class _HAClientAppState extends State<HAClientApp> {
|
||||
if (purchase is List<PurchaseDetails>) {
|
||||
if (purchase[0].status == PurchaseStatus.purchased) {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
popup: Popup(
|
||||
title: "Thanks a lot!",
|
||||
body: "Thank you for supporting HA Client development!",
|
||||
positiveText: "Ok"
|
||||
@ -298,7 +298,10 @@ class _HAClientAppState extends State<HAClientApp> {
|
||||
decoration: TextDecoration.underline
|
||||
)),
|
||||
onPressed: () {
|
||||
eventBus.fire(ShowTokenLoginPopupEvent(goBackFirst: true));
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
goBackFirst: true,
|
||||
popup: TokenLoginPopup()
|
||||
));
|
||||
},
|
||||
)
|
||||
],
|
||||
|
@ -23,7 +23,7 @@ class MobileAppIntegrationManager {
|
||||
return '${HomeAssistant().userName}\'s ${DeviceInfoManager().model}';
|
||||
}
|
||||
|
||||
static Future checkAppRegistration({bool showOkDialog: false}) {
|
||||
static Future checkAppRegistration() {
|
||||
Completer completer = Completer();
|
||||
_appRegistrationData["device_name"] = ConnectionManager().mobileAppDeviceName ?? getDefaultDeviceName();
|
||||
(_appRegistrationData["app_data"] as Map)["push_token"] = "${HomeAssistant().fcmToken}";
|
||||
@ -52,7 +52,7 @@ class MobileAppIntegrationManager {
|
||||
|
||||
completer.complete();
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
popup: Popup(
|
||||
title: "Mobile app Integration was created",
|
||||
body: "HA Client was registered as MobileApp in your Home Assistant. To start using notifications you need to restart your Home Assistant",
|
||||
positiveText: "Restart now",
|
||||
@ -94,15 +94,6 @@ class MobileAppIntegrationManager {
|
||||
_askToRemoveAndRegisterApp();
|
||||
} else {
|
||||
Logger.d('App registration works fine');
|
||||
if (showOkDialog) {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
title: "All good",
|
||||
body: "HA Client integration with your Home Assistant server works fine",
|
||||
positiveText: "Ok"
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
completer.complete();
|
||||
@ -122,7 +113,7 @@ class MobileAppIntegrationManager {
|
||||
|
||||
static void _showError() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
popup: Popup(
|
||||
title: "App integration is not working properly",
|
||||
body: "Something wrong with HA Client integration on your Home Assistant server. Please report this issue. You can try to remove Mobile App integration from Home Assistant and restart server to fix this issue.",
|
||||
positiveText: "Report to GitHub",
|
||||
@ -139,7 +130,7 @@ class MobileAppIntegrationManager {
|
||||
|
||||
static void _askToRemoveAndRegisterApp() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
popup: Popup(
|
||||
title: "Mobile app integration needs to be updated",
|
||||
body: "You need to update HA Client integration to continue using notifications and location tracking. Please remove 'Mobile App' integration for this device from your Home Assistant and restart Home Assistant. Then go back to HA Client to create app integration again.",
|
||||
positiveText: "Ok",
|
||||
@ -153,7 +144,7 @@ class MobileAppIntegrationManager {
|
||||
|
||||
static void _askToRegisterApp() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
RegisterAppPopup(
|
||||
popup: RegisterAppPopup(
|
||||
title: "Mobile App integration is missing",
|
||||
body: "Looks like mobile app integration was removed from your Home Assistant or it needs to be updated.",
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ class StartupUserMessagesManager {
|
||||
|
||||
void _showSupportAppDevelopmentMessage() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
popup: Popup(
|
||||
title: "Hi!",
|
||||
body: "As you may have noticed this app contains no ads. Also all app features are available for you for free. I'm not planning to change this in nearest future, but still you can support this application development materially. There is one-time payment available as well as several subscription options. Thanks.",
|
||||
positiveText: "Show options",
|
||||
|
@ -186,6 +186,9 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
_showPopupSubscription = eventBus.on<ShowPopupEvent>().listen((event){
|
||||
if (!_popupShown) {
|
||||
_popupShown = true;
|
||||
if (event.goBackFirst) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
event.popup.show(context).then((_){
|
||||
_popupShown = false;
|
||||
});
|
||||
@ -539,7 +542,9 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
FlatButton(
|
||||
child: Text("Login with long-lived token", style: Theme.of(context).textTheme.button),
|
||||
color: Theme.of(context).primaryColor,
|
||||
onPressed: () => eventBus.fire(ShowTokenLoginPopupEvent(goBackFirst: false))
|
||||
onPressed: () => eventBus.fire(ShowPopupEvent(
|
||||
popup: TokenLoginPopup()
|
||||
))
|
||||
),
|
||||
Container(height: 20,),
|
||||
FlatButton(
|
||||
|
@ -58,35 +58,9 @@ class NotifyServiceCallEvent {
|
||||
|
||||
class ShowPopupEvent {
|
||||
final Popup popup;
|
||||
|
||||
ShowPopupEvent(this.popup);
|
||||
}
|
||||
/*
|
||||
class ShowPopupDialogEvent {
|
||||
final String title;
|
||||
final String body;
|
||||
final String positiveText;
|
||||
final String negativeText;
|
||||
final onPositive;
|
||||
final onNegative;
|
||||
|
||||
ShowPopupDialogEvent({this.title, this.body, this.positiveText: "Ok", this.negativeText: "Cancel", this.onPositive, this.onNegative});
|
||||
}
|
||||
|
||||
class ShowPopupMessageEvent {
|
||||
final String title;
|
||||
final String body;
|
||||
final String buttonText;
|
||||
final onButtonClick;
|
||||
|
||||
ShowPopupMessageEvent({this.title, this.body, this.buttonText: "Ok", this.onButtonClick});
|
||||
}
|
||||
*/
|
||||
|
||||
class ShowTokenLoginPopupEvent {
|
||||
final bool goBackFirst;
|
||||
|
||||
ShowTokenLoginPopupEvent({this.goBackFirst: false});
|
||||
ShowPopupEvent({this.popup, this.goBackFirst: false});
|
||||
}
|
||||
|
||||
class ShowEntityPageEvent {
|
||||
|
Reference in New Issue
Block a user