提交 bd686d99 authored 作者: yueweilu's avatar yueweilu

课程 继续学习 直接跳阅读页

上级 dcb636c6
......@@ -45,6 +45,12 @@ class CourseController extends GetxController {
update();
}
/// 获取图书详细信息
Future<BookDetailModel> getBookDetails(String bookId) async {
final result = await LibraryAPI.details(bookId:bookId);
return result;
}
/// 获取课程内图书列表
Future<void> _getCourse([bool isRefresh = false]) async {
......
......@@ -94,7 +94,18 @@ class _CoursePageState extends State<CoursePage> {
itemBuilder: (BuildContext context, int index) {
CourseModel model = controller.courses[index];
return GestureDetector(
child: Book(model: model,),
child: Book(
model: model,
onTapContinue: () async{
BookDetailModel bookDetails = await controller.getBookDetails(model.bookId.toString());
if(context.mounted){
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': bookDetails.bookId.toString(),'chapter_id': bookDetails.chapterId.toString(),'chapter_name':bookDetails.chapterName.toString()},extra:bookDetails);
if (result == true){
controller.getNums();
}
}
},
),
onTap: (){
context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
......
......@@ -2,9 +2,11 @@ part of course;
class Book extends StatelessWidget {
final CourseModel model;
final void Function() onTapContinue;
const Book({
Key? key,
required this.model
required this.model,
required this.onTapContinue
}) : super(key: key);
@override
......@@ -56,7 +58,12 @@ class Book extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 3.5.w),
child: Text(model.typeName,style: TextStyle(fontSize: 11.w,height: 1.3,color: model.type ==0||model.type ==1 ?Colours.c9:AppTheme.primary),),
),
model.type == 2? Text('继续学习',style: TextStyle(fontSize: 11.w,height: 1.3,color: AppTheme.primary,fontWeight: Fonts.boldSemi),):const SizedBox()
model.type == 2? GestureDetector(
onTap: (){
onTapContinue();
},
child: Text('继续学习',style: TextStyle(fontSize: 11.w,height: 1.3,color: AppTheme.primary,fontWeight: Fonts.boldSemi),)
):const SizedBox()
],
)
],
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论