|
|
@ -2,6 +2,7 @@ import 'dart:ui'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:huixiang/community/community_view/community_dynamic.dart'; |
|
|
|
import 'package:huixiang/community/community_view/community_dynamic.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
@ -15,8 +16,12 @@ import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:huixiang/view_widget/tips_dialog.dart'; |
|
|
|
import 'package:huixiang/view_widget/tips_dialog.dart'; |
|
|
|
import 'package:huixiang/web/web_view/comment_list.dart'; |
|
|
|
import 'package:huixiang/web/web_view/comment_list.dart'; |
|
|
|
import 'package:huixiang/web/web_view/input_comment.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'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../view_widget/classic_header.dart'; |
|
|
|
|
|
|
|
import '../view_widget/my_footer.dart'; |
|
|
|
|
|
|
|
|
|
|
|
class CommunityDetails extends StatefulWidget { |
|
|
|
class CommunityDetails extends StatefulWidget { |
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
|
|
|
|
|
|
|
@ -54,6 +59,7 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
double keyboard = -1; |
|
|
|
double keyboard = -1; |
|
|
|
bool needShowSmiley = false; |
|
|
|
bool needShowSmiley = false; |
|
|
|
bool needHideSmiley = false; |
|
|
|
bool needHideSmiley = false; |
|
|
|
|
|
|
|
final RefreshController refreshController = RefreshController(); |
|
|
|
|
|
|
|
|
|
|
|
void didChangeMetrics() { |
|
|
|
void didChangeMetrics() { |
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
@ -94,11 +100,21 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
void initState() { |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
super.initState(); |
|
|
|
// comunity = widget.arguments["comment"]; |
|
|
|
// comunity = widget.arguments["comment"]; |
|
|
|
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
businessId = widget.arguments["businessId"]; |
|
|
|
businessId = widget.arguments["businessId"]; |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
commentFocus.addListener(_focusNodeListener); |
|
|
|
commentFocus.addListener(_focusNodeListener); |
|
|
|
|
|
|
|
scrollController.addListener(() { |
|
|
|
_queryMemberCommentList(); |
|
|
|
//滚动监听,键盘如果弹起,滚动时收起 |
|
|
|
|
|
|
|
if(MediaQuery.of(context).viewInsets.bottom > 0) |
|
|
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
|
|
|
if(needShowSmiley && window.viewInsets.bottom > 0.1) |
|
|
|
|
|
|
|
needHideSmiley = false; |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
emojiShowing = false; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
_queryMemberCommentList(true); |
|
|
|
queryDetails(businessId); |
|
|
|
queryDetails(businessId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -130,9 +146,10 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void dispose(){ |
|
|
|
void dispose(){ |
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
commentFocus.removeListener(_focusNodeListener); |
|
|
|
commentFocus.removeListener(_focusNodeListener); |
|
|
|
super.dispose(); |
|
|
|
refreshController.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///详情接口 |
|
|
|
///详情接口 |
|
|
@ -147,14 +164,24 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
BaseData<Article> baseData = |
|
|
|
BaseData<Article> baseData = |
|
|
|
await apiService.informationInfo(id).catchError((onError) { |
|
|
|
await apiService.informationInfo(id).catchError((onError) { |
|
|
|
debugPrint(onError.toString()); |
|
|
|
debugPrint(onError.toString()); |
|
|
|
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|
article = baseData.data; |
|
|
|
article = baseData.data; |
|
|
|
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_onRefresh() { |
|
|
|
|
|
|
|
queryDetails(businessId); |
|
|
|
|
|
|
|
_queryMemberCommentList(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
double h = MediaQuery.of(context).viewInsets.bottom; |
|
|
|
double h = MediaQuery.of(context).viewInsets.bottom; |
|
|
@ -186,61 +213,81 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
Expanded( |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: SmartRefresher( |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
controller: refreshController, |
|
|
|
child: Column( |
|
|
|
enablePullDown: true, |
|
|
|
children: [ |
|
|
|
enablePullUp: false, |
|
|
|
if (article != null) |
|
|
|
header: MyHeader(), |
|
|
|
CommunityDynamic( |
|
|
|
footer: CustomFooter( |
|
|
|
article, |
|
|
|
builder: (context, mode) { |
|
|
|
0, |
|
|
|
return MyFooter(mode); |
|
|
|
exitFull: () { |
|
|
|
}, |
|
|
|
setState(() {}); |
|
|
|
), |
|
|
|
}, |
|
|
|
onRefresh: () { |
|
|
|
userId: widget.arguments != null |
|
|
|
setState(() { |
|
|
|
? widget.arguments["userId"] |
|
|
|
emojiShowing = false; |
|
|
|
: widget.arguments["mid"], |
|
|
|
isKeyBoardShow = emojiShowing; |
|
|
|
itemCount: 3, |
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
isDetails: true, |
|
|
|
_onRefresh(); |
|
|
|
heightFun: (height) { |
|
|
|
}); |
|
|
|
this.height = height + |
|
|
|
}, |
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
scrollController:scrollController, |
|
|
|
kToolbarHeight + |
|
|
|
child: SingleChildScrollView( |
|
|
|
24; |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
if (mounted) setState(() {}); |
|
|
|
child: Column( |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
if (article != null) |
|
|
|
|
|
|
|
CommunityDynamic( |
|
|
|
|
|
|
|
article, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
exitFull: () { |
|
|
|
|
|
|
|
setState(() {}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
userId: widget.arguments != null |
|
|
|
|
|
|
|
? widget.arguments["userId"] |
|
|
|
|
|
|
|
: widget.arguments["mid"], |
|
|
|
|
|
|
|
itemCount: 3, |
|
|
|
|
|
|
|
isDetails: true, |
|
|
|
|
|
|
|
heightFun: (height) { |
|
|
|
|
|
|
|
this.height = height + |
|
|
|
|
|
|
|
MediaQuery.of(context).padding.top + |
|
|
|
|
|
|
|
kToolbarHeight + |
|
|
|
|
|
|
|
24; |
|
|
|
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CommentList( |
|
|
|
|
|
|
|
commentKey, |
|
|
|
|
|
|
|
article?.likes ?? 0, |
|
|
|
|
|
|
|
businessId, |
|
|
|
|
|
|
|
4, |
|
|
|
|
|
|
|
isKeyBoardShow, |
|
|
|
|
|
|
|
_reply, |
|
|
|
|
|
|
|
_delCommentTips, |
|
|
|
|
|
|
|
12.sp, |
|
|
|
|
|
|
|
requestApiFinish: (total) { |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
commentTotal = total; |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
CommentList( |
|
|
|
if (memberList == null || memberList.length == 0) |
|
|
|
commentKey, |
|
|
|
Container( |
|
|
|
article?.likes ?? 0, |
|
|
|
width: double.infinity, |
|
|
|
businessId, |
|
|
|
alignment: Alignment.topCenter, |
|
|
|
4, |
|
|
|
margin: EdgeInsets.only(top: 40), |
|
|
|
isKeyBoardShow, |
|
|
|
padding: EdgeInsets.all(22.h), |
|
|
|
_reply, |
|
|
|
child: Text( |
|
|
|
_delCommentTips, |
|
|
|
S.of(context).zanwupinglun, |
|
|
|
12.sp, |
|
|
|
style: TextStyle( |
|
|
|
requestApiFinish: (total) { |
|
|
|
fontSize: 12, |
|
|
|
setState(() { |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
commentTotal = total; |
|
|
|
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, |
|
|
@ -299,7 +346,7 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
state.queryMemberCommentList(); |
|
|
|
state.queryMemberCommentList(); |
|
|
|
commentTextController.text = ""; |
|
|
|
commentTextController.text = ""; |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
_queryMemberCommentList(); |
|
|
|
_queryMemberCommentList(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -351,14 +398,15 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///评论列表 |
|
|
|
///评论列表 |
|
|
|
_queryMemberCommentList() async { |
|
|
|
_queryMemberCommentList(bool isOnRefresh) async { |
|
|
|
|
|
|
|
if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
if (apiService == null) |
|
|
|
if (apiService == null) |
|
|
|
apiService = ApiService( |
|
|
|
apiService = ApiService( |
|
|
|
Dio(), |
|
|
|
Dio(), |
|
|
|
context: context, |
|
|
|
context: context, |
|
|
|
token: sharedPreferences.getString("token"), |
|
|
|
token: sharedPreferences.getString("token"), |
|
|
|
showLoading: true, |
|
|
|
// showLoading: true, |
|
|
|
); |
|
|
|
); |
|
|
|
BaseData<PageInfo<MemberCommentList>> baseData = |
|
|
|
BaseData<PageInfo<MemberCommentList>> baseData = |
|
|
|
await apiService.memberCommentList({ |
|
|
|
await apiService.memberCommentList({ |
|
|
@ -372,6 +420,9 @@ class _CommunityDetails extends State<CommunityDetails> |
|
|
|
memberList = baseData.data.list; |
|
|
|
memberList = baseData.data.list; |
|
|
|
contentHeight(); |
|
|
|
contentHeight(); |
|
|
|
if (mounted) setState(() {}); |
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|