You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

3 years ago
3 years ago
import 'package:flutter/material.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
3 years ago
import 'package:shared_preferences/shared_preferences.dart';
3 years ago
import 'package:webview_flutter/webview_flutter.dart';
3 years ago
class WebTurntableActivity extends StatefulWidget {
final Map<String, dynamic>? arguments;
3 years ago
///转盘活动
WebTurntableActivity({this.arguments});
@override
State<StatefulWidget> createState() {
return _WebTurntableActivity();
}
}
class _WebTurntableActivity extends State<WebTurntableActivity> with WidgetsBindingObserver {
final ScrollController scrollController = ScrollController();
String? token;
late WebViewController _webViewController;
3 years ago
3 years ago
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
3 years ago
SharedPreferences.getInstance().then((value) => {
token = value.getString('token'),
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onWebResourceError: (WebResourceError error) {},
onNavigationRequest: (NavigationRequest request) {
// if (request.url.startsWith('https://www.youtube.com/')) {
// return NavigationDecision.prevent;
// }
return NavigationDecision.navigate;
},
),
)
..loadRequest(Uri.parse("http://192.168.10.90:5500/lottery.html?token=${token}"))
3 years ago
});
3 years ago
}
3 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
action: Container(
margin: EdgeInsets.only(right: 10),
child: GestureDetector(
onTap: () {
3 years ago
// share();
3 years ago
},
child: Icon(
Icons.share,
size: 24,
color: Colors.black,
),
),
),
3 years ago
title: "",
3 years ago
background: Color(0xFFFFFFFFF),
leadingColor: Colors.black,
),
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
alignment: Alignment.center,
child: WebViewWidget(
controller: _webViewController,
),
),
3 years ago
);
}
3 years ago
}