浏览代码

Fix scroll

/main
Shiyun Wen 3 年前
当前提交
7d56f661
共有 2 个文件被更改,包括 52 次插入29 次删除
  1. 72
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  2. 9
      com.unity.uiwidgets/Runtime/widgets/scroll_metrics.cs

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


public const float _kPickerHeight = 216.0f;
public const bool _kUseMagnifier = true;
public const float _kMagnification = 1.05f;
public const float _kDatePickerPadSize = 12.0f;
public const float _kDatePickerPadSize = 5f;//12.0f;
public const float _kSqueeze = 1.25f;
public static TextStyle _kDefaultPickerTextStyle = new TextStyle(
letterSpacing: -0.83f

public static TextStyle _themeTextStyle(BuildContext context, bool isValid = true ) {
TextStyle style = CupertinoTheme.of(context).textTheme.dateTimePickerTextStyle;
return isValid ? style : style.copyWith(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context));
return isValid ? style : style.copyWith(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)
);
}
public static void _animateColumnControllerToItem(FixedExtentScrollController controller, int targetItem) {

int selectedAmPm;
bool isHourRegionFlipped {
get { return _isHourRegionFlipped(selectedAmPm);}
get {
if (_isHourRegionFlipped(selectedAmPm)) {
int x = 0;
}
return _isHourRegionFlipped(selectedAmPm);
}
}
bool _isHourRegionFlipped(int selectedAmPm) => selectedAmPm != meridiemRegion;
int meridiemRegion;

}
DateTime selectedDateTime {
get {
return (new DateTime(
var hours = selectedHour;
var minutes = selectedMinute;
var initialDate = new DateTime(
)).AddHours(selectedHour).AddMinutes(selectedMinute).AddDays(selectedDayFromInitial);
);
return initialDate.AddMinutes( hours * 60 + minutes).AddDays(selectedDayFromInitial);
}
}
void _onSelectedItemChange(int index) {

initialDateTime.Year,
initialDateTime.Month,
initialDateTime.Day
)).AddHours( _selectedHour(meridiemIndex, hourIndex)).AddDays(selectedDayFromInitial);
)).AddHours(_selectedHour(meridiemIndex, hourIndex)).AddDays(selectedDayFromInitial);
bool minimum = widget.minimumDate == null ? true : widget.minimumDate?.CompareTo(rangeEnd) < 0;
bool maxmum = widget.maximumDate == null ? false : (widget.maximumDate?.CompareTo(rangeStart) < 0);
var minimum = widget.minimumDate == null ? true : widget.minimumDate?.CompareTo(rangeEnd) < 0;
var maxmum = widget.maximumDate == null ? false : widget.maximumDate?.CompareTo(rangeStart) < 0;
return minimum && !maxmum;
}
Widget _buildHourPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {

context,
new Text(
localizations.datePickerHour(displayHour),
//semanticsLabel: localizations.datePickerHourSemanticsLabel(displayHour),
style: CupertinoDatePickerUtils._themeTextStyle(context,
isValid: _isValidHour(selectedAmPm, index))
)

onSelectedItemChanged: (int index) =>{
bool regionChanged = meridiemRegion != (int)(index / 12);
bool debugIsFlipped = isHourRegionFlipped;
//Debug.Log("region " + meridiemRegion + "ampm " + selectedAmPm);
//Debug.Log("change region " + meridiemRegion + "ampm " + selectedAmPm);
if (debugIsFlipped != isHourRegionFlipped) {
var test = debugIsFlipped;
int i = 1;
}
if (!widget.use24hFormat && regionChanged) {

_onSelectedItemChange(index);
}
if (debugIsFlipped != isHourRegionFlipped) {
int i = 1;
}
D.assert(debugIsFlipped == isHourRegionFlipped);
},
children: widgets,

initialDateTime.Year,
initialDateTime.Month,
initialDateTime.Day
var minimum = widget.minimumDate == null ? false : widget.minimumDate?.CompareTo(date) > 0;
var maxmum = widget.maximumDate == null ? false : widget.maximumDate?.CompareTo(date) < 0;
bool isInvalidMinute = minimum || maxmum;
bool miniDate = widget.minimumDate == null ? false : widget.minimumDate?.CompareTo(date) > 0;
bool maxDate = widget.maximumDate == null ? false : widget.maximumDate?.CompareTo(date) < 0;
bool isInvalidMinute = miniDate || maxDate;
widgets.Add( itemPositioningBuilder(
context,

DateTime selectedDate = selectedDateTime;
bool minCheck = widget.minimumDate == null ? false : widget.minimumDate?.CompareTo(selectedDate) > 0 ;
bool maxCheck = widget.maximumDate == null ? false :widget.maximumDate?.CompareTo(selectedDate) < 0 ;
bool maxCheck = widget.maximumDate == null ? false : widget.maximumDate?.CompareTo(selectedDate) < 0 ;
if (minCheck || maxCheck) {
// We have minCheck === !maxCheck.

_buildHourPicker,
_buildMinutePicker
};
var test = 1;
if (!widget.use24hFormat) {
if (localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.date_time_dayPeriod
|| localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.time_dayPeriod_date) {

backgroundColor: widget.backgroundColor,
squeeze: CupertinoDatePickerUtils._kSqueeze,
onSelectedItemChanged: (int index) => {
if (index < 0) {
index += 31;
}
selectedDay = index + 1;
if (_isCurrentDateValid)
widget.onDateTimeChanged(new DateTime(selectedYear, selectedMonth, selectedDay));

backgroundColor: widget.backgroundColor,
squeeze: CupertinoDatePickerUtils._kSqueeze,
onSelectedItemChanged: (int index) => {
if (index < 0)
index += 12;
Debug.Log("month is " + selectedMonth);
if (selectedMonth == 0) {
int j = 100;
}
if (_isCurrentDateValid)
widget.onDateTimeChanged(new DateTime(selectedYear, selectedMonth, selectedDay));
},

}
DateTime minSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay);
DateTime maxSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay + 1);
DateTime maxSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay ).AddDays(1);
bool minCheck = widget.minimumDate == null ? true : widget.minimumDate?.CompareTo(maxSelectDate) > 0 ;
bool minCheck = widget.minimumDate == null ? false : widget.minimumDate?.CompareTo(maxSelectDate) > 0 ;
if (!minCheck || maxCheck) {
if (minCheck || maxCheck) {
DateTime targetDate = minCheck ? (DateTime) widget.maximumDate : (DateTime) widget.minimumDate;
_scrollToDate(targetDate);
return;

float totalWidth = CupertinoDatePickerUtils._kPickerWidth;
D.assert(paddingValue >= 0);
switch (widget.mode) {
case CupertinoTimerPickerMode.hm:
// Pad the widget to make it as wide as `_kPickerWidth`.

}
}
}

9
com.unity.uiwidgets/Runtime/widgets/scroll_metrics.cs


);
}
/*if (it is IFixedExtentMetrics) {
return new FixedExtentMetrics(
if (it is IFixedExtentMetrics) {
Debug.Log("item index " + ((IFixedExtentMetrics)it).itemIndex );
return new FixedExtentMetrics(
itemIndex: ((IFixedExtentMetrics)it).itemIndex
itemIndex: ((IFixedExtentMetrics)it).itemIndex
}*/
}
return new FixedScrollMetrics(
minScrollExtent: minScrollExtent ?? it.minScrollExtent,

正在加载...
取消
保存