diff --git a/ios/Podfile.lock b/ios/Podfile.lock index bba069cf..6e58a0cb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -143,6 +143,9 @@ PODS: - mob_sharesdk/ShareSDKPlatforms/WatermelonVideo (4.4.0): - mob_sharesdk/ShareSDK - MOBFoundation (>= 3.2.9) + - mob_sharesdk/ShareSDKPlatforms/WeChat_Lite (4.4.0): + - mob_sharesdk/ShareSDK + - MOBFoundation (>= 3.2.9) - mob_sharesdk/ShareSDKPlatforms/WhatsApp (4.4.0): - mob_sharesdk/ShareSDK - MOBFoundation (>= 3.2.9) diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index cf339df4..391b8702 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -6,7 +6,6 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/member_comment_list.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; @@ -14,7 +13,6 @@ import 'package:huixiang/view_widget/my_appbar.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:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CommunityDetails extends StatefulWidget { @@ -100,7 +98,6 @@ class _CommunityDetails extends State with WidgetsBindingObser setState(() { article = baseData.data; }); - } else { } } diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index 0ec68090..6a695ff6 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:huixiang/community/community_child_list.dart'; import 'package:huixiang/community/community_child_page.dart'; import 'package:huixiang/home/huixiang_brand_page.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; @@ -39,9 +40,20 @@ class _CommunityPage extends State tabcontroller = TabController(length: lables.length, vsync: this, initialIndex: 1); } + _toRelease() async { + var result = await Navigator.of(context).pushNamed('/router/release_dynamic'); + + // int tmpIndex = tabcontroller.index; + // setState(() { + // tabcontroller.index = (tabcontroller.index == lables.length -1)?0:tabcontroller.index+1; + // }); + // setState(() { + // tabcontroller.index = tmpIndex; + // }); + } + @override Widget build(BuildContext context) { - debugPrint("createState createState createState ......"); return Scaffold( appBar: MyAppBar( leading: false, @@ -72,7 +84,7 @@ class _CommunityPage extends State ), ), onTap: () { - Navigator.of(context).pushNamed('/router/release_dynamic'); + _toRelease(); }, action: GestureDetector( behavior: HitTestBehavior.opaque, @@ -98,16 +110,8 @@ class _CommunityPage extends State }else if(e == "课程"){ return CommunityCourse(); } - else if(e == "关注"){ - if (guanzhu == null ){ - guanzhu = CommunityChildPage("关注");; - } - return guanzhu; - }else if(e == "推荐"){ - if (tuijian == null){ - tuijian = CommunityChildPage("推荐"); - } - return tuijian; + else { + return CommunityChildList(e); } }).toList(), controller: tabcontroller, diff --git a/lib/community/community_view/class_details_video.dart b/lib/community/community_view/class_details_video.dart index a051e0f6..5c60c698 100644 --- a/lib/community/community_view/class_details_video.dart +++ b/lib/community/community_view/class_details_video.dart @@ -11,6 +11,7 @@ class ClassDetailsVideo extends StatefulWidget { final bool isShowImg; final Function exitFull; final String coverImg; + final String videoUrl; ClassDetailsVideo( { @@ -19,7 +20,8 @@ class ClassDetailsVideo extends StatefulWidget { this.isShowImg, this.exitFull, this.heightFun, - this.coverImg + this.coverImg, + this.videoUrl }) : super(key: key); @override @@ -41,6 +43,9 @@ class ClassDetailsVideoState extends State { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); + if(widget.videoUrl != null){ + initVideo(widget.videoUrl); + } } @override @@ -91,14 +96,11 @@ class ClassDetailsVideoState extends State { @override Widget build(BuildContext context) { return Container( - key: globalKey,child:videoWidget( - MediaQuery.of(context).size.width, - videoPlayerController != null - ? (MediaQuery.of(context).size.width) / - videoPlayerController.value.aspectRatio - : MediaQuery.of(context).size.width / 2, - widget.coverImg, - )); + key: globalKey,child:(videoPlayerController?.value?.isInitialized ?? false) ?videoWidget( + MediaQuery.of(context).size.width, + (MediaQuery.of(context).size.width/videoPlayerController.value.aspectRatio)-43, + widget.coverImg, + ):Container()); } @override @@ -129,15 +131,16 @@ class ClassDetailsVideoState extends State { ? Container( color: Colors.black, width: width, - // height: - height: width / 7 * 5, + // height: width / 7 * 5, + height: height, child: chewies = Chewie( controller: chewieAudioController, ), ) : Container( width: width, - height:width / 7 * 5, + // height:width / 7 * 5, + height: height, )), if (widget.isShowImg) GestureDetector( @@ -150,7 +153,8 @@ class ClassDetailsVideoState extends State { }, child: Container( width: width, - height: width / 7 * 5, + // height: width / 7 * 5, + height: height, color: Colors.black, child: Stack( children: [ diff --git a/lib/community/headlines/article_list.dart b/lib/community/headlines/article_list.dart index 9bf6a0e0..4bf58089 100644 --- a/lib/community/headlines/article_list.dart +++ b/lib/community/headlines/article_list.dart @@ -1,20 +1,10 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/article.dart'; -import 'package:huixiang/retrofit/data/banner.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; -import 'package:huixiang/view_widget/hot_item.dart'; -import 'package:huixiang/view_widget/my_appbar.dart'; -import 'package:huixiang/view_widget/my_footer.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/lib/community/photo_view_gallery_screen.dart b/lib/community/photo_view_gallery_screen.dart index 86daaf63..2076af6a 100644 --- a/lib/community/photo_view_gallery_screen.dart +++ b/lib/community/photo_view_gallery_screen.dart @@ -1,7 +1,9 @@ -import 'package:cached_network_image/cached_network_image.dart'; +import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:photo_view/photo_view.dart'; +import 'package:huixiang/utils/ImgCachePath.dart'; +import 'package:network_to_file_image/network_to_file_image.dart'; import 'package:photo_view/photo_view_gallery.dart'; +import 'package:path/path.dart' as p; class PhotoViewGalleryScreen extends StatefulWidget { List images=[]; @@ -26,7 +28,10 @@ class _PhotoViewGalleryScreenState extends State { super.initState(); currentIndex=widget.index; } - + File fileFromDocsDir(String filename) { + String pathName = p.join(ImgCachePath.instance.path, filename); + return File(pathName); + } @override Widget build(BuildContext context) { return Scaffold( @@ -42,8 +47,12 @@ class _PhotoViewGalleryScreenState extends State { scrollPhysics: const BouncingScrollPhysics(), builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( - imageProvider: CachedNetworkImageProvider(widget.images[index]), - + imageProvider: NetworkToFileImage( + url: widget.images[index], + file: fileFromDocsDir(widget.images[index].toString() + .replaceAll("https://pos.upload.gznl.top/", "").replaceAll("/", "")), + debug: true, + ), ); }, itemCount: widget.images.length, diff --git a/lib/main.dart b/lib/main.dart index ff2580d3..f634b27e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -55,6 +55,7 @@ import 'package:huixiang/store/store_order.dart'; import 'package:huixiang/settlement/settlement.dart'; import 'package:huixiang/test_page.dart'; import 'package:huixiang/union/location_map_page.dart'; +import 'package:huixiang/utils/ImgCachePath.dart'; import 'package:huixiang/web/web_page.dart'; import 'package:huixiang/union/union_details_page.dart'; @@ -70,6 +71,7 @@ import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'community/community_view/class_details.dart'; import 'community/headlines/headlines_column_details.dart'; +import 'community/new_community_details.dart'; import 'community/photo_view_gallery_screen.dart'; import 'home/guide_page.dart'; import 'home/home_view/activity_list.dart'; @@ -102,6 +104,7 @@ void main() async { } else { locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW'); } + ImgCachePath(); initSdk(); bool isFirst = sharedPreferences.getBool("isFirst"); @@ -302,6 +305,8 @@ Map routers = { '/router/release_dynamic': (context, {arguments}) => ReleaseDynamic(), '/router/community_details': (context, {arguments}) => CommunityDetails(arguments: arguments), + '/router/new_community_details': (context, {arguments}) => + NewCommunityDetails(arguments: arguments), '/router/user_info_page': (context, {arguments}) => UserInfoPage(), '/router/recharge_page': (context, {arguments}) => RechargePage(), '/router/mine_wallet': (context, {arguments}) => MineWalletPage(), diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index aacd3933..42c98f39 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -137,11 +137,12 @@ class _StoreOrderPage extends State } queryMemberInfo() async { - BaseData baseData = await minService.memberInfo() - .catchError((error){debugPrint(error);}); + BaseData baseData = await minService.memberInfo().catchError((error) { + debugPrint(error); + }); if (baseData != null && baseData.isSuccess) { SharedPreferences.getInstance().then( - (value) => { + (value) => { value.setString('minMember', jsonEncode(baseData.data)), }, ); @@ -150,8 +151,10 @@ class _StoreOrderPage extends State ///获取父订单(火锅订单加菜前调用) getParentInfo() async { - BaseData baseData = await minService.getParentInfo("$tableId") - .catchError((error) {debugPrint(error);}); + BaseData baseData = + await minService.getParentInfo("$tableId").catchError((error) { + debugPrint(error); + }); if (baseData != null && baseData.isSuccess) { if (baseData.data != null) { parentId = baseData.data["id"]; @@ -182,7 +185,8 @@ class _StoreOrderPage extends State /// 查询店铺信息 queryStoreInfo() async { - BaseData baseData = await apiService.queryStoreInfo(storeId).catchError((error) { + BaseData baseData = + await apiService.queryStoreInfo(storeId).catchError((error) { debugPrint(error); }); if (baseData != null && baseData.isSuccess) { @@ -202,8 +206,7 @@ class _StoreOrderPage extends State @override Widget build(BuildContext context) { - return - WillPopScope( + return WillPopScope( onWillPop: () async { if (dialogShowing) { debugPrint("ssssasdadsasdadasd"); @@ -213,8 +216,7 @@ class _StoreOrderPage extends State return true; } }, - child: - Container( + child: Container( color: Colors.white, child: Stack( children: [ @@ -227,14 +229,15 @@ class _StoreOrderPage extends State controller: controller, dragStartBehavior: DragStartBehavior.start, physics: BouncingScrollPhysics(), - headerSliverBuilder: (BuildContext context, bool innerScrolled) { + headerSliverBuilder: + (BuildContext context, bool innerScrolled) { return [ SliverOverlapAbsorber( handle: NestedScrollView.sliverOverlapAbsorberHandleFor( context), sliver: SliverAppBar( - expandedHeight: - (storeInfo != null && storeInfo.couponVOList != null) + expandedHeight: (storeInfo != null && + storeInfo.couponVOList != null) ? 470.h : 365.h, floating: false, @@ -262,9 +265,8 @@ class _StoreOrderPage extends State ), ), flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : ''), + title: Title(controller, + storeInfo != null ? storeInfo.storeName : ''), collapseMode: CollapseMode.pin, stretchModes: [ StretchMode.zoomBackground, @@ -555,6 +557,7 @@ class _StoreOrderPage extends State return; } } + await Navigator.of(context).pushNamed( '/router/settlement', arguments: { @@ -562,15 +565,15 @@ class _StoreOrderPage extends State "tableId": tableId, "parentCode": parentCode, "parentId": parentId, - "pName":pName, - "pid":pid, - "cName":cName, - "cid":cid, + "pName": pName, + "pid": pid, + "cName": cName, + "cid": cid, "shoppingCart": shopCarGoods, "numberOfPeople": numberOfPeople, }, ); - if(tableId >0){ + if (tableId > 0) { getParentInfo(); } queryShopCar().then((value) { @@ -651,18 +654,19 @@ class _StoreOrderPage extends State } ///选规格 - _queryMiNiDetail(String id,int count) async { + _queryMiNiDetail(String id, int count) async { EasyLoading.show(status: S.current.zhengzaijiazai); BaseData baseData = await minService.miNiDetail(id); if (baseData != null && baseData.isSuccess) { - showStoreSelector(baseData.data, id,count); + showStoreSelector(baseData.data, id, count); } } ///选规格弹窗 - showStoreSelector(MiNiDetail miNiDetail, String id,int count) async { - if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1 - && miNiDetail.attrList[0].attrValueList.length == 1) { + showStoreSelector(MiNiDetail miNiDetail, String id, int count) async { + if (miNiDetail.attrList != null && + miNiDetail.attrList.length == 1 && + miNiDetail.attrList[0].attrValueList.length == 1) { _addShopCar(miNiDetail, [], count); } else { EasyLoading.dismiss(); @@ -687,7 +691,7 @@ class _StoreOrderPage extends State ///添加购物车 Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { ProductSkuVOListBean productSku; - if (selectSkus!= null && selectSkus.length == 0) { + if (selectSkus != null && selectSkus.length == 0) { productSku = miNiDetail.productSkuVOList.first; } else { productSku = miNiDetail.productSkuVOList.firstWhere((element) { @@ -743,28 +747,28 @@ class _StoreOrderPage extends State ///查询购物车 Future queryShopCar() async { - pName="";//活动 - pid="";//活动 - cName="";//优惠券 - cid="";//优惠券 + pName = ""; //活动 + pid = ""; //活动 + cName = ""; //优惠券 + cid = ""; //优惠券 BaseData> baseDate = await minService.getShoppingCart(tableId); if (baseDate != null && baseDate.isSuccess && baseDate.data != null && baseDate.data.length > 0) { - if( baseDate.data[0].selectDiscount ==1){ + if (baseDate.data[0].selectDiscount == 1) { baseDate.data[0].couponList.forEach((element) { - if(element.isMaxCoupon){ + if (element.isMaxCoupon) { cName = element.promotionName; cid = element.id; } }); - }else if(baseDate.data[0].selectDiscount==2){ + } else if (baseDate.data[0].selectDiscount == 2) { baseDate.data[0].promotionInfoList.forEach((element) { - if(element.isMaxPromotion){ - pName=element.name; - pid=element.id; + if (element.isMaxPromotion) { + pName = element.name; + pid = element.id; } }); } diff --git a/lib/utils/ImgCachePath.dart b/lib/utils/ImgCachePath.dart index e69de29b..fa3c41a0 100644 --- a/lib/utils/ImgCachePath.dart +++ b/lib/utils/ImgCachePath.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:path_provider/path_provider.dart'; + +class ImgCachePath{ + factory ImgCachePath() => _getInstance(); + + static ImgCachePath get instance => _getInstance(); + + static ImgCachePath _instance; + + String _path; + + String get path => _path; + + ImgCachePath._internal(){ + fileFromDocsDir(); + } + + fileFromDocsDir() async { + Directory tempDir = await getTemporaryDirectory(); + Directory directory = new Directory('${tempDir.path}/ImgCache'); + if (!directory.existsSync()) { + directory.createSync(); + } + _path = directory.path; + } + + static ImgCachePath _getInstance(){ + if(_instance == null){ + _instance = ImgCachePath._internal(); + } + return _instance; + } +} \ No newline at end of file diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index e03f81d5..4caaa7b9 100644 --- a/lib/view_widget/custom_image.dart +++ b/lib/view_widget/custom_image.dart @@ -1,8 +1,8 @@ import 'dart:io'; - -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter/material.dart'; +import 'package:huixiang/utils/ImgCachePath.dart'; +import 'package:network_to_file_image/network_to_file_image.dart'; +import 'package:path/path.dart' as p; class MImage extends StatelessWidget { final String src; @@ -29,6 +29,11 @@ class MImage extends StatelessWidget { this.radius = BorderRadius.zero, }); + File fileFromDocsDir(String filename) { + String pathName = p.join(ImgCachePath.instance.path, filename); + return File(pathName); + } + @override Widget build(BuildContext context) { Widget image = LayoutBuilder( @@ -41,10 +46,13 @@ class MImage extends StatelessWidget { // "$src$oper/imageMogr2/thumbnail/${constraints.constrainWidth() * scaleIndex}" // "x${constraints.constrainHeight() * scaleIndex}/format/webp/quality/100"; // } - + int _w = ((constraints.constrainWidth()==double.infinity? + MediaQuery.of(context).size.width:constraints.constrainWidth()) * scaleIndex).toInt(); + int _h = ((constraints.constrainHeight()==double.infinity? + MediaQuery.of(context).size.height:constraints.constrainHeight()) * scaleIndex).toInt(); ///压缩图片 if ((src??"").startsWith("http")) { - imageUrl = "$src?imageView2/1/format/jpg/q/50"; + imageUrl = "$src?imageView2/1/w/${_w}/h/${_h}/format/jpg/q/75"; } // print("imageUrl:$imageUrl"); @@ -58,43 +66,38 @@ class MImage extends StatelessWidget { ); } Widget cachedNetworkImage; - if (src.startsWith("http")) { - cachedNetworkImage = CachedNetworkImage( - imageUrl: imageUrl, - cacheManager: DefaultCacheManager(), - fadeInDuration: Duration(milliseconds: 300), - fadeOutDuration: Duration(milliseconds: 300), - imageBuilder: (context, provide) { - return Image( - image: provide, - fit: fit, - ); - }, - errorWidget: (context, error, stackTrace) { - return Image.asset( - errorSrc, - fit: fit, - ); - }, - placeholder: (context, placeholder) { - return Image.asset( - fadeSrc, - fit: fit, - ); - }, - ); - } else if (src.startsWith("file")) { - cachedNetworkImage = Image.file( - File(src), - fit: fit, - errorBuilder: (context, error, stackTrace) { - return Image.asset( - errorSrc, - fit: fit, - ); - }, - ); - } + if (src.startsWith("http")) { + cachedNetworkImage = Image( + image: ResizeImage(NetworkToFileImage( + url: imageUrl, + file: fileFromDocsDir("resize"+src.replaceAll("https:", "") + .replaceAll("http:", "") + .replaceAll("pos.upload.gznl.top", "") + .replaceAll("/", "")), + debug: true, + ), + width: _w, + height: _h), + errorBuilder: (context, error, stackTrace) { + return Image.asset( + errorSrc, + fit: fit, + ); + }, + fit: fit, + ); + } else if (src.startsWith("file")) { + cachedNetworkImage = Image.file( + File(src), + fit: fit, + errorBuilder: (context, error, stackTrace) { + return Image.asset( + errorSrc, + fit: fit, + ); + }, + ); + } return cachedNetworkImage; }, ); diff --git a/pubspec.lock b/pubspec.lock index 301148f0..7b7b2595 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,13 +50,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.1.6" - cached_network_image: - dependency: "direct main" - description: - name: cached_network_image - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.0" characters: dependency: transitive description: @@ -209,13 +202,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.4" - flutter_cache_manager: - dependency: transitive - description: - name: flutter_cache_manager - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.3" flutter_easyloading: dependency: "direct main" description: @@ -269,7 +255,7 @@ packages: name: flutter_screenutil url: "https://pub.flutter-io.cn" source: hosted - version: "5.0.3" + version: "5.1.0" flutter_smart_dialog: dependency: "direct main" description: @@ -350,13 +336,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.15.0" - http: - dependency: transitive - description: - name: http - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.12.2" http_parser: dependency: transitive description: @@ -434,6 +413,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" + network_to_file_image: + dependency: "direct main" + description: + name: network_to_file_image + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.8" numerus: dependency: transitive description: @@ -677,20 +663,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.8.1" - sqflite: - dependency: transitive - description: - name: sqflite - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.2+4" - sqflite_common: - dependency: transitive - description: - name: sqflite_common - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.3+3" stack_trace: dependency: transitive description: @@ -712,13 +684,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" - synchronized: - dependency: transitive - description: - name: synchronized - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.2.0+2" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 98b64fa5..6f6affec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -65,7 +65,7 @@ dependencies: scan: ^1.5.0 path_provider: ^1.2.0 - cached_network_image: ^2.0.0 + network_to_file_image: ^2.0.0 flutter_html: ^2.1.5 #2.1.0 chewie_audio: ^1.1.2