Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion lib/time_picker/route/date_picker_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ class _PickerState extends State<_PickerContentView> {
_setMonth();
break;
case DateType.Day:
_setDay();
break;
case DateType.Hour:
_setHour();
Expand Down Expand Up @@ -540,6 +541,40 @@ class _PickerState extends State<_PickerContentView> {
}
}

void _setDay() {
/// 小时的变化
if (_dateItemModel.hour) {
int index = 0;
int begin = 0;
int end = 23;
// 限制区域
if (intNotEmpty(minDate.hour)) {
begin = minDate.hour!;
}
if (intNotEmpty(maxDate.hour) &&
_selectData.year == maxDate.year &&
_selectData.month == maxDate.month &&
_selectData.day == maxDate.day
) {
end = maxDate.hour!;
}

_dateTimeData.hour = TimeUtils.calcHour(begin: begin, end: end);

if (_initSelectData.hour != null) {
index = _dateTimeData.hour.indexOf(_initSelectData.hour);
index = index < 0 ? 0 : index;
}
// setState(() {
// _selectData.hour = _dateTimeData.hour[index];
// scrollCtrl[DateType.Hour] =
// FixedExtentScrollController(initialItem: index);
// });
_setHour();
_setMinute();
}
}

void _setHour() {
// 可能造成 分 秒 list的改变
if (_dateItemModel.minute) {
Expand All @@ -554,7 +589,12 @@ class _PickerState extends State<_PickerContentView> {
if (intNotEmpty(minDate.minute) && _selectData.hour == minDate.hour) {
beginMinute = minDate.minute!;
}
if (intNotEmpty(maxDate.minute) && _selectData.hour == maxDate.hour) {
if (intNotEmpty(maxDate.minute) &&
_selectData.year == maxDate.year &&
_selectData.month == maxDate.month &&
_selectData.day == maxDate.day &&
_selectData.hour == maxDate.hour
) {
endMinute = maxDate.minute!;
}

Expand Down