前言
近期有个事务需求,涉及用户付费相关的计算,需求一个日历组件,组件功用如下:
- 仅支撑从明天开端挑选预订日期
- 仅支撑可选范围内的日期
- 日期的挑选是连续的
- 有个推荐日期,需求联动更新
- todo:
- 支撑不连续的日期挑选
Github:tw_calendar
装置
dependencies:
tw_calendar: latest_version
作用
demo 演示
事务运用 headerView
运用
装备特点
/// 开端的年月份
final DateTime firstDate;
/// 结束的年月份
final DateTime lastDate;
/// 挑选开端日期
final DateTime? selectedStartDate;
/// 挑选结束日期
final DateTime? selectedEndDate;
/// 点击办法回调
final Function? onSelectFinish;
/// 头部组件
final Widget? headerView;
/// 挑选模式
final TWCalendarListSeletedMode? seletedMode;
/// 月视图高度,为空则占满剩下空间
final double? monthBodyHeight;
/// 周视图高度, 默认 48
final double? weekDayHeight;
/// 水平空隙
final double? horizontalSpace;
/// 承认周视图高度, 默认 66
final double? ensureViewHeight;
/// 承认按钮的空隙
final EdgeInsetsGeometry? ensureViewPadding;
/// 承认按钮选中颜色
final Color? ensureViewSelectedColor;
/// 承认未按钮选中颜色
final Color? ensureViewUnSelectedColor;
/// 今日的日期的布景颜色
final Color? dayNumberTodayColor;
/// 选中日期布景颜色
final Color? dayNumberSelectedColor;
/// 承认按钮字体大小
final double? ensureTitleFontSize;
/// 点击回调
final void Function(DateTime seletedDate, int seletedDays)? onSelectDayRang;
/// 挑选承认按钮 title 回调
final String Function(
DateTime? selectStartTime, DateTime? selectEndTime, int seletedDays)?
onSelectDayTitle;
DEMO
TWCalendarList(
firstDate: TWCalendarTool.tomorrow,
lastDate: DateTime(2022, 11, 21),
selectedStartDate: DateTime(2022, 9, 2),
selectedEndDate: DateTime(2022, 9, 10),
monthBodyHeight: 300.w,
seletedMode: TWCalendarListSeletedMode.singleSerial,
headerView: Container(
alignment: Alignment.center,
height: 55.w,
child: Text(
'日历组件',
style: TextStyle(
color: TWColors.tw333333,
fontSize: 18.w,
),
),
),
onSelectDayRang: ((seletedDate, seletedDays) {
print('seletedDate : $seletedDate, seletedDays : $seletedDays');
}),
onSelectFinish: (selectStartTime, selectEndTime) {
print(
'selectStartTime : $selectStartTime, selectEndTime : $selectEndTime');
Navigator.pop(context);
},
)
感谢
参考及修改至 demo: flutter_calendar_list