|
|
|
@ -5,6 +5,7 @@ import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
|
import 'package:huixiang/retrofit/data/comunity_comment.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/border_text.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/icon_text.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
@ -16,16 +17,18 @@ class CommunityDynamic extends StatefulWidget {
|
|
|
|
|
final Function(double height) heightFun; |
|
|
|
|
final bool isDetails; |
|
|
|
|
final int commentType; |
|
|
|
|
final Function removalDynamic; |
|
|
|
|
|
|
|
|
|
final ComunityComment comment; |
|
|
|
|
|
|
|
|
|
CommunityDynamic( |
|
|
|
|
this.comment, |
|
|
|
|
this.commentType,{ |
|
|
|
|
this.commentType, { |
|
|
|
|
Key key, |
|
|
|
|
this.itemCount = 9, |
|
|
|
|
this.heightFun, |
|
|
|
|
this.isDetails = false, |
|
|
|
|
this.removalDynamic, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -33,6 +36,7 @@ class CommunityDynamic extends StatefulWidget {
|
|
|
|
|
return _CommunityDynamic(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _CommunityDynamic extends State<CommunityDynamic> { |
|
|
|
|
GlobalKey globalKey = GlobalKey(); |
|
|
|
|
double height = 0; |
|
|
|
@ -51,7 +55,20 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
_vipFollow(followId) async { |
|
|
|
|
BaseData baseData = await apiService.follow(followId); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
SmartDialog.showToast("关注成功"); |
|
|
|
|
SmartDialog.showToast("关注成功", alignment: Alignment.center); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///删除动态 |
|
|
|
|
_deleteDynamic(id) async { |
|
|
|
|
BaseData baseData = await apiService.deleteTrend(id); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
SmartDialog.showToast("删除成功", alignment: Alignment.center); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -60,6 +77,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
return Column( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
margin: EdgeInsets.only(top: 2), |
|
|
|
|
key: globalKey, |
|
|
|
|
alignment: Alignment.topCenter, |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
@ -88,7 +106,9 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
MImage( |
|
|
|
|
widget.comment != null ? widget.comment.memberInfo.avatar : "", |
|
|
|
|
widget.comment != null |
|
|
|
|
? widget.comment.memberInfo.avatar |
|
|
|
|
: "", |
|
|
|
|
width: 44, |
|
|
|
|
height: 44, |
|
|
|
|
isCircle: true, |
|
|
|
@ -104,7 +124,9 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
widget.comment != null ? widget.comment.memberInfo.nickname : "", |
|
|
|
|
widget.comment != null |
|
|
|
|
? widget.comment.memberInfo.nickname |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
@ -112,7 +134,9 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
widget.comment != null ? widget.comment.createTime : "", |
|
|
|
|
widget.comment != null |
|
|
|
|
? widget.comment.createTime |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
@ -125,33 +149,46 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
if(widget.commentType == 0){ |
|
|
|
|
widget.comment.selfFollow = !(widget.comment.selfFollow??false); |
|
|
|
|
if (widget.commentType == 0) { |
|
|
|
|
widget.comment.selfFollow = |
|
|
|
|
!(widget.comment.selfFollow ?? false); |
|
|
|
|
_vipFollow(widget.comment.memberInfo.mid); |
|
|
|
|
}else{ |
|
|
|
|
SmartDialog.showToast("删除成功", alignment: Alignment.center); |
|
|
|
|
} else { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: (widget.commentType == 0)?RoundButton( |
|
|
|
|
child: (widget.commentType == 0) |
|
|
|
|
? RoundButton( |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
horizontal: 8, |
|
|
|
|
vertical: 3, |
|
|
|
|
), |
|
|
|
|
backgroup: (widget.comment.selfFollow??false) ? Color(0xFFE6E6E6) : Color(0xFF32A060), |
|
|
|
|
textColor: (widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , |
|
|
|
|
text:(widget.comment.selfFollow??false) ? "已关注":"关注", |
|
|
|
|
backgroup: (widget.comment.selfFollow ?? false) |
|
|
|
|
? Color(0xFFE6E6E6) |
|
|
|
|
: Color(0xFF32A060), |
|
|
|
|
textColor: (widget.comment.selfFollow ?? false) |
|
|
|
|
? Color(0xFF808080) |
|
|
|
|
: Colors.white, |
|
|
|
|
text: (widget.comment.selfFollow ?? false) |
|
|
|
|
? "已关注" |
|
|
|
|
: "关注", |
|
|
|
|
radius: 20, |
|
|
|
|
icons: Icon( |
|
|
|
|
(widget.comment.selfFollow??false) ? Icons.check: Icons.add, |
|
|
|
|
color:(widget.comment.selfFollow??false) ? Color(0xFF808080):Colors.white , |
|
|
|
|
(widget.comment.selfFollow ?? false) |
|
|
|
|
? Icons.check |
|
|
|
|
: Icons.add, |
|
|
|
|
color: (widget.comment.selfFollow ?? false) |
|
|
|
|
? Color(0xFF808080) |
|
|
|
|
: Colors.white, |
|
|
|
|
size: 14, |
|
|
|
|
), |
|
|
|
|
):Icon( |
|
|
|
|
) |
|
|
|
|
: Icon( |
|
|
|
|
Icons.close, |
|
|
|
|
color:Colors.black, |
|
|
|
|
color: Colors.black, |
|
|
|
|
size: 16, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -162,7 +199,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
widget.comment.subject ?? "", |
|
|
|
|
maxLines: 5, |
|
|
|
|
// maxLines: 5, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
@ -181,7 +218,10 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
IconText( |
|
|
|
|
"${widget.comment.viewers ?? 0}", |
|
|
|
|
(widget.comment != null) |
|
|
|
|
? "${widget.comment.viewers}" |
|
|
|
|
: "", |
|
|
|
|
// "${widget.comment.viewers ?? 0}", |
|
|
|
|
space: 4.w, |
|
|
|
|
leftImage: "assets/svg/liulanliang.svg", |
|
|
|
|
iconSize: 16, |
|
|
|
@ -280,6 +320,81 @@ class _CommunityDynamic extends State<CommunityDynamic> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///删除动态弹窗 |
|
|
|
|
showDeleteDialog() { |
|
|
|
|
showDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return AlertDialog( |
|
|
|
|
content: Container( |
|
|
|
|
width: MediaQuery.of(context).size.width - 84, |
|
|
|
|
height: 110.h, |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
"确定要删除这条动态?", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 17.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 30.h, |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: InkWell( |
|
|
|
|
child: BorderText( |
|
|
|
|
text: "取消", |
|
|
|
|
textColor: Color(0xFF32A060), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
borderColor: Color(0xFF32A060), |
|
|
|
|
radius: 4, |
|
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
|
borderWidth: 1, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 16.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: InkWell( |
|
|
|
|
child: RoundButton( |
|
|
|
|
text: "确定", |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
radius: 4, |
|
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
_deleteDynamic(widget.comment.id); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void didChangeDependencies() { |
|
|
|
|
if (widget.heightFun != null) |
|
|
|
|