part of library_content;

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

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

class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<LibraryContentController>(
      init: LibraryContentController(),
      builder: (controller) => CustomPullScrollView(
        controller: controller.refreshController,
        onRefresh: controller.onRefresh,
        onLoading: controller.onLoading,
        child: ListView.builder(
          itemCount: controller.books.length,
          itemBuilder: (BuildContext context, int index) {
            // if (index == 0){
            //   return Container(
            //     color: Colors.transparent,
            //     padding: const EdgeInsets.symmetric(horizontal: 10),
            //     child: BuildBanner(items: controller.ads,),
            //   );
            // }
            // else {
              CourseModel model = controller.books[index];
              return GestureDetector(
                onTap: (){
                  context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
                },
                child: LibraryCell(model: model,onTap: (){
                  controller.love(bookId: model.bookId.toString(), isCollection: model.isCollection!);
                },),
              );
            }
          // },
        ),
      ),
    );
  }
  @override
  bool get wantKeepAlive => true;
}
