mirror of
https://github.com/git-touch/git-touch
synced 2025-01-07 13:22:52 +01:00
fix: handle navigation in webview
This commit is contained in:
parent
fcd416debe
commit
d940f3b3e9
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ class HtmlView extends StatefulWidget {
|
|||||||
class _HtmlViewState extends State<HtmlView> {
|
class _HtmlViewState extends State<HtmlView> {
|
||||||
double height;
|
double height;
|
||||||
WebViewController controller;
|
WebViewController controller;
|
||||||
|
var loaded = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -56,6 +58,15 @@ class _HtmlViewState extends State<HtmlView> {
|
|||||||
height = double.parse(res);
|
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