intimacy_analyse_report_widget.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:keyboard/resource/string.gen.dart';
  4. import '../../../resource/assets.gen.dart';
  5. import '../../../resource/colors.gen.dart';
  6. import '../../../widget/markdown/markdown_viewer.dart';
  7. /// 亲密度报告组件
  8. class IntimacyAnalyseReportWidget extends StatelessWidget {
  9. /// 报告内容
  10. final String reportContent;
  11. const IntimacyAnalyseReportWidget({super.key, required this.reportContent});
  12. @override
  13. Widget build(BuildContext context) {
  14. // 卡片背景
  15. return Container(
  16. height: 424.h,
  17. margin: EdgeInsets.only(left: 12, right: 12, bottom: 0),
  18. padding: EdgeInsets.only(bottom: 12),
  19. decoration: BoxDecoration(
  20. image: DecorationImage(
  21. image: Assets.images.bgIntimacyAnalyseReportPreview.provider(),
  22. fit: BoxFit.fill,
  23. ),
  24. ),
  25. child: Stack(
  26. children: [
  27. // 图标和标题
  28. _buildReportTopLayout(),
  29. // 内容
  30. Container(
  31. margin: EdgeInsets.only(top: 51, left: 12, right: 12, bottom: 5),
  32. decoration: ShapeDecoration(
  33. color: ColorName.white,
  34. shape: RoundedRectangleBorder(
  35. borderRadius: BorderRadius.circular(30.r),
  36. ),
  37. ),
  38. child:
  39. reportContent.isEmpty
  40. ? _buildCreatingLayout()
  41. : _buildReportContentLayout(),
  42. ),
  43. ],
  44. ),
  45. );
  46. }
  47. /// 报告的顶部布局-包含:图标和标题
  48. Widget _buildReportTopLayout() {
  49. return Row(
  50. children: [
  51. Assets.images.iconIntimacyAnalyseReportPreviewLove.image(
  52. width: 50,
  53. height: 48,
  54. ),
  55. Assets.images.iconIntimacyAnalyseReportPreviewTitle.image(
  56. width: 178,
  57. height: 24,
  58. ),
  59. ],
  60. );
  61. }
  62. /// 报告内容布局
  63. Widget _buildReportContentLayout() {
  64. return MarkdownViewer(content: reportContent);
  65. }
  66. /// 生成中布局
  67. Widget _buildCreatingLayout() {
  68. return Center(
  69. child: Column(
  70. // 垂直水平都居中
  71. mainAxisAlignment: MainAxisAlignment.center,
  72. crossAxisAlignment: CrossAxisAlignment.center,
  73. children: [
  74. // 图标
  75. Assets.images.iconIntimacyAnalysisReportCreating.image(
  76. width: 82,
  77. height: 82,
  78. ),
  79. SizedBox(height: 3.h),
  80. // 文字
  81. Text(
  82. StringName.intimacyAnalyseReportCreating,
  83. style: TextStyle(
  84. fontSize: 14.sp,
  85. color: ColorName.black60,
  86. fontWeight: FontWeight.w400,
  87. ),
  88. ),
  89. ],
  90. ),
  91. );
  92. }
  93. }