更新梦想树逻辑

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 exploreCount = 0.obs;
final chatMsgList = RxList<ChatMsg>([]); final chatMsgList = RxList<ChatMsg>([]);
final scrollController = ScrollController(); final scrollController = ScrollController();
final selectKnowledge = Rx<KnowledgePoint?>(null);
late String account = ''; late String account = '';
late int gender = 1; late int gender = 1;
@ -37,7 +38,6 @@ class HomeController extends GetxController {
late List<ExploreApp> rightExploreApps = []; late List<ExploreApp> rightExploreApps = [];
late List<Goal> goals = []; late List<Goal> goals = [];
late List<KnowledgePoint> knowledgePoints = []; late List<KnowledgePoint> knowledgePoints = [];
late KnowledgePoint selectKnowledge;
final int second = 5; final int second = 5;
StreamSubscription<dynamic>? subscription; StreamSubscription<dynamic>? subscription;
@ -93,7 +93,7 @@ class HomeController extends GetxController {
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));
knowledgePoints.add(KnowledgePoint( 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( 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));
knowledgePoints.add(KnowledgePoint( knowledgePoints.add(KnowledgePoint(
@ -221,11 +221,11 @@ class HomeController extends GetxController {
} }
Future leareKnowledge(KnowledgePoint knowledge) async { Future leareKnowledge(KnowledgePoint knowledge) async {
selectKnowledge = knowledge; selectKnowledge.value = knowledge;
chatMsgList.clear(); chatMsgList.clear();
chatMsgList.add(ChatMsg( chatMsgList.add(ChatMsg(
id: Guid.newGuid.toString(), id: Guid.newGuid.toString(),
knowledgeId: selectKnowledge.id, knowledgeId: knowledge.id,
isBot: 1, isBot: 1,
text: '探梦者,关于“${knowledge.title}”这个话题,你有什么想法或者疑问? 我们起交流吧!', text: '探梦者,关于“${knowledge.title}”这个话题,你有什么想法或者疑问? 我们起交流吧!',
)); ));
@ -237,8 +237,19 @@ class HomeController extends GetxController {
id: Guid.newGuid.toString(), id: Guid.newGuid.toString(),
text: txt, text: txt,
isBot: 0, isBot: 0,
knowledgeId: selectKnowledge.id, knowledgeId: selectKnowledge.value!.id,
); );
chatMsgList.add(chatMsg); 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( Center(
child: Text( child: Text(
controller.selectKnowledge.title!, controller.selectKnowledge.value!.title!,
style: TextStyles.boldWhiteShadow34_200, style: TextStyles.boldWhiteShadow34_200,
), ),
) )
@ -54,36 +54,40 @@ class ExploreStudyView extends GetView<HomeController> {
), ),
), ),
const RSizedBox(height: 10.0), const RSizedBox(height: 10.0),
Row( Obx(
mainAxisAlignment: MainAxisAlignment.center, () => Row(
children: [ mainAxisAlignment: MainAxisAlignment.center,
Container( children: [
width: 214.w, Container(
height: 63.h, width: 214.w,
decoration: BoxDecoration( height: 63.h,
image: DecorationImage( decoration: BoxDecoration(
image: controller.selectKnowledge.leared! image: DecorationImage(
? Images.studyKnowledgePre image: controller.selectKnowledge.value!.leared!
: Images.studyKnowledgeDefault, ? Images.studyKnowledgePre
fit: BoxFit.fill, : 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,
), ),
], ),
), 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( Flexible(
fit: FlexFit.tight, fit: FlexFit.tight,

View File

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

View File

@ -1,4 +1,3 @@
import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:flustars_flutter3/flustars_flutter3.dart'; 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:flutter_screenutil/flutter_screenutil.dart';
import 'package:keyboard_actions/keyboard_actions_config.dart'; import 'package:keyboard_actions/keyboard_actions_config.dart';
import 'package:keyboard_actions/keyboard_actions_item.dart'; import 'package:keyboard_actions/keyboard_actions_item.dart';
import 'package:pdf/widgets.dart' as pw;
import '../constants/constants.dart'; import '../constants/constants.dart';
import 'theme_utils.dart'; import 'theme_utils.dart';
class SavePdf {
pw.Document document;
String name;
String path;
SavePdf(this.document, this.name, this.path);
}
class Utils { 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, static String formatPrice(String price,
{MoneyFormat format = MoneyFormat.END_INTEGER}) { {MoneyFormat format = MoneyFormat.END_INTEGER}) {
return MoneyUtil.changeYWithUnit( return MoneyUtil.changeYWithUnit(
@ -88,11 +71,8 @@ Future<T?> showElasticDialog<T>({
); );
} }
Widget buildDialogTransitions( Widget buildDialogTransitions(BuildContext context, Animation<double> animation,
BuildContext context, Animation<double> secondaryAnimation, Widget child) {
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return FadeTransition( return FadeTransition(
opacity: CurvedAnimation( opacity: CurvedAnimation(
parent: animation, parent: animation,

View File

@ -17,14 +17,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.1.0" 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: async:
dependency: transitive dependency: transitive
description: description:
@ -33,22 +25,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.11.0" 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: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -177,14 +153,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "5.3.3" 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: easy_refresh:
dependency: "direct main" dependency: "direct main"
description: description:
@ -309,14 +277,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.0.2" 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: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@ -325,14 +285,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.18.1" 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: keyboard_actions:
dependency: "direct main" dependency: "direct main"
description: description:
@ -469,22 +421,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.2.1" 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: platform:
dependency: transitive dependency: transitive
description: description:
@ -501,14 +437,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.6" 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: qiniu_flutter_sdk:
dependency: "direct main" dependency: "direct main"
description: description:
@ -525,14 +453,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.5.0" 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: rational:
dependency: transitive dependency: transitive
description: description:
@ -635,7 +555,7 @@ packages:
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
sp_util: sp_util:
dependency: "direct main" dependency: transitive
description: description:
name: sp_util name: sp_util
sha256: "9da43dce5de79c17a787d0626bf01538d63090ca32521200d22a232171c495dc" sha256: "9da43dce5de79c17a787d0626bf01538d63090ca32521200d22a232171c495dc"
@ -762,14 +682,6 @@ packages:
url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/" url: "https://mirrors.sjtug.sjtu.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.0.3" 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: sdks:
dart: ">=3.1.0-185.0.dev <4.0.0" dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.13.0" flutter: ">=3.13.0"

View File

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