123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import '../../../../common/models/index.dart';
- import '../../../../common/style/index.dart';
- import 'index.dart';
- class OfficeCenterPage extends GetView<OfficeCenterController> {
- const OfficeCenterPage({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return GetBuilder<OfficeCenterController>(
- builder: (_) {
- return Scaffold(
- appBar: AppBar(
- title: Obx(() => Text(controller.state.title)),
- actions: [
- Obx(() {
- final len = controller.state.taskSelectedList.length;
- return Visibility(
- visible: len > 0,
- child: TextButton(
- onPressed: () => controller.gotoQuickProcess(),
- child: Text('process_task_quick_process'.tr, style: AppTheme.whitePrimaryTextStyle)),
- );
- })
- ],
- ),
- body: SafeArea(
- child: Obx(
- () => Column(children: [
- searchBar(context),
- const SizedBox(height: 5),
- Expanded(
- flex: 1,
- child: SmartRefresher(
- enablePullDown: true,
- enablePullUp: controller.state.hasMoreData,
- controller: controller.refreshController,
- onRefresh: controller.onRefresh,
- onLoading: controller.onLoadMore,
- child: ListView.separated(
- separatorBuilder: ((context, index) =>
- const Divider(height: 1)),
- itemCount: controller.state.dataList.length,
- itemBuilder: (context, index) {
- final item = controller.state.dataList[index];
- if (item is TaskData) {
- return taskItem(item, context);
- } else if (item is TaskCompletedData) {
- return taskCompletedItem(item, context);
- } else if (item is ReadData) {
- return readItem(item, context);
- } else if (item is ReadCompletedData) {
- return readCompletedItem(item, context);
- }
- return Container();
- },
- )))
- ]),
- )),
- );
- },
- );
- }
- Widget searchBar(BuildContext context) {
- return Padding(
- padding:
- const EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8),
- child: Container(
- height: 36,
- decoration: BoxDecoration(
- color: Theme.of(context).colorScheme.background,
- borderRadius: const BorderRadius.all(Radius.circular(18))),
- alignment: Alignment.centerLeft,
- child: Padding(
- padding: const EdgeInsets.only(left: 10),
- child: Row(
- children: [
- SizedBox(
- width: 22,
- height: 22,
- child: Icon(Icons.search,
- color: Theme.of(context).colorScheme.primary),
- ),
- Expanded(
- flex: 1,
- child: Padding(
- padding: const EdgeInsets.only(left: 5),
- child: TextField(
- autofocus: false,
- controller: controller.searchController,
- decoration: InputDecoration(
- isDense: true,
- border: InputBorder.none,
- hintText: 'process_office_center_search_placeholder'.tr,
- hintStyle: Theme.of(context).textTheme.bodySmall,
- ),
- style: Theme.of(context).textTheme.bodyMedium,
- textInputAction: TextInputAction.search,
- onSubmitted: controller.onSearch,
- ),
- ),
- )
- ],
- ),
- ),
- ));
- }
- Widget taskItem(TaskData task, BuildContext context) {
- String title = task.title ?? '';
- if (title.isEmpty) {
- title = 'process_work_no_title_no_process'.tr;
- }
- String time = task.startTime ?? '';
- if (time.isNotEmpty) {
- time = time.substring(0, 10);
- }
- return Obx(() {
- final len = controller.state.taskSelectedList.length;
- // 是否可快速处理
- bool rapid = task.allowRapid ?? false;
- // 只能选择相同的活动上的待办
- if (rapid &&
- (len == 0 ||
- (len > 0 &&
- controller.state.taskSelectedList[0].activity ==
- task.activity
- && controller.state.taskSelectedList[0].process ==
- task.process))) {
- return CheckboxListTile(
- // onTap: () => controller.clickTask(task),
- title: Text('[${task.processName}] $title'),
- subtitle: Text(task.activityName ?? ''),
- secondary: TextButton(onPressed: (() => controller.clickTask(task)), child: Text('process_task_open_work'.tr)),
- // GestureDetector(
- // onTap: () => controller.clickTask(task),
- // child: Row(
- // mainAxisAlignment: MainAxisAlignment.end,
- // mainAxisSize: MainAxisSize.min,
- // children: [
- // Text(time, style: Theme.of(context).textTheme.bodySmall),
- // const Icon(
- // Icons.keyboard_arrow_right,
- // color: AppColor.hintText,
- // size: 22,
- // )
- // ]),
- // ),
- controlAffinity: ListTileControlAffinity.leading,
- value: controller.isItemChecked(task),
- onChanged: (value) => controller.onSelectChange(value, task),
- );
- } else {
- return ListTile(
- onTap: () => controller.clickTask(task),
- title: Text('[${task.processName}] $title'),
- subtitle: Text(task.activityName ?? ''),
- trailing: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(time, style: Theme.of(context).textTheme.bodySmall),
- const Icon(
- Icons.keyboard_arrow_right,
- color: AppColor.hintText,
- size: 22,
- )
- ]),
- );
- }
- });
- }
- Widget taskCompletedItem(
- TaskCompletedData taskCompleted, BuildContext context) {
- String title = taskCompleted.title ?? '';
- if (title.isEmpty) {
- title = 'process_work_no_title_no_process'.tr;
- }
- String time = taskCompleted.startTime ?? '';
- if (time.isNotEmpty) {
- time = time.substring(0, 10);
- }
- return ListTile(
- onTap: () => controller.clickTaskCompleted(taskCompleted),
- title: Text('[${taskCompleted.processName}] $title'),
- subtitle: Padding(
- padding: const EdgeInsets.only(top: 5),
- child: Text(taskCompleted.activityName ?? '')),
- trailing: Column(
- children: [
- taskCompleted.completed == true
- ? Container(
- width: 64,
- height: 18,
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(9)),
- color: AppColor.o2Blue),
- child: Center(
- child: Text('process_work_completed_tag'.tr,
- style: const TextStyle(
- color: Colors.white, fontSize: 13))),
- )
- : const SizedBox(height: 18),
- const SizedBox(height: 5),
- Expanded(
- flex: 1,
- child: Text(time,
- style: Theme.of(context).textTheme.bodySmall,
- textAlign: TextAlign.center)),
- ],
- ));
- }
- Widget readItem(ReadData read, BuildContext context) {
- String title = read.title ?? '';
- if (title.isEmpty) {
- title = 'process_work_no_title_no_process'.tr;
- }
- String time = read.startTime ?? '';
- if (time.isNotEmpty) {
- time = time.substring(0, 10);
- }
- return ListTile(
- onTap: () => controller.clickRead(read),
- title: Text('[${read.processName}] $title'),
- subtitle: Text(read.activityName ?? ''),
- trailing: Column(
- children: [
- read.completed == true
- ? Container(
- width: 64,
- height: 18,
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(9)),
- color: AppColor.o2Blue),
- child: Center(
- child: Text('process_work_completed_tag'.tr,
- style:
- const TextStyle(color: Colors.white, fontSize: 13))),
- )
- : const SizedBox(height: 18),
- const SizedBox(height: 5),
- Expanded(
- flex: 1,
- child: Text(time,
- style: Theme.of(context).textTheme.bodySmall,
- textAlign: TextAlign.center)),
- ],
- ),
- );
- }
- Widget readCompletedItem(
- ReadCompletedData readCompleted, BuildContext context) {
- String title = readCompleted.title ?? '';
- if (title.isEmpty) {
- title = 'process_work_no_title_no_process'.tr;
- }
- String time = readCompleted.startTime ?? '';
- if (time.isNotEmpty) {
- time = time.substring(0, 10);
- }
- return ListTile(
- onTap: () => controller.clickReadCompleted(readCompleted),
- title: Text('[${readCompleted.processName}] $title'),
- subtitle: Text(readCompleted.activityName ?? ''),
- trailing: Column(
- children: [
- readCompleted.completed == true
- ? Container(
- width: 64,
- height: 18,
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(9)),
- color: AppColor.o2Blue),
- child: Center(
- child: Text('process_work_completed_tag'.tr,
- style:
- const TextStyle(color: Colors.white, fontSize: 13))),
- )
- : const SizedBox(height: 18),
- const SizedBox(height: 5),
- Expanded(
- flex: 1,
- child: Text(time,
- style: Theme.of(context).textTheme.bodySmall,
- textAlign: TextAlign.center)),
- ],
- ),
- );
- }
- }
|