Browse Source

动态列表视频优化

ff_new
w-R 3 years ago
parent
commit
95baeeb134
  1. 3
      ios/Podfile.lock
  2. 3
      lib/community/community_details.dart
  3. 28
      lib/community/community_page.dart
  4. 26
      lib/community/community_view/class_details_video.dart
  5. 10
      lib/community/headlines/article_list.dart
  6. 19
      lib/community/photo_view_gallery_screen.dart
  7. 5
      lib/main.dart
  8. 74
      lib/store/store_order.dart
  9. 35
      lib/utils/ImgCachePath.dart
  10. 47
      lib/view_widget/custom_image.dart
  11. 51
      pubspec.lock
  12. 2
      pubspec.yaml

3
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)

3
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<CommunityDetails> with WidgetsBindingObser
setState(() {
article = baseData.data;
});
} else {
}
}

28
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<CommunityPage>
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<CommunityPage>
),
),
onTap: () {
Navigator.of(context).pushNamed('/router/release_dynamic');
_toRelease();
},
action: GestureDetector(
behavior: HitTestBehavior.opaque,
@ -98,16 +110,8 @@ class _CommunityPage extends State<CommunityPage>
}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,

26
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<ClassDetailsVideo> {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
if(widget.videoUrl != null){
initVideo(widget.videoUrl);
}
}
@override
@ -91,14 +96,11 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
@override
Widget build(BuildContext context) {
return Container(
key: globalKey,child:videoWidget(
key: globalKey,child:(videoPlayerController?.value?.isInitialized ?? false) ?videoWidget(
MediaQuery.of(context).size.width,
videoPlayerController != null
? (MediaQuery.of(context).size.width) /
videoPlayerController.value.aspectRatio
: MediaQuery.of(context).size.width / 2,
(MediaQuery.of(context).size.width/videoPlayerController.value.aspectRatio)-43,
widget.coverImg,
));
):Container());
}
@override
@ -129,15 +131,16 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
? 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<ClassDetailsVideo> {
},
child: Container(
width: width,
height: width / 7 * 5,
// height: width / 7 * 5,
height: height,
color: Colors.black,
child: Stack(
children: [

10
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';

19
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<PhotoViewGalleryScreen> {
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<PhotoViewGalleryScreen> {
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,

5
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<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/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(),

74
lib/store/store_order.dart

@ -137,8 +137,9 @@ class _StoreOrderPage extends State<StoreOrderPage>
}
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) => {
@ -150,8 +151,10 @@ class _StoreOrderPage extends State<StoreOrderPage>
///
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<StoreOrderPage>
///
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<StoreOrderPage>
@override
Widget build(BuildContext context) {
return
WillPopScope(
return WillPopScope(
onWillPop: () async {
if (dialogShowing) {
debugPrint("ssssasdadsasdadasd");
@ -213,8 +216,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
return true;
}
},
child:
Container(
child: Container(
color: Colors.white,
child: Stack(
children: [
@ -227,14 +229,15 @@ class _StoreOrderPage extends State<StoreOrderPage>
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,8 +265,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
),
),
flexibleSpace: FlexibleSpaceBar(
title: Title(
controller,
title: Title(controller,
storeInfo != null ? storeInfo.storeName : ''),
collapseMode: CollapseMode.pin,
stretchModes: [
@ -555,6 +557,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
return;
}
}
await Navigator.of(context).pushNamed(
'/router/settlement',
arguments: {
@ -562,15 +565,15 @@ class _StoreOrderPage extends State<StoreOrderPage>
"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<StoreOrderPage>
}
///
_queryMiNiDetail(String id,int count) async {
_queryMiNiDetail(String id, int count) async {
EasyLoading.show(status: S.current.zhengzaijiazai);
BaseData<MiNiDetail> 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<StoreOrderPage>
///
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<StoreOrderPage>
///
Future<ShoppingCart> queryShopCar() async {
pName="";//
pid="";//
cName="";//
cid="";//
pName = ""; //
pid = ""; //
cName = ""; //
cid = ""; //
BaseData<List<ShoppingCart>> 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;
}
});
}

35
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;
}
}

47
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");
@ -59,30 +67,25 @@ 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) {
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,
);
},
placeholder: (context, placeholder) {
return Image.asset(
fadeSrc,
fit: fit,
);
},
);
} else if (src.startsWith("file")) {
cachedNetworkImage = Image.file(
File(src),

51
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:

2
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

Loading…
Cancel
Save