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

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

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

Loading…
Cancel
Save