From a2672450ed793fcfb4088774ce9af2f6bd3ad09e Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 30 Jul 2021 21:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9UI=EF=BC=8C=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/generated/l10n.dart | 30 --------- lib/home/home_page.dart | 62 +++++++++--------- lib/integral/integral_page.dart | 6 +- lib/main_page.dart | 71 ++++++++++++--------- lib/union/store_details_page.dart | 100 +++++++++++++++++++++++++++--- lib/union/union_page.dart | 28 +++++---- lib/view_widget/icon_text.dart | 4 ++ pubspec.lock | 6 +- pubspec.yaml | 5 +- 9 files changed, 197 insertions(+), 115 deletions(-) diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 34ec6319..0c5b25c6 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -3985,36 +3985,6 @@ class S { ); } - /// `一心回乡用户隐私政策` - String get xieyitanchuang { - return Intl.message( - '一心回乡用户隐私政策', - name: 'xieyitanchuang', - desc: '', - args: [], - ); - } - - /// `《隐私协议》` - String get yinsixieyi { - return Intl.message( - '《隐私协议》', - name: 'yinsixieyi', - desc: '', - args: [], - ); - } - - /// `适用门店` - String get shiyongmendian { - return Intl.message( - '适用门店', - name: 'shiyongmendian', - desc: '', - args: [], - ); - } - /// `并使用本机号码登录` String get privacy_policy4 { return Intl.message( diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 24fbaa32..77763637 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -177,36 +177,36 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { child: Column( children: [ banner(), - ItemTitle( - text: S - .of(context) - .jinrihuiyuanrenwu, - imgPath: "assets/image/icon_today_task.png", - moreText: S - .of(context) - .renwuzhongxin, - onTap: () { - SharedPreferences.getInstance().then((value) { - if (value.getString('token') == null) { - loginTips(); - } else { - Navigator.of(context).pushNamed('/router/integral_page'); - } - }); - }, - ), - InkWell( - onTap: () { - SharedPreferences.getInstance().then((value) { - if (value.getString('token') == null) { - loginTips(); - } else { - Navigator.of(context).pushNamed('/router/integral_page'); - } - }); - }, - child: signIn(), - ), + // ItemTitle( + // text: S + // .of(context) + // .jinrihuiyuanrenwu, + // imgPath: "assets/image/icon_today_task.png", + // moreText: S + // .of(context) + // .renwuzhongxin, + // onTap: () { + // SharedPreferences.getInstance().then((value) { + // if (value.getString('token') == null) { + // loginTips(); + // } else { + // Navigator.of(context).pushNamed('/router/integral_page'); + // } + // }); + // }, + // ), + // InkWell( + // onTap: () { + // SharedPreferences.getInstance().then((value) { + // if (value.getString('token') == null) { + // loginTips(); + // } else { + // Navigator.of(context).pushNamed('/router/integral_page'); + // } + // }); + // }, + // child: signIn(), + // ), ItemTitle( text: S .of(context) @@ -612,7 +612,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { child: ListView.builder( padding: EdgeInsets.only(left: 10.w, right: 10.w), scrollDirection: Axis.horizontal, - physics: ClampingScrollPhysics(), + physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return Container( height: 60.h, diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index 6e5d8b37..59b71236 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -37,8 +37,9 @@ class _IntegralPage extends State { SharedPreferences.getInstance().then((value) { apiService = - ApiService(Dio(), context: context, token: value.getString("token")); + ApiService(Dio(), context: context, token: value.getString("token"), showLoading: false); userinfo = UserInfo.fromJson(jsonDecode(value.getString("user"))); + SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai); querySignInfo(); }); } @@ -62,7 +63,7 @@ class _IntegralPage extends State { .indexWhere((element) => element.id == userinfo.memberRankVo.id) + 1); } - + SmartDialog.dismiss(); if (baseData != null && baseData.isSuccess) { signInfo = SignInfo.fromJson(baseData.data); setState(() {}); @@ -511,6 +512,7 @@ class _IntegralPage extends State { SmartDialog.showToast("今日已签到了"); return; } + SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai); BaseData baseData = await apiService.signIn(); if (baseData != null && baseData.isSuccess) { querySignInfo(); diff --git a/lib/main_page.dart b/lib/main_page.dart index 72c4e222..096369a2 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -23,6 +23,7 @@ class MainPage extends StatefulWidget { } class _MainPage extends State { + List _widgetOptions; List icons; @@ -32,6 +33,8 @@ class _MainPage extends State { void initState() { super.initState(); + pushRoute(); + _widgetOptions = [ BrandPage(), MainHomePage(), @@ -64,32 +67,10 @@ class _MainPage extends State { xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { print("xgPushClickAction1: ${event.toString()}"); if (event["actionType"] == 2) return event; - Map customMessage = jsonDecode(event["customMessage"]); - if (event["actionType"] == 0 && customMessage != null) { - String routeName = ""; - Map params = {}; - switch(customMessage["typed"]) { - case 1://articleId - routeName = "/router/store_detail_page"; - params["articleId"] = customMessage["info"]; - break; - case 2://activityId - routeName = "/router/store_detail_page"; - params["activityId"] = customMessage["info"]; - break; - case 3://id - routeName = "/router/union_detail_page"; - params["id"] = customMessage["info"]; - break; - case 4://goodsId - routeName = "/router/integral_store_page"; - params["goodsId"] = customMessage["info"]; - break; - } - print("xgPushClickAction: routeName: $routeName"); - if (routeName != "") { - Navigator.of(context).pushNamed(routeName, arguments: params); - } + if (event["actionType"] == 0 && event["customMessage"] != null) { + SharedPreferences.getInstance().then((value) { + value.setString("pushData", event["customMessage"]); + }); } return event; }, onReceiveNotificationResponse: (event) async { @@ -102,6 +83,40 @@ class _MainPage extends State { } + pushRoute() async { + SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); + String pushData = sharedPreferences.getString("pushData"); + if (pushData == null || pushData == "") return; + Map pushMap = jsonDecode(pushData); + if (pushMap != null) { + String routeName = ""; + Map params = {}; + switch(pushMap["typed"]) { + case 1: + routeName = "/router/store_detail_page"; + params["articleId"] = pushMap["info"]; + break; + case 2: + routeName = "/router/store_detail_page"; + params["activityId"] = pushMap["info"]; + break; + case 3: + routeName = "/router/union_detail_page"; + params["id"] = pushMap["info"]; + break; + case 4: + routeName = "/router/integral_store_page"; + params["goodsId"] = pushMap["info"]; + break; + } + sharedPreferences.setString("pushData", ""); + print("xgPushClickAction: routeName: $routeName"); + if (routeName != "") { + Navigator.of(context).pushNamed(routeName, arguments: params); + } + } + } + queryUserInfo() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); if (sharedPreferences.getString("token") == null || sharedPreferences.getString("token") == "") return; @@ -122,7 +137,7 @@ class _MainPage extends State { } } - PageController pageController = PageController(); + PageController pageController = PageController(initialPage: 1); @override Widget build(BuildContext context) { @@ -172,7 +187,7 @@ class _MainPage extends State { ); } - var clickIndex = 0; + var clickIndex = 1; Widget bottomNavigationItem(text, index) { var isSelected = index == clickIndex; diff --git a/lib/union/store_details_page.dart b/lib/union/store_details_page.dart index cf57262b..340b1479 100644 --- a/lib/union/store_details_page.dart +++ b/lib/union/store_details_page.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:chewie_audio/chewie_audio.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; @@ -13,6 +16,12 @@ 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:video_player/video_player.dart'; +import 'package:webview_flutter/webview_flutter.dart'; +import 'package:flutter_html/src/replaced_element.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:chewie/src/chewie_progress_colors.dart' as chewie; +import 'package:chewie/chewie.dart'; class StoreDetailsPage extends StatefulWidget { final Map arguments; @@ -33,6 +42,8 @@ class _StoreDetailsPage extends State { void initState() { super.initState(); + if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); + SharedPreferences.getInstance().then((value) { apiService = ApiService(Dio(), context: context, token: value.getString("token")); @@ -58,11 +69,6 @@ class _StoreDetailsPage extends State { } share() async { - // await registerWxApi(appId: "wx3b269e795ed23e5f", doOnAndroid: true, universalLink: "https://hx.lotus-wallet.com/app/"); - // shareToWeChat(WeChatShareWebPageModel( - // "http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}", - // scene: WeChatScene.SESSION)); - // SharesdkPlugin.showMenu(); SSDKMap params = SSDKMap() ..setGeneral( activity != null @@ -152,14 +158,14 @@ class _StoreDetailsPage extends State { ? article.mainTitle : "", style: TextStyle( - fontSize: 16, + fontSize: 16.sp, fontWeight: FontWeight.bold, color: Color(0xFF353535), ), ), ), Container( - padding: EdgeInsets.symmetric(horizontal: 12), + padding: EdgeInsets.symmetric(horizontal: 12.w), child: Row( children: [ InkWell( @@ -212,6 +218,29 @@ class _StoreDetailsPage extends State { return Container(); }), }, + customRender: { + "video" : (context, parsedChild, attributes, element) { + print("video attributes: ${element.attributes}"); + print("video attributes: ${element.attributeSpans}"); + print("video attributes: ${element.children.first.attributes["src"]}"); + print("video attributes: ${parsedChild}"); + return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]); + }, + "iframe" : (context, parsedChild, attributes, element) { + print("iframe attributes: ${element.toString()}"); + print("iframe attributes: ${parsedChild}"); + return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]); + }, + "audio" : (context, parsedChild, attributes, element) { + final sources = [ + if (element.attributes['src'] != null) element.attributes['src'], + ]; + if (sources == null || sources.isEmpty || sources.first == null) { + return EmptyContentElement(); + } + return audioWidget(attributes['controls'] != null, attributes['loop'] != null, attributes['autoplay'] != null, sources, context.style.width ?? 300.w); + }, + }, ), ], ), @@ -220,10 +249,65 @@ class _StoreDetailsPage extends State { ); } + VideoPlayerController videoPlayerController; + ChewieController chewieAudioController; + Chewie chewies; + + Widget videoWidget(double width, double height, src, sandboxMode) { + print("src : $src"); + return Container( + width: MediaQuery.of(context).size.width, + height: (MediaQuery.of(context).size.width) / (width / height), + child: chewies = Chewie( + controller: chewieAudioController = ChewieController( + videoPlayerController: videoPlayerController = VideoPlayerController.network( + src, + ), + aspectRatio: width / height, + //宽高比 + autoPlay: !true, + //自动播放 + looping: false, + //循环播放 + // 拖动条样式颜色 + materialProgressColors: chewie.ChewieProgressColors( + playedColor: Colors.white, + handleColor: Colors.white, + backgroundColor: Colors.grey, + bufferedColor: Colors.transparent, + ), + autoInitialize: true, + ), + ), + ); + } + + Widget audioWidget(showControls, loop, autoplay, src, width) { + return Container( + width: width, + child: chewies = Chewie( + controller: chewieAudioController = ChewieController( + videoPlayerController: VideoPlayerController.network( + src.first ?? "", + ), + autoPlay: autoplay, + looping: loop, + showControls: showControls, + autoInitialize: true, + ), + ), + ); + } + @override void dispose() { - super.dispose(); + if (chewieAudioController != null) + chewieAudioController.dispose(); + if (videoPlayerController != null) + videoPlayerController.dispose(); + + super.dispose(); } } diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 5b74eee0..c6dd4e4d 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -19,6 +19,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:amap_flutter_base/amap_flutter_base.dart'; import 'package:amap_flutter_map/amap_flutter_map.dart'; @@ -649,6 +650,9 @@ class _UnionPage extends State ), ], ), + SizedBox( + width: 4.w, + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, @@ -692,30 +696,32 @@ class _UnionPage extends State child: Container(), flex: 1, ), - Container( - alignment: Alignment.centerRight, - child: Text( - store.address, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xFF727272), - fontSize: 12.sp, - ), + IconText( + store.address, + isMax: true, + overFlow: TextOverflow.ellipsis, + textStyle: TextStyle( + color: Color(0xFF727272), + fontSize: 12.sp, ), + leftImage: "assets/image/icon_union_location_black.png", + iconSize: 14, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text( + IconText( (store.openStartTime == null && store.openEndTime == null) ? S.of(context).quantian : "${store.openStartTime.substring(0, store.openStartTime.lastIndexOf(":"))}-${store.openEndTime.substring(0, store.openEndTime.lastIndexOf(":"))}", - style: TextStyle( + textStyle: TextStyle( color: Color(0xFFA29E9E), fontSize: 12.sp, ), + leftImage: "assets/image/icon_union_time.png", + iconSize: 14, ), Visibility( child: Text( diff --git a/lib/view_widget/icon_text.dart b/lib/view_widget/icon_text.dart index 3c7d02af..aadb8114 100644 --- a/lib/view_widget/icon_text.dart +++ b/lib/view_widget/icon_text.dart @@ -10,6 +10,7 @@ class IconText extends StatelessWidget { final double iconSize; final double space; final Color iconColor; + final TextOverflow overFlow; final CrossAxisAlignment textAxisAlignment; final bool isMax; @@ -22,6 +23,7 @@ class IconText extends StatelessWidget { this.isMax = false, this.iconSize = 16, this.space = 1, + this.overFlow = TextOverflow.fade, this.textAxisAlignment = CrossAxisAlignment.center, this.iconColor = Colors.black, this.textStyle}); @@ -58,12 +60,14 @@ class IconText extends StatelessWidget { widgets.add(isMax ? Expanded( child: Text( text, + overflow: overFlow, textAlign: TextAlign.start, style: textStyle, ), flex: 1, ) : Text( text, + overflow: overFlow, textAlign: TextAlign.center, style: textStyle, )); diff --git a/pubspec.lock b/pubspec.lock index 668f04a7..d3bbf51a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -170,14 +170,14 @@ packages: source: hosted version: "1.0.4" chewie: - dependency: "direct main" + dependency: transitive description: name: chewie url: "https://pub.flutter-io.cn" source: hosted version: "0.12.2" chewie_audio: - dependency: transitive + dependency: "direct main" description: name: chewie_audio url: "https://pub.flutter-io.cn" @@ -1023,7 +1023,7 @@ packages: source: hosted version: "1.2.0" webview_flutter: - dependency: transitive + dependency: "direct main" description: name: webview_flutter url: "https://pub.flutter-io.cn" diff --git a/pubspec.yaml b/pubspec.yaml index fbe0374e..68982372 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -85,9 +85,10 @@ dependencies: cached_network_image: ^2.0.0 flutter_html: ^1.3.0 #2.1.0 - photo_view: ^0.11.1 + webview_flutter: ^1.0.7 + chewie_audio: ^1.1.2 - chewie: ^0.12.2 + photo_view: ^0.11.1 video_player: ^1.0.1 package_info: ^2.0.2