浏览代码

Fix scroll index.

public int trueIndexOf(int index)  : in flutter Example: [ListWheelChildLoopingListDelegate] is built by looping a list of
  /// length 8. Then, trueIndexOf(10) = 2 and trueIndexOf(-5) = 3.
new DateTime(year: selectedYear, month: selectedMonth,
                                day: selectedDay)) : like in february, the date is still in 30, which will cause errors.
/main
Shiyun Wen 3 年前
当前提交
eb622493
共有 2 个文件被更改,包括 21 次插入12 次删除
  1. 20
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  2. 13
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs

20
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs


bool _isCurrentDateValid {
// The current date selection represents a range [minSelectedData, maxSelectDate].
get {
var minSelectedDate = new DateTime(year: selectedYear, month: selectedMonth, 1);
minSelectedDate = minSelectedDate.AddDays(selectedDay - 1);
var maxSelectedDate = minSelectedDate.AddDays(1);

onSelectedItemChanged: index => {
selectedDay = index + 1;
if (_isCurrentDateValid) {
widget.onDateTimeChanged(new DateTime(year: selectedYear, month: selectedMonth,
day: selectedDay));
var date = new DateTime(year: selectedYear, month: selectedMonth,day:1);
date.AddDays(selectedDay - 1);
widget.onDateTimeChanged(date);
}
},
children: widgets,

backgroundColor: widget.backgroundColor,
squeeze: CupertinoDatePickerUtils._kSqueeze,
onSelectedItemChanged: index => {
if (index < 0) {
index = -index;
}
widget.onDateTimeChanged(new DateTime(year: selectedYear, month: selectedMonth,
day: selectedDay));
var date = new DateTime(year: selectedYear, month: selectedMonth,day:1);
date.AddDays(selectedDay - 1);
widget.onDateTimeChanged(date);
}
},
children: widgets,

onSelectedItemChanged: index => {
selectedYear = index;
if (_isCurrentDateValid) {
widget.onDateTimeChanged(new DateTime(year: selectedYear, month: selectedMonth,
day: selectedDay));
var date = new DateTime(year: selectedYear, month: selectedMonth,day:1);
date.AddDays(selectedDay - 1);
widget.onDateTimeChanged(date);
}
},
itemBuilder: (_context, year) => {

13
com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs


}
public int trueIndexOf(int index) {
return index % children.Count;
var result = index;
if (index < 0) {
if (index % children.Count == 0)
result = 0;
else {
result = index % children.Count + children.Count;
}
}
else
result = index % children.Count;
return result;
}
public Widget build(BuildContext context, int index) {

正在加载...
取消
保存