novel_detail_header.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import 'package:flutter/material.dart';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'dart:ui' as ui;
  4. import 'package:shuqi/public.dart';
  5. class NovelDetailHeader extends StatelessWidget {
  6. final Novel novel;
  7. NovelDetailHeader(this.novel);
  8. @override
  9. Widget build(BuildContext context) {
  10. var width = Screen.width;
  11. var height = 218.0 + Screen.topSafeHeight;
  12. return Container(
  13. width: width,
  14. height: height,
  15. child: Stack(
  16. children: <Widget>[
  17. Image(
  18. image: CachedNetworkImageProvider(novel.imgUrl),
  19. fit: BoxFit.fitWidth,
  20. width: width,
  21. height: height,
  22. ),
  23. Container(color: Color(0xbb000000), width: width, height: height),
  24. BackdropFilter(
  25. filter: ui.ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
  26. child: buildContent(context),
  27. ),
  28. ],
  29. ),
  30. );
  31. }
  32. Widget buildContent(BuildContext context) {
  33. var width = Screen.width;
  34. return Container(
  35. width: width,
  36. padding: EdgeInsets.fromLTRB(15, 54 + Screen.topSafeHeight, 10, 0),
  37. color: Colors.transparent,
  38. child: Row(
  39. crossAxisAlignment: CrossAxisAlignment.start,
  40. children: <Widget>[
  41. NovelCoverImage(novel.imgUrl, width: 100, height: 133),
  42. SizedBox(width: 15),
  43. Expanded(
  44. child: Column(
  45. crossAxisAlignment: CrossAxisAlignment.start,
  46. children: <Widget>[
  47. Text(novel.name, style: TextStyle(fontSize: fixedFontSize(18), color: Colors.white, fontWeight: FontWeight.bold)),
  48. SizedBox(height: 10),
  49. Text(novel.author, style: TextStyle(fontSize: fixedFontSize(14), color: SQColor.white)),
  50. SizedBox(height: 10),
  51. Text('${novel.wordCount}万字 ${novel.price}书豆/千字', style: TextStyle(fontSize: fixedFontSize(14), color: SQColor.white)),
  52. SizedBox(height: 10),
  53. buildScore(),
  54. SizedBox(height: 10),
  55. Row(
  56. crossAxisAlignment: CrossAxisAlignment.center,
  57. children: <Widget>[
  58. Image.asset('assets/img/read_icon_vip.png'),
  59. Expanded(
  60. child: Text(
  61. ' 续费包月会员,万本小说免费读 >',
  62. style: TextStyle(fontSize: fixedFontSize(14), color: Color(0xFFFEA900)),
  63. maxLines: 1,
  64. ),
  65. ),
  66. ],
  67. ),
  68. ],
  69. ),
  70. )
  71. ],
  72. ),
  73. );
  74. }
  75. Widget buildScore() {
  76. List<Widget> children = [Text('评分:${novel.score}分 ', style: TextStyle(fontSize: fixedFontSize(14), color: Color(0xfff8e71c)))];
  77. var star = novel.score;
  78. for (var i = 0; i < 5; i++) {
  79. if (star < i) {
  80. break;
  81. }
  82. var img;
  83. if (star <= i + 0.5) {
  84. img = Image.asset('assets/img/detail_star_half.png');
  85. } else {
  86. img = Image.asset('assets/img/detail_star.png');
  87. }
  88. children.add(img);
  89. children.add(SizedBox(width: 5));
  90. }
  91. return Row(
  92. children: children,
  93. );
  94. }
  95. }