novel_cell.dart 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:flutter/material.dart';
  2. import 'package:shuqi/public.dart';
  3. class NovelCell extends StatelessWidget {
  4. final Novel novel;
  5. NovelCell(this.novel);
  6. @override
  7. Widget build(BuildContext context) {
  8. return GestureDetector(
  9. onTap: () {
  10. AppNavigator.pushNovelDetail(context, novel);
  11. },
  12. child: Container(
  13. padding: EdgeInsets.all(15),
  14. child: Row(
  15. crossAxisAlignment: CrossAxisAlignment.start,
  16. children: <Widget>[
  17. NovelCoverImage(novel.imgUrl, width: 70, height: 93),
  18. SizedBox(width: 15),
  19. Expanded(
  20. child: buildRight(),
  21. ),
  22. ],
  23. ),
  24. ),
  25. );
  26. }
  27. Widget buildRight() {
  28. return Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: <Widget>[
  31. Text(
  32. novel.name,
  33. style: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
  34. ),
  35. SizedBox(height: 5),
  36. Text(
  37. novel.introduction,
  38. maxLines: 2,
  39. overflow: TextOverflow.ellipsis,
  40. style: TextStyle(
  41. fontSize: 14,
  42. color: SQColor.gray,
  43. ),
  44. ),
  45. SizedBox(height: 5),
  46. Row(
  47. children: <Widget>[
  48. Text(
  49. novel.author,
  50. style: TextStyle(fontSize: 14, color: SQColor.gray),
  51. ),
  52. Expanded(child: Container()),
  53. buildTag(novel.status, novel.statusColor()),
  54. SizedBox(width: 5),
  55. buildTag(novel.type, SQColor.gray),
  56. ],
  57. )
  58. ],
  59. );
  60. }
  61. Widget buildTag(String title, Color color) {
  62. return Container(
  63. padding: EdgeInsets.fromLTRB(5, 2, 5, 3),
  64. decoration: BoxDecoration(
  65. border: Border.all(color: Color.fromARGB(99, color.red, color.green, color.blue), width: 0.5),
  66. borderRadius: BorderRadius.circular(3),
  67. ),
  68. child: Text(
  69. title,
  70. style: TextStyle(fontSize: 11, color: color),
  71. ),
  72. );
  73. }
  74. }