|
|
|
@ -25,6 +25,7 @@ class ClassDetails extends StatefulWidget {
|
|
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
|
|
|
|
|
|
ClassDetails({this.arguments}); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
|
return _ClassDetails(); |
|
|
|
@ -68,7 +69,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
token: value.getString("token"), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
BaseData<List<Chapter>> baseData = await apiService.catalogList(courseId).catchError((onError) {}); |
|
|
|
|
BaseData<List<Chapter>> baseData = |
|
|
|
|
await apiService.catalogList(courseId).catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
chapterList.clear(); |
|
|
|
@ -76,7 +78,6 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
chapterIndex = 0; |
|
|
|
|
initVideo(chapterList[chapterIndex].content.fileUrl); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
@ -91,7 +92,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
token: value.getString("token"), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
BaseData<CourseDetails> baseData = await apiService.course(id).catchError((error) {}); |
|
|
|
|
BaseData<CourseDetails> baseData = |
|
|
|
|
await apiService.course(id).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
course = baseData.data; |
|
|
|
@ -99,7 +101,6 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
|
/** |
|
|
|
@ -122,10 +123,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
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) |
|
|
|
@ -162,10 +160,13 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
? (MediaQuery.of(context).size.width) / |
|
|
|
|
videoPlayerController.value.aspectRatio |
|
|
|
|
: MediaQuery.of(context).size.width / 2, |
|
|
|
|
chapterList.length>chapterIndex?chapterList[chapterIndex].content.coverImg:"", |
|
|
|
|
chapterList.length > chapterIndex |
|
|
|
|
? chapterList[chapterIndex].content.coverImg |
|
|
|
|
: "", |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
margin: EdgeInsets.only(top: 40.h, left: 16.w, right: 16.w), |
|
|
|
|
margin: EdgeInsets.only( |
|
|
|
|
top: 40.h, left: 16.w, right: 16.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.transparent, |
|
|
|
|
), |
|
|
|
@ -180,7 +181,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
height: 24, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(course != null ? course.viewers+1 :0); |
|
|
|
|
Navigator.of(context).pop( |
|
|
|
|
course != null ? course.viewers + 1 : 0); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -222,7 +224,10 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
( course?.tags != null && course.tags.length > 0 )?course.tags[0] : "", |
|
|
|
|
(course?.tags != null && |
|
|
|
|
course.tags.length > 0) |
|
|
|
|
? course.tags[0] |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
@ -251,7 +256,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
SizedBox( |
|
|
|
|
height: 10.h, |
|
|
|
|
), |
|
|
|
|
Padding(padding: EdgeInsets.only(right: 16), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(right: 16), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
@ -277,7 +283,9 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
width: 4, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
course != null ? course.viewers.toString() :"", |
|
|
|
|
course != null |
|
|
|
|
? course.viewers.toString() |
|
|
|
|
: "", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
@ -287,7 +295,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
),), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 10.h, |
|
|
|
|
), |
|
|
|
@ -314,9 +323,11 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
_reply, |
|
|
|
|
_delCommentTips, |
|
|
|
|
12.sp, |
|
|
|
|
requestApiFinish: (total){setState(() { |
|
|
|
|
requestApiFinish: (total) { |
|
|
|
|
setState(() { |
|
|
|
|
commentTotal = total; |
|
|
|
|
});}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
if (commentTotal == 0) |
|
|
|
|
Container( |
|
|
|
@ -325,9 +336,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
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, |
|
|
|
@ -338,7 +347,9 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1,), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
/// 富文本评论的输入框 |
|
|
|
|
InputComment( |
|
|
|
|
inputKey, |
|
|
|
@ -386,8 +397,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
|
|
|
|
|
Future<void> _fullScreenListener() async { |
|
|
|
|
if (!chewieAudioController.isFullScreen) { |
|
|
|
|
Future.delayed(Duration(seconds: 1), () { |
|
|
|
|
}); |
|
|
|
|
Future.delayed(Duration(seconds: 1), () {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -397,8 +407,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
data: MediaQuery.of(context).copyWith( |
|
|
|
|
textScaleFactor: 0.9, |
|
|
|
|
), |
|
|
|
|
child: !isShowImg |
|
|
|
|
? (chewieAudioController != null |
|
|
|
|
child: Stack(children: [ |
|
|
|
|
(chewieAudioController != null |
|
|
|
|
? Container( |
|
|
|
|
width: width, |
|
|
|
|
height: height, |
|
|
|
@ -409,23 +419,28 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
: Container( |
|
|
|
|
width: width, |
|
|
|
|
height: height, |
|
|
|
|
)) |
|
|
|
|
: GestureDetector( |
|
|
|
|
)), |
|
|
|
|
if(isShowImg) |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
isShowImg = false; |
|
|
|
|
if(chewieAudioController != null) |
|
|
|
|
chewieAudioController.play(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: width, |
|
|
|
|
height: width / 7 * 5, |
|
|
|
|
height: height, |
|
|
|
|
color: Colors.black, |
|
|
|
|
child: Stack( |
|
|
|
|
children: [ |
|
|
|
|
Center( |
|
|
|
|
child: MImage( |
|
|
|
|
src, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
width:width, |
|
|
|
|
height: height, |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
errorSrc: "assets/image/default_2_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_2_1.png", |
|
|
|
|
), |
|
|
|
@ -441,7 +456,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget anthology() { |
|
|
|
@ -486,6 +501,8 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
setState(() { |
|
|
|
|
chapterIndex = position; |
|
|
|
|
isShowImg = true; |
|
|
|
|
if(chewieAudioController != null) |
|
|
|
|
chewieAudioController.pause(); |
|
|
|
|
initVideo(chapterList[position].content.fileUrl); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
@ -523,10 +540,11 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///课程点赞 |
|
|
|
|
_queryCourseLikes() async { |
|
|
|
|
BaseData baseData = await apiService.courseLikes(widget.arguments["id"]).catchError((onError) {}); |
|
|
|
|
BaseData baseData = await apiService |
|
|
|
|
.courseLikes(widget.arguments["id"]) |
|
|
|
|
.catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
if (course.selfLiked ?? false) |
|
|
|
@ -566,10 +584,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver{
|
|
|
|
|
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, |
|
|
|
|
); |
|
|
|
|