|
|
@ -1,148 +1,8 @@ |
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
import 'dart:ui'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/rendering.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/data/activity.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/data/article.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:huixiang/view_widget/share_dialog.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/view_widget/tips_dialog.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/web/web_view/comment_list.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/web/web_view/input_comment.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/web/web_view/web_content.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/web/web_view/web_header.dart'; |
|
|
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_defines.dart'; |
|
|
|
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart'; |
|
|
|
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_map.dart'; |
|
|
|
|
|
|
|
import 'package:webview_flutter/webview_flutter.dart'; |
|
|
|
import 'package:webview_flutter/webview_flutter.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WebTurntableActivity extends StatefulWidget { |
|
|
|
|
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///转盘活动 |
|
|
|
|
|
|
|
WebTurntableActivity({this.arguments}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
|
|
|
|
return _WebTurntableActivity(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _WebTurntableActivity extends State<WebTurntableActivity> with WidgetsBindingObserver { |
|
|
|
|
|
|
|
ApiService apiService; |
|
|
|
|
|
|
|
var commentFocus = FocusNode(); |
|
|
|
|
|
|
|
final double fontSize = 16.sp; |
|
|
|
|
|
|
|
final ScrollController scrollController = ScrollController(); |
|
|
|
|
|
|
|
Activity activity; |
|
|
|
|
|
|
|
Article article; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void initState() { |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
|
|
|
|
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryHtml(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isKeyBoardShow = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void dispose() { |
|
|
|
|
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryHtml() async { |
|
|
|
class WebTurntableActivity extends StatelessWidget { |
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
|
|
|
if (apiService == null) |
|
|
|
|
|
|
|
apiService = |
|
|
|
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (widget.arguments["activityId"] != null) { |
|
|
|
|
|
|
|
// BaseData<Activity> baseData = await apiService |
|
|
|
|
|
|
|
// .activityInfo(widget.arguments["activityId"]) |
|
|
|
|
|
|
|
// .catchError((onError) {}); |
|
|
|
|
|
|
|
// if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
// activity = baseData.data; |
|
|
|
|
|
|
|
// setState(() {}); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// if (widget.arguments["articleId"] != null) { |
|
|
|
|
|
|
|
// BaseData<Article> baseData = await apiService |
|
|
|
|
|
|
|
// .informationInfo(widget.arguments["articleId"]) |
|
|
|
|
|
|
|
// .catchError((onError) {}); |
|
|
|
|
|
|
|
// if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
// article = baseData.data; |
|
|
|
|
|
|
|
// setState(() {}); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
share() async { |
|
|
|
|
|
|
|
SSDKMap params = SSDKMap() |
|
|
|
|
|
|
|
..setGeneral( |
|
|
|
|
|
|
|
activity != null |
|
|
|
|
|
|
|
? activity.mainTitle |
|
|
|
|
|
|
|
: article != null |
|
|
|
|
|
|
|
? article.mainTitle |
|
|
|
|
|
|
|
: "", |
|
|
|
|
|
|
|
activity != null |
|
|
|
|
|
|
|
? activity.viceTitle |
|
|
|
|
|
|
|
: article != null |
|
|
|
|
|
|
|
? article.viceTitle |
|
|
|
|
|
|
|
: "", |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
activity != null |
|
|
|
|
|
|
|
? activity.coverImg |
|
|
|
|
|
|
|
: article != null |
|
|
|
|
|
|
|
? article.coverImg |
|
|
|
|
|
|
|
: "", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
activity != null |
|
|
|
|
|
|
|
? activity.coverImg |
|
|
|
|
|
|
|
: article != null |
|
|
|
|
|
|
|
? article.coverImg |
|
|
|
|
|
|
|
: "", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
buildShareUrl(), |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
SSDKContentTypes.webpage, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showModalBottomSheet( |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
|
|
|
builder: (context) { |
|
|
|
|
|
|
|
return ShareDialog((platform) { |
|
|
|
|
|
|
|
if (platform == ShareSDKPlatforms.line) { |
|
|
|
|
|
|
|
params.map["type"] = SSDKContentTypes.text.value; |
|
|
|
|
|
|
|
params.map["text"] = |
|
|
|
|
|
|
|
"${activity != null ? activity.viceTitle : article != null ? article.viceTitle : ""} ${buildShareUrl()}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SharesdkPlugin.share(platform, params, |
|
|
|
|
|
|
|
(state, userData, contentEntity, error) { |
|
|
|
|
|
|
|
print("share!$state"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String buildShareUrl() { |
|
|
|
|
|
|
|
return "https://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}&type=${activity != null ? "activity" : article != null ? "article" : ""}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
@ -152,7 +12,7 @@ class _WebTurntableActivity extends State<WebTurntableActivity> with WidgetsBind |
|
|
|
margin: EdgeInsets.only(right: 10), |
|
|
|
margin: EdgeInsets.only(right: 10), |
|
|
|
child: GestureDetector( |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () { |
|
|
|
onTap: () { |
|
|
|
share(); |
|
|
|
// share(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Icon( |
|
|
|
child: Icon( |
|
|
|
Icons.share, |
|
|
|
Icons.share, |
|
|
@ -161,42 +21,17 @@ class _WebTurntableActivity extends State<WebTurntableActivity> with WidgetsBind |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
title: "", |
|
|
|
background: Color(0xFFFFFFFFF), |
|
|
|
background: Color(0xFFFFFFFFF), |
|
|
|
leadingColor: Colors.black, |
|
|
|
leadingColor: Colors.black, |
|
|
|
), |
|
|
|
), |
|
|
|
body: Container( |
|
|
|
body: Container( |
|
|
|
child: Column( |
|
|
|
width: MediaQuery.of(context).size.width, |
|
|
|
children: [ |
|
|
|
height: MediaQuery.of(context).size.height, |
|
|
|
Expanded( |
|
|
|
child: |
|
|
|
child: GestureDetector( |
|
|
|
WebView( |
|
|
|
onTap: () { |
|
|
|
initialUrl: "http://192.168.10.90:5500/lottery.html", |
|
|
|
commentFocus.unfocus(); |
|
|
|
)), |
|
|
|
}, |
|
|
|
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
|
|
|
controller: scrollController, |
|
|
|
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
|
|
|
child: Column( |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
/// 富文本的头部 |
|
|
|
|
|
|
|
WebHeader(widget.arguments, activity, article, 16), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 富文本的内容 |
|
|
|
|
|
|
|
WebContent( |
|
|
|
|
|
|
|
activity, |
|
|
|
|
|
|
|
article, |
|
|
|
|
|
|
|
() { |
|
|
|
|
|
|
|
setState(() {}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
flex: 1, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |