更新梦想树逻辑

This commit is contained in:
tanghong668 2023-11-28 15:44:41 +08:00
parent e108665408
commit 10e99e64d5
6 changed files with 174 additions and 253 deletions

View File

@ -25,6 +25,7 @@ class HomeController extends GetxController {
final exploreCount = 0.obs;
final chatMsgList = RxList<ChatMsg>([]);
final scrollController = ScrollController();
final selectKnowledge = Rx<KnowledgePoint?>(null);
late String account = '';
late int gender = 1;
@ -37,7 +38,6 @@ class HomeController extends GetxController {
late List<ExploreApp> rightExploreApps = [];
late List<Goal> goals = [];
late List<KnowledgePoint> knowledgePoints = [];
late KnowledgePoint selectKnowledge;
final int second = 5;
StreamSubscription<dynamic>? subscription;
@ -93,7 +93,7 @@ class HomeController extends GetxController {
knowledgePoints.add(KnowledgePoint(
id: 1, left: 559.0, top: 149.0, title: '钱是怎么形成的?', leared: false));
knowledgePoints.add(KnowledgePoint(
id: 2, right: 751.0, top: 198.0, title: '小实验溶解糖', leared: true));
id: 2, right: 751.0, top: 198.0, title: '小实验溶解糖', leared: false));
knowledgePoints.add(KnowledgePoint(
id: 3, left: 632.0, top: 278.0, title: '科学家是怎么工作的?', leared: false));
knowledgePoints.add(KnowledgePoint(
@ -221,11 +221,11 @@ class HomeController extends GetxController {
}
Future leareKnowledge(KnowledgePoint knowledge) async {
selectKnowledge = knowledge;
selectKnowledge.value = knowledge;
chatMsgList.clear();
chatMsgList.add(ChatMsg(
id: Guid.newGuid.toString(),
knowledgeId: selectKnowledge.id,
knowledgeId: knowledge.id,
isBot: 1,
text: '探梦者,关于“${knowledge.title}”这个话题,你有什么想法或者疑问? 我们起交流吧!',
));
@ -237,8 +237,19 @@ class HomeController extends GetxController {
id: Guid.newGuid.toString(),
text: txt,
isBot: 0,
knowledgeId: selectKnowledge.id,
knowledgeId: selectKnowledge.value!.id,
);
chatMsgList.add(chatMsg);
var knowledge =
knowledgePoints.firstWhere((t) => t.id == selectKnowledge.value!.id);
knowledge.leared = true;
selectKnowledge.update((val) {
val!.leared = true;
});
exploreCount.value++;
if (exploreCount.value >= 2) {
explored.value = true;
}
}
}

View File

@ -46,7 +46,7 @@ class ExploreStudyView extends GetView<HomeController> {
),
Center(
child: Text(
controller.selectKnowledge.title!,
controller.selectKnowledge.value!.title!,
style: TextStyles.boldWhiteShadow34_200,
),
)
@ -54,36 +54,40 @@ class ExploreStudyView extends GetView<HomeController> {
),
),
const RSizedBox(height: 10.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 214.w,
height: 63.h,
decoration: BoxDecoration(
image: DecorationImage(
image: controller.selectKnowledge.leared!
? Images.studyKnowledgePre
: Images.studyKnowledgeDefault,
fit: BoxFit.fill,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
controller.selectKnowledge.leared!
? Images.studyIllumePre
: Images.studyIllumeDefault,
const RSizedBox(width: 4.0),
Text(
controller.selectKnowledge.leared! ? '已点亮知识点' : '点亮知识点',
style: TextStyles.mediumWhite20,
Obx(
() => Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 214.w,
height: 63.h,
decoration: BoxDecoration(
image: DecorationImage(
image: controller.selectKnowledge.value!.leared!
? Images.studyKnowledgePre
: Images.studyKnowledgeDefault,
fit: BoxFit.fill,
),
],
),
)
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
controller.selectKnowledge.value!.leared!
? Images.studyIllumePre
: Images.studyIllumeDefault,
const RSizedBox(width: 4.0),
Text(
controller.selectKnowledge.value!.leared!
? '已点亮知识点'
: '点亮知识点',
style: TextStyles.mediumWhite20,
),
],
),
)
],
),
),
Flexible(
fit: FlexFit.tight,

View File

@ -100,12 +100,14 @@ class HomeView extends GetView<HomeController> {
),
controller.prompt.value
? Container()
: Positioned(
right: 49.w,
top: 50.h,
child: ExploreWidget(
explored: controller.explored.value,
exploreCount: controller.exploreCount.value,
: Obx(
() => Positioned(
right: 49.w,
top: 50.h,
child: ExploreWidget(
explored: controller.explored.value,
exploreCount: controller.exploreCount.value,
),
),
),
controller.prompt.value
@ -155,42 +157,48 @@ class HomeView extends GetView<HomeController> {
Widget goalWidget() {
return Stack(
children: [
controller.explored.value
? Positioned(
left: 15.w,
top: 20.h,
child: Container(
height: 311.h,
width: 230.w,
color: Colors.transparent,
child: fourthGoalWidget(),
),
)
: Container(),
controller.explored.value
? Positioned(
left: 352.w,
top: 0.0,
child: Container(
height: 221.h,
width: 281.w,
color: Colors.transparent,
child: thirdGoalWidget(),
),
)
: Container(),
controller.explored.value
? Positioned(
left: 363.w,
top: 180.h,
child: Container(
height: 240.h,
width: 240.w,
color: Colors.transparent,
child: secondGoalWidget(),
),
)
: Container(),
Obx(
() => controller.explored.value
? Positioned(
left: 15.w,
top: 20.h,
child: Container(
height: 311.h,
width: 230.w,
color: Colors.transparent,
child: fourthGoalWidget(),
),
)
: Container(),
),
Obx(
() => controller.explored.value
? Positioned(
left: 352.w,
top: 0.0,
child: Container(
height: 221.h,
width: 281.w,
color: Colors.transparent,
child: thirdGoalWidget(),
),
)
: Container(),
),
Obx(
() => controller.explored.value
? Positioned(
left: 363.w,
top: 180.h,
child: Container(
height: 240.h,
width: 240.w,
color: Colors.transparent,
child: secondGoalWidget(),
),
)
: Container(),
),
],
);
}
@ -439,54 +447,60 @@ class HomeView extends GetView<HomeController> {
),
),
),
controller.explored.value
? Positioned(
left: 15.w,
top: 20.h,
child: Container(
height: 311.h,
width: 230.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeFourthLeaf,
fit: BoxFit.fill,
Obx(
() => controller.explored.value
? Positioned(
left: 15.w,
top: 20.h,
child: Container(
height: 311.h,
width: 230.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeFourthLeaf,
fit: BoxFit.fill,
),
),
),
),
)
: Container(),
controller.explored.value
? Positioned(
left: 352.w,
top: 0.0,
child: Container(
height: 221.h,
width: 281.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeThirdLeaf,
fit: BoxFit.fill,
)
: Container(),
),
Obx(
() => controller.explored.value
? Positioned(
left: 352.w,
top: 0.0,
child: Container(
height: 221.h,
width: 281.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeThirdLeaf,
fit: BoxFit.fill,
),
),
),
),
)
: Container(),
controller.explored.value
? Positioned(
left: 363.w,
top: 180.h,
child: Container(
height: 240.h,
width: 240.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeSecondLeaf,
fit: BoxFit.fill,
)
: Container(),
),
Obx(
() => controller.explored.value
? Positioned(
left: 363.w,
top: 180.h,
child: Container(
height: 240.h,
width: 240.w,
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.homeSecondLeaf,
fit: BoxFit.fill,
),
),
),
),
)
: Container(),
)
: Container(),
),
controller.prompt.value ? Container() : firstLeafWidget(),
Positioned(
left: 168.w,
@ -557,9 +571,11 @@ class HomeView extends GetView<HomeController> {
Positioned(
left: 23.w,
top: 26.h,
child: Text(
'本月已点亮0个知识点',
style: TextStyles.mediumWhiteShadow12_111,
child: Obx(
() => Text(
'本月已点亮${controller.exploreCount.value}个知识点',
style: TextStyles.mediumWhiteShadow12_111,
),
),
),
],
@ -605,21 +621,23 @@ class HomeView extends GetView<HomeController> {
onTap: () {
if (controller.explored.value) {}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LoadAssetImage(
'home/${controller.explored.value ? app.icon : app.grayIcon}',
height: 74.w,
width: 74.w,
fit: BoxFit.fill,
),
const RSizedBox(height: 2),
Text(
app.name!,
style: TextStyles.boldWhite16,
)
],
child: Obx(
() => Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LoadAssetImage(
'home/${controller.explored.value ? app.icon : app.grayIcon}',
height: 74.w,
width: 74.w,
fit: BoxFit.fill,
),
const RSizedBox(height: 2),
Text(
app.name!,
style: TextStyles.boldWhite16,
)
],
),
),
),
);

View File

@ -1,4 +1,3 @@
import 'dart:io';
import 'dart:ui';
import 'package:flustars_flutter3/flustars_flutter3.dart';
@ -6,27 +5,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:keyboard_actions/keyboard_actions_config.dart';
import 'package:keyboard_actions/keyboard_actions_item.dart';
import 'package:pdf/widgets.dart' as pw;
import '../constants/constants.dart';
import 'theme_utils.dart';
class SavePdf {
pw.Document document;
String name;
String path;
SavePdf(this.document, this.name, this.path);
}
class Utils {
static Future<String> savePdf(SavePdf pdf) async {
var filePath = "${pdf.path}/${pdf.name}.pdf";
final file = File(filePath);
await file.writeAsBytes(await pdf.document.save());
return filePath;
}
static String formatPrice(String price,
{MoneyFormat format = MoneyFormat.END_INTEGER}) {
return MoneyUtil.changeYWithUnit(
@ -88,11 +71,8 @@ Future<T?> showElasticDialog<T>({
);
}
Widget buildDialogTransitions(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
Widget buildDialogTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return FadeTransition(
opacity: CurvedAnimation(
parent: animation,

View File

@ -17,14 +17,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "1.1.0"
archive:
dependency: transitive
description:
name: archive
sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "3.4.6"
async:
dependency: transitive
description:
@ -33,22 +25,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.11.0"
barcode:
dependency: transitive
description:
name: barcode
sha256: "789f898eef0bd88312470bdb2cc996f895ad7dd5f89e9adde84b204546a90b45"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.2.4"
bidi:
dependency: transitive
description:
name: bidi
sha256: "1a7d0c696324b2089f72e7671fd1f1f64fef44c980f3cebc84e803967c597b63"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.0.10"
boolean_selector:
dependency: transitive
description:
@ -177,14 +153,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "5.3.3"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.3.9"
easy_refresh:
dependency: "direct main"
description:
@ -309,14 +277,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "4.0.2"
image:
dependency: transitive
description:
name: image
sha256: "028f61960d56f26414eb616b48b04eb37d700cbe477b7fb09bf1d7ce57fd9271"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "4.1.3"
intl:
dependency: "direct main"
description:
@ -325,14 +285,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "0.18.1"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "0.6.7"
keyboard_actions:
dependency: "direct main"
description:
@ -469,22 +421,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.2.1"
pdf:
dependency: "direct main"
description:
name: pdf
sha256: "9f75fc7f5580ea5e635b5724de58fb27f684c9ad03ed46fdc1aac768e4557315"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "3.10.4"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "5.4.0"
platform:
dependency: transitive
description:
@ -501,14 +437,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "2.1.6"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "3.7.3"
qiniu_flutter_sdk:
dependency: "direct main"
description:
@ -525,14 +453,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "0.5.0"
qr:
dependency: transitive
description:
name: qr
sha256: "64957a3930367bf97cc211a5af99551d630f2f4625e38af10edd6b19131b64b3"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "3.0.1"
rational:
dependency: transitive
description:
@ -635,7 +555,7 @@ packages:
source: hosted
version: "1.10.0"
sp_util:
dependency: "direct main"
dependency: transitive
description:
name: sp_util
sha256: "9da43dce5de79c17a787d0626bf01538d63090ca32521200d22a232171c495dc"
@ -762,14 +682,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "1.0.3"
xml:
dependency: transitive
description:
name: xml
sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.13.0"

View File

@ -1,5 +1,5 @@
name: dreampad
version: 1.1.4
version: 0.1.1
publish_to: none
description: Dream Pad.
environment:
@ -17,8 +17,6 @@ dependencies:
device_info_plus: 8.1.0
# Dart 常用工具类库 https://github.com/Sky24n/common_utils
common_utils: 2.1.0
sp_util: 2.0.3
# Flutter 常用工具类库 https://github.com/mdddj/flustars
flustars_flutter3: ^3.0.0
# 数据库 https://github.com/tekartik/sqflite
sqflite: ^2.0.1
@ -28,10 +26,8 @@ dependencies:
flutter_guid: ^0.3.1
animated_text_kit: ^4.2.2
flutter_smart_dialog: ^4.9.4
dropdown_button2: ^2.3.8
bubble_box: ^0.5.3
flutter_screenutil: ^5.9.0
pdf: ^3.10.4
easy_refresh: ^3.3.2+1
scrollview_observer: ^1.16.5
qiniu_flutter_sdk: ^0.5.0