feat: Permission dialog before open link in browser

This commit is contained in:
Krille 2023-05-02 14:09:46 +02:00
commit 942fac427c
3 changed files with 13 additions and 21 deletions

View file

@ -22,7 +22,7 @@ class UrlLauncher {
const UrlLauncher(this.context, this.url);
void launchUrl() {
void launchUrl() async {
if (url!.toLowerCase().startsWith(AppConfig.deepLinkPrefix) ||
url!.toLowerCase().startsWith(AppConfig.inviteLinkPrefix) ||
{'#', '@', '!', '+', '\$'}.contains(url![0]) ||
@ -37,6 +37,15 @@ class UrlLauncher {
);
return;
}
final consent = await showOkCancelAlertDialog(
context: context,
title: L10n.of(context)!.openLinkInBrowser,
message: url,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
);
if (consent != OkCancelResult.ok) return;
if (!{'https', 'http'}.contains(uri.scheme)) {
// just launch non-https / non-http uris directly