feat(update):更新时间组件星期显示
This commit is contained in:
@@ -83,38 +83,44 @@ class _CalendarChooseWidgetState extends State<CalendarChooseWidget> {
|
||||
String get dealTimeString {
|
||||
String? time = "";
|
||||
if (endTime == null) {
|
||||
time = DateTimeUtils.dateTimeUtilsTool(
|
||||
dateTime: startTime.toString(),
|
||||
dateTimeUtilsType:
|
||||
widget.dateTimeUtilsType ?? DateTimeUtilsType.yearMonthDay,
|
||||
);
|
||||
time = _formatDisplayDate(startTime);
|
||||
} else if (endTime == startTime) {
|
||||
time = DateTimeUtils.dateTimeUtilsTool(
|
||||
dateTime: startTime.toString(),
|
||||
dateTimeUtilsType:
|
||||
widget.dateTimeUtilsType ?? DateTimeUtilsType.yearMonthDay,
|
||||
);
|
||||
time = _formatDisplayDate(startTime);
|
||||
} else {
|
||||
time = "${DateTimeUtils.dateTimeUtilsTool(
|
||||
dateTime: startTime.toString(),
|
||||
dateTimeUtilsType:
|
||||
widget.dateTimeUtilsType ?? DateTimeUtilsType.yearMonthDay,
|
||||
)} - ${DateTimeUtils.dateTimeUtilsTool(
|
||||
dateTime: endTime.toString(),
|
||||
dateTimeUtilsType:
|
||||
widget.dateTimeUtilsType ?? DateTimeUtilsType.yearMonthDay,
|
||||
)}";
|
||||
time =
|
||||
"${_formatDisplayDate(startTime)} - ${_formatDisplayDate(endTime)}";
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
String _formatDisplayDate(DateTime? dateTime) {
|
||||
if (dateTime == null) {
|
||||
return '-- --';
|
||||
}
|
||||
final dateType = widget.dateTimeUtilsType ?? DateTimeUtilsType.yearMonthDay;
|
||||
final formatted = DateTimeUtils.dateTimeUtilsTool(
|
||||
dateTime: dateTime.toString(),
|
||||
dateTimeUtilsType: dateType,
|
||||
);
|
||||
if (widget.chooseIndex == 1 &&
|
||||
dateType == DateTimeUtilsType.yearMonthDayWord) {
|
||||
return '$formatted ${DateTimeUtils.getWeekDay(dateTime)}';
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
///日历弹窗
|
||||
onTapDate() {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final singlePickerHeight =
|
||||
screenHeight * 0.5 < 420 ? 420.0 : screenHeight * 0.5;
|
||||
final rangePickerHeight =
|
||||
screenHeight * 0.5 < 460 ? 460.0 : screenHeight * 0.5;
|
||||
if (widget.chooseIndex == 1) {
|
||||
ToastUtils.showBottomSheet(
|
||||
context: context,
|
||||
title: '选择时间',
|
||||
height: MediaQuery.of(context).size.height / 2,
|
||||
height: singlePickerHeight,
|
||||
isShowConfirm: true,
|
||||
contentWidget: CustomDatePicker(
|
||||
initialDate: DateTime.now(),
|
||||
@@ -131,7 +137,7 @@ class _CalendarChooseWidgetState extends State<CalendarChooseWidget> {
|
||||
ToastUtils.showBottomSheet(
|
||||
context: context,
|
||||
title: '选择时间',
|
||||
height: MediaQuery.of(context).size.height / 2,
|
||||
height: rangePickerHeight,
|
||||
isShowConfirm: true,
|
||||
contentWidget: CustomCalendarRangePickerWidget(
|
||||
firstDate: DateTime(DateTime.now().year - 2),
|
||||
|
||||
Reference in New Issue
Block a user