buildWidget method
构建主体
Implementation
@override
Widget buildWidget(XBCalendarVM vm, BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(15), topRight: Radius.circular(15)),
child: Container(
height: screenH * 0.85,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 50,
child: Row(
children: [
XBButton(
onTap: vm.goCurrentDay,
coverTransparentWhileOpacity: true,
child: Container(
width: _closeW + spaces.gapLess * 2,
height: 50,
alignment: Alignment.center,
child: XBImage(
"packages/xb_calendar/assets/images/icon_current_day.png",
width: _closeW,
),
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
title ?? "日期选择",
style: display?.textStyleTitle,
))),
XBButton(
onTap: () {
pop();
onCancel?.call();
},
coverTransparentWhileOpacity: true,
child: Padding(
padding: EdgeInsets.only(
left: spaces.gapLess,
right: spaces.gapLess,
top: 10,
bottom: 10),
child: XBImage(
"packages/xb_calendar/assets/images/icon_close.png",
width: _closeW,
),
),
)
],
),
),
SizedBox(
height: 50,
child: Row(
children: [
Expanded(
child: chooseBtn(
text: vm.scrollYear,
onPrevious: vm.previousYear,
onNext: vm.nextYear,
mainAxisAlignment: MainAxisAlignment.start),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
vm.scrollDate,
style: display?.textStyleScrollDate,
)),
),
Expanded(
child: chooseBtn(
text: vm.scrollMonth,
onPrevious: vm.previousMonth,
onNext: vm.nextMonth,
mainAxisAlignment: MainAxisAlignment.end),
),
],
),
),
SizedBox(
height: 50,
child: Row(
children: vm.weekDaysWidgets,
),
),
Container(
height: 10,
color: Colors.grey.withAlpha(30),
),
Expanded(
child: ScrollConfiguration(
behavior: const ScrollBehavior()
.copyWith(overscroll: false, scrollbars: false), // 禁用滚动条
child: ListView.builder(
controller: vm.controller,
itemCount: vm.monthCount,
itemBuilder: (context, index) {
XBCalendarMonth month = vm.monthForIndex(index);
return XBCalendarMonthCell(
month: month,
onSelectDate: vm.onSelectDate,
display: display,
yearUnit: yearUnit,
monthUnit: monthUnit,
);
},
),
)),
hms(vm),
xbSpaceHeight(donePaddingTop),
Padding(
padding: EdgeInsets.only(
left: spaces.gapDef,
right: spaces.gapDef,
bottom: safeAreaBottom + spaces.gapDef),
child: XBButton(
onTap: vm.onDone,
child: ClipRRect(
borderRadius:
BorderRadius.circular(display?.dDoneBtnRadius ?? 6),
child: Container(
alignment: Alignment.center,
height: display?.dDoneBtnHeight ?? 50,
color: display?.colorDoneBtnBg ?? Colors.blue,
child: Text(
doneBtnText ?? "确定",
style: display?.textStyleDoneBtn ??
const TextStyle(color: Colors.white),
)),
)),
)
],
),
),
);
}