intimacy_analyse_report_widget.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import '../../../resource/assets.gen.dart';
  4. import '../../../resource/colors.gen.dart';
  5. import '../../../widget/markdown/markdown_viewer.dart';
  6. /// 亲密度报告组件
  7. class IntimacyAnalyseReportWidget extends StatelessWidget {
  8. /// 报告内容
  9. final String reportContent;
  10. const IntimacyAnalyseReportWidget({super.key, required this.reportContent});
  11. @override
  12. Widget build(BuildContext context) {
  13. // 卡片背景
  14. return Stack(
  15. // 让大小,撑满父组件
  16. fit: StackFit.expand,
  17. children: [
  18. // 中间内容
  19. Container(
  20. margin: EdgeInsets.only(left: 12, right: 12, bottom: 0),
  21. padding: EdgeInsets.only(bottom: 12),
  22. decoration: BoxDecoration(
  23. image: DecorationImage(
  24. image: Assets.images.bgIntimacyAnalyseReportPreview.provider(),
  25. fit: BoxFit.fill,
  26. ),
  27. ),
  28. // 圆角背景
  29. child: Stack(
  30. children: [
  31. // 图标和标题
  32. _buildReportPreviewTopLayout(),
  33. Container(
  34. margin: EdgeInsets.only(
  35. top: 51,
  36. left: 12,
  37. right: 12,
  38. bottom: 5,
  39. ),
  40. decoration: ShapeDecoration(
  41. color: ColorName.white,
  42. shape: RoundedRectangleBorder(
  43. borderRadius: BorderRadius.circular(20.r),
  44. ),
  45. ),
  46. child: Padding(
  47. padding: const EdgeInsets.only(
  48. left: 14,
  49. right: 14,
  50. top: 20,
  51. bottom: 14,
  52. ),
  53. // 内容
  54. child: Container(
  55. color: Colors.red,
  56. height: 424.h,
  57. child: LayoutBuilder(
  58. builder: (
  59. BuildContext context,
  60. BoxConstraints constraints,
  61. ) {
  62. return SingleChildScrollView(
  63. physics: BouncingScrollPhysics(),
  64. // 渲染Markdown
  65. child: ConstrainedBox(
  66. constraints: BoxConstraints(
  67. // 确保最小高度
  68. minHeight: constraints.maxHeight,
  69. ),
  70. child: MarkdownViewer(content: reportContent),
  71. ),
  72. );
  73. },
  74. ),
  75. ),
  76. ),
  77. ),
  78. ],
  79. ),
  80. ),
  81. // 底部阴影
  82. Positioned(
  83. left: 0,
  84. right: 0,
  85. bottom: 0,
  86. child: Container(
  87. child: Assets.images.bgIntimacyAnalyseReportPreviewMask.image(
  88. height: 126,
  89. ),
  90. ),
  91. ),
  92. ],
  93. );
  94. }
  95. /// 报告预览布局-顶部布局-包含:图标和标题
  96. Widget _buildReportPreviewTopLayout() {
  97. return Row(
  98. children: [
  99. Assets.images.iconIntimacyAnalyseReportPreviewLove.image(
  100. width: 50,
  101. height: 48,
  102. ),
  103. Assets.images.iconIntimacyAnalyseReportPreviewTitle.image(
  104. width: 178,
  105. height: 24,
  106. ),
  107. ],
  108. );
  109. }
  110. }