|
|
@@ -1,5 +1,7 @@
|
|
|
import 'package:electronic_assistant/base/base_controller.dart';
|
|
|
import 'package:electronic_assistant/data/repositories/agenda_repository.dart';
|
|
|
+import 'package:electronic_assistant/module/agenda/utils.dart';
|
|
|
+import 'package:electronic_assistant/popup/agenda_time_popup.dart';
|
|
|
import 'package:electronic_assistant/utils/error_handler.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
|
|
@@ -7,10 +9,14 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
|
|
import '../../data/api/request/agenda_request.dart';
|
|
|
import '../../data/bean/agenda.dart';
|
|
|
+import '../../utils/time_utils.dart';
|
|
|
import 'detail/view.dart';
|
|
|
|
|
|
class AgendaController extends BaseController {
|
|
|
- String get filterTxt => '展示近两周待办';
|
|
|
+ AgendaTimeType? _timeFilterType;
|
|
|
+ final _filterTxt = ''.obs;
|
|
|
+
|
|
|
+ String get filterTxt => _filterTxt.value;
|
|
|
|
|
|
final agendaDetailPopupTag = 'agendaDetailPopupTag';
|
|
|
final todoIsExpanded = true.obs;
|
|
|
@@ -23,18 +29,43 @@ class AgendaController extends BaseController {
|
|
|
final doneSize = 0.obs;
|
|
|
final int limit = 10;
|
|
|
|
|
|
- int _timeFilterIndex = 0;
|
|
|
-
|
|
|
- int get timeFilterIndex => _timeFilterIndex;
|
|
|
+ AgendaTimeType? get timeFilterType => _timeFilterType;
|
|
|
+ DateRange? searchTime;
|
|
|
|
|
|
@override
|
|
|
void onReady() {
|
|
|
+ reset();
|
|
|
refreshTodoTaskList();
|
|
|
agendaDonePage(0, limit, isClearAll: true);
|
|
|
}
|
|
|
|
|
|
- void setTimeFilterIndex(int index) {
|
|
|
- _timeFilterIndex = index;
|
|
|
+ void reset() {
|
|
|
+ _setTimeFilterType(AgendaTimeType.nearlyAWeek);
|
|
|
+ }
|
|
|
+
|
|
|
+ void onClickTimeType(AgendaTimeType type) {
|
|
|
+ _setTimeFilterType(type);
|
|
|
+ refreshTodoTaskList();
|
|
|
+ agendaDonePage(0, limit, isClearAll: true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void _setTimeFilterType(AgendaTimeType type) {
|
|
|
+ _timeFilterType = type;
|
|
|
+ _filterTxt.value = getAgendaFilterTxt(type);
|
|
|
+ switch (type) {
|
|
|
+ case AgendaTimeType.nearlyAWeek:
|
|
|
+ searchTime = TimeUtils.getLastDates(const Duration(days: 7));
|
|
|
+ break;
|
|
|
+ case AgendaTimeType.nearlyTwoWeek:
|
|
|
+ searchTime = TimeUtils.getLastDates(const Duration(days: 14));
|
|
|
+ break;
|
|
|
+ case AgendaTimeType.nearlyAMonth:
|
|
|
+ searchTime = TimeUtils.getLastDates(const Duration(days: 31));
|
|
|
+ break;
|
|
|
+ case AgendaTimeType.customTime:
|
|
|
+ searchTime = TimeUtils.getLastDates(const Duration());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void onLoadMoreDoneData() {
|
|
|
@@ -43,7 +74,12 @@ class AgendaController extends BaseController {
|
|
|
|
|
|
agendaDonePage(int offset, int limit, {bool? isClearAll}) {
|
|
|
agendaRepository
|
|
|
- .agendaPage(offset, limit, completeStatus: TaskStatus.DONE)
|
|
|
+ .agendaPage(
|
|
|
+ offset, limit,
|
|
|
+ completeStatus: TaskStatus.DONE,
|
|
|
+ // startTime: searchTime?.startTime.millisecondsSinceEpoch,
|
|
|
+ // endTime: searchTime?.endTime.millisecondsSinceEpoch
|
|
|
+ )
|
|
|
.then((response) {
|
|
|
doneSize.value = response.count;
|
|
|
if (isClearAll == true) {
|
|
|
@@ -68,7 +104,12 @@ class AgendaController extends BaseController {
|
|
|
|
|
|
refreshTodoTaskList() {
|
|
|
agendaRepository
|
|
|
- .agendaPage(0, 999, completeStatus: TaskStatus.TODO)
|
|
|
+ .agendaPage(
|
|
|
+ 0, 999,
|
|
|
+ completeStatus: TaskStatus.TODO,
|
|
|
+ // startTime: searchTime?.startTime.millisecondsSinceEpoch,
|
|
|
+ // endTime: searchTime?.endTime.millisecondsSinceEpoch
|
|
|
+ )
|
|
|
.then((response) {
|
|
|
agendaTodoList.clear();
|
|
|
if (response.list != null) {
|
|
|
@@ -119,4 +160,12 @@ class AgendaController extends BaseController {
|
|
|
void onAgendaUpdate(Agenda item) {
|
|
|
AgendaDetailPage.start(item);
|
|
|
}
|
|
|
+
|
|
|
+ void clearFilterTime() {
|
|
|
+ _timeFilterType = null;
|
|
|
+ _filterTxt.value = '';
|
|
|
+ searchTime = null;
|
|
|
+ refreshTodoTaskList();
|
|
|
+ agendaDonePage(0, limit, isClearAll: true);
|
|
|
+ }
|
|
|
}
|