浏览代码

bug fix on material datetime picker widget

/zxw-fix_material_datepicker_issue
Xingwei Zhu 3 年前
当前提交
778177cf
共有 6 个文件被更改,包括 17 次插入8 次删除
  1. 6
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs
  2. 9
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  3. 2
      com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs
  4. 2
      com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs
  5. 2
      com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs
  6. 4
      com.unity.uiwidgets/Runtime/material/time_picker.cs

6
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs


this.labelText = labelText;
this.selectDate = selectDate;
this.selectedTime = selectedTime;
this.selectDate = selectDate;
this.selectedDate = selectedDate;
this.selectTime = selectTime;
}

material_.showDatePicker(
context: context,
initialDate: this.selectedDate.Value,
firstDate: new DateTime(2015, 8, 0),
lastDate: new DateTime(2101, 0, 0)
firstDate: new DateTime(2015, 8, 1),
lastDate: new DateTime(2030, 1, 1)
).then((object value) =>
{
var picked = (DateTime) value;

9
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs


buildRoute: (BuildContext context) => new PageSelectorDemo()
),
new GalleryDemo(
title: "Pickers",
subtitle: "Date and time selection widgets",
icon: GalleryIcons.events,
category: GalleryDemoCategory._kMaterialComponents,
routeName: DateAndTimePickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/showDatePicker.html",
buildRoute: (BuildContext context) => new DateAndTimePickerDemo()
),
new GalleryDemo(
title: "Progress indicators",
subtitle: "Linear, circular, indeterminate",
icon: GalleryIcons.progress_activity,

2
com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs


for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) {
string weekday = localizations.narrowWeekdays[i];
result.Add(new Center(child: new Text(weekday, style: headerStyle)));
if (i == (localizations.firstDayOfWeekIndex - 1) % 7)
if (i == (localizations.firstDayOfWeekIndex - 1 + 7) % 7)
break;
}

2
com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs


}
public static DateTime addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) {
return new DateTime(monthDate.Year, monthDate.Month + monthsToAdd, 1);
return monthDate.AddMonths(monthsToAdd);
}
public static int firstDayOffset(int year, int month, MaterialLocalizations localizations) {

2
com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs


public readonly WhitelistingTextInputFormatter _filterFormatter =
// Only allow digits and separators (slash, dot, comma, hyphen, space).
new WhitelistingTextInputFormatter(new Regex(@"[\d\/\.,-\s]+"));
new WhitelistingTextInputFormatter(new Regex(@"[\d\/\.,\- ]+"));
public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
TextEditingValue filteredValue = _filterFormatter.formatEditUpdate(oldValue, newValue);

4
com.unity.uiwidgets/Runtime/material/time_picker.cs


if (fragmentContext.use24HourDials) {
int selectedHour = fragmentContext.selectedTime.hour;
return fragmentContext.selectedTime.replacing(
hour: (selectedHour + hoursToAdd) % TimeOfDay.hoursPerDay
hour: (selectedHour + hoursToAdd + TimeOfDay.hoursPerDay) % TimeOfDay.hoursPerDay
);
}
else {

hour: periodOffset + (hours + hoursToAdd) % TimeOfDay.hoursPerPeriod
hour: (periodOffset + (hours + hoursToAdd) + TimeOfDay.hoursPerPeriod) % TimeOfDay.hoursPerPeriod
);
}
}

正在加载...
取消
保存