From 21fdeb55957f501d3a1c94c7e4cfc99d4a63db91 Mon Sep 17 00:00:00 2001 From: LXD312569496 <450468291@qq.com> Date: Tue, 3 Dec 2019 22:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=91=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E7=9A=84=E7=9B=91=E5=90=AC=E6=96=B9=E6=B3=95=EF=BC=8CaddWeekCh?= =?UTF-8?q?angeListener?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/configuration.dart | 2 ++ lib/controller.dart | 10 ++++++++++ lib/widget/week_view_pager.dart | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/configuration.dart b/lib/configuration.dart index 3bed95a..5786dd0 100644 --- a/lib/configuration.dart +++ b/lib/configuration.dart @@ -65,6 +65,8 @@ class CalendarConfiguration { ObserverList monthChangeListeners = ObserverList(); //保存多个月份监听的事件 + ObserverList weekChangeListeners = + ObserverList(); //周视图切换 /** * 下面的信息不是配置的,是根据配置信息进行计算出来的 diff --git a/lib/controller.dart b/lib/controller.dart index 2a71fb9..197ac7b 100644 --- a/lib/controller.dart +++ b/lib/controller.dart @@ -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); + /** * 月份切换事件 */ diff --git a/lib/widget/week_view_pager.dart b/lib/widget/week_view_pager.dart index 3a468c0..98b1b71 100644 --- a/lib/widget/week_view_pager.dart +++ b/lib/widget/week_view_pager.dart @@ -54,13 +54,17 @@ class _WeekViewPagerState extends State 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,