|
|
|
@ -19,7 +19,6 @@ import 'package:video_player/video_player.dart';
|
|
|
|
|
|
|
|
|
|
import '../photo_view_gallery_screen.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CommunityDynamic extends StatefulWidget { |
|
|
|
|
final int itemCount; |
|
|
|
|
final Function(double height) heightFun; |
|
|
|
@ -77,11 +76,9 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
String filePath; |
|
|
|
|
|
|
|
|
|
initVideo() async { |
|
|
|
|
if(widget?.article?.content == null) |
|
|
|
|
return; |
|
|
|
|
if (widget?.article?.content == null) return; |
|
|
|
|
var cnt = jsonDecode(widget.article.content); |
|
|
|
|
if (cnt["type"] == "video" && |
|
|
|
|
cnt["video"] != null) { |
|
|
|
|
if (cnt["type"] == "video" && cnt["video"] != null) { |
|
|
|
|
if (widget.isList) { |
|
|
|
|
videoPlayerController = VideoPlayerController.network( |
|
|
|
|
cnt["video"], |
|
|
|
@ -116,11 +113,12 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///关注/取关会员 |
|
|
|
|
_vipFollow(followId,isFollow) async { |
|
|
|
|
_vipFollow(followId, isFollow) async { |
|
|
|
|
BaseData baseData = await apiService.follow(followId); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
widget.exitFull(); |
|
|
|
|
SmartDialog.showToast(isFollow?"关注成功":"取关成功", alignment: Alignment.center); |
|
|
|
|
SmartDialog.showToast(isFollow ? "关注成功" : "取关成功", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
setState(() {}); |
|
|
|
|
} else { |
|
|
|
|
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
@ -173,26 +171,29 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
if(widget?.article?.authorHeadImg == ""){ |
|
|
|
|
SmartDialog.showToast("用户暂未设置头像", alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Navigator.push(context, MaterialPageRoute( builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images:[widget?.article?.authorHeadImg ?? ""],//传入图片list |
|
|
|
|
index: 0,//传入当前点击的图片的index |
|
|
|
|
), )); |
|
|
|
|
}, |
|
|
|
|
child: MImage( |
|
|
|
|
widget?.article?.authorHeadImg ?? "", |
|
|
|
|
width: 44, |
|
|
|
|
height: 44, |
|
|
|
|
isCircle: true, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.push( |
|
|
|
|
context, |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images: [(widget?.article?.authorHeadImg ?? "").isEmpty? |
|
|
|
|
"https://lmg.jj20.com/up/allimg/tx30/09041130358711081.jpg":widget?.article?.authorHeadImg |
|
|
|
|
], //传入图片list |
|
|
|
|
index: 0, //传入当前点击的图片的index |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
}, |
|
|
|
|
child: |
|
|
|
|
MImage( |
|
|
|
|
(widget?.article?.authorHeadImg ?? "https://lmg.jj20.com/up/allimg/tx30/09041130358711081.jpg") + "?imageView2/1/w/200/h/200/format/jpg/q/75", |
|
|
|
|
width: 44, |
|
|
|
|
height: 44, |
|
|
|
|
isCircle: true, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 8, |
|
|
|
|
), |
|
|
|
@ -228,7 +229,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
if (widget.commentType == 0) { |
|
|
|
|
widget.article.liked = |
|
|
|
|
!(widget.article.liked ?? false); |
|
|
|
|
_vipFollow(widget.article.updateUser,widget.article.liked ?? false); |
|
|
|
|
_vipFollow(widget.article.updateUser, |
|
|
|
|
widget.article.liked ?? false); |
|
|
|
|
} else { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} |
|
|
|
@ -261,11 +263,14 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
size: 15, |
|
|
|
|
), |
|
|
|
|
)) |
|
|
|
|
: Padding(padding: EdgeInsets.all(20),child:Icon( |
|
|
|
|
Icons.close, |
|
|
|
|
color: Colors.black, |
|
|
|
|
size: 16, |
|
|
|
|
),), |
|
|
|
|
: Padding( |
|
|
|
|
padding: EdgeInsets.all(20), |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.close, |
|
|
|
|
color: Colors.black, |
|
|
|
|
size: 16, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
@ -344,34 +349,41 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
} |
|
|
|
|
var cnt = jsonDecode(subjectInfo); |
|
|
|
|
Widget itemWidget = Container(); |
|
|
|
|
if (cnt["type"] == "image"&& cnt["images"] != null && cnt["images"].length > 0) { |
|
|
|
|
if (cnt["type"] == "image" && |
|
|
|
|
cnt["images"] != null && |
|
|
|
|
cnt["images"].length > 0) { |
|
|
|
|
if (cnt["images"].length == 1) { |
|
|
|
|
itemWidget = Container( |
|
|
|
|
child: InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
// ImagePickers.previewImages(subjectInfo.images,0); |
|
|
|
|
Navigator.push(context, MaterialPageRoute( builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images:cnt["images"],//传入图片list |
|
|
|
|
index: 0,//传入当前点击的图片的index |
|
|
|
|
), ), ); |
|
|
|
|
}, |
|
|
|
|
child: MImage( |
|
|
|
|
cnt["images"][0], |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
radius: BorderRadius.circular(2), |
|
|
|
|
width: MediaQuery.of(context).size.width / 1.5, |
|
|
|
|
height: MediaQuery.of(context).size.width / 1.5, |
|
|
|
|
errorSrc: "assets/image/default_2_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_2_1.png", |
|
|
|
|
)), |
|
|
|
|
onTap: () { |
|
|
|
|
// ImagePickers.previewImages(subjectInfo.images,0); |
|
|
|
|
Navigator.push( |
|
|
|
|
context, |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images: cnt["images"], //传入图片list |
|
|
|
|
index: 0, //传入当前点击的图片的index |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: MImage( |
|
|
|
|
cnt["images"][0].replaceAll(".jpg", ".jpg?imageView2/0/q/75"), |
|
|
|
|
fit: BoxFit.contain, |
|
|
|
|
radius: BorderRadius.circular(2), |
|
|
|
|
width: MediaQuery.of(context).size.width/1.5, |
|
|
|
|
height:MediaQuery.of(context).size.width, |
|
|
|
|
errorSrc: "assets/image/default_2_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_2_1.png", |
|
|
|
|
)), |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
itemWidget = GridView.builder( |
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
crossAxisCount: (cnt["images"].length == 2 || |
|
|
|
|
cnt["images"].length == 4) |
|
|
|
|
? 2 |
|
|
|
|
: 3, |
|
|
|
|
crossAxisCount: |
|
|
|
|
(cnt["images"].length == 2 || cnt["images"].length == 4) |
|
|
|
|
? 2 |
|
|
|
|
: 3, |
|
|
|
|
crossAxisSpacing: 12.w, |
|
|
|
|
mainAxisSpacing: 12.w, |
|
|
|
|
childAspectRatio: 1, |
|
|
|
@ -384,13 +396,19 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
child: InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
// ImagePickers.previewImages(subjectInfo.images, position); |
|
|
|
|
Navigator.push(context, MaterialPageRoute( builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images:cnt["images"],//传入图片list |
|
|
|
|
index: position,//传入当前点击的图片的index |
|
|
|
|
), ), ); |
|
|
|
|
Navigator.push( |
|
|
|
|
context, |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (context) => PhotoViewGalleryScreen( |
|
|
|
|
images: cnt["images"], //传入图片list |
|
|
|
|
index: position, //传入当前点击的图片的index |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: MImage( |
|
|
|
|
cnt["images"][position], |
|
|
|
|
cnt["images"][position] |
|
|
|
|
.replaceAll(".jpg", ".jpg?imageView2/0/q/75"), |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
aspectRatio: 1, |
|
|
|
|
radius: BorderRadius.circular(1), |
|
|
|
@ -403,15 +421,16 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
itemCount: cnt["images"].length, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (cnt["type"] == "video" && cnt["video"]!= null && cnt["video"].isNotEmpty) { |
|
|
|
|
} else if (cnt["type"] == "video" && |
|
|
|
|
cnt["video"] != null && |
|
|
|
|
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, |
|
|
|
|
!widget.isList ? cnt["video"] : widget.article.coverImg, |
|
|
|
|
cnt["video"].replaceAll(".mp4", "_poster.jpg"), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
return Column( |
|
|
|
|