part of library;

class LibraryContentPage extends StatefulWidget {
  final LibraryController controller;
  // final CategoryModel categoryModel;
  const LibraryContentPage({
    Key? key,
    required this.controller,
    // required this.categoryModel
  }) : super(key: key);

  @override
  State<LibraryContentPage> createState() => _LibraryContentPageState();
}

class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    return widget.controller.books.isEmpty?Container(
      padding: EdgeInsets.only(top: 110.w),
      alignment: Alignment.center,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SizedBox(height: 152.w, width: 195.w,
            child: Image.asset( 'assets/images/none.png',),),
          SizedBox(height: 13.w,),
        ],
      ),
    ):ListView.builder(
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      itemCount: widget.controller.books.length,
      itemBuilder: (BuildContext context, int index) {
        CourseModel model = widget.controller.books[index];
        return GestureDetector(
          onTap: (){
            context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
          },
          child: LibraryCell(model: model,onTap: (){
            if(UserStore.to.isLogin){
              widget.controller.love(model: model);
            }
            else{
              context.pushNamed(Routes.login);
            }

          },),
        );
      }
    );
  }
  @override
  bool get wantKeepAlive => true;
}
