fix: update download dialog blocking the UI

This commit is contained in:
Kingkor Roy Tirtho 2022-12-08 10:07:54 +06:00
parent 3386dac78e
commit 3925f74395

View File

@ -53,40 +53,45 @@ void useUpdateChecker(WidgetRef ref) {
final latestVersion = value.last; final latestVersion = value.last;
if (currentVersion == null || latestVersion == null) return; if (currentVersion == null || latestVersion == null) return;
if (latestVersion <= currentVersion) return; if (latestVersion <= currentVersion) return;
showPlatformAlertDialog(context, builder: (context) { showPlatformAlertDialog(
const url = context,
"https://spotube.netlify.app/other-downloads/stable-downloads"; barrierDismissible: true,
return PlatformAlertDialog( barrierColor: Colors.black26,
macosAppIcon: Sidebar.brandLogo(), builder: (context) {
title: const PlatformText("Spotube has an update"), const url =
primaryActions: [ "https://spotube.netlify.app/other-downloads/stable-downloads";
PlatformFilledButton( return PlatformAlertDialog(
child: const Text("Download Now"), macosAppIcon: Sidebar.brandLogo(),
onPressed: () => download(url), title: const PlatformText("Spotube has an update"),
), primaryActions: [
], PlatformFilledButton(
content: Column( child: const Text("Download Now"),
crossAxisAlignment: CrossAxisAlignment.start, onPressed: () => download(url),
mainAxisSize: MainAxisSize.min,
children: [
Text("Spotube v${value.last} has been released"),
Row(
children: [
const PlatformText("Read the latest "),
AnchorButton(
"release notes",
style: const TextStyle(color: Colors.blue),
onTap: () => launchUrlString(
url,
mode: LaunchMode.externalApplication,
),
),
],
), ),
], ],
), content: Column(
); mainAxisSize: MainAxisSize.min,
}); children: [
Text("Spotube v${value.last} has been released"),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const PlatformText("Read the latest "),
AnchorButton(
"release notes",
style: const TextStyle(color: Colors.blue),
onTap: () => launchUrlString(
url,
mode: LaunchMode.externalApplication,
),
),
],
),
],
),
);
},
);
}); });
return null; return null;
}, [packageInfo, isCheckUpdateEnabled]); }, [packageInfo, isCheckUpdateEnabled]);