mirror of
https://github.com/git-touch/git-touch
synced 2024-12-15 01:45:05 +01:00
fix: handle navigation in webview
This commit is contained in:
parent
fcd416debe
commit
d940f3b3e9
@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@ -33,6 +34,7 @@ class HtmlView extends StatefulWidget {
|
||||
class _HtmlViewState extends State<HtmlView> {
|
||||
double height;
|
||||
WebViewController controller;
|
||||
var loaded = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -56,6 +58,15 @@ class _HtmlViewState extends State<HtmlView> {
|
||||
height = double.parse(res);
|
||||
});
|
||||
},
|
||||
navigationDelegate: (request) {
|
||||
if (loaded) {
|
||||
launchUrl(request.url); // TODO:
|
||||
return NavigationDecision.prevent;
|
||||
} else {
|
||||
loaded = true;
|
||||
return NavigationDecision.navigate;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user