|
|
@ -84,7 +84,7 @@ class CalendarController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//初始化pageController,initialPage默认是当前时间对于的页面
|
|
|
|
//初始化pageController,initialPage默认是当前时间对于的页面
|
|
|
|
int initialPage;
|
|
|
|
int initialPage = 0;
|
|
|
|
int nowMonthIndex = 0;
|
|
|
|
int nowMonthIndex = 0;
|
|
|
|
monthList.clear();
|
|
|
|
monthList.clear();
|
|
|
|
for (int i = minYear; i <= maxYear; i++) {
|
|
|
|
for (int i = minYear; i <= maxYear; i++) {
|
|
|
@ -111,7 +111,8 @@ class CalendarController {
|
|
|
|
nowMonthIndex++;
|
|
|
|
nowMonthIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.monthController = new PageController(initialPage: initialPage);
|
|
|
|
this.monthController =
|
|
|
|
|
|
|
|
new PageController(initialPage: initialPage, keepPage: true);
|
|
|
|
LogUtil.log(
|
|
|
|
LogUtil.log(
|
|
|
|
TAG: this.runtimeType,
|
|
|
|
TAG: this.runtimeType,
|
|
|
|
message: "start:${DateModel.fromDateTime(DateTime(
|
|
|
|
message: "start:${DateModel.fromDateTime(DateTime(
|
|
|
@ -153,7 +154,7 @@ class CalendarController {
|
|
|
|
|
|
|
|
|
|
|
|
calendarConfiguration.monthList = monthList;
|
|
|
|
calendarConfiguration.monthList = monthList;
|
|
|
|
calendarConfiguration.weekList = weekList;
|
|
|
|
calendarConfiguration.weekList = weekList;
|
|
|
|
calendarConfiguration.pageController = monthController;
|
|
|
|
calendarConfiguration.monthController = monthController;
|
|
|
|
calendarConfiguration.weekController = weekController;
|
|
|
|
calendarConfiguration.weekController = weekController;
|
|
|
|
calendarConfiguration.dayWidgetBuilder = dayWidgetBuilder;
|
|
|
|
calendarConfiguration.dayWidgetBuilder = dayWidgetBuilder;
|
|
|
|
calendarConfiguration.weekBarItemWidgetBuilder = weekBarItemWidgetBuilder;
|
|
|
|
calendarConfiguration.weekBarItemWidgetBuilder = weekBarItemWidgetBuilder;
|
|
|
@ -200,22 +201,31 @@ class CalendarController {
|
|
|
|
Future<bool> previousPage() async {
|
|
|
|
Future<bool> previousPage() async {
|
|
|
|
if (calendarProvider.expandStatus.value == true) {
|
|
|
|
if (calendarProvider.expandStatus.value == true) {
|
|
|
|
//月视图
|
|
|
|
//月视图
|
|
|
|
int currentIndex = monthController.page.toInt();
|
|
|
|
int currentIndex =
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.monthController.page.toInt();
|
|
|
|
if (currentIndex == 0) {
|
|
|
|
if (currentIndex == 0) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
monthController.previousPage(
|
|
|
|
calendarProvider.calendarConfiguration.monthController
|
|
|
|
duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
.previousPage(duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.monthChange(
|
|
|
|
|
|
|
|
monthList[currentIndex].year, monthList[currentIndex].month);
|
|
|
|
|
|
|
|
DateModel temp = new DateModel();
|
|
|
|
|
|
|
|
temp.year = monthList[currentIndex].year;
|
|
|
|
|
|
|
|
temp.month = monthList[currentIndex].month;
|
|
|
|
|
|
|
|
temp.day = monthList[currentIndex].day + 14;
|
|
|
|
|
|
|
|
calendarProvider.lastClickDateModel = temp;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//周视图
|
|
|
|
//周视图
|
|
|
|
int currentIndex = weekController.page.toInt();
|
|
|
|
int currentIndex =
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.weekController.page.toInt();
|
|
|
|
if (currentIndex == 0) {
|
|
|
|
if (currentIndex == 0) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
weekController.previousPage(
|
|
|
|
calendarProvider.calendarConfiguration.weekController
|
|
|
|
duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
.previousPage(duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -229,21 +239,31 @@ class CalendarController {
|
|
|
|
Future<bool> nextPage() async {
|
|
|
|
Future<bool> nextPage() async {
|
|
|
|
if (calendarProvider.expandStatus.value == true) {
|
|
|
|
if (calendarProvider.expandStatus.value == true) {
|
|
|
|
//月视图
|
|
|
|
//月视图
|
|
|
|
int currentIndex = monthController.page.toInt();
|
|
|
|
int currentIndex =
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.monthController.page.toInt();
|
|
|
|
if (monthList.length - 1 == currentIndex) {
|
|
|
|
if (monthList.length - 1 == currentIndex) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
monthController.nextPage(
|
|
|
|
calendarProvider.calendarConfiguration.monthController
|
|
|
|
duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
.nextPage(duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.monthChange(
|
|
|
|
|
|
|
|
monthList[currentIndex].year, monthList[currentIndex].month);
|
|
|
|
|
|
|
|
DateModel temp = new DateModel();
|
|
|
|
|
|
|
|
temp.year = monthList[currentIndex].year;
|
|
|
|
|
|
|
|
temp.month = monthList[currentIndex].month;
|
|
|
|
|
|
|
|
temp.day = monthList[currentIndex].day + 14;
|
|
|
|
|
|
|
|
calendarProvider.lastClickDateModel = temp;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//周视图
|
|
|
|
//周视图
|
|
|
|
int currentIndex = weekController.page.toInt();
|
|
|
|
int currentIndex =
|
|
|
|
|
|
|
|
calendarProvider.calendarConfiguration.weekController.page.toInt();
|
|
|
|
if (weekList.length - 1 == currentIndex) {
|
|
|
|
if (weekList.length - 1 == currentIndex) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
weekController.nextPage(duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
calendarProvider.calendarConfiguration.weekController
|
|
|
|
|
|
|
|
.nextPage(duration: DEFAULT_DURATION, curve: Curves.ease);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -261,14 +281,16 @@ class CalendarController {
|
|
|
|
if (targetPage == -1) {
|
|
|
|
if (targetPage == -1) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (monthController.hasClients == false) {
|
|
|
|
if (calendarProvider.calendarConfiguration.monthController.hasClients ==
|
|
|
|
|
|
|
|
false) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needAnimation) {
|
|
|
|
if (needAnimation) {
|
|
|
|
monthController.animateToPage(targetPage,
|
|
|
|
calendarProvider.calendarConfiguration.monthController
|
|
|
|
duration: duration, curve: curve);
|
|
|
|
.animateToPage(targetPage, duration: duration, curve: curve);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
monthController.jumpToPage(targetPage);
|
|
|
|
calendarProvider.calendarConfiguration.monthController
|
|
|
|
|
|
|
|
.jumpToPage(targetPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
DateModel dateModel = DateModel.fromDateTime(DateTime(year, month, 1));
|
|
|
|
DateModel dateModel = DateModel.fromDateTime(DateTime(year, month, 1));
|
|
|
@ -282,14 +304,16 @@ class CalendarController {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (weekController.hasClients == false) {
|
|
|
|
if (calendarProvider.calendarConfiguration.weekController.hasClients ==
|
|
|
|
|
|
|
|
false) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needAnimation) {
|
|
|
|
if (needAnimation) {
|
|
|
|
weekController.animateToPage(targetPage,
|
|
|
|
calendarProvider.calendarConfiguration.weekController
|
|
|
|
duration: duration, curve: curve);
|
|
|
|
.animateToPage(targetPage, duration: duration, curve: curve);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
weekController.jumpToPage(targetPage);
|
|
|
|
calendarProvider.calendarConfiguration.weekController
|
|
|
|
|
|
|
|
.jumpToPage(targetPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -299,8 +323,11 @@ class CalendarController {
|
|
|
|
{bool needAnimation = false,
|
|
|
|
{bool needAnimation = false,
|
|
|
|
Duration duration = const Duration(milliseconds: 500),
|
|
|
|
Duration duration = const Duration(milliseconds: 500),
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
DateTime targetDateTime =
|
|
|
|
DateTime targetDateTime = monthList[calendarProvider
|
|
|
|
monthList[monthController.page.toInt() + 12].getDateTime();
|
|
|
|
.calendarConfiguration.monthController.page
|
|
|
|
|
|
|
|
.toInt() +
|
|
|
|
|
|
|
|
12]
|
|
|
|
|
|
|
|
.getDateTime();
|
|
|
|
moveToCalendar(
|
|
|
|
moveToCalendar(
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
@ -311,8 +338,11 @@ class CalendarController {
|
|
|
|
{bool needAnimation = false,
|
|
|
|
{bool needAnimation = false,
|
|
|
|
Duration duration = const Duration(milliseconds: 500),
|
|
|
|
Duration duration = const Duration(milliseconds: 500),
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
DateTime targetDateTime =
|
|
|
|
DateTime targetDateTime = monthList[calendarProvider
|
|
|
|
monthList[monthController.page.toInt() - 12].getDateTime();
|
|
|
|
.calendarConfiguration.monthController.page
|
|
|
|
|
|
|
|
.toInt() -
|
|
|
|
|
|
|
|
12]
|
|
|
|
|
|
|
|
.getDateTime();
|
|
|
|
moveToCalendar(
|
|
|
|
moveToCalendar(
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
@ -325,22 +355,33 @@ class CalendarController {
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
Curve curve = Curves.ease}) {
|
|
|
|
// 如果当前显示的是周视图的话,需要计算出第一个月的index后,调用weekController
|
|
|
|
// 如果当前显示的是周视图的话,需要计算出第一个月的index后,调用weekController
|
|
|
|
if (calendarProvider.expandStatus.value == false) {
|
|
|
|
if (calendarProvider.expandStatus.value == false) {
|
|
|
|
int currentMonth = weekList[weekController.page.toInt()].month;
|
|
|
|
int currentMonth = weekList[calendarProvider
|
|
|
|
for (int i = weekController.page.toInt(); i < weekList.length; i++) {
|
|
|
|
.calendarConfiguration.weekController.page
|
|
|
|
|
|
|
|
.toInt()]
|
|
|
|
|
|
|
|
.month;
|
|
|
|
|
|
|
|
for (int i = calendarProvider.calendarConfiguration.weekController.page
|
|
|
|
|
|
|
|
.toInt();
|
|
|
|
|
|
|
|
i < weekList.length;
|
|
|
|
|
|
|
|
i++) {
|
|
|
|
if (weekList[i].month != currentMonth) {
|
|
|
|
if (weekList[i].month != currentMonth) {
|
|
|
|
weekController.jumpToPage(i);
|
|
|
|
calendarProvider.calendarConfiguration.weekController.jumpToPage(i);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((monthController.page.toInt() + 1) >= monthList.length) {
|
|
|
|
if ((calendarProvider.calendarConfiguration.monthController.page.toInt() +
|
|
|
|
|
|
|
|
1) >=
|
|
|
|
|
|
|
|
monthList.length) {
|
|
|
|
LogUtil.log(TAG: this.runtimeType, message: "moveToNextMonth:当前是最后一个月份");
|
|
|
|
LogUtil.log(TAG: this.runtimeType, message: "moveToNextMonth:当前是最后一个月份");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DateTime targetDateTime =
|
|
|
|
DateTime targetDateTime = monthList[calendarProvider
|
|
|
|
monthList[monthController.page.toInt() + 1].getDateTime();
|
|
|
|
.calendarConfiguration.monthController.page
|
|
|
|
|
|
|
|
.toInt() +
|
|
|
|
|
|
|
|
1]
|
|
|
|
|
|
|
|
.getDateTime();
|
|
|
|
moveToCalendar(
|
|
|
|
moveToCalendar(
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
@ -354,25 +395,32 @@ class CalendarController {
|
|
|
|
// 如果当前显示的是周视图的话,需要计算出第一个月的index后,调用weekController
|
|
|
|
// 如果当前显示的是周视图的话,需要计算出第一个月的index后,调用weekController
|
|
|
|
if (calendarProvider.expandStatus.value == false) {
|
|
|
|
if (calendarProvider.expandStatus.value == false) {
|
|
|
|
int currentMonth = weekList[weekController.page.toInt()].month;
|
|
|
|
int currentMonth = weekList[weekController.page.toInt()].month;
|
|
|
|
for (int i = weekController.page.toInt(); i >= 0; i--) {
|
|
|
|
for (int i = calendarProvider.calendarConfiguration.weekController.page
|
|
|
|
|
|
|
|
.toInt();
|
|
|
|
|
|
|
|
i >= 0;
|
|
|
|
|
|
|
|
i--) {
|
|
|
|
if (weekList[i].month != currentMonth &&
|
|
|
|
if (weekList[i].month != currentMonth &&
|
|
|
|
weekList[i].isAfter(DateModel.fromDateTime(DateTime(
|
|
|
|
weekList[i].isAfter(DateModel.fromDateTime(DateTime(
|
|
|
|
calendarConfiguration.minYear,
|
|
|
|
calendarConfiguration.minYear,
|
|
|
|
calendarConfiguration.minYearMonth)))) {
|
|
|
|
calendarConfiguration.minYearMonth)))) {
|
|
|
|
weekController.jumpToPage(i);
|
|
|
|
calendarProvider.calendarConfiguration.weekController.jumpToPage(i);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((monthController.page.toInt()) == 0) {
|
|
|
|
if ((calendarProvider.calendarConfiguration.monthController.page.toInt()) ==
|
|
|
|
|
|
|
|
0) {
|
|
|
|
LogUtil.log(
|
|
|
|
LogUtil.log(
|
|
|
|
TAG: this.runtimeType, message: "moveToPreviousMonth:当前是第一个月份");
|
|
|
|
TAG: this.runtimeType, message: "moveToPreviousMonth:当前是第一个月份");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DateTime targetDateTime =
|
|
|
|
DateTime targetDateTime = monthList[calendarProvider
|
|
|
|
monthList[monthController.page.toInt() - 1].getDateTime();
|
|
|
|
.calendarConfiguration.monthController.page
|
|
|
|
|
|
|
|
.toInt() -
|
|
|
|
|
|
|
|
1]
|
|
|
|
|
|
|
|
.getDateTime();
|
|
|
|
moveToCalendar(
|
|
|
|
moveToCalendar(
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
targetDateTime.year, targetDateTime.month, targetDateTime.day,
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
|
needAnimation: needAnimation, duration: duration, curve: curve);
|
|
|
@ -398,7 +446,7 @@ class CalendarController {
|
|
|
|
* 默认的weekBar
|
|
|
|
* 默认的weekBar
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Widget defaultWeekBarWidget() {
|
|
|
|
Widget defaultWeekBarWidget() {
|
|
|
|
return DefaultWeekBar();
|
|
|
|
return const DefaultWeekBar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|