|
|
@@ -1,16 +1,19 @@
|
|
|
import 'package:electronic_assistant/base/base_page.dart';
|
|
|
+import 'package:electronic_assistant/data/bean/talks.dart';
|
|
|
import 'package:electronic_assistant/resource/assets.gen.dart';
|
|
|
import 'package:electronic_assistant/resource/colors.gen.dart';
|
|
|
import 'package:electronic_assistant/resource/string.gen.dart';
|
|
|
import 'package:electronic_assistant/utils/expand.dart';
|
|
|
import 'package:electronic_assistant/utils/toast_util.dart';
|
|
|
-import 'package:flutter/gestures.dart';
|
|
|
+import 'package:electronic_assistant/widget/pull_to_refresh.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
+import '../../data/bean/agenda.dart';
|
|
|
import '../../router/app_pages.dart';
|
|
|
+import '../task/task_item_view.dart';
|
|
|
import 'controller.dart';
|
|
|
|
|
|
class HomePage extends BasePage<HomePageController> {
|
|
|
@@ -33,21 +36,33 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
child: buildOperationBar(),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: CustomScrollView(
|
|
|
- slivers: [
|
|
|
- buildTalkRecordTitle(),
|
|
|
- SliverToBoxAdapter(
|
|
|
- child: Container(
|
|
|
- height: 0.3111.sw,
|
|
|
- margin: EdgeInsets.only(bottom: 15.h),
|
|
|
- child: buildTalkRecord(),
|
|
|
+ child: PullToRefresh(
|
|
|
+ enableRefresh: true,
|
|
|
+ controller: controller.refreshController,
|
|
|
+ onRefresh: () {
|
|
|
+ controller.requestHomeData();
|
|
|
+ },
|
|
|
+ child: CustomScrollView(
|
|
|
+ slivers: [
|
|
|
+ buildTalkRecordTitle(),
|
|
|
+ SliverToBoxAdapter(
|
|
|
+ child: Container(
|
|
|
+ height: 0.3111.sw,
|
|
|
+ margin: EdgeInsets.only(bottom: 15.h),
|
|
|
+ child: buildTalkRecord(),
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- buildTalkTodoTitle(),
|
|
|
- SliverAnimatedList(
|
|
|
- itemBuilder: _buildTodoItem, initialItemCount: 20),
|
|
|
- buildSeeMoreView(),
|
|
|
- ],
|
|
|
+ buildTalkTodoTitle(),
|
|
|
+ SliverAnimatedList(
|
|
|
+ key: controller.agendaList.listKey,
|
|
|
+ itemBuilder: (context, index, animation) {
|
|
|
+ return _buildInsertTodoItem(context, index, animation,
|
|
|
+ controller.agendaList.items[index]);
|
|
|
+ },
|
|
|
+ initialItemCount: controller.agendaList.length),
|
|
|
+ buildSeeMoreView(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
))
|
|
|
],
|
|
|
),
|
|
|
@@ -66,23 +81,24 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
child: Container(
|
|
|
alignment: Alignment.center,
|
|
|
padding: const EdgeInsets.only(top: 12, bottom: 36).w,
|
|
|
- child: RichText(
|
|
|
- text: TextSpan(
|
|
|
- text: StringName.homeTalkTodo1.tr,
|
|
|
- style:
|
|
|
- TextStyle(color: ColorName.secondaryTextColor, fontSize: 12.sp),
|
|
|
- children: <TextSpan>[
|
|
|
- TextSpan(
|
|
|
- text: StringName.homeTalkTodo2.tr,
|
|
|
- style:
|
|
|
- TextStyle(color: ColorName.colorPrimary, fontSize: 12.sp),
|
|
|
- recognizer: TapGestureRecognizer()
|
|
|
- ..onTap = () {
|
|
|
- ToastUtil.showToast('点击了全部');
|
|
|
- }),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+
|
|
|
+ // child: RichText(
|
|
|
+ // text: TextSpan(
|
|
|
+ // text: StringName.homeTalkTodo1.tr,
|
|
|
+ // style:
|
|
|
+ // TextStyle(color: ColorName.secondaryTextColor, fontSize: 12.sp),
|
|
|
+ // children: <TextSpan>[
|
|
|
+ // TextSpan(
|
|
|
+ // text: StringName.homeTalkTodo2.tr,
|
|
|
+ // style:
|
|
|
+ // TextStyle(color: ColorName.colorPrimary, fontSize: 12.sp),
|
|
|
+ // recognizer: TapGestureRecognizer()
|
|
|
+ // ..onTap = () {
|
|
|
+ // ToastUtil.showToast('点击了全部');
|
|
|
+ // }),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
@@ -92,9 +108,10 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
child: Column(
|
|
|
children: [
|
|
|
SizedBox(height: 9.w),
|
|
|
- buildTitle(StringName.homeTalkTodoTitle.tr, () {
|
|
|
- ToastUtil.showToast('待办事项 查看全部');
|
|
|
- }),
|
|
|
+ // buildTitle(StringName.homeTalkTodoTitle.tr, () {
|
|
|
+ // Get.toNamed(RoutePath.task);
|
|
|
+ // }),
|
|
|
+ buildTitle(StringName.homeTalkTodoTitle.tr, null),
|
|
|
SizedBox(height: 12.w)
|
|
|
],
|
|
|
));
|
|
|
@@ -215,7 +232,13 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
slivers: [
|
|
|
SliverToBoxAdapter(child: SizedBox(width: 12.w)),
|
|
|
buildGoRecordView(),
|
|
|
- SliverAnimatedList(itemBuilder: _buildTalkItem, initialItemCount: 10)
|
|
|
+ SliverAnimatedList(
|
|
|
+ key: controller.taskList.listKey,
|
|
|
+ itemBuilder: (context, index, animation) {
|
|
|
+ return _buildInsertTalkItem(context, index, animation,
|
|
|
+ controller.taskList.items[index]);
|
|
|
+ },
|
|
|
+ initialItemCount: controller.taskList.length),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
@@ -280,50 +303,15 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- Widget _buildTodoItem(
|
|
|
- BuildContext context, int index, Animation<double> animation) {
|
|
|
- return Container(
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 17).w,
|
|
|
- margin: const EdgeInsets.only(left: 12, right: 12, bottom: 8).w,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- ),
|
|
|
- child: Row(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- children: [
|
|
|
- SizedBox(
|
|
|
- width: 20.w,
|
|
|
- height: 20.w,
|
|
|
- child: Assets.images.iconAgentChecked.image()),
|
|
|
- SizedBox(width: 8.w),
|
|
|
- Text('今天要完成某项任务',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 15.sp,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- color: ColorName.primaryTextColor)),
|
|
|
- const Spacer(),
|
|
|
- Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- gradient: LinearGradient(
|
|
|
- colors: ['#9075FF'.toColor(), '#4366FF'.toColor()],
|
|
|
- stops: const [0.3, 1.0],
|
|
|
- ),
|
|
|
- borderRadius: BorderRadius.circular(6),
|
|
|
- ),
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4).w,
|
|
|
- child: Text(
|
|
|
- StringName.homeTalkThinking.tr,
|
|
|
- style: TextStyle(fontSize: 13.sp, color: ColorName.white),
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
+ Widget _buildInsertTalkItem(BuildContext context, int index,
|
|
|
+ Animation<double> animation, TalkBean item) {
|
|
|
+ return FadeTransition(
|
|
|
+ opacity: animation,
|
|
|
+ child: _buildTalkView(item),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildTalkItem(
|
|
|
- BuildContext context, int index, Animation<double> animation) {
|
|
|
+ Widget _buildTalkView(TalkBean item) {
|
|
|
return Container(
|
|
|
width: 258.w,
|
|
|
margin: EdgeInsets.only(right: 8.w),
|
|
|
@@ -340,19 +328,24 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
children: [
|
|
|
Row(
|
|
|
children: [
|
|
|
- Container(
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 6).w,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: '#DFE4FC'.toColor(),
|
|
|
- borderRadius: BorderRadius.circular(4),
|
|
|
- ),
|
|
|
- child: Text(
|
|
|
- StringName.homeTalkExample.tr,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 12.sp, color: ColorName.colorPrimary),
|
|
|
- )),
|
|
|
+ Visibility(
|
|
|
+ visible: item.isExample.isTrue,
|
|
|
+ child: Container(
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 6).w,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: '#DFE4FC'.toColor(),
|
|
|
+ borderRadius: BorderRadius.circular(4),
|
|
|
+ ),
|
|
|
+ child: Text(
|
|
|
+ StringName.homeTalkExample.tr,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.sp, color: ColorName.colorPrimary),
|
|
|
+ )),
|
|
|
+ ),
|
|
|
SizedBox(width: 6.w),
|
|
|
- Text('与吴总张总沟通活动策划',
|
|
|
+ Text(item.title.orEmpty,
|
|
|
+ maxLines: 1,
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
style: TextStyle(
|
|
|
fontSize: 15.sp,
|
|
|
color: ColorName.colorPrimary,
|
|
|
@@ -361,23 +354,24 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
),
|
|
|
SizedBox(height: 5.h),
|
|
|
Text(
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 12.sp, color: ColorName.secondaryTextColor),
|
|
|
- overflow: TextOverflow.ellipsis,
|
|
|
- maxLines: 2,
|
|
|
- '这个群,现在由我管理。目的是把你们训练成一个个社会高薪人士,从本周起,已经个个社会高薪人士,从本周起,已经个个社会高薪人士,从本周起,已经'),
|
|
|
+ item.summary.orEmpty,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.sp, color: ColorName.secondaryTextColor),
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
+ maxLines: 2,
|
|
|
+ ),
|
|
|
SizedBox(height: 8.h),
|
|
|
Row(
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
children: [
|
|
|
- Text('1m12s',
|
|
|
+ Text(item.duration.toFormattedDuration(),
|
|
|
style: TextStyle(
|
|
|
fontSize: 12.sp, color: ColorName.tertiaryTextColor)),
|
|
|
SizedBox(width: 6.w),
|
|
|
Container(
|
|
|
width: 1, height: 9, color: ColorName.tertiaryTextColor),
|
|
|
SizedBox(width: 6.w),
|
|
|
- Text('2024-04-15 10:04',
|
|
|
+ Text(item.createTime.orEmpty,
|
|
|
style: TextStyle(
|
|
|
fontSize: 12.sp, color: ColorName.tertiaryTextColor))
|
|
|
],
|
|
|
@@ -386,7 +380,33 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- Widget buildTitle(String titleName, VoidCallback onTap) {
|
|
|
+ Widget _buildInsertTodoItem(BuildContext context, int index,
|
|
|
+ Animation<double> animation, Agenda item) {
|
|
|
+ HomePageController controller = Get.find();
|
|
|
+ return SlideTransition(
|
|
|
+ position: animation.drive(
|
|
|
+ Tween<Offset>(
|
|
|
+ begin: const Offset(0, 0.1),
|
|
|
+ end: Offset.zero,
|
|
|
+ ).chain(CurveTween(curve: Curves.easeInOut)),
|
|
|
+ ),
|
|
|
+ child: FadeTransition(
|
|
|
+ opacity: animation,
|
|
|
+ child: taskItemView(item, onCheckClick: () {
|
|
|
+ controller.agendaList.remove(
|
|
|
+ index,
|
|
|
+ (context, animation, item) =>
|
|
|
+ _buildRemoveTodoItem(context, index, animation, item));
|
|
|
+ }),
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildRemoveTodoItem(BuildContext context, int index,
|
|
|
+ Animation<double> animation, Agenda item) {
|
|
|
+ return SizeTransition(sizeFactor: animation, child: taskItemView(item));
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget buildTitle(String titleName, VoidCallback? onTap) {
|
|
|
return Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12).w,
|
|
|
child: Row(
|
|
|
@@ -398,23 +418,26 @@ class HomePage extends BasePage<HomePageController> {
|
|
|
fontSize: 17.sp,
|
|
|
color: ColorName.primaryTextColor)),
|
|
|
const Spacer(),
|
|
|
- GestureDetector(
|
|
|
- onTap: onTap,
|
|
|
- child: Padding(
|
|
|
- padding: const EdgeInsets.symmetric(vertical: 6).w,
|
|
|
- child: Row(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- StringName.homeTalkSeeAll.tr,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 13.sp, color: ColorName.secondaryTextColor),
|
|
|
- ),
|
|
|
- SizedBox(
|
|
|
- width: 16.w,
|
|
|
- height: 16.w,
|
|
|
- child: Assets.images.iconHomeTalkArrow.image()),
|
|
|
- ],
|
|
|
+ Visibility(
|
|
|
+ visible: onTap == null ? false : true,
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: onTap,
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.symmetric(vertical: 6).w,
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ StringName.homeTalkSeeAll.tr,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 13.sp, color: ColorName.secondaryTextColor),
|
|
|
+ ),
|
|
|
+ SizedBox(
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w,
|
|
|
+ child: Assets.images.iconHomeTalkArrow.image()),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
)
|