| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.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 Stack(
- // 让大小,撑满父组件
- fit: StackFit.expand,
- children: [
- // 中间内容
- Container(
- 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: [
- // 图标和标题
- _buildReportPreviewTopLayout(),
- Container(
- margin: EdgeInsets.only(
- top: 51,
- left: 12,
- right: 12,
- bottom: 5,
- ),
- decoration: ShapeDecoration(
- color: ColorName.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20.r),
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.only(
- left: 14,
- right: 14,
- top: 20,
- bottom: 14,
- ),
- // 内容
- child: Container(
- color: Colors.red,
- height: 424.h,
- child: LayoutBuilder(
- builder: (
- BuildContext context,
- BoxConstraints constraints,
- ) {
- return SingleChildScrollView(
- physics: BouncingScrollPhysics(),
- // 渲染Markdown
- child: ConstrainedBox(
- constraints: BoxConstraints(
- // 确保最小高度
- minHeight: constraints.maxHeight,
- ),
- child: MarkdownViewer(content: reportContent),
- ),
- );
- },
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- // 底部阴影
- Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: Container(
- child: Assets.images.bgIntimacyAnalyseReportPreviewMask.image(
- height: 126,
- ),
- ),
- ),
- ],
- );
- }
- /// 报告预览布局-顶部布局-包含:图标和标题
- Widget _buildReportPreviewTopLayout() {
- return Row(
- children: [
- Assets.images.iconIntimacyAnalyseReportPreviewLove.image(
- width: 50,
- height: 48,
- ),
- Assets.images.iconIntimacyAnalyseReportPreviewTitle.image(
- width: 178,
- height: 24,
- ),
- ],
- );
- }
- }
|