fix: переход по ссылкам и диплинки с миниапов
This commit is contained in:
@@ -6,6 +6,21 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../frontend/widgets/custom_notification.dart';
|
||||
import '../../frontend/widgets/max_link_handler.dart';
|
||||
|
||||
const Set<String> _webViewSchemes = {
|
||||
'http',
|
||||
'https',
|
||||
'about',
|
||||
'data',
|
||||
'blob',
|
||||
'javascript',
|
||||
'file',
|
||||
};
|
||||
|
||||
bool leavesWebView(String? scheme) {
|
||||
if (scheme == null || scheme.isEmpty) return false;
|
||||
return !_webViewSchemes.contains(scheme.toLowerCase());
|
||||
}
|
||||
|
||||
Future<void> openExternalUrl(BuildContext context, String url) async {
|
||||
if (await tryHandleMaxLink(context, url)) return;
|
||||
if (!context.mounted) return;
|
||||
|
||||
@@ -182,8 +182,13 @@ class _WebAppScreenState extends State<WebAppScreen> {
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
final handler = widget.shouldOverrideUrlLoading;
|
||||
if (handler == null) return NavigationActionPolicy.ALLOW;
|
||||
return handler(controller, action, _launch?.url);
|
||||
if (handler != null) return handler(controller, action, _launch?.url);
|
||||
|
||||
if (uri != null && leavesWebView(uri.scheme)) {
|
||||
if (mounted) await openExternalUrl(context, uri.toString());
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
return NavigationActionPolicy.ALLOW;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user