浏览代码

Remove text direction.

/main
Yuncong Zhang 6 年前
当前提交
fbe8af56
共有 6 个文件被更改,包括 57 次插入236 次删除
  1. 26
      Runtime/material/dropdown.cs
  2. 28
      Runtime/material/input_border.cs
  3. 200
      Runtime/material/input_decorator.cs
  4. 33
      Runtime/material/progress_indicator.cs
  5. 4
      Runtime/widgets/form.cs
  6. 2
      Runtime/widgets/will_pop_scope.cs

26
Runtime/material/dropdown.cs


public _DropdownMenuRouteLayout(
Rect buttonRect,
float menuTop,
float menuHeight,
TextDirection textDirection
float menuHeight
this.textDirection = textDirection;
public readonly TextDirection textDirection;
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
float maxHeight = Mathf.Max(0.0f, constraints.maxHeight - 2 * DropdownConstants._kMenuItemHeight);

return true;
});
float left;
switch (this.textDirection) {
case TextDirection.rtl:
left = this.buttonRect.right.clamp(0.0f, size.width) - childSize.width;
break;
case TextDirection.ltr:
left = this.buttonRect.left.clamp(0.0f, size.width - childSize.width);
break;
default:
throw new Exception("Unknown text direction: " + this.textDirection);
}
float left = this.buttonRect.right.clamp(0.0f, size.width) - childSize.width;
return new Offset(left, this.menuTop);
}

|| this.menuTop != oldDelegate.menuTop
|| this.menuHeight != oldDelegate.menuHeight
|| this.textDirection != oldDelegate.textDirection;
|| this.menuHeight != oldDelegate.menuHeight;
}
}

this.scrollController = new ScrollController(initialScrollOffset: scrollOffset);
}
TextDirection textDirection = Directionality.of(context);
Widget menu = new _DropdownMenu<T>(
route: this,
padding: this.padding

layoutDelegate: new _DropdownMenuRouteLayout<T>(
buttonRect: this.buttonRect,
menuTop: menuTop ?? 0.0f,
menuHeight: menuHeight,
textDirection: textDirection
menuHeight: menuHeight
),
child: menu
);

void _handleTap() {
RenderBox itemBox = (RenderBox) this.context.findRenderObject();
Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
TextDirection textDirection = Directionality.of(this.context);
EdgeInsets menuMargin = ButtonTheme.of(this.context).alignedDropdown
? DropdownConstants._kAlignedMenuMargin
: DropdownConstants._kUnalignedMenuMargin;

28
Runtime/material/input_border.cs


public abstract void paint(Canvas canvas, Rect rect,
float gapStart,
float gapExtent = 0.0f,
float gapPercentage = 0.0f,
TextDirection? textDirection = null
float gapPercentage = 0.0f
);
public override void paint(Canvas canvas, Rect rect) {

public override void paint(Canvas canvas, Rect rect,
float gapStart,
float gapExtent = 0.0f,
float gapPercentage = 0.0f,
TextDirection? textDirection = null
float gapPercentage = 0.0f
class UnderlineInputBorder : InputBorder {
public class UnderlineInputBorder : InputBorder {
public UnderlineInputBorder(
BorderSide borderSide = null,
BorderRadius borderRadius = null

public override void paint(Canvas canvas, Rect rect,
float gapStart,
float gapExtent = 0.0f,
float gapPercentage = 0.0f,
TextDirection? textDirection = null
float gapPercentage = 0.0f
) {
if (this.borderRadius.bottomLeft != Radius.zero || this.borderRadius.bottomRight != Radius.zero) {
canvas.clipPath(this.getOuterPath(rect));

public override void paint(Canvas canvas, Rect rect,
float gapStart,
float gapExtent = 0.0f,
float gapPercentage = 0.0f,
TextDirection? textDirection = null
float gapPercentage = 0.0f
) {
D.assert(gapPercentage >= 0.0f && gapPercentage <= 1.0f);
D.assert(_cornersAreCircular(this.borderRadius));

}
else {
float extent = MathUtils.lerpFloat(0.0f, gapExtent + this.gapPadding * 2.0f, gapPercentage);
switch (textDirection) {
case TextDirection.rtl: {
Path path = this._gapBorderPath(canvas, center, gapStart + this.gapPadding - extent, extent);
canvas.drawPath(path, paint);
break;
}
case TextDirection.ltr: {
Path path = this._gapBorderPath(canvas, center, gapStart - this.gapPadding, extent);
canvas.drawPath(path, paint);
break;
}
}
Path path = this._gapBorderPath(canvas, center, gapStart - this.gapPadding, extent);
canvas.drawPath(path, paint);
}
}

200
Runtime/material/input_decorator.cs


_InputBorderTween border = null,
Animation<float> gapAnimation = null,
_InputBorderGap gap = null,
TextDirection? textDirection = null,
Color fillColor = null
) : base(repaint: repaint) {
this.borderAnimation = borderAnimation;

this.textDirection = textDirection;
this.fillColor = fillColor;
}

public readonly _InputBorderGap gap;
public readonly TextDirection? textDirection;
public readonly Color fillColor;
public override void paint(Canvas canvas, Size size) {

canvasRect,
gapStart: this.gap.start,
gapExtent: this.gap.extent,
gapPercentage: this.gapAnimation.value,
textDirection: this.textDirection
gapPercentage: this.gapAnimation.value
);
}

|| this.gapAnimation != oldPainter.gapAnimation
|| this.border != oldPainter.border
|| this.gap != oldPainter.gap
|| this.textDirection != oldPainter.textDirection;
|| this.gap != oldPainter.gap;
}
}

border: this._border,
gapAnimation: this.widget.gapAnimation,
gap: this.widget.gap,
textDirection: Directionality.of(context),
fillColor: this.widget.fillColor
),
child: this.widget.child

class _RenderDecoration : RenderBox {
public _RenderDecoration(
_Decoration decoration,
TextDirection? textDirection,
D.assert(textDirection != null);
this._textDirection = textDirection;
this._textBaseline = textBaseline;
this._isFocused = isFocused;
}

_Decoration _decoration;
public TextDirection? textDirection {
get { return this._textDirection; }
set {
D.assert(value != null);
if (this._textDirection == value) {
return;
}
this._textDirection = value;
this.markNeedsLayout();
}
}
TextDirection? _textDirection;
public TextBaseline? textBaseline {
get { return this._textBaseline; }
set {

width: overallWidth - _boxSize(this.icon).width
);
this.container.layout(containerConstraints, parentUsesSize: true);
float x;
switch (this.textDirection) {
case TextDirection.rtl:
x = 0.0f;
break;
case TextDirection.ltr:
x = _boxSize(this.icon).width;
break;
default:
throw new Exception("Unknown direction: " + this.textDirection);
}
float x = _boxSize(this.icon).width;
_boxParentData(this.container).offset = new Offset(x, 0.0f);
}

: layout.outlineBaseline) ?? 0.0f;
if (this.icon != null) {
float x;
switch (this.textDirection) {
case TextDirection.rtl:
x = overallWidth - this.icon.size.width;
break;
case TextDirection.ltr:
x = 0.0f;
break;
default:
throw new Exception("Unknown direction: " + this.textDirection);
}
float x = 0.0f;
switch (this.textDirection) {
case TextDirection.rtl: {
float start = right - _boxSize(this.icon).width;
float end = left;
if (this.prefixIcon != null) {
start += this.contentPadding.left;
start -= centerLayout(this.prefixIcon, start - this.prefixIcon.size.width);
}
if (this.label != null) {
centerLayout(this.label, start - this.label.size.width);
}
if (this.prefix != null) {
start -= baselineLayout(this.prefix, start - this.prefix.size.width);
}
if (this.input != null) {
baselineLayout(this.input, start - this.input.size.width);
}
if (this.hint != null) {
baselineLayout(this.hint, start - this.hint.size.width);
}
if (this.suffixIcon != null) {
end -= this.contentPadding.left;
end += centerLayout(this.suffixIcon, end);
}
if (this.suffix != null) {
end += baselineLayout(this.suffix, end);
}
break;
}
case TextDirection.ltr: {
float start = left + _boxSize(this.icon).width;
float end = right;
if (this.prefixIcon != null) {
start -= this.contentPadding.left;
start += centerLayout(this.prefixIcon, start);
}
if (this.label != null) {
centerLayout(this.label, start);
}
float start = left + _boxSize(this.icon).width;
float end = right;
if (this.prefixIcon != null) {
start -= this.contentPadding.left;
start += centerLayout(this.prefixIcon, start);
}
if (this.prefix != null) {
start += baselineLayout(this.prefix, start);
}
if (this.label != null) {
centerLayout(this.label, start);
}
if (this.input != null) {
baselineLayout(this.input, start);
}
if (this.prefix != null) {
start += baselineLayout(this.prefix, start);
}
if (this.hint != null) {
baselineLayout(this.hint, start);
}
if (this.input != null) {
baselineLayout(this.input, start);
}
if (this.suffixIcon != null) {
end += this.contentPadding.right;
end -= centerLayout(this.suffixIcon, end - this.suffixIcon.size.width);
}
if (this.hint != null) {
baselineLayout(this.hint, start);
}
if (this.suffix != null) {
end -= baselineLayout(this.suffix, end - this.suffix.size.width);
}
if (this.suffixIcon != null) {
end += this.contentPadding.right;
end -= centerLayout(this.suffixIcon, end - this.suffixIcon.size.width);
}
break;
}
if (this.suffix != null) {
end -= baselineLayout(this.suffix, end - this.suffix.size.width);
}
if (this.helperError != null || this.counter != null) {

switch (this.textDirection) {
case TextDirection.rtl:
if (this.helperError != null) {
baselineLayout(this.helperError,
right - this.helperError.size.width - _boxSize(this.icon).width);
}
if (this.helperError != null) {
baselineLayout(this.helperError, left + _boxSize(this.icon).width);
}
if (this.counter != null) {
baselineLayout(this.counter, left);
}
if (this.counter != null) {
baselineLayout(this.counter, right - this.counter.size.width);
}
break;
case TextDirection.ltr:
if (this.helperError != null) {
baselineLayout(this.helperError, left + _boxSize(this.icon).width);
}
if (this.counter != null) {
baselineLayout(this.counter, right - this.counter.size.width);
}
break;
}
switch (this.textDirection) {
case TextDirection.rtl:
this.decoration.borderGap.start = labelX + this.label.size.width;
break;
case TextDirection.ltr:
this.decoration.borderGap.start = labelX - _boxSize(this.icon).width;
break;
}
this.decoration.borderGap.start = labelX - _boxSize(this.icon).width;
this.decoration.borderGap.extent = this.label.size.width * 0.75f;
}

bool isOutlineBorder = this.decoration.border != null && this.decoration.border.isOutline;
float floatingY = isOutlineBorder ? -labelHeight * 0.25f : this.contentPadding.top;
float scale = MathUtils.lerpFloat(1.0f, 0.75f, t);
float dx;
switch (this.textDirection) {
case TextDirection.rtl:
dx = labelOffset.dx + this.label.size.width * (1.0f - scale);
break;
case TextDirection.ltr:
dx = labelOffset.dx;
break;
default:
throw new Exception("Unknown direction: " + this.textDirection);
}
float dx = labelOffset.dx;
float dy = MathUtils.lerpFloat(0.0f, floatingY - labelOffset.dy, t);
this._labelTransform = Matrix3.I();
this._labelTransform.preTranslate(dx, labelOffset.dy + dy);

public _Decorator(
Key key = null,
_Decoration decoration = null,
TextDirection? textDirection = null,
D.assert(textDirection != null);
this.textDirection = textDirection;
public readonly TextDirection? textDirection;
public readonly TextBaseline? textBaseline;
public readonly bool isFocused;

public override RenderObject createRenderObject(BuildContext context) {
return new _RenderDecoration(
decoration: this.decoration,
textDirection: this.textDirection,
textBaseline: this.textBaseline,
isFocused: this.isFocused
);

_RenderDecoration renderObject = _renderObject as _RenderDecoration;
renderObject.decoration = this.decoration;
renderObject.textDirection = this.textDirection;
renderObject.textBaseline = this.textBaseline;
renderObject.isFocused = this.isFocused;
}

overflow: TextOverflow.ellipsis
);
TextDirection textDirection = Directionality.of(context);
EdgeInsets contentPadding;
float? floatingLabelHeight;
if (this.decoration.isCollapsed) {

counter: counter,
container: container
),
textDirection: textDirection,
textBaseline: textBaseline,
isFocused: this.isFocused
);

33
Runtime/material/progress_indicator.cs


Color backgroundColor = null,
Color valueColor = null,
float? value = null,
float? animationValue = null,
TextDirection? textDirection = null
float? animationValue = null
D.assert(textDirection != null);
this.textDirection = textDirection;
}
public readonly Color backgroundColor;

public readonly TextDirection? textDirection;
static readonly Curve line1Head = new Interval(
0.0f,

return;
}
float left;
switch (this.textDirection) {
case TextDirection.rtl:
left = size.width - width - x;
break;
case TextDirection.ltr:
left = x;
break;
default:
throw new Exception("Unknown text direction: " + this.textDirection);
}
float left = x;
canvas.drawRect(new Offset(left, 0.0f) & new Size(width, size.height), paint);
}

return painter.backgroundColor != this.backgroundColor
|| painter.valueColor != this.valueColor
|| painter.value != this.value
|| painter.animationValue != this.animationValue
|| painter.textDirection != this.textDirection;
|| painter.animationValue != this.animationValue;
}
}

base.dispose();
}
Widget _buildIndicator(BuildContext context, float animationValue, TextDirection textDirection) {
Widget _buildIndicator(BuildContext context, float animationValue) {
return new Container(
constraints: new BoxConstraints(
minWidth: float.PositiveInfinity,

backgroundColor: this.widget._getBackgroundColor(context),
valueColor: this.widget._getValueColor(context),
value: this.widget.value,
animationValue: animationValue,
textDirection: textDirection
animationValue: animationValue
)
)
);

TextDirection textDirection = Directionality.of(context);
return this._buildIndicator(context, this._controller.value, textDirection);
return this._buildIndicator(context, this._controller.value);
return this._buildIndicator(_context, this._controller.value, textDirection);
return this._buildIndicator(_context, this._controller.value);
}
);
}

4
Runtime/widgets/form.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
class Form : StatefulWidget {
public class Form : StatefulWidget {
public Form(
Key key = null,
Widget child = null,

}
}
class FormState : State<Form> {
public class FormState : State<Form> {
int _generation = 0;
public readonly HashSet<FormFieldState<dynamic>> _fields = new HashSet<FormFieldState<dynamic>>();

2
Runtime/widgets/will_pop_scope.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
class WillPopScope : StatefulWidget {
public class WillPopScope : StatefulWidget {
public WillPopScope(
Key key = null,
Widget child = null,

正在加载...
取消
保存