支持verticalSpacing和itemSize属性,代码修改

develop^2
LXD312569496 5 years ago committed by xiaodong
parent 8b45252b9f
commit 083abc01ca

@ -151,14 +151,17 @@ class CalendarContainerState extends State<CalendarContainer>
MediaQueryData mediaQueryData =
MediaQueryData.fromWindow(WidgetsBinding.instance.window);
itemHeight = calendarProvider.calendarConfiguration.itemSize ??
mediaQueryData.orientation == Orientation.landscape
? mediaQueryData.size.height / 10
print("mediaQueryData.orientation:${mediaQueryData}");
//itemSize/7/7
itemHeight = calendarProvider.calendarConfiguration.itemSize != null
? calendarProvider.calendarConfiguration.itemSize
: mediaQueryData.orientation == Orientation.landscape
? mediaQueryData.size.height / 7
: mediaQueryData.size.width / 7;
if (calendarProvider.totalHeight == null) {
calendarProvider.totalHeight = itemHeight * 6 +
calendarProvider.calendarConfiguration.verticalSpacing * (6 - 1);
}
totalHeight = calendarProvider.totalHeight;
}
@override
@ -172,10 +175,6 @@ class CalendarContainerState extends State<CalendarContainer>
//,,:a horizontal viewport was given an unlimited amount of I/flutter ( 6759): vertical space in which to expand.
// itemHeight = calendarProvider.calendarConfiguration.itemSize ??
// MediaQuery.of(context).size.width / 7;
if (totalHeight == null) {
totalHeight = itemHeight * 6 +
calendarProvider.calendarConfiguration.verticalSpacing * (6 - 1);
}
return Container(
width: itemHeight * 7,
child: new Column(

@ -108,8 +108,8 @@ class _MonthViewState extends State<MonthView>
return new GridView.builder(
addAutomaticKeepAlives: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, mainAxisSpacing: 10),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, mainAxisSpacing: configuration.verticalSpacing),
itemCount: items.isEmpty ? 0 : 7 * lineCount,
itemBuilder: (context, index) {
DateModel dateModel = items[index];

@ -86,18 +86,18 @@ class _MonthViewPagerState extends State<MonthViewPager> with AutomaticKeepAlive
if (calendarProvider.calendarConfiguration.showMode !=
Constants.MODE_SHOW_ONLY_WEEK) {
//setState使
int lineCount =
DateUtil.getMonthViewLineCount(dateModel.year, dateModel.month);
double newHeight = (calendarProvider.calendarConfiguration.itemSize ??
MediaQuery.of(context).size.width / 7) *
lineCount +
calendarProvider.calendarConfiguration.verticalSpacing *
(lineCount - 1);
if (calendarProvider.totalHeight.toInt() != newHeight.toInt()) {
LogUtil.log(TAG: this.runtimeType, message: "月份视图高度发生变化");
calendarProvider.totalHeight = newHeight;
// calendarProvider.changeTotalHeight(newHeight);
}
// int lineCount =
// DateUtil.getMonthViewLineCount(dateModel.year, dateModel.month);
// double newHeight = (calendarProvider.calendarConfiguration.itemSize ??
// MediaQuery.of(context).size.width / 7) *
// lineCount +
// calendarProvider.calendarConfiguration.verticalSpacing *
// (lineCount - 1);
// if (calendarProvider.totalHeight.toInt() != newHeight.toInt()) {
// LogUtil.log(TAG: this.runtimeType, message: "月份视图高度发生变化");
// calendarProvider.totalHeight = newHeight;
//// calendarProvider.changeTotalHeight(newHeight);
// }
}
},
controller: configuration.monthController,

Loading…
Cancel
Save