|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
|
|
import 'package:chewie/chewie.dart'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
@ -42,11 +44,9 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
var commentFocus = FocusNode(); |
|
|
|
|
String parenId = "0"; |
|
|
|
|
String hintText = S.current.liuxianinjingcaidepinglunba; |
|
|
|
|
List<MemberCommentList> memberList = []; |
|
|
|
|
final GlobalKey inputKey = GlobalKey(); |
|
|
|
|
final TextEditingController commentTextController = TextEditingController(); |
|
|
|
|
int commentTotal = 0; |
|
|
|
|
double commentHeight = 60.h; |
|
|
|
|
CourseDetails course; |
|
|
|
|
List<Chapter> chapterList = []; |
|
|
|
|
bool isShowImg = true; |
|
|
|
@ -149,203 +149,212 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Scaffold( |
|
|
|
|
body: Container( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Stack( |
|
|
|
|
child:Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
videoWidget( |
|
|
|
|
MediaQuery.of(context).size.width, |
|
|
|
|
videoPlayerController != null |
|
|
|
|
? (MediaQuery.of(context).size.width) / |
|
|
|
|
videoPlayerController.value.aspectRatio |
|
|
|
|
: MediaQuery.of(context).size.width / 2, |
|
|
|
|
chapterList.length>chapterIndex?chapterList[chapterIndex].content.coverImg:"", |
|
|
|
|
Stack( |
|
|
|
|
children: [ |
|
|
|
|
videoWidget( |
|
|
|
|
MediaQuery.of(context).size.width, |
|
|
|
|
videoPlayerController != null |
|
|
|
|
? (MediaQuery.of(context).size.width) / |
|
|
|
|
videoPlayerController.value.aspectRatio |
|
|
|
|
: MediaQuery.of(context).size.width / 2, |
|
|
|
|
chapterList.length>chapterIndex?chapterList[chapterIndex].content.coverImg:"", |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
margin: EdgeInsets.only(top: 40.h, left: 16.w, right: 16.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.transparent, |
|
|
|
|
), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.arrow_back_ios, |
|
|
|
|
color: Colors.white, |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
margin: EdgeInsets.only(top: 40.h, left: 16.w, right: 16.w), |
|
|
|
|
height: 123, |
|
|
|
|
margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
|
padding: EdgeInsets.only(left: 16,top: 16,right: 10), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.transparent, |
|
|
|
|
), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.arrow_back_ios, |
|
|
|
|
color: Colors.white, |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
color: Colors.white, |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 2), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
height: 123, |
|
|
|
|
margin: EdgeInsets.only(bottom: 16.h), |
|
|
|
|
padding: EdgeInsets.only(left: 16,top: 16,right: 10), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 2), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Row( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
height: 22.h, |
|
|
|
|
width: 40.w, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
height: 22.h, |
|
|
|
|
width: 40.w, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
( course?.tags != null && course.tags.length > 0 )?course.tags[0] : "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
( course?.tags != null && course.tags.length > 0 )?course.tags[0] : "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 6.w, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
course != null ?course.subject:"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 6.w, |
|
|
|
|
height:10.h, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
course != null ?course.subject:"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height:10.h, |
|
|
|
|
), |
|
|
|
|
Padding(padding: EdgeInsets.only(right: 16), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"讲师:${course !=null ? course.author.name :""}", |
|
|
|
|
Padding(padding: EdgeInsets.only(right: 16), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"讲师:${course !=null ? course.author.name :""}", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Text( |
|
|
|
|
"播放次数", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Text( |
|
|
|
|
"播放次数", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width:4, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
course != null ? course.viewers.toString() :"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width:4, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
course != null ? course.viewers.toString() :"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
),), |
|
|
|
|
SizedBox( |
|
|
|
|
height:10.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
course != null ?course.introduce:"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
),), |
|
|
|
|
SizedBox( |
|
|
|
|
height:10.h, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
course != null ?course.introduce:"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
anthology(), |
|
|
|
|
CommentList( |
|
|
|
|
commentKey, |
|
|
|
|
course?.likes ?? course?.likes?? 0, |
|
|
|
|
widget.arguments["id"], |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
_reply, |
|
|
|
|
_delCommentTips, |
|
|
|
|
12.sp, |
|
|
|
|
requestApiFinish: (total){setState(() { |
|
|
|
|
commentTotal = total; |
|
|
|
|
});}, |
|
|
|
|
), |
|
|
|
|
if (commentTotal == 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), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
anthology(), |
|
|
|
|
CommentList( |
|
|
|
|
commentKey, |
|
|
|
|
course?.likes ?? course?.likes?? 0, |
|
|
|
|
course?.id ?? course?.id ??"", |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
_reply, |
|
|
|
|
_delCommentTips, |
|
|
|
|
12.sp, |
|
|
|
|
), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
/// 富文本评论的输入框 |
|
|
|
|
InputComment( |
|
|
|
|
inputKey, |
|
|
|
|
hintText, |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
commentFocus, |
|
|
|
|
commentTextController, |
|
|
|
|
_toComment, |
|
|
|
|
_queryMemberComment, |
|
|
|
|
_queryInformationLikes, |
|
|
|
|
isLike: false, |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1,), |
|
|
|
|
/// 富文本评论的输入框 |
|
|
|
|
InputComment( |
|
|
|
|
inputKey, |
|
|
|
|
hintText, |
|
|
|
|
isKeyBoardShow, |
|
|
|
|
commentFocus, |
|
|
|
|
commentTextController, |
|
|
|
|
_toComment, |
|
|
|
|
_queryMemberComment, |
|
|
|
|
_queryInformationLikes, |
|
|
|
|
isLike: false, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
@ -517,25 +526,9 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
contentHeight() { |
|
|
|
|
double contentHeight = MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.size |
|
|
|
|
.height - |
|
|
|
|
kToolbarHeight - |
|
|
|
|
MediaQuery |
|
|
|
|
.of(context) |
|
|
|
|
.padding |
|
|
|
|
.top - |
|
|
|
|
160.h; |
|
|
|
|
if ((contentHeight - 60.h) > (128.h * memberList.length)) { |
|
|
|
|
commentHeight = contentHeight - (128.h * memberList.length); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///给文章/活动点赞 |
|
|
|
|
_queryInformationLikes() async { |
|
|
|
|
BaseData baseData = await apiService.informationLikes("1455102859841372160"); |
|
|
|
|
BaseData baseData = await apiService.informationLikes(widget.arguments["id"]); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
commentKey.currentState.setState(() {}); |
|
|
|
|
setState(() { |
|
|
|
@ -555,7 +548,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
BaseData baseData = await apiService.memberComment({ |
|
|
|
|
"content": content, |
|
|
|
|
"parentId": parenId, |
|
|
|
|
"relationalId":course.id, |
|
|
|
|
"relationalId":widget.arguments["id"], |
|
|
|
|
"relationalType": 1 |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
@ -563,32 +556,6 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
state.queryMemberCommentList(); |
|
|
|
|
commentTextController.text = ""; |
|
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
|
_queryMemberCommentList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///评论列表 |
|
|
|
|
_queryMemberCommentList() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: sharedPreferences.getString("token"), |
|
|
|
|
showLoading: false, |
|
|
|
|
); |
|
|
|
|
BaseData<PageInfo<MemberCommentList>> baseData = |
|
|
|
|
await apiService.memberCommentList({ |
|
|
|
|
"pageNum": 1, |
|
|
|
|
"pageSize": 100, |
|
|
|
|
"relationalId":course.id, |
|
|
|
|
"relationalType": 1, |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
commentTotal = baseData.data.size; |
|
|
|
|
memberList = baseData.data.list; |
|
|
|
|
contentHeight(); |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|