novel_second_hybird_card.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. import 'novel_grid_item.dart';
  3. import 'home_section_view.dart';
  4. import 'home_novel_cover_view.dart';
  5. import 'home_model.dart';
  6. class NovelSecondHybirdCard extends StatelessWidget {
  7. final HomeModule cardInfo;
  8. NovelSecondHybirdCard(this.cardInfo);
  9. @override
  10. Widget build(BuildContext context) {
  11. var novels = cardInfo.books;
  12. if (novels == null || novels.length < 5) {
  13. return Container();
  14. }
  15. var topNovels = novels.sublist(0, 4);
  16. List<Widget> children = [];
  17. topNovels.forEach((novel) {
  18. children.add(HomeNovelCoverView(novel));
  19. });
  20. var bottomNovels = novels.sublist(4);
  21. bottomNovels.forEach((novel) {
  22. children.add(NovelGridItem(novel));
  23. });
  24. return Container(
  25. color: Colors.white,
  26. child: Column(
  27. children: <Widget>[
  28. HomeSectionView(cardInfo.name),
  29. Container(
  30. padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
  31. child: Wrap(spacing: 15, runSpacing: 15, children: children),
  32. ),
  33. Container(
  34. height: 10,
  35. color: Color(0xfff5f5f5),
  36. )
  37. ],
  38. ),
  39. );
  40. }
  41. }