diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index e8231bf3..52e69705 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -326,6 +326,7 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { totalMsg = 0; }); }); + // Navigator.of(context).pushNamed('/router/web_turntable_activity'); }, child: Container( height: 24, diff --git a/lib/main.dart b/lib/main.dart index 0c5205d3..2775f999 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -302,7 +302,7 @@ Map routers = { '/router/store_selector_page': (context, {arguments}) => StoreSelectorPage(), '/router/video_playback_page': (context, {arguments}) => VideoPlaybackPage(), '/router/web_page': (context, {arguments}) => WebPage(arguments: arguments), - '/router/web_turntable_activity': (context, {arguments}) => WebTurntableActivity(arguments: arguments), + '/router/web_turntable_activity': (context, {arguments}) => WebTurntableActivity(), '/router/help_feedback_page': (context, {arguments}) => HelpFeedbackPage(), '/router/founder_story_page': (context, {arguments}) => FounderStoryPage(), '/router/system_msg_page': (context, {arguments}) => SystemMessagePage(), diff --git a/lib/web/web_turntable_activity.dart b/lib/web/web_turntable_activity.dart index f268ef13..3da0be09 100644 --- a/lib/web/web_turntable_activity.dart +++ b/lib/web/web_turntable_activity.dart @@ -1,148 +1,8 @@ -import 'dart:io'; -import 'dart:ui'; - -import 'package:dio/dio.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/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:flutter/cupertino.dart'; - -class WebTurntableActivity extends StatefulWidget { - final Map arguments; - - ///转盘活动 - WebTurntableActivity({this.arguments}); - - @override - State createState() { - return _WebTurntableActivity(); - } -} - -class _WebTurntableActivity extends State 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 { - SharedPreferences value = await SharedPreferences.getInstance(); - if (apiService == null) - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); - - // if (widget.arguments["activityId"] != null) { - // BaseData baseData = await apiService - // .activityInfo(widget.arguments["activityId"]) - // .catchError((onError) {}); - // if (baseData != null && baseData.isSuccess) { - // activity = baseData.data; - // setState(() {}); - // } - // } - // if (widget.arguments["articleId"] != null) { - // BaseData
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" : ""}"; - } +class WebTurntableActivity extends StatelessWidget { @override Widget build(BuildContext context) { @@ -152,7 +12,7 @@ class _WebTurntableActivity extends State with WidgetsBind margin: EdgeInsets.only(right: 10), child: GestureDetector( onTap: () { - share(); + // share(); }, child: Icon( Icons.share, @@ -161,42 +21,17 @@ class _WebTurntableActivity extends State with WidgetsBind ), ), ), + title: "", background: Color(0xFFFFFFFFF), leadingColor: Colors.black, ), body: Container( - child: Column( - children: [ - Expanded( - child: GestureDetector( - onTap: () { - commentFocus.unfocus(); - }, - child: SingleChildScrollView( - controller: scrollController, - physics: BouncingScrollPhysics(), - child: Column( - children: [ - /// 富文本的头部 - WebHeader(widget.arguments, activity, article, 16), - - /// 富文本的内容 - WebContent( - activity, - article, - () { - setState(() {}); - }, - ), - ], - ), - ), - ), - flex: 1, - ), - ], - ), - ), + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: + WebView( + initialUrl: "http://192.168.10.90:5500/lottery.html", + )), ); } -} +} \ No newline at end of file