dreampad/lib/app/modules/home/views/explore_study_view.dart

142 lines
4.2 KiB
Dart
Raw Permalink Normal View History

2023-11-28 10:44:58 +08:00
import 'package:dreampad/app/modules/home/models/chat_msg_model.dart';
import 'package:dreampad/app/shared/shared.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
import '../widgets/chat_input_widget.dart';
import '../widgets/receive_message_widget.dart';
import '../widgets/send_message_widget.dart';
class ExploreStudyView extends GetView<HomeController> {
const ExploreStudyView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: Images.studyKnowledgeBg,
fit: BoxFit.fill,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: buildBody(context),
),
),
);
}
Widget buildBody(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.max,
children: [
const RSizedBox(height: 22.0),
Container(
height: 78.h,
padding: REdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0),
child: Stack(
children: [
MyBackButton(
onPressed: () {
Get.back();
},
),
Center(
child: Text(
2023-11-28 15:44:41 +08:00
controller.selectKnowledge.value!.title!,
2023-11-28 10:44:58 +08:00
style: TextStyles.boldWhiteShadow34_200,
),
)
],
),
),
const RSizedBox(height: 10.0),
2023-11-28 15:44:41 +08:00
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,
2023-11-28 10:44:58 +08:00
),
2023-11-28 15:44:41 +08:00
),
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,
),
],
),
)
],
),
2023-11-28 10:44:58 +08:00
),
Flexible(
fit: FlexFit.tight,
child: Container(
padding: REdgeInsets.only(
left: 45.0,
top: 10.0,
right: 45.0,
),
child: buildMsgList(context),
),
),
ChatInputWidget(
onPressed: (txt) {
controller.addSendMsg(txt);
},
),
],
);
}
Widget buildMsgList(BuildContext context) {
return Obx(
() => ListView.builder(
shrinkWrap: true,
itemCount: controller.chatMsgList.length,
controller: controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (_, int index) {
ChatMsg chat = controller.chatMsgList[index];
if (chat.isBot == 1) {
return ReceiveMessageWidget(
'AI小助手',
Images.avatar,
child: Text(
chat.text!,
style: TextStyles.mediumGray3315,
),
);
} else {
return SendMessageWidget(
chat.text!,
controller.account,
Images.avatarUser,
);
}
},
),
);
}
}