網站首頁 編程語言 正文
前言
近期有個業務需求,涉及用戶付費相關的計算,需要一個日歷組件,組件功能如下:
- 僅支持從明天開始選擇預定日期
- 僅支持可選范圍內的日期
- 日期的選擇是連續的
- 有個推薦日期,需要聯動更新
- 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
原文鏈接:https://juejin.cn/post/7127970073897074702
相關推薦
- 2022-01-08 Unity如何制作道具tips隨著屏幕邊界自適應變換位置,確保不超出屏幕的功能
- 2023-04-03 iOS數據持久化KeyChain數據操作詳解_IOS
- 2023-01-23 C#實現鼠標左右鍵切換效果_C#教程
- 2022-10-01 詳解Python變量與注釋高級用法_python
- 2022-06-10 SQL?SERVER使用表分區優化性能_MsSql
- 2022-04-11 C++中引用和const關鍵字介紹_C 語言
- 2022-02-28 ESlint 報錯 ESlint: this line has a lines of 103.max
- 2022-07-20 C語言深入探究直接插入排序與希爾排序使用案例講解_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支