|
|
|
@ -15,6 +15,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/comment_menu.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/login_tips_dialog.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/tips_dialog.dart'; |
|
|
|
|
import 'package:huixiang/web/web_view/input_comment.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
@ -48,7 +49,6 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
int commentTotal = 0; |
|
|
|
|
Article article; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void didChangeMetrics() { |
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
|
@ -56,15 +56,17 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
if (MediaQuery.of(context).viewInsets.bottom == 0) { |
|
|
|
|
if (isKeyBoardShow) { |
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
setState(() { |
|
|
|
|
hintText = S.current.liuxianinjingcaidepinglunba; |
|
|
|
|
isKeyBoardShow = false; |
|
|
|
|
}); |
|
|
|
|
if (mounted) |
|
|
|
|
setState(() { |
|
|
|
|
hintText = S.current.liuxianinjingcaidepinglunba; |
|
|
|
|
isKeyBoardShow = false; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
setState(() { |
|
|
|
|
isKeyBoardShow = true; |
|
|
|
|
}); |
|
|
|
|
if (mounted) |
|
|
|
|
setState(() { |
|
|
|
|
isKeyBoardShow = true; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -83,186 +85,140 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
queryDetails() async { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = |
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
|
BaseData<Article> baseData = await apiService |
|
|
|
|
.informationInfo(comunity.id) |
|
|
|
|
.catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
} |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: value.getString("token"), |
|
|
|
|
); |
|
|
|
|
BaseData<Article> baseData = |
|
|
|
|
await apiService.informationInfo(comunity.id).catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Scaffold( |
|
|
|
|
body: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: NestedScrollView( |
|
|
|
|
headerSliverBuilder: (context, position) { |
|
|
|
|
return [ |
|
|
|
|
SliverOverlapAbsorber( |
|
|
|
|
handle: |
|
|
|
|
NestedScrollView.sliverOverlapAbsorberHandleFor(context), |
|
|
|
|
sliver: SliverAppBar( |
|
|
|
|
expandedHeight: (height == 0) ? 614 : height, |
|
|
|
|
pinned: true, |
|
|
|
|
backgroundColor: Colors.white, |
|
|
|
|
title: Text( |
|
|
|
|
"动态详情", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 18.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
elevation: 0, |
|
|
|
|
leading: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
appBar: MyAppBar( |
|
|
|
|
title: "动态详情", |
|
|
|
|
titleColor: Colors.black, |
|
|
|
|
titleSize: 18.sp, |
|
|
|
|
background: Colors.white, |
|
|
|
|
leading: true, |
|
|
|
|
leadingColor: Colors.black, |
|
|
|
|
), |
|
|
|
|
body: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
CommunityDynamic( |
|
|
|
|
comunity, |
|
|
|
|
0, |
|
|
|
|
exitFull: () { |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
itemCount: 3, |
|
|
|
|
isDetails: true, |
|
|
|
|
heightFun: (height) { |
|
|
|
|
this.height = height + |
|
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
|
kToolbarHeight + |
|
|
|
|
24; |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.centerRight, |
|
|
|
|
margin: EdgeInsets.only(left: 10), |
|
|
|
|
padding: EdgeInsets.all(6), |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.arrow_back_ios, |
|
|
|
|
color: Colors.black, |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flexibleSpace: FlexibleSpaceBar( |
|
|
|
|
//Colors.white, |
|
|
|
|
background: Container( |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: MediaQuery.of(context).padding.top + |
|
|
|
|
kToolbarHeight, |
|
|
|
|
), |
|
|
|
|
color: Colors.white, |
|
|
|
|
child: CommunityDynamic( |
|
|
|
|
comunity,0,exitFull: (){setState(() { |
|
|
|
|
|
|
|
|
|
});}, |
|
|
|
|
itemCount: 3, |
|
|
|
|
isDetails: true, |
|
|
|
|
heightFun: (height) { |
|
|
|
|
this.height = height + |
|
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
|
kToolbarHeight + |
|
|
|
|
24; |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
collapseMode: CollapseMode.pin, |
|
|
|
|
), |
|
|
|
|
bottom: PreferredSize( |
|
|
|
|
preferredSize: Size( |
|
|
|
|
MediaQuery.of(context).size.width, |
|
|
|
|
46, |
|
|
|
|
), |
|
|
|
|
child: Container( |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
margin: EdgeInsets.only(top: 16.h), |
|
|
|
|
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, |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
S.of(context).xihuan_( |
|
|
|
|
"${comunity?.likes ?? comunity?.likes ?? "0"}"), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
]; |
|
|
|
|
}, |
|
|
|
|
body: Container( |
|
|
|
|
height: MediaQuery.of(context).size.height - |
|
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
|
kToolbarHeight - 68, |
|
|
|
|
margin: EdgeInsets.only(top: 50 + kToolbarHeight), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
if (memberList != null && memberList.length > 0) |
|
|
|
|
Expanded(child: 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 |
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
if (memberList == null || memberList.length == 0) |
|
|
|
|
Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
alignment: Alignment.topCenter, |
|
|
|
|
margin: EdgeInsets.only(top: 40), |
|
|
|
|
padding: EdgeInsets.all(22.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).zanwupinglun, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xFFA0A0A0), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
)), |
|
|
|
|
if (memberList == null || memberList.length == 0) |
|
|
|
|
Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
alignment: Alignment.topCenter, |
|
|
|
|
margin: EdgeInsets.only(top:40), |
|
|
|
|
padding: EdgeInsets.all(22.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).zanwupinglun, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xFFA0A0A0), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
/// 富文本评论的输入框 |
|
|
|
|
InputComment( |
|
|
|
|
inputKey, |
|
|
|
|
hintText, |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
commentFocus, |
|
|
|
|
commentTextController, |
|
|
|
|
_toComment, |
|
|
|
|
_queryMemberComment, |
|
|
|
|
_queryInformationLikes, |
|
|
|
|
isLike: comunity.selfLike, |
|
|
|
|
/// 富文本评论的输入框 |
|
|
|
|
InputComment( |
|
|
|
|
inputKey, |
|
|
|
|
hintText, |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
commentFocus, |
|
|
|
|
commentTextController, |
|
|
|
|
_toComment, |
|
|
|
|
_queryMemberComment, |
|
|
|
|
_queryInformationLikes, |
|
|
|
|
isLike: comunity.selfLike, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
))); |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///给文章/活动点赞 |
|
|
|
@ -271,10 +227,11 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// commentKey.currentState.setState(() {}); |
|
|
|
|
setState(() { |
|
|
|
|
if(comunity.selfLike??false) |
|
|
|
|
if (comunity.selfLike ?? false) |
|
|
|
|
comunity.likes -= 1; |
|
|
|
|
else comunity.likes += 1; |
|
|
|
|
comunity.selfLike = !comunity.selfLike??false; |
|
|
|
|
else |
|
|
|
|
comunity.likes += 1; |
|
|
|
|
comunity.selfLike = !comunity.selfLike ?? false; |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
@ -303,11 +260,12 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); |
|
|
|
|
Offset first = firstRenderBox.localToGlobal(Offset.zero); |
|
|
|
|
scrollController.animateTo( |
|
|
|
|
first.dy + |
|
|
|
|
scrollController.offset - |
|
|
|
|
(kToolbarHeight + MediaQuery.of(context).padding.top), |
|
|
|
|
duration: Duration(milliseconds: 300), |
|
|
|
|
curve: Curves.easeIn); |
|
|
|
|
first.dy + |
|
|
|
|
scrollController.offset - |
|
|
|
|
(kToolbarHeight + MediaQuery.of(context).padding.top), |
|
|
|
|
duration: Duration(milliseconds: 300), |
|
|
|
|
curve: Curves.easeIn, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final GlobalKey inputKey = GlobalKey(); |
|
|
|
@ -415,7 +373,7 @@ class _CommunityDetails extends State<CommunityDetails>
|
|
|
|
|
commentTotal = baseData.data.size; |
|
|
|
|
memberList = baseData.data.list; |
|
|
|
|
contentHeight(); |
|
|
|
|
setState(() {}); |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|