Resolves #201 New progress indicator in the bottom of the app
This commit is contained in:
parent
12088d9516
commit
cdf55ce68b
@ -13,6 +13,7 @@ import 'package:date_format/date_format.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:flutter_colorpicker/material_picker.dart';
|
import 'package:flutter_colorpicker/material_picker.dart';
|
||||||
import 'package:charts_flutter/flutter.dart' as charts;
|
import 'package:charts_flutter/flutter.dart' as charts;
|
||||||
|
import 'package:progress_indicators/progress_indicators.dart';
|
||||||
|
|
||||||
part 'entity_class/const.dart';
|
part 'entity_class/const.dart';
|
||||||
part 'entity_class/entity.class.dart';
|
part 'entity_class/entity.class.dart';
|
||||||
@ -242,7 +243,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
_refreshData() async {
|
_refreshData() async {
|
||||||
_homeAssistant.updateSettings(_webSocketApiEndpoint, _password, _authType, _useLovelaceUI);
|
_homeAssistant.updateSettings(_webSocketApiEndpoint, _password, _authType, _useLovelaceUI);
|
||||||
_hideBottomBar();
|
_hideBottomBar();
|
||||||
_showInfoBottomBar(message: "Refreshing...");
|
_showInfoBottomBar(progress: true,);
|
||||||
await _homeAssistant.fetch().then((result) {
|
await _homeAssistant.fetch().then((result) {
|
||||||
_hideBottomBar();
|
_hideBottomBar();
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
@ -383,13 +384,15 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
Widget _bottomBarAction;
|
Widget _bottomBarAction;
|
||||||
bool _showBottomBar = false;
|
bool _showBottomBar = false;
|
||||||
String _bottomBarText;
|
String _bottomBarText;
|
||||||
|
bool _bottomBarProgress;
|
||||||
Color _bottomBarColor;
|
Color _bottomBarColor;
|
||||||
|
|
||||||
void _showInfoBottomBar({@required String message}) {
|
void _showInfoBottomBar({String message, bool progress: false}) {
|
||||||
_bottomBarAction = Container(height: 0.0, width: 0.0,);
|
_bottomBarAction = Container(height: 0.0, width: 0.0,);
|
||||||
_bottomBarColor = Colors.grey.shade50;
|
_bottomBarColor = Colors.grey.shade50;
|
||||||
setState(() {
|
setState(() {
|
||||||
_bottomBarText = "$message";
|
_bottomBarText = message;
|
||||||
|
_bottomBarProgress = progress;
|
||||||
_showBottomBar = true;
|
_showBottomBar = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -472,6 +475,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_bottomBarProgress = false;
|
||||||
_bottomBarText = "$message (code: $errorCode)";
|
_bottomBarText = "$message (code: $errorCode)";
|
||||||
_showBottomBar = true;
|
_showBottomBar = true;
|
||||||
});
|
});
|
||||||
@ -535,24 +539,51 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget bottomBar;
|
Widget bottomBar;
|
||||||
if (_showBottomBar) {
|
if (_showBottomBar) {
|
||||||
bottomBar = Container(
|
List<Widget> bottomBarChildren = [];
|
||||||
color: _bottomBarColor,
|
if (_bottomBarText != null) {
|
||||||
child: Row(
|
bottomBarChildren.add(
|
||||||
mainAxisSize: MainAxisSize.max,
|
Padding(
|
||||||
children: <Widget>[
|
padding: EdgeInsets.fromLTRB(
|
||||||
Expanded(
|
Sizes.leftWidgetPadding, Sizes.rowPadding, 0.0,
|
||||||
child: Padding(
|
Sizes.rowPadding),
|
||||||
padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, 0.0, Sizes.rowPadding),
|
child: Text(
|
||||||
child: Text(
|
"$_bottomBarText",
|
||||||
"$_bottomBarText",
|
textAlign: TextAlign.left,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_bottomBarProgress) {
|
||||||
|
bottomBarChildren.add(
|
||||||
|
CollectionScaleTransition(
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(Icons.stop, size: 10.0, color: EntityColor.stateColor(EntityState.on),),
|
||||||
|
Icon(Icons.stop, size: 10.0, color: EntityColor.stateColor(EntityState.unavailable),),
|
||||||
|
Icon(Icons.stop, size: 10.0, color: EntityColor.stateColor(EntityState.off),),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bottomBarChildren.isNotEmpty) {
|
||||||
|
bottomBar = Container(
|
||||||
|
color: _bottomBarColor,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: _bottomBarProgress ? CrossAxisAlignment.center : CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: bottomBarChildren,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
_bottomBarAction
|
||||||
_bottomBarAction
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
// This method is rerun every time setState is called.
|
// This method is rerun every time setState is called.
|
||||||
if (_homeAssistant.ui == null || _homeAssistant.ui.views == null) {
|
if (_homeAssistant.ui == null || _homeAssistant.ui.views == null) {
|
||||||
|
Reference in New Issue
Block a user