From a631a134eddc677c46ace774e79699f9063ca6cc Mon Sep 17 00:00:00 2001 From: Loki <654612@qq.com> Date: Mon, 24 Jan 2022 13:49:36 +0800 Subject: [PATCH] image pre cached |view controller inited --- ios/Podfile.lock | 27 +++++----- ios/Runner.xcodeproj/project.pbxproj | 5 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/community/community_page.dart | 29 +++++------ .../community_view/community_dynamic.dart | 51 +------------------ lib/community/photo_view_gallery_screen.dart | 3 +- 6 files changed, 32 insertions(+), 85 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 814fbd6c..bba069cf 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -143,9 +143,6 @@ 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) @@ -173,7 +170,7 @@ PODS: - SDWebImage (5.12.1): - SDWebImage/Core (= 5.12.1) - SDWebImage/Core (5.12.1) - - shared_preferences (0.0.1): + - shared_preferences_ios (0.0.1): - Flutter - sharesdk_plugin (1.1.2): - Flutter @@ -207,12 +204,12 @@ PODS: - mob_sharesdk/ShareSDKPlatforms/Twitter - mob_sharesdk/ShareSDKPlatforms/VKontakte - mob_sharesdk/ShareSDKPlatforms/WatermelonVideo - - mob_sharesdk/ShareSDKPlatforms/WeChat_Lite - mob_sharesdk/ShareSDKPlatforms/WhatsApp - mob_sharesdk/ShareSDKPlatforms/Yixin - mob_sharesdk/ShareSDKPlatforms/YouDaoNote - mob_sharesdk/ShareSDKRestoreScene - mob_sharesdk/ShareSDKUI + - WechatOpenSDK_Fuck (~> 1.9.2) - sqflite (0.0.2): - Flutter - FMDB (>= 2.7.5) @@ -248,7 +245,7 @@ DEPENDENCIES: - path_provider (from `.symlinks/plugins/path_provider/ios`) - permission_handler (from `.symlinks/plugins/permission_handler/ios`) - scan (from `.symlinks/plugins/scan/ios`) - - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) - sharesdk_plugin (from `.symlinks/plugins/sharesdk_plugin/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - SSZipArchive (~> 2.4.2) @@ -298,8 +295,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler/ios" scan: :path: ".symlinks/plugins/scan/ios" - shared_preferences: - :path: ".symlinks/plugins/shared_preferences/ios" + shared_preferences_ios: + :path: ".symlinks/plugins/shared_preferences_ios/ios" sharesdk_plugin: :path: ".symlinks/plugins/sharesdk_plugin/ios" sqflite: @@ -321,13 +318,13 @@ SPEC CHECKSUMS: AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce BaiduMapKit: 907c6d9b74f66c3ff4741fc4b568ae0b339917f8 BMKLocationKit: 097814ef672b1e57e86e6c1968d7892fb78002bf - Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a flutter_baidu_mapapi_base: 90fddba11ec4435406a7211d6ee905b4311c31db flutter_baidu_mapapi_map: 771bf00671832b1fcddb17733518cd631529df16 flutter_baidu_mapapi_search: 4cffaa74e739a4114595c4f82f790e1783bb612d flutter_baidu_mapapi_utils: a5bd582b91ecd35be1bc45558b38f49d5684f70a flutter_bmflocation: 12f1ba91bae4b16d78d4f475023e0254ed351f1c - fluwx: c192ef1ea3617badb813fa1a761ffc5c9c12208a + fluwx: 02670633ce7509206f62b366e9734e7dda81e100 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a image_pickers: 5e6ec7083f9363d014c0fb061f1b9cd97bb5e451 mob_sharesdk: c771f001e00739d24301a9fa250247601efe7a3c @@ -337,17 +334,17 @@ SPEC CHECKSUMS: permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 scan: aea35bb4aa59ccc8839c576a18cd57c7d492cc86 SDWebImage: 4dc3e42d9ec0c1028b960a33ac6b637bb432207b - shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d - sharesdk_plugin: 5a59e49d2d5e55c8e8f67cc9ddf05172c2494a6b + shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 + sharesdk_plugin: 31d5b9be9522985da8e3a90ff73f6e12e62f9049 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2 - thumbnails: bb4f4e9bb4b51c8ae4e6ad9a2fa81373f9b634ad + thumbnails: df4b2db0d4030d134e7665da9c3060b0d78726fe TPNS-iOS: 57a146496858ba2fb5d43e5f240feb19243b69cb tpns_flutter_plugin: a366649c8ad71f19dfb864d3c994ed0480b69daa url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef - video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e + video_player: ecd305f42e9044793efd34846e1ce64c31ea6fcb wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f - webview_flutter: 3603125dfd3bcbc9d8d418c3f80aeecf331c068b + webview_flutter: 5fb4def2bbd4339889ee14d045b605cefc5bc232 WechatOpenSDK_Fuck: aa8f4b0af902837e887a1d40c62f06c060c1dc98 ZLPhotoBrowser-objc: c7657d3bc85ae231884e058d0e3638f619164736 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1c282ba8..158dfa11 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -674,7 +674,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -994,7 +994,6 @@ "-l\"flutter_baidu_mapapi_map\"", "-l\"flutter_baidu_mapapi_base\"", "-l\"permission_handler\"", - "-l\"shared_preferences\"", "-l\"sqflite\"", "-l\"sqlite3\"", "-l\"video_player\"", @@ -1232,7 +1231,6 @@ "-l\"flutter_baidu_mapapi_map\"", "-l\"flutter_baidu_mapapi_base\"", "-l\"permission_handler\"", - "-l\"shared_preferences\"", "-l\"sqflite\"", "-l\"sqlite3\"", "-l\"video_player\"", @@ -1361,7 +1359,6 @@ "-l\"flutter_baidu_mapapi_map\"", "-l\"flutter_baidu_mapapi_base\"", "-l\"permission_handler\"", - "-l\"shared_preferences\"", "-l\"sqflite\"", "-l\"sqlite3\"", "-l\"video_player\"", diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb2dffc4..c87d15a3 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ with SingleTickerProviderStateMixin { TabController tabcontroller; + CommunityChildPage guanzhu,tuijian ; + List lables = [ "关注", "推荐", @@ -37,20 +39,9 @@ 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, @@ -81,7 +72,7 @@ class _CommunityPage extends State ), ), onTap: () { - _toRelease(); + Navigator.of(context).pushNamed('/router/release_dynamic'); }, action: GestureDetector( behavior: HitTestBehavior.opaque, @@ -107,8 +98,16 @@ class _CommunityPage extends State }else if(e == "课程"){ return CommunityCourse(); } - else { - return CommunityChildPage(e); + else if(e == "关注"){ + if (guanzhu == null ){ + guanzhu = CommunityChildPage("关注");; + } + return guanzhu; + }else if(e == "推荐"){ + if (tuijian == null){ + tuijian = CommunityChildPage("推荐"); + } + return tuijian; } }).toList(), controller: tabcontroller, diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index c87e5207..9dc1c780 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -54,7 +54,6 @@ class _CommunityDynamic extends State { double height = 0; ApiService apiService; - VideoPlayerController videoPlayerController; ChewieController chewieAudioController; Chewie chewies; @@ -70,47 +69,10 @@ class _CommunityDynamic extends State { ), }, ); - initVideo(); } String filePath; - initVideo() async { - if (widget?.article?.content == null) return; - var cnt = jsonDecode(widget.article.content); - if (cnt["type"] == "video" && cnt["video"] != null) { - if (widget.isList) { - videoPlayerController = VideoPlayerController.network( - cnt["video"], - )..initialize().then((value) {}); - } else { - videoPlayerController = VideoPlayerController.network( - cnt["video"], - )..initialize().then((value) { - chewieAudioController = ChewieController( - videoPlayerController: videoPlayerController, - aspectRatio: videoPlayerController.value.aspectRatio, - //宽高比 - autoPlay: false, - //自动播放 - looping: false, - //循环播放 - allowFullScreen: true, - // 拖动条样式颜色 - materialProgressColors: chewie.ChewieProgressColors( - playedColor: Colors.white, - handleColor: Colors.white, - backgroundColor: Colors.grey, - bufferedColor: Colors.transparent, - ), - autoInitialize: true, - ); - chewieAudioController.addListener(_fullScreenListener); - if (mounted) setState(() {}); - }); - } - } - } ///关注/取关会员 _vipFollow(followId, isFollow) async { @@ -425,10 +387,7 @@ class _CommunityDynamic extends State { cnt["video"].isNotEmpty) { itemWidget = videoWidget( MediaQuery.of(context).size.width - 32, - videoPlayerController != null - ? (MediaQuery.of(context).size.width - 32) / - videoPlayerController.value.aspectRatio - : MediaQuery.of(context).size.width / 2, + MediaQuery.of(context).size.width / 2, cnt["video"].replaceAll(".mp4", "_poster.jpg"), ); } @@ -455,10 +414,6 @@ class _CommunityDynamic extends State { chewieAudioController = null; } - if (videoPlayerController != null) { - videoPlayerController.pause(); - videoPlayerController.dispose(); - } } Widget videoWidget(double width, double height, src) { @@ -491,9 +446,7 @@ class _CommunityDynamic extends State { height: double.infinity, child: MImage( src, - aspectRatio: videoPlayerController != null - ? videoPlayerController.value.aspectRatio - : (width / 7 * 5), + aspectRatio: width / 7 * 5, fit: BoxFit.cover, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", diff --git a/lib/community/photo_view_gallery_screen.dart b/lib/community/photo_view_gallery_screen.dart index 08c0e0f7..86daaf63 100644 --- a/lib/community/photo_view_gallery_screen.dart +++ b/lib/community/photo_view_gallery_screen.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view_gallery.dart'; @@ -41,7 +42,7 @@ class _PhotoViewGalleryScreenState extends State { scrollPhysics: const BouncingScrollPhysics(), builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( - imageProvider: NetworkImage(widget.images[index]), + imageProvider: CachedNetworkImageProvider(widget.images[index]), ); },