From 70479542a50c28714cede66754eabe3c585bf0ae Mon Sep 17 00:00:00 2001 From: zhutao <1812073942@qq.com> Date: Wed, 24 Sep 2025 11:34:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=85=A8=E9=83=A8=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AF=B9=E8=AF=9D=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/plan/detail/other/done_stamp.dart | 3 +- .../detail/viewmodel/plan_detail_store.dart | 17 ++- lib/page/plan/detail/widgets/avatar_card.dart | 123 +++++++++--------- 3 files changed, 76 insertions(+), 67 deletions(-) diff --git a/lib/page/plan/detail/other/done_stamp.dart b/lib/page/plan/detail/other/done_stamp.dart index ee15d89..5af0115 100644 --- a/lib/page/plan/detail/other/done_stamp.dart +++ b/lib/page/plan/detail/other/done_stamp.dart @@ -17,8 +17,7 @@ class _DoneStampState extends State { return Consumer( builder: (context, store, _) { //是否全部完成 - bool allDone = store.planDetail.stepsList.every((item) => item.stepStatus == 2); - if (!allDone || store.planDetail.stepsList.isEmpty) { + if (!store.isAllDone() ) { return Container(); } return Align( diff --git a/lib/page/plan/detail/viewmodel/plan_detail_store.dart b/lib/page/plan/detail/viewmodel/plan_detail_store.dart index 77b5cce..da8693d 100644 --- a/lib/page/plan/detail/viewmodel/plan_detail_store.dart +++ b/lib/page/plan/detail/viewmodel/plan_detail_store.dart @@ -46,6 +46,11 @@ class PlanDetailStore extends ChangeNotifier { ///计划详情 PlanDetailDto planDetail = PlanDetailDto(summary: "Plan Details"); + ///是否全部完成 + bool isAllDone() => + planDetail.stepsList.isNotEmpty && + planDetail.stepsList.every((item) => item.stepStatus == 2); + ///是否正在编辑 bool isEdit = false; @@ -56,7 +61,7 @@ class PlanDetailStore extends ChangeNotifier { } ///流请求工具 - StreamUtils streamUtils = StreamUtils(); + final StreamUtils _streamUtils = StreamUtils(); ///创建计划 void createPlan() async { @@ -65,7 +70,7 @@ class PlanDetailStore extends ChangeNotifier { ///生成摘要--------------------------- String summary = ""; - streamUtils.sendStream( + _streamUtils.sendStream( "/plan/make_summary", data: {"plan_id": planId}, onCall: (chunk) { @@ -79,7 +84,7 @@ class PlanDetailStore extends ChangeNotifier { /// 生成对白------------------------------- String dialog = ""; - await streamUtils.sendStream( + await _streamUtils.sendStream( "/plan/make_dialog", data: {"plan_id": planId}, onCall: (chunk) { @@ -92,7 +97,7 @@ class PlanDetailStore extends ChangeNotifier { ); /// 生成步骤------------------------------- - await streamUtils.sendStream( + await _streamUtils.sendStream( "/plan/make_step", data: {"plan_id": planId}, onCall: (chunk) { @@ -115,7 +120,7 @@ class PlanDetailStore extends ChangeNotifier { ); /// 生成步骤解释 ------------------------------- - await streamUtils.sendStream( + await _streamUtils.sendStream( "/plan/make_step_explain", data: { "plan_id": planId, @@ -137,7 +142,7 @@ class PlanDetailStore extends ChangeNotifier { ); /// 生成建议 ------------------ - await streamUtils.sendStream( + await _streamUtils.sendStream( "/plan/make_suggestion", data: { "plan_id": planId, diff --git a/lib/page/plan/detail/widgets/avatar_card.dart b/lib/page/plan/detail/widgets/avatar_card.dart index 6198534..64dc1a3 100644 --- a/lib/page/plan/detail/widgets/avatar_card.dart +++ b/lib/page/plan/detail/widgets/avatar_card.dart @@ -78,73 +78,78 @@ class _AvatarCardState extends State with SingleTickerProviderStateM @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 30), - child: Transform.translate( - offset: Offset(0, 50), - child: Column( - children: [ - BothSizeTransition( - animation: _animation, - offset: Offset(50, 50), - child: Container( - padding: EdgeInsets.only(bottom: 10), - child: InkWell( - onTap: _toggleShow, - child: Stack( - children: [ - Container( - width: double.infinity, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(3), - border: Border.all(color: Colors.black, width: 1), - ), - child: Text( - _dialog, - style: TextStyle(fontSize: 12), - textAlign: TextAlign.center, - ), + return Selector( + selector: (_, store) => store.isAllDone(), + builder: (context, isAllDone, _) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 30), + child: Transform.translate( + offset: Offset(0, 50), + child: Column( + children: [ + BothSizeTransition( + animation: _animation, + offset: Offset(50, 50), + child: Container( + padding: EdgeInsets.only(bottom: 10), + child: InkWell( + onTap: _toggleShow, + child: Stack( + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(3), + border: Border.all(color: Colors.black, width: 1), + ), + child: Text( + isAllDone ? "🎉 Great — you’ve completed everything! 🎉" : _dialog, + style: TextStyle(fontSize: 12), + textAlign: TextAlign.center, + ), + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: CustomPaint( + painter: BubblePainter(), + ), + ), + ], ), + ), + ), + ), + SizedBox( + width: double.infinity, + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + Image.asset("assets/image/kbn.png", height: 100), Positioned( - bottom: 0, - left: 0, - right: 0, - child: CustomPaint( - painter: BubblePainter(), + top: 20, + child: Transform.translate( + offset: Offset(40, -10), + child: GestureDetector( + onTap: _toggleShow, + child: BothSizeTransition( + animation: ReverseAnimation(_animation), + offset: Offset(-50, -50), + child: Icon(RemixIcons.message_2_line), + ), + ), ), ), ], ), ), - ), + ], ), - SizedBox( - width: double.infinity, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Image.asset("assets/image/kbn.png", height: 100), - Positioned( - top: 20, - child: Transform.translate( - offset: Offset(40, -10), - child: GestureDetector( - onTap: _toggleShow, - child: BothSizeTransition( - animation: ReverseAnimation(_animation), - offset: Offset(-50, -50), - child: Icon(RemixIcons.message_2_line), - ), - ), - ), - ), - ], - ), - ), - ], - ), - ), + ), + ); + }, ); } }