增加周切换的监听方法,addWeekChangeListener

develop^2
LXD312569496 5 years ago committed by xiaodong
parent f812e4b84d
commit 21fdeb5595

@ -65,6 +65,8 @@ class CalendarConfiguration {
ObserverList<OnMonthChange> monthChangeListeners = ObserverList<OnMonthChange> monthChangeListeners =
ObserverList<OnMonthChange>(); // ObserverList<OnMonthChange>(); //
ObserverList<OnWeekChange> weekChangeListeners =
ObserverList<OnWeekChange>(); //
/** /**
* *

@ -184,6 +184,11 @@ class CalendarController {
calendarConfiguration.weekController = weekController; calendarConfiguration.weekController = weekController;
} }
//
void addWeekChangeListener(OnWeekChange listener){
this.calendarConfiguration.weekChangeListeners.add(listener);
}
// //
void addMonthChangeListener(OnMonthChange listener) { void addMonthChangeListener(OnMonthChange listener) {
// this.calendarConfiguration.monthChange = listener; // this.calendarConfiguration.monthChange = listener;
@ -532,6 +537,11 @@ bool defaultInRange(DateModel dateModel) {
return true; return true;
} }
/**
*
*/
typedef void OnWeekChange(int year, int month);
/** /**
* *
*/ */

@ -54,13 +54,17 @@ class _WeekViewPagerState extends State<WeekViewPager>
if (calendarProvider.expandStatus.value == true) { if (calendarProvider.expandStatus.value == true) {
return; return;
} }
LogUtil.log( LogUtil.log(
TAG: this.runtimeType, TAG: this.runtimeType,
message: message:
"WeekViewPager PageView onPageChanged,position:$position"); "WeekViewPager PageView onPageChanged,position:$position");
//
DateModel firstDayOfWeek = configuration.weekList[position]; DateModel firstDayOfWeek = configuration.weekList[position];
int currentMonth = firstDayOfWeek.month; int currentMonth = firstDayOfWeek.month;
//
configuration.weekChangeListeners.forEach((listener) {
listener(firstDayOfWeek.year, firstDayOfWeek.month);
});
if (lastMonth != currentMonth) { if (lastMonth != currentMonth) {
LogUtil.log( LogUtil.log(
TAG: this.runtimeType, TAG: this.runtimeType,

Loading…
Cancel
Save