|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
|
|
|
|
class TreatyPage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _TreatyPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TreatyPage extends State<TreatyPage> {
|
|
|
|
var controller = new ScrollController();
|
|
|
|
|
|
|
|
WebViewController? _webViewController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
title:S.of(context).yinsishengming,
|
|
|
|
titleColor: Colors.black,
|
|
|
|
background: Colors.transparent,
|
|
|
|
leadingColor: Colors.black,
|
|
|
|
),
|
|
|
|
body:
|
|
|
|
Container(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
height: MediaQuery.of(context).size.height,
|
|
|
|
alignment: Alignment.center, //TreatyPage
|
|
|
|
child: FutureBuilder(
|
|
|
|
future: loadWeb(),
|
|
|
|
builder: (context, AsyncSnapshot snapshot) {
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
return Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
} else if (snapshot.hasError) {
|
|
|
|
return Text("加载失败");
|
|
|
|
} else {
|
|
|
|
return snapshot.data ?? Text("NO DATA");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Widget> loadWeb() async {
|
|
|
|
Widget res ;
|
|
|
|
try {
|
|
|
|
_webViewController = WebViewController()
|
|
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
|
|
..setNavigationDelegate(
|
|
|
|
NavigationDelegate(
|
|
|
|
onProgress: (int progress) {},
|
|
|
|
onPageStarted: (String url) {},
|
|
|
|
onPageFinished: (String url) {
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
},
|
|
|
|
onWebResourceError: (WebResourceError error) {},
|
|
|
|
onNavigationRequest: (NavigationRequest request) {
|
|
|
|
// if (request.url.startsWith('https://www.youtube.com/')) {
|
|
|
|
// return NavigationDecision.prevent;
|
|
|
|
// }
|
|
|
|
return NavigationDecision.navigate;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
..loadRequest(Uri.parse("http://huixiang.lotus-wallet.com/Privacy.html"));
|
|
|
|
res = WebViewWidget(controller: _webViewController!);
|
|
|
|
} catch (error) {
|
|
|
|
res = Text("加载失败");
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|