|
|
|
@ -32,8 +32,7 @@ class CommunityDetails extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _CommunityDetails extends State<CommunityDetails> |
|
|
|
|
with WidgetsBindingObserver { |
|
|
|
|
class _CommunityDetails extends State<CommunityDetails> with WidgetsBindingObserver { |
|
|
|
|
double height = 0; |
|
|
|
|
double commentHeight = 60.h; |
|
|
|
|
ComunityComment comunity; |
|
|
|
@ -54,7 +53,10 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
void didChangeMetrics() { |
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
|
|
if (!mounted) return; |
|
|
|
|
if (MediaQuery.of(context).viewInsets.bottom == 0) { |
|
|
|
|
if (MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.viewInsets |
|
|
|
|
.bottom == 0) { |
|
|
|
|
if (isKeyBoardShow) { |
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
if (mounted) |
|
|
|
@ -91,8 +93,10 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
context: context, |
|
|
|
|
token: value.getString("token"), |
|
|
|
|
); |
|
|
|
|
BaseData<Article> baseData = |
|
|
|
|
await apiService.informationInfo(comunity.id).catchError((onError) {}); |
|
|
|
|
BaseData<Article> baseData = await apiService.informationInfo(comunity.id) |
|
|
|
|
.catchError((onError) { |
|
|
|
|
debugPrint(onError); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -125,74 +129,23 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
isDetails: true, |
|
|
|
|
heightFun: (height) { |
|
|
|
|
this.height = height + |
|
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
|
MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.padding |
|
|
|
|
.top + |
|
|
|
|
kToolbarHeight + |
|
|
|
|
24; |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
// CommentList( |
|
|
|
|
// commentKey, |
|
|
|
|
// widget.arguments, |
|
|
|
|
// activity, |
|
|
|
|
// article, |
|
|
|
|
// isKeyBoardShow, |
|
|
|
|
// _reply, |
|
|
|
|
// _delCommentTips, |
|
|
|
|
// 12.sp, |
|
|
|
|
// ) |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
color: Colors.white, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).pinglun_(commentTotal.toString()), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xff1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 16.w, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
S.of(context).xihuan_( |
|
|
|
|
"${comunity?.likes ?? comunity?.likes ?? "0"}"), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xff1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (memberList != null && memberList.length > 0) |
|
|
|
|
ListView.builder( |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemCount: memberList != null ? memberList.length : 0, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return Material( |
|
|
|
|
color: Colors.white, |
|
|
|
|
child: InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
showPressMenu( |
|
|
|
|
memberList[position].createUser, |
|
|
|
|
memberList[position], |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: CommunityComment( |
|
|
|
|
memberList[position], |
|
|
|
|
_queryCommentLike, |
|
|
|
|
(memberList.length - 1 == position) ? 1 : 0, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
CommentList( |
|
|
|
|
commentKey, |
|
|
|
|
"${comunity?.likes ?? comunity?.likes ?? "0"}", |
|
|
|
|
comunity.id, |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
_reply, |
|
|
|
|
_delCommentTips, |
|
|
|
|
12.sp, |
|
|
|
|
), |
|
|
|
|
if (memberList == null || memberList.length == 0) |
|
|
|
|
Container( |
|
|
|
@ -201,7 +154,9 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
margin: EdgeInsets.only(top: 40), |
|
|
|
|
padding: EdgeInsets.all(22.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).zanwupinglun, |
|
|
|
|
S |
|
|
|
|
.of(context) |
|
|
|
|
.zanwupinglun, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
@ -237,7 +192,7 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
_queryInformationLikes() async { |
|
|
|
|
BaseData baseData = await apiService.informationLikes(comunity.id); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// commentKey.currentState.setState(() {}); |
|
|
|
|
commentKey.currentState.setState(() {}); |
|
|
|
|
setState(() { |
|
|
|
|
if (comunity.selfLike ?? false) |
|
|
|
|
comunity.likes -= 1; |
|
|
|
@ -259,7 +214,7 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
"relationalType": 1 |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// commentKey.currentState.initState(); |
|
|
|
|
commentKey.currentState.initState(); |
|
|
|
|
commentTextController.text = ""; |
|
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
|
_queryMemberCommentList(); |
|
|
|
@ -274,7 +229,10 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
scrollController.animateTo( |
|
|
|
|
first.dy + |
|
|
|
|
scrollController.offset - |
|
|
|
|
(kToolbarHeight + MediaQuery.of(context).padding.top), |
|
|
|
|
(kToolbarHeight + MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.padding |
|
|
|
|
.top), |
|
|
|
|
duration: Duration(milliseconds: 300), |
|
|
|
|
curve: Curves.easeIn, |
|
|
|
|
); |
|
|
|
@ -284,40 +242,21 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
final TextEditingController commentTextController = TextEditingController(); |
|
|
|
|
|
|
|
|
|
contentHeight() { |
|
|
|
|
double contentHeight = MediaQuery.of(context).size.height - |
|
|
|
|
double contentHeight = MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.size |
|
|
|
|
.height - |
|
|
|
|
kToolbarHeight - |
|
|
|
|
MediaQuery.of(context).padding.top - |
|
|
|
|
MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.padding |
|
|
|
|
.top - |
|
|
|
|
160.h; |
|
|
|
|
if ((contentHeight - 60.h) > (128.h * memberList.length)) { |
|
|
|
|
commentHeight = contentHeight - (128.h * memberList.length); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showPressMenu(String userId, memberComment) { |
|
|
|
|
if (isKeyBoardShow) { |
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
SmartDialog.show( |
|
|
|
|
widget: CommentMenu( |
|
|
|
|
(type) { |
|
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
if (type == "huifu") { |
|
|
|
|
_reply(memberComment); |
|
|
|
|
} else if (type == "shanchu") { |
|
|
|
|
_delCommentTips(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
isSelf: userId == value.getString("userId"), |
|
|
|
|
), |
|
|
|
|
alignmentTemp: Alignment.bottomCenter, |
|
|
|
|
isUseAnimationTemp: true, |
|
|
|
|
animationDurationTemp: Duration(milliseconds: 300), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///删除评论的提示 |
|
|
|
|
_delCommentTips() { |
|
|
|
|
SmartDialog.show(widget: Tips(() { |
|
|
|
@ -329,7 +268,7 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
delComment() async { |
|
|
|
|
BaseData baseData = await apiService.delComment(""); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// commentKey.currentState.initState(); |
|
|
|
|
commentKey.currentState.initState(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -340,30 +279,6 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
hintText = S.of(context).huifu_("${memberComment.username}"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///评论点赞 |
|
|
|
|
_queryCommentLike(String id) async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
String token = sharedPreferences.getString("token"); |
|
|
|
|
if (token == null || token == "") { |
|
|
|
|
LoginTipsDialog().show(context); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
BaseData baseData = await apiService.commentLike(id).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
memberList.forEach((element) { |
|
|
|
|
if (element.id == id) { |
|
|
|
|
if (element.liked) { |
|
|
|
|
element.likes -= 1; |
|
|
|
|
element.liked = false; |
|
|
|
|
} else { |
|
|
|
|
element.likes += 1; |
|
|
|
|
element.liked = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///评论列表 |
|
|
|
|
_queryMemberCommentList() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|