Resolves #546 Device name is missed
This commit is contained in:
parent
5bc0b0868a
commit
3fddc3b5a7
@ -19,7 +19,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
StreamSubscription _showErrorSubscription;
|
||||
StreamSubscription _startAuthSubscription;
|
||||
StreamSubscription _showPopupSubscription;
|
||||
StreamSubscription _showTokenLoginPopupSubscription;
|
||||
StreamSubscription _reloadUISubscription;
|
||||
StreamSubscription _fullReloadSubscription;
|
||||
StreamSubscription _showPageSubscription;
|
||||
@ -187,14 +186,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
event.popup.show(context);
|
||||
});
|
||||
}
|
||||
if (_showTokenLoginPopupSubscription == null) {
|
||||
_showTokenLoginPopupSubscription = eventBus.on<ShowTokenLoginPopupEvent>().listen((event){
|
||||
if (event.goBackFirst) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
_showTokenLoginDialog();
|
||||
});
|
||||
}
|
||||
if (_serviceCallSubscription == null) {
|
||||
_serviceCallSubscription =
|
||||
eventBus.on<NotifyServiceCallEvent>().listen((event) {
|
||||
@ -259,77 +250,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
}
|
||||
}
|
||||
|
||||
final _tokenLoginFormKey = GlobalKey<FormState>();
|
||||
|
||||
void _showTokenLoginDialog() {
|
||||
// flutter defined function
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
// return object of type Dialog
|
||||
return SimpleDialog(
|
||||
title: new Text('Login with long-lived token'),
|
||||
children: <Widget>[
|
||||
Form(
|
||||
key: _tokenLoginFormKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: TextFormField(
|
||||
onSaved: (newValue) {
|
||||
final storage = new FlutterSecureStorage();
|
||||
storage.write(key: "hacl_llt", value: newValue).then((_) {
|
||||
Navigator.of(context).pop();
|
||||
eventBus.fire(SettingsChangedEvent(true));
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Please enter long-lived token',
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
hintStyle: Theme.of(context).textTheme.subhead.copyWith(
|
||||
color: Theme.of(context).textTheme.overline.color
|
||||
)
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Long-lived token can\'t be emty';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text('Login'),
|
||||
onPressed: () {
|
||||
if (_tokenLoginFormKey.currentState.validate()) {
|
||||
_tokenLoginFormKey.currentState.save();
|
||||
}
|
||||
},
|
||||
),
|
||||
Container(width: 10),
|
||||
FlatButton(
|
||||
child: Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _notifyServiceCalled(String domain, String service, entityId) {
|
||||
_bottomInfoBarController.showInfoBottomBar(
|
||||
message: "Calling $domain.$service",
|
||||
@ -731,7 +651,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
//final flutterWebviewPlugin = new FlutterWebviewPlugin();
|
||||
//flutterWebviewPlugin.dispose();
|
||||
_viewsTabController?.dispose();
|
||||
_showTokenLoginPopupSubscription?.cancel();
|
||||
_stateSubscription?.cancel();
|
||||
_lovelaceSubscription?.cancel();
|
||||
_settingsSubscription?.cancel();
|
||||
|
@ -25,12 +25,12 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
|
||||
_loadSettings();
|
||||
} else {
|
||||
_deviceName = MobileAppIntegrationManager.getDefaultDeviceName();
|
||||
_includeDeviceName = true;
|
||||
_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
_loadSettings() async {
|
||||
Logger.d('Loading settings...');
|
||||
_includeDeviceName = widget.quickStart || ConnectionManager().webhookId == null;
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String domain = prefs.getString('hassio-domain')?? '';
|
||||
|
@ -46,4 +46,81 @@ class Popup {
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TokenLoginPopup extends Popup {
|
||||
|
||||
TokenLoginPopup() : super(title: 'Login with long-lived token', body: '');
|
||||
|
||||
final _tokenLoginFormKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void show(BuildContext context) {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
// return object of type Dialog
|
||||
return SimpleDialog(
|
||||
title: new Text('Login with long-lived token'),
|
||||
children: <Widget>[
|
||||
Form(
|
||||
key: _tokenLoginFormKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: TextFormField(
|
||||
onSaved: (newValue) {
|
||||
final storage = new FlutterSecureStorage();
|
||||
storage.write(key: "hacl_llt", value: newValue).then((_) {
|
||||
Navigator.of(context).pop();
|
||||
eventBus.fire(SettingsChangedEvent(true));
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Please enter long-lived token',
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
hintStyle: Theme.of(context).textTheme.subhead.copyWith(
|
||||
color: Theme.of(context).textTheme.overline.color
|
||||
)
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Long-lived token can\'t be emty';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text('Login'),
|
||||
onPressed: () {
|
||||
if (_tokenLoginFormKey.currentState.validate()) {
|
||||
_tokenLoginFormKey.currentState.save();
|
||||
}
|
||||
},
|
||||
),
|
||||
Container(width: 10),
|
||||
FlatButton(
|
||||
child: Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user