From 9d9ebe2f14daf12294bc3ef13eb25bb8cd5651e1 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 18 Feb 2022 11:20:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8A=A0=E6=9B=B4;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 2 + lib/web/web_turntable_activity.dart | 202 ++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 lib/web/web_turntable_activity.dart diff --git a/lib/main.dart b/lib/main.dart index be5430b7..0c5205d3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -62,6 +62,7 @@ import 'package:huixiang/union/union_details_page.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/web/web_turntable_activity.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sharesdk_plugin/sharesdk_interface.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart'; @@ -301,6 +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/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 new file mode 100644 index 00000000..f268ef13 --- /dev/null +++ b/lib/web/web_turntable_activity.dart @@ -0,0 +1,202 @@ +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" : ""}"; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: MyAppBar( + action: Container( + margin: EdgeInsets.only(right: 10), + child: GestureDetector( + onTap: () { + share(); + }, + child: Icon( + Icons.share, + size: 24, + color: Colors.black, + ), + ), + ), + 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, + ), + ], + ), + ), + ); + } +} From 8ad6a4895cecfde41d739cb161d4638bf5029462 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 18 Feb 2022 13:34:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8A=A0=E6=9B=B4;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home/home_page.dart | 1 + lib/main.dart | 2 +- lib/web/web_turntable_activity.dart | 185 ++-------------------------- 3 files changed, 12 insertions(+), 176 deletions(-) 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 From 5187eb62b471f0190bc71d02f3e972bf90f24432 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 18 Feb 2022 16:39:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=82=80=E8=AF=B7=E7=A0=81=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/qr/qr_share.dart | 29 +++++++++++++++-------------- pubspec.lock | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/qr/qr_share.dart b/lib/qr/qr_share.dart index 66bb89ce..7fd13b48 100644 --- a/lib/qr/qr_share.dart +++ b/lib/qr/qr_share.dart @@ -81,7 +81,7 @@ class _QrSharePage extends State { children: [ Positioned( child: Image.asset( - "assets/image/qr_share_bg_yq.png", + "assets/image/qr_share_bg.png", fit: BoxFit.fill, ), top: 0, @@ -153,25 +153,26 @@ class _QrSharePage extends State { S.of(context).fenxiangyaoqingma, textAlign: TextAlign.center, style: TextStyle( + height: 1.5, color: Color(0xFF2E3552), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), ), - Container( - margin: EdgeInsets.only(left: 16.w, right: 24.w), - child: Text( - // S.of(context).fenxiangyaoqing, - S.of(context).beiyaoqingdejiangli, - textAlign: TextAlign.center, - style: TextStyle( - color: Color(0xFF2E3552), - fontSize: 16.sp, - fontWeight: MyFontWeight.regular, - ), - ), - ), + // Container( + // margin: EdgeInsets.only(left: 16.w, right: 24.w), + // child: Text( + // // S.of(context).fenxiangyaoqing, + // S.of(context).beiyaoqingdejiangli, + // textAlign: TextAlign.center, + // style: TextStyle( + // color: Color(0xFF2E3552), + // fontSize: 16.sp, + // fontWeight: MyFontWeight.regular, + // ), + // ), + // ), SizedBox( height: 1.h, ), diff --git a/pubspec.lock b/pubspec.lock index 085d455b..b3474fc4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -255,7 +255,7 @@ packages: name: flutter_screenutil url: "https://pub.flutter-io.cn" source: hosted - version: "5.3.0" + version: "5.3.1" flutter_smart_dialog: dependency: "direct main" description: