From 31101221e0e0cc22d8b9d20d6418d5c7023f3ab0 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Thu, 14 Sep 2023 20:41:25 +0530 Subject: [PATCH] feat closable update card Signed-off-by: Sahil Yeole --- .../lib/desktop/pages/desktop_home_page.dart | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index d458402d3..e48dda51d 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -48,6 +48,7 @@ class _DesktopHomePageState extends State var watchIsInputMonitoring = false; var watchIsCanRecordAudio = false; Timer? _updateTimer; + bool isCardClosed = false; @override Widget build(BuildContext context) { @@ -321,14 +322,15 @@ class _DesktopHomePageState extends State } Future buildHelpCards() async { - if (updateUrl.isNotEmpty) { + if (updateUrl.isNotEmpty && !isCardClosed) { return buildInstallCard( "Status", "There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.", "Click to download", () async { final Uri url = Uri.parse('https://rustdesk.com/download'); await launchUrl(url); - }); + }, + closeButton: true); } if (systemError.isNotEmpty) { return buildInstallCard("", systemError, "", () {}); @@ -394,11 +396,20 @@ class _DesktopHomePageState extends State Widget buildInstallCard(String title, String content, String btnText, GestureTapCallback onPressed, - {String? help, String? link}) { - return Container( - margin: EdgeInsets.only(top: 20), - child: Container( - decoration: BoxDecoration( + {String? help, String? link, bool? closeButton}) { + + void closeCard() { + setState(() { + isCardClosed = true; + }); + } + + return Stack( + children: [ + Container( + margin: EdgeInsets.only(top: 20), + child: Container( + decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, @@ -467,6 +478,21 @@ class _DesktopHomePageState extends State )).marginOnly(top: 6)), ] : []))), + ), + if (closeButton != null && closeButton == true) + Positioned( + top: 18, + right: 0, + child: IconButton( + icon: Icon( + Icons.close, + color: Colors.white, + size: 20, + ), + onPressed: closeCard, + ), + ), + ], ); }