import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:keyboard/resource/string.gen.dart'; import '../../../resource/assets.gen.dart'; import '../../../resource/colors.gen.dart'; import '../../../widget/markdown/markdown_viewer.dart'; /// 亲密度报告组件 class IntimacyAnalyseReportWidget extends StatelessWidget { /// 报告内容 final String reportContent; const IntimacyAnalyseReportWidget({super.key, required this.reportContent}); @override Widget build(BuildContext context) { // 卡片背景 return Container( height: 424.h, margin: EdgeInsets.only(left: 12, right: 12, bottom: 0), padding: EdgeInsets.only(bottom: 12), decoration: BoxDecoration( image: DecorationImage( image: Assets.images.bgIntimacyAnalyseReportPreview.provider(), fit: BoxFit.fill, ), ), child: Stack( children: [ // 图标和标题 _buildReportTopLayout(), // 内容 Container( margin: EdgeInsets.only(top: 51, left: 12, right: 12, bottom: 5), decoration: ShapeDecoration( color: ColorName.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), ), ), child: reportContent.isEmpty ? _buildCreatingLayout() : _buildReportContentLayout(), ), ], ), ); } /// 报告的顶部布局-包含:图标和标题 Widget _buildReportTopLayout() { return Row( children: [ Assets.images.iconIntimacyAnalyseReportPreviewLove.image( width: 50, height: 48, ), Assets.images.iconIntimacyAnalyseReportPreviewTitle.image( width: 178, height: 24, ), ], ); } /// 报告内容布局 Widget _buildReportContentLayout() { return MarkdownViewer(content: reportContent); } /// 生成中布局 Widget _buildCreatingLayout() { return Center( child: Column( // 垂直水平都居中 mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ // 图标 Assets.images.iconIntimacyAnalysisReportCreating.image( width: 82, height: 82, ), SizedBox(height: 3.h), // 文字 Text( StringName.intimacyAnalyseReportCreating, style: TextStyle( fontSize: 14.sp, color: ColorName.black60, fontWeight: FontWeight.w400, ), ), ], ), ); } }