Compare commits

...

2 Commits

Author SHA1 Message Date
8c51f9c9b2 Merge remote-tracking branch 'origin/master' into yuanjunyao_dev
# Conflicts:
#	lib/app/modules/home/controllers/home_controller.dart
2023-11-28 21:22:12 +08:00
tanghong668
7b50ff0f78 修正知识点亮 2023-11-28 19:23:08 +08:00
3 changed files with 53 additions and 44 deletions

View File

@ -30,6 +30,7 @@ class HomeController extends GetxController {
final chatMsgList = RxList<ChatMsg>([]); final chatMsgList = RxList<ChatMsg>([]);
final scrollController = ScrollController(); final scrollController = ScrollController();
final selectKnowledge = Rx<KnowledgePoint?>(null); final selectKnowledge = Rx<KnowledgePoint?>(null);
final knowledgePoints = RxList<Rx<KnowledgePoint>>([]);
late String account = ''; late String account = '';
late int gender = 1; late int gender = 1;
@ -41,9 +42,7 @@ class HomeController extends GetxController {
late List<ExploreApp> leftExploreApps = []; late List<ExploreApp> leftExploreApps = [];
late List<ExploreApp> rightExploreApps = []; late List<ExploreApp> rightExploreApps = [];
late List<Goal> goals = []; late List<Goal> goals = [];
late List<KnowledgePoint> knowledgePoints = []; final int second = 3;
final int second = 5;
StreamSubscription<dynamic>? subscription; StreamSubscription<dynamic>? subscription;
@override @override
@ -54,7 +53,7 @@ class HomeController extends GetxController {
age = SpUtil.getInt(Constant.age, defValue: 10)!; age = SpUtil.getInt(Constant.age, defValue: 10)!;
occupationName = SpUtil.getString(Constant.occupationName).nullSafe; occupationName = SpUtil.getString(Constant.occupationName).nullSafe;
occupationId = SpUtil.getInt(Constant.occupationId, defValue: 2)!; occupationId = SpUtil.getInt(Constant.occupationId, defValue: 2)!;
create.value = SpUtil.getBool(Constant.create, defValue: true)!; // create.value = SpUtil.getBool(Constant.create, defValue: true)!;
initLeftExploreApps(); initLeftExploreApps();
initRightExploreApps(); initRightExploreApps();
initArtistGoals(); initArtistGoals();
@ -95,17 +94,23 @@ class HomeController extends GetxController {
void initKnowledgePoints() { void initKnowledgePoints() {
knowledgePoints.add(KnowledgePoint( 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( 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( 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( 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( 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( 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() { void initArtistGoals() {
@ -297,9 +302,11 @@ class HomeController extends GetxController {
scrollController.jumpTo(scrollController.position.maxScrollExtent); scrollController.jumpTo(scrollController.position.maxScrollExtent);
}); });
var knowledge = var knowledge = knowledgePoints
knowledgePoints.firstWhere((t) => t.id == selectKnowledge.value!.id); .firstWhere((t) => t.value.id == selectKnowledge.value!.id);
knowledge.leared = true; knowledge.update((val) {
val!.leared = true;
});
selectKnowledge.update((val) { selectKnowledge.update((val) {
val!.leared = true; val!.leared = true;
}); });

View File

@ -159,23 +159,24 @@ class ExploreView extends GetView<HomeController> {
} }
Widget buildKnowledge(BuildContext context) { Widget buildKnowledge(BuildContext context) {
return Stack( return Obx(
() => Stack(
children: controller.knowledgePoints.map((e) { children: controller.knowledgePoints.map((e) {
return Positioned( return Positioned(
top: e.top!.h, top: e.value.top!.h,
left: e.left != null ? e.left!.w : null, left: e.value.left != null ? e.value.left!.w : null,
right: e.right != null ? e.right!.w : null, right: e.value.right != null ? e.value.right!.w : null,
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(minWidth: 214.w, minHeight: 68.h), constraints: BoxConstraints(minWidth: 214.w, minHeight: 68.h),
child: GestureDetector( child: GestureDetector(
onTap: () async { onTap: () async {
await controller.leareKnowledge(e); await controller.leareKnowledge(e.value);
}, },
child: Container( child: Container(
padding: REdgeInsets.symmetric(horizontal: 9.0), padding: REdgeInsets.symmetric(horizontal: 9.0),
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: e.leared! image: e.value.leared!
? Images.studyKnowledgePointPre ? Images.studyKnowledgePointPre
: Images.studyKnowledgePointDefault, : Images.studyKnowledgePointDefault,
fit: BoxFit.fill, fit: BoxFit.fill,
@ -183,8 +184,8 @@ class ExploreView extends GetView<HomeController> {
), ),
child: Center( child: Center(
child: Text( child: Text(
e.title!, e.value.title!,
style: e.leared! style: e.value.leared!
? TextStyles.boldWhiteShadow22_104 ? TextStyles.boldWhiteShadow22_104
: TextStyles.mediumColor22, : TextStyles.mediumColor22,
), ),
@ -194,6 +195,7 @@ class ExploreView extends GetView<HomeController> {
), ),
); );
}).toList(), }).toList(),
),
); );
} }
} }

View File

@ -549,7 +549,7 @@ class HomeView extends GetView<HomeController> {
void showGoalDialog(Goal goal) { void showGoalDialog(Goal goal) {
SmartDialog.show( SmartDialog.show(
maskColor: const Color(0xFF02184B).withOpacity(0.8), maskColor: const Color(0xFF02184B).withOpacity(0.7),
alignment: Alignment.center, alignment: Alignment.center,
builder: (_) { builder: (_) {
return GoalDialog( return GoalDialog(