支持显示月视图和周视图的情况,优先显示周视图,MODE_SHOW_WEEK_AND_MONTH

develop^2
LXD312569496 5 years ago committed by xiaodong
parent 083abc01ca
commit 389ce46a29

@ -110,7 +110,8 @@ class CalendarProvider extends ChangeNotifier {
? selectDateModel
: DateModel.fromDateTime(DateTime.now())
..day = 15;
if (calendarConfiguration.showMode == Constants.MODE_SHOW_ONLY_WEEK) {
if (calendarConfiguration.showMode == Constants.MODE_SHOW_ONLY_WEEK ||
calendarConfiguration.showMode == Constants.MODE_SHOW_WEEK_AND_MONTH) {
expandStatus = ValueNotifier(false);
} else {
expandStatus = ValueNotifier(true);

@ -7,7 +7,8 @@ class Constants {
//
static const int MODE_SHOW_ONLY_MONTH=1;//
static const int MODE_SHOW_ONLY_WEEK=2;//
static const int MODE_SHOW_WEEK_AND_MONTH=3;//
static const int MODE_SHOW_WEEK_AND_MONTH=3;//
static const int MODE_SHOW_MONTH_AND_WEEK=4;//
/**

@ -93,8 +93,7 @@ class CalendarController {
maxYearMonth,
))}");
if (showMode == Constants.MODE_SHOW_ONLY_MONTH ||
showMode == Constants.MODE_SHOW_WEEK_AND_MONTH) {
if (showMode != Constants.MODE_SHOW_ONLY_WEEK) {
//pageController,initialPage
int initialPage = 0;
int nowMonthIndex = 0;
@ -132,8 +131,7 @@ class CalendarController {
"初始化月份视图的信息:一共有${monthList.length}个月initialPage为${nowMonthIndex}");
}
if (showMode == Constants.MODE_SHOW_ONLY_WEEK ||
showMode == Constants.MODE_SHOW_WEEK_AND_MONTH) {
if (showMode != Constants.MODE_SHOW_ONLY_MONTH) {
//
///72
int initialWeekPage = 0;
@ -230,7 +228,8 @@ class CalendarController {
calendarProvider.calendarConfiguration.monthController
.previousPage(duration: DEFAULT_DURATION, curve: Curves.ease);
calendarProvider.calendarConfiguration.monthChange(
monthList[currentIndex-1].year, monthList[currentIndex-1].month);
monthList[currentIndex - 1].year,
monthList[currentIndex - 1].month);
DateModel temp = new DateModel();
temp.year = monthList[currentIndex].year;
temp.month = monthList[currentIndex].month;
@ -268,7 +267,8 @@ class CalendarController {
calendarProvider.calendarConfiguration.monthController
.nextPage(duration: DEFAULT_DURATION, curve: Curves.ease);
calendarProvider.calendarConfiguration.monthChange(
monthList[currentIndex+1].year, monthList[currentIndex+1].month);
monthList[currentIndex + 1].year,
monthList[currentIndex + 1].month);
DateModel temp = new DateModel();
temp.year = monthList[currentIndex].year;
temp.month = monthList[currentIndex].month;

@ -73,12 +73,10 @@ class CalendarContainerState extends State<CalendarContainer>
double itemHeight;
double totalHeight;
bool expand = true;
bool expand;
CalendarProvider calendarProvider;
var state = CrossFadeState.showFirst;
List<Widget> widgets = [];
int index = 0;
@ -95,20 +93,28 @@ class CalendarContainerState extends State<CalendarContainer>
Constants.MODE_SHOW_WEEK_AND_MONTH) {
widgets.add(const MonthViewPager());
widgets.add(const WeekViewPager());
index = 1;
} else if (calendarProvider.calendarConfiguration.showMode ==
Constants.MODE_SHOW_MONTH_AND_WEEK) {
widgets.add(const MonthViewPager());
widgets.add(const WeekViewPager());
index = 0;
} else {
//
widgets.add(const MonthViewPager());
}
expand = calendarProvider.expandStatus.value;
//
if (calendarProvider.calendarConfiguration.showMode ==
Constants.MODE_SHOW_WEEK_AND_MONTH) {
Constants.MODE_SHOW_WEEK_AND_MONTH ||
calendarProvider.calendarConfiguration.showMode ==
Constants.MODE_SHOW_MONTH_AND_WEEK) {
calendarProvider.expandStatus.addListener(() {
setState(() {
print(
"calendarProvider.expandStatus.value:${calendarProvider.expandStatus.value}");
expand = calendarProvider.expandStatus.value;
state = (state == CrossFadeState.showSecond
? CrossFadeState.showFirst
: CrossFadeState.showSecond);
if (expand) {
index = 0;
//
@ -122,6 +128,9 @@ class CalendarContainerState extends State<CalendarContainer>
}
});
});
}else{
index=0;
}
// widget.calendarController.addMonthChangeListener((year, month) {
@ -151,7 +160,6 @@ class CalendarContainerState extends State<CalendarContainer>
MediaQueryData mediaQueryData =
MediaQueryData.fromWindow(WidgetsBinding.instance.window);
print("mediaQueryData.orientation:${mediaQueryData}");
//itemSize/7/7
itemHeight = calendarProvider.calendarConfiguration.itemSize != null
? calendarProvider.calendarConfiguration.itemSize

@ -186,7 +186,7 @@ class ItemContainerState extends State<ItemContainer> {
@override
Widget build(BuildContext context) {
LogUtil.log(TAG: this.runtimeType, message: "ItemContainerState build");
// LogUtil.log(TAG: this.runtimeType, message: "ItemContainerState build");
calendarProvider = Provider.of<CalendarProvider>(context, listen: false);
configuration = calendarProvider.calendarConfiguration;
@ -243,21 +243,21 @@ class ItemContainerState extends State<ItemContainer> {
@override
void deactivate() {
LogUtil.log(
TAG: this.runtimeType, message: "ItemContainerState deactivate");
// LogUtil.log(
// TAG: this.runtimeType, message: "ItemContainerState deactivate");
super.deactivate();
}
@override
void dispose() {
LogUtil.log(TAG: this.runtimeType, message: "ItemContainerState dispose");
// LogUtil.log(TAG: this.runtimeType, message: "ItemContainerState dispose");
super.dispose();
}
@override
void didUpdateWidget(ItemContainer oldWidget) {
LogUtil.log(
TAG: this.runtimeType, message: "ItemContainerState didUpdateWidget");
// LogUtil.log(
// TAG: this.runtimeType, message: "ItemContainerState didUpdateWidget");
super.didUpdateWidget(oldWidget);
}
}

Loading…
Cancel
Save