浏览代码

fix errors

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
bf942caf
共有 6 个文件被更改,包括 110 次插入116 次删除
  1. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs
  2. 71
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  3. 32
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  4. 32
      com.unity.uiwidgets/Runtime/cupertino/picker.cs
  5. 2
      com.unity.uiwidgets/Runtime/cupertino/slider.cs
  6. 86
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs


//return new CupertinoNavigationDemo();
//return new CupertinoAlertDemo();
return new CupertinoPickerDemo();
//return new CupertinoPickerDemo();
return new CupertinoSwitchDemo();
}
}

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


}
return false;
},
child: CupertinoPicker.builder(
child: new CupertinoPicker(
scrollController: dateController,
offAxisFraction: offAxisFraction,
itemExtent: CupertinoDatePickerUtils._kItemExtent,

onSelectedItemChanged: (int index)=> {
_onSelectedItemChange(index);
},
itemBuilder: (BuildContext context, int index) =>{
DateTime rangeStart = new DateTime(
initialDateTime.Year,
initialDateTime.Month,
initialDateTime.Day + index
itemBuilder: (BuildContext context, int index) => {
var startDay = initialDateTime.Day + index;
var rangeStart = new DateTime(
year:initialDateTime.Year,
month:initialDateTime.Month,
day:startDay
DateTime rangeEnd = new DateTime(
initialDateTime.Year,
initialDateTime.Month,
initialDateTime.Day + index + 1
);
var rangeEnd = rangeStart.AddDays(1);
if (widget.minimumDate?.CompareTo(rangeEnd) > 0 )
if (widget.minimumDate?.CompareTo(rangeEnd) > 0 )
return null;
if (widget.maximumDate?.CompareTo(rangeStart) > 0)
return null;

if (textDirectionFactor == -1)
padding = padding.flipped;
pickers.Add(new LayoutId(
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext context1, Widget child) =>{
return new Container(
alignment: i == columnWidths.Count - 1
? alignCenterLeft
: alignCenterRight,
padding: padding,
child: new Container(
alignment: i == columnWidths.Count - 1 ? alignCenterLeft : alignCenterRight,
width: i == 0 || i == columnWidths.Count - 1
? (float?) null : (float)(columnWidths[i] + CupertinoDatePickerUtils._kDatePickerPadSize),
child: child
)
);
}
float width = columnWidths[i];
pickers.Add(
new LayoutId(
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext context1, Widget child) =>{
return new Container(
alignment: i == columnWidths.Count - 1
? alignCenterLeft
: alignCenterRight,
padding: padding,
child: new Container(
alignment: i == columnWidths.Count - 1 ? alignCenterLeft : alignCenterRight,
width: i == 0 || i == columnWidths.Count - 1
? (float?) null : (float)(width + CupertinoDatePickerUtils._kDatePickerPadSize),
child: child
)
);
}
)
));
}

CupertinoDatePicker._getColumnWidth(_PickerColumnType.year, localizations, context);
}
DateTime _lastDayInMonth(int year, int month) => new DateTime(year, month + 1, 0);
DateTime _lastDayInMonth(int year, int month) {
//new DateTime(year, month + 1, 0);
var date = new DateTime(year,month,1);
date.AddMonths(1);
date.Subtract(new TimeSpan(1, 0, 0, 0));
return date;
}
Widget _buildDayPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
int daysInCurrentMonth = _lastDayInMonth(selectedYear, selectedMonth).Day;

return false;
},
child: CupertinoPicker.builder(
child: new CupertinoPicker (
scrollController: yearController,
itemExtent: CupertinoDatePickerUtils._kItemExtent,
offAxisFraction: offAxisFraction,

32
com.unity.uiwidgets/Runtime/cupertino/dialog.cs


public readonly bool isPressed;
public override void applyParentData(RenderObject renderObject) {
D.assert(renderObject.parentData is _DialogActionButtonParentData);
_DialogActionButtonParentData parentData = renderObject.parentData as _DialogActionButtonParentData;
D.assert(renderObject.parentData is _ActionButtonParentData);
_ActionButtonParentData parentData = renderObject.parentData as _ActionButtonParentData;
if (parentData.isPressed != isPressed) {
parentData.isPressed = isPressed;
AbstractNodeMixinDiagnosticableTree targetParent = renderObject.parent;

}
}
class _DialogActionButtonParentData : MultiChildLayoutParentData {
/*class _DialogActionButtonParentData : MultiChildLayoutParentData {
public _DialogActionButtonParentData(
bool isPressed = false
) {

public bool isPressed;
}
}*/
public class CupertinoDialogAction : StatelessWidget {
public CupertinoDialogAction(

RenderBox currentChild = firstChild;
while (currentChild != null) {
D.assert(currentChild.parentData is _DialogActionButtonParentData);
_DialogActionButtonParentData parentData = currentChild.parentData as _DialogActionButtonParentData;
D.assert(currentChild.parentData is _ActionButtonParentData);
_ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData;
if (parentData.isPressed) {
childList.Add(currentChild);
}

get {
RenderBox currentChild = firstChild;
while (currentChild != null) {
D.assert(currentChild.parentData is _DialogActionButtonParentData);
_DialogActionButtonParentData parentData = currentChild.parentData as _DialogActionButtonParentData;
D.assert(currentChild.parentData is _ActionButtonParentData);
_ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData;
if (parentData.isPressed) {
return true;
}

}
public override void setupParentData(RenderObject child) {
if (!(child.parentData is _DialogActionButtonParentData)) {
child.parentData = new _DialogActionButtonParentData();
if (!(child.parentData is _ActionButtonParentData)) {
child.parentData = new _ActionButtonParentData();
}
}

RenderBox prevChild = null;
while (child != null) {
D.assert(child.parentData is _DialogActionButtonParentData);
_DialogActionButtonParentData currentButtonParentData =
child.parentData as _DialogActionButtonParentData;
D.assert(child.parentData is _ActionButtonParentData);
_ActionButtonParentData currentButtonParentData =
child.parentData as _ActionButtonParentData;
D.assert(prevChild.parentData is _DialogActionButtonParentData);
_DialogActionButtonParentData previousButtonParentData =
prevChild.parentData as _DialogActionButtonParentData;
D.assert(prevChild.parentData is _ActionButtonParentData);
_ActionButtonParentData previousButtonParentData =
prevChild.parentData as _ActionButtonParentData;
isPrevButtonPressed = previousButtonParentData.isPressed;
}

32
com.unity.uiwidgets/Runtime/cupertino/picker.cs


public class CupertinoPicker : StatefulWidget {
public CupertinoPicker(
List<Widget> children,
Key key = null,
float? diameterRatio = null,
Color backgroundColor = null,

float? squeeze = null,
float? itemExtent = null,
ValueChanged<int> onSelectedItemChanged = null,
List<Widget> children = null,
D.assert(children != null);
// D.assert(children != null);
D.assert(diameterRatio > 0.0f, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(magnification > 0);
D.assert(itemExtent != null);

: new ListWheelChildListDelegate(children: children);
}
public static CupertinoPicker builder(
public CupertinoPicker(
Key key = null,
float? diameterRatio = null,
Color backgroundColor = null,

D.assert(itemExtent != null);
D.assert(itemExtent > 0);
D.assert(squeeze > 0);
CupertinoPicker picker = new CupertinoPicker(
key,
diameterRatio ,
backgroundColor,
offAxisFraction ,
useMagnifier ,
magnification ,
scrollController,
squeeze ,
itemExtent,
onSelectedItemChanged);
picker.childDelegate = new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
return picker;
this.diameterRatio = diameterRatio;
this.backgroundColor = backgroundColor;
this.offAxisFraction = offAxisFraction;
this.useMagnifier = useMagnifier;
this.magnification = magnification;
this.scrollController = scrollController;
this.squeeze = squeeze;
this.itemExtent = itemExtent;
this.onSelectedItemChanged = onSelectedItemChanged;
childDelegate =new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
}
public readonly float? diameterRatio;

Positioned.fill(
child: new _CupertinoPickerSemantics(
scrollController: widget.scrollController ?? _controller,
child: ListWheelScrollView.useDelegate(
child: new ListWheelScrollView(
controller: widget.scrollController ?? _controller,
physics: new FixedExtentScrollPhysics(),
diameterRatio: widget.diameterRatio ?? CupertinoPickerUtils._kDefaultDiameterRatio,

2
com.unity.uiwidgets/Runtime/cupertino/slider.cs


D.assert(onChanged != null);
D.assert(value >= min && value <= max);
D.assert(divisions == null || divisions > 0);
D.assert(thumbColor != null);
this.value = value.Value;
this.onChanged = onChanged;
this.onChangeStart = onChangeStart;

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


}
public int trueIndexOf(int index) {
while (index < 0) {
index += children.Count;
}
return index % children.Count;
}

}
while (index < 0) {
index += children.Count;
}
return new Container(child: children[index % children.Count]);
return new Container(child: children[Mathf.Abs(index % children.Count)]);
}
public bool shouldRebuild(ListWheelChildDelegate oldDelegate) {

}
public void jumpToItem(int itemIndex) {
foreach (_FixedExtentScrollPosition position in positions) {
foreach (_FixedExtentScrollPosition position in positions.Cast<_FixedExtentScrollPosition>()) {
position.jumpTo(itemIndex * position.itemExtent);
}
}

public class ListWheelScrollView : StatefulWidget {
public ListWheelScrollView(
List<Widget> children,
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

float squeeze = 1.0f,
ValueChanged<int> onSelectedItemChanged = null,
bool clipToSize = true,
bool renderChildrenOutsideViewport = false,
List<Widget> children = null
bool renderChildrenOutsideViewport = false
D.assert(children != null || childDelegate != null);
//D.assert(children != null);
D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(perspective > 0);
D.assert(perspective <= 0.01f, () => RenderListWheelViewport.perspectiveTooHighMessage);

this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
}
public static ListWheelScrollView useDelegate(
public ListWheelScrollView (
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

bool clipToSize = true,
bool renderChildrenOutsideViewport = false,
ListWheelChildDelegate childDelegate = null
) {
) : base(key: key) {
D.assert(childDelegate != null);
D.assert(diameterRatio > 0.0, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(perspective > 0);

!renderChildrenOutsideViewport || !clipToSize,()=>
RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
);
var view = new ListWheelScrollView(
itemExtent: itemExtent,
key: key,
controller: controller,
physics: physics,
diameterRatio: diameterRatio,
perspective: perspective,
offAxisFraction: offAxisFraction,
useMagnifier: useMagnifier,
magnification: magnification,
onSelectedItemChanged: onSelectedItemChanged,
clipToSize: clipToSize,
renderChildrenOutsideViewport: renderChildrenOutsideViewport
);
view.childDelegate = childDelegate;
return view;
this.controller = controller;
this.physics = physics;
this.diameterRatio = diameterRatio;
this.perspective = perspective;
this.offAxisFraction = offAxisFraction;
this.useMagnifier = useMagnifier;
this.magnification = magnification;
this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.itemExtent = itemExtent;
this.squeeze = squeeze;
this.onSelectedItemChanged = onSelectedItemChanged;
this.clipToSize = clipToSize;
this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
this.childDelegate = childDelegate;
}
public readonly ScrollController controller;

useMagnifier: widget.useMagnifier,
magnification: widget.magnification,
overAndUnderCenterOpacity: widget.overAndUnderCenterOpacity,
itemExtent: widget.itemExtent ?? 0.0f,
itemExtent: widget.itemExtent ,
squeeze: widget.squeeze,
clipToSize: widget.clipToSize,
renderChildrenOutsideViewport: widget.renderChildrenOutsideViewport,

}
public new RenderListWheelViewport renderObject {
get { return (RenderListWheelViewport) base.renderObject; }
get { return (RenderListWheelViewport)base.renderObject; }
}

}
int firstIndex = _childElements.First()?.Key ?? 0;
int lastIndex = _childElements.Last()?.Key ?? 0;
int lastIndex = _childElements.Last()?.Key ?? _childElements.Count;
for (int index = firstIndex; index <= lastIndex; ++index) {
Element newChild = updateChild(_childElements[index], retrieveWidget(index), index);

owner.buildScope(this, () => {
bool insertFirst = after == null;
D.assert(insertFirst || _childElements[index - 1] != null);
Element newChild = updateChild(_childElements.getOrDefault(index), retrieveWidget(index),
index);
Element newChild = updateChild(_childElements.getOrDefault(index), retrieveWidget(index), index);
if (newChild != null) {
_childElements[index] = newChild;
}

protected override void insertChildRenderObject(RenderObject child, object slot) {
RenderListWheelViewport renderObject = this.renderObject;
D.assert(renderObject.debugValidateChild(child));
renderObject.insert(child as RenderBox, after: _childElements[(int)slot - 1]?.renderObject as RenderBox);
int slotNum = (int) slot;
if(slotNum >= 1)
renderObject.insert(child as RenderBox, after: _childElements.getOrDefault(slotNum - 1).renderObject as RenderBox);
protected override void moveChildRenderObject(RenderObject child, dynamic slot) {
const string moveChildRenderObjectErrorMessage =
protected override void moveChildRenderObject(RenderObject child, dynamic slot) {
string moveChildRenderObjectErrorMessage =
"Currently we maintain the list in contiguous increasing order, so " +
"moving children around is not allowed.";
D.assert(false, () => moveChildRenderObjectErrorMessage);

!renderChildrenOutsideViewport || !clipToSize,
() => RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
);
this.itemExtent = itemExtent;
this.offset = offset;
this.childDelegate = childDelegate;
this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.itemExtent = itemExtent;
this.squeeze = squeeze;
this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.squeeze = squeeze;
this.offset = offset;
this.childDelegate = childDelegate;
}
public readonly float diameterRatio;

useMagnifier: useMagnifier,
magnification: magnification,
overAndUnderCenterOpacity: overAndUnderCenterOpacity,
itemExtent: itemExtent ?? 0.0f,
itemExtent: itemExtent ?? 1.0f ,
squeeze: squeeze,
clipToSize: clipToSize,
renderChildrenOutsideViewport: renderChildrenOutsideViewport

viewport.useMagnifier = useMagnifier;
viewport.magnification = magnification;
viewport.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
viewport.itemExtent = itemExtent ?? 0.0f;
viewport.itemExtent = itemExtent ?? 1.0f;
viewport.squeeze = squeeze;
viewport.clipToSize = clipToSize;
viewport.renderChildrenOutsideViewport = renderChildrenOutsideViewport;

正在加载...
取消
保存