Resolves #355 Add login button on empty screen
This commit is contained in:
@ -170,6 +170,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
StreamSubscription _startAuthSubscription;
|
StreamSubscription _startAuthSubscription;
|
||||||
StreamSubscription _reloadUISubscription;
|
StreamSubscription _reloadUISubscription;
|
||||||
int _previousViewCount;
|
int _previousViewCount;
|
||||||
|
bool _showLoginButton = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -282,7 +283,9 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
|
|
||||||
if (_startAuthSubscription == null) {
|
if (_startAuthSubscription == null) {
|
||||||
_startAuthSubscription = eventBus.on<StartAuthEvent>().listen((event){
|
_startAuthSubscription = eventBus.on<StartAuthEvent>().listen((event){
|
||||||
_showOAuth();
|
setState(() {
|
||||||
|
_showLoginButton = true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,13 +650,30 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
child: new Text("Reload"),
|
child: new Text("Reload"),
|
||||||
value: "reload",
|
value: "reload",
|
||||||
));
|
));
|
||||||
|
List<Widget> emptyBody = [
|
||||||
|
Icon(
|
||||||
|
MaterialDesignIcons.getIconDataFromIconName("mdi:border-none-variant"),
|
||||||
|
size: 100.0,
|
||||||
|
color: Colors.black26,
|
||||||
|
),
|
||||||
|
];
|
||||||
if (Connection().isAuthenticated) {
|
if (Connection().isAuthenticated) {
|
||||||
|
_showLoginButton = false;
|
||||||
popupMenuItems.add(
|
popupMenuItems.add(
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: new Text("Logout"),
|
child: new Text("Logout"),
|
||||||
value: "logout",
|
value: "logout",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (_showLoginButton) {
|
||||||
|
emptyBody = [
|
||||||
|
FlatButton(
|
||||||
|
child: Text("Login with Home Assistant", style: TextStyle(fontSize: 16.0, color: Colors.white)),
|
||||||
|
color: Colors.blue,
|
||||||
|
onPressed: () => _showOAuth(),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
return NestedScrollView(
|
return NestedScrollView(
|
||||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||||
return <Widget>[
|
return <Widget>[
|
||||||
@ -702,13 +722,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
Center(
|
Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: emptyBody
|
||||||
Icon(
|
|
||||||
MaterialDesignIcons.getIconDataFromIconName("mdi:border-none-variant"),
|
|
||||||
size: 100.0,
|
|
||||||
color: Colors.black26,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
Reference in New Issue
Block a user