From 7b50ff0f78ffdf39f5111aa2ddbad3213c656edd Mon Sep 17 00:00:00 2001 From: tanghong668 <13926187239@163.com> Date: Tue, 28 Nov 2023 19:22:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=9F=A5=E8=AF=86=E7=82=B9?= =?UTF-8?q?=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/controllers/home_controller.dart | 33 ++++++---- lib/app/modules/home/views/explore_view.dart | 62 ++++++++++--------- lib/app/modules/home/views/home_view.dart | 2 +- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/lib/app/modules/home/controllers/home_controller.dart b/lib/app/modules/home/controllers/home_controller.dart index ebb83b4..1c9caf9 100644 --- a/lib/app/modules/home/controllers/home_controller.dart +++ b/lib/app/modules/home/controllers/home_controller.dart @@ -26,6 +26,7 @@ class HomeController extends GetxController { final chatMsgList = RxList([]); final scrollController = ScrollController(); final selectKnowledge = Rx(null); + final knowledgePoints = RxList>([]); late String account = ''; late int gender = 1; @@ -37,9 +38,7 @@ class HomeController extends GetxController { late List leftExploreApps = []; late List rightExploreApps = []; late List goals = []; - late List knowledgePoints = []; - - final int second = 5; + final int second = 3; StreamSubscription? subscription; @override @@ -50,7 +49,7 @@ class HomeController extends GetxController { age = SpUtil.getInt(Constant.age, defValue: 10)!; occupationName = SpUtil.getString(Constant.occupationName).nullSafe; occupationId = SpUtil.getInt(Constant.occupationId, defValue: 2)!; - create.value = SpUtil.getBool(Constant.create, defValue: true)!; + // create.value = SpUtil.getBool(Constant.create, defValue: true)!; initLeftExploreApps(); initRightExploreApps(); initArtistGoals(); @@ -91,17 +90,23 @@ class HomeController extends GetxController { void initKnowledgePoints() { knowledgePoints.add(KnowledgePoint( - id: 1, left: 559.0, top: 149.0, title: '钱是怎么形成的?', leared: false)); + id: 1, left: 559.0, top: 149.0, title: '钱是怎么形成的?', leared: false) + .obs); knowledgePoints.add(KnowledgePoint( - id: 2, right: 751.0, top: 198.0, title: '小实验溶解糖', leared: false)); + id: 2, right: 751.0, top: 198.0, title: '小实验溶解糖', leared: false) + .obs); knowledgePoints.add(KnowledgePoint( - id: 3, left: 632.0, top: 278.0, title: '科学家是怎么工作的?', leared: false)); + id: 3, left: 632.0, top: 278.0, title: '科学家是怎么工作的?', leared: false) + .obs); knowledgePoints.add(KnowledgePoint( - id: 4, left: 814.0, top: 376.0, title: '艺术家——梵高', leared: false)); + id: 4, left: 814.0, top: 376.0, title: '艺术家——梵高', leared: false) + .obs); knowledgePoints.add(KnowledgePoint( - id: 5, right: 696.0, top: 438.0, title: '什么是科学?', leared: false)); + id: 5, right: 696.0, top: 438.0, title: '什么是科学?', leared: false) + .obs); knowledgePoints.add(KnowledgePoint( - id: 6, left: 741.0, top: 499.0, title: '足球比赛规则', leared: false)); + id: 6, left: 741.0, top: 499.0, title: '足球比赛规则', leared: false) + .obs); } void initArtistGoals() { @@ -241,9 +246,11 @@ class HomeController extends GetxController { ); chatMsgList.add(chatMsg); - var knowledge = - knowledgePoints.firstWhere((t) => t.id == selectKnowledge.value!.id); - knowledge.leared = true; + var knowledge = knowledgePoints + .firstWhere((t) => t.value.id == selectKnowledge.value!.id); + knowledge.update((val) { + val!.leared = true; + }); selectKnowledge.update((val) { val!.leared = true; }); diff --git a/lib/app/modules/home/views/explore_view.dart b/lib/app/modules/home/views/explore_view.dart index cfdfe75..d11e1f1 100644 --- a/lib/app/modules/home/views/explore_view.dart +++ b/lib/app/modules/home/views/explore_view.dart @@ -159,41 +159,43 @@ class ExploreView extends GetView { } Widget buildKnowledge(BuildContext context) { - return Stack( - children: controller.knowledgePoints.map((e) { - return Positioned( - top: e.top!.h, - left: e.left != null ? e.left!.w : null, - right: e.right != null ? e.right!.w : null, - child: ConstrainedBox( - constraints: BoxConstraints(minWidth: 214.w, minHeight: 68.h), - child: GestureDetector( - onTap: () async { - await controller.leareKnowledge(e); - }, - child: Container( - padding: REdgeInsets.symmetric(horizontal: 9.0), - decoration: BoxDecoration( - image: DecorationImage( - image: e.leared! - ? Images.studyKnowledgePointPre - : Images.studyKnowledgePointDefault, - fit: BoxFit.fill, + return Obx( + () => Stack( + children: controller.knowledgePoints.map((e) { + return Positioned( + top: e.value.top!.h, + left: e.value.left != null ? e.value.left!.w : null, + right: e.value.right != null ? e.value.right!.w : null, + child: ConstrainedBox( + constraints: BoxConstraints(minWidth: 214.w, minHeight: 68.h), + child: GestureDetector( + onTap: () async { + await controller.leareKnowledge(e.value); + }, + child: Container( + padding: REdgeInsets.symmetric(horizontal: 9.0), + decoration: BoxDecoration( + image: DecorationImage( + image: e.value.leared! + ? Images.studyKnowledgePointPre + : Images.studyKnowledgePointDefault, + fit: BoxFit.fill, + ), ), - ), - child: Center( - child: Text( - e.title!, - style: e.leared! - ? TextStyles.boldWhiteShadow22_104 - : TextStyles.mediumColor22, + child: Center( + child: Text( + e.value.title!, + style: e.value.leared! + ? TextStyles.boldWhiteShadow22_104 + : TextStyles.mediumColor22, + ), ), ), ), ), - ), - ); - }).toList(), + ); + }).toList(), + ), ); } } diff --git a/lib/app/modules/home/views/home_view.dart b/lib/app/modules/home/views/home_view.dart index 26bd8f4..7af991a 100644 --- a/lib/app/modules/home/views/home_view.dart +++ b/lib/app/modules/home/views/home_view.dart @@ -529,7 +529,7 @@ class HomeView extends GetView { void showGoalDialog(Goal goal) { SmartDialog.show( - maskColor: const Color(0xFF02184B).withOpacity(0.8), + maskColor: const Color(0xFF02184B).withOpacity(0.7), alignment: Alignment.center, builder: (_) { return GoalDialog(