增加周切换的监听方法,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>(); //
ObserverList<OnWeekChange> weekChangeListeners =
ObserverList<OnWeekChange>(); //
/**
*

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

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

Loading…
Cancel
Save