From f41c9f9197630aa11442fdfedea052745674910d Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Fri, 23 Nov 2018 16:38:26 +0200 Subject: [PATCH] Resolves #202 Service call info --- lib/main.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index b35181b..41aaa71 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -269,6 +269,10 @@ class _MainPageState extends State with WidgetsBindingObserver { } void _callService(String domain, String service, String entityId, Map additionalParams) { + _showInfoBottomBar( + message: "Calling $domain.$service", + duration: Duration(seconds: 3) + ); _homeAssistant.callService(domain, service, entityId, additionalParams).catchError((e) => _setErrorState(e)); } @@ -386,8 +390,10 @@ class _MainPageState extends State with WidgetsBindingObserver { String _bottomBarText; bool _bottomBarProgress; Color _bottomBarColor; + Timer _bottomBarTimer; - void _showInfoBottomBar({String message, bool progress: false}) { + void _showInfoBottomBar({String message, bool progress: false, Duration duration}) { + _bottomBarTimer?.cancel(); _bottomBarAction = Container(height: 0.0, width: 0.0,); _bottomBarColor = Colors.grey.shade50; setState(() { @@ -395,6 +401,11 @@ class _MainPageState extends State with WidgetsBindingObserver { _bottomBarProgress = progress; _showBottomBar = true; }); + if (duration != null) { + _bottomBarTimer = Timer(duration, () { + _hideBottomBar(); + }); + } } void _showErrorBottomBar({Key key, @required String message, @required int errorCode}) {