浏览代码

review c-f

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
aac25425
共有 11 个文件被更改,包括 326 次插入270 次删除
  1. 4
      com.unity.uiwidgets/Runtime/painting/text_painter.cs
  2. 4
      com.unity.uiwidgets/Runtime/painting/text_style.cs
  3. 75
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  4. 59
      com.unity.uiwidgets/Runtime/widgets/color_filter.cs
  5. 32
      com.unity.uiwidgets/Runtime/widgets/container.cs
  6. 28
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  7. 7
      com.unity.uiwidgets/Runtime/widgets/dismissible.cs
  8. 32
      com.unity.uiwidgets/Runtime/widgets/drag_target.cs
  9. 165
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  10. 154
      com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs
  11. 36
      com.unity.uiwidgets/Runtime/widgets/image.cs

4
com.unity.uiwidgets/Runtime/painting/text_painter.cs


public class TextPainter {
InlineSpan _text;
TextAlign _textAlign;
TextAlign? _textAlign;
TextDirection? _textDirection;
float _textScaleFactor;
Paragraph _layoutTemplate;

}
}
public TextAlign textAlign {
public TextAlign? textAlign {
get { return _textAlign; }
set {
if (_textAlign == value) {

4
com.unity.uiwidgets/Runtime/painting/text_style.cs


}
public ParagraphStyle getParagraphStyle(
TextAlign textAlign,
TextDirection textDirection,
TextAlign? textAlign = null,
TextDirection? textDirection = null,
float? textScaleFactor = 1.0f,
string ellipsis = null,
int? maxLines = null,

75
com.unity.uiwidgets/Runtime/rendering/editable.cs


public class RenderEditable : RenderBox, RelayoutWhenSystemFontsChangeMixin {
public RenderEditable(
TextSpan text,
TextDirection textDirection,
TextAlign textAlign = TextAlign.left,
TextSpan text = null,
TextDirection? textDirection = null,
TextAlign textAlign = TextAlign.start,
Color cursorColor = null,
Color backgroundCursorColor = null,
ValueNotifier<bool> showCursor = null,

bool forceLine = true,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
bool obscureText = false,
Locale locale = null,
float cursorWidth = 1.0f,
Radius cursorRadius = null,
bool paintCursorAboveText = false,

ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
bool? enableInteractiveSelection = null,
EdgeInsets floatingCursorAddedMargin = null,
TextSelectionDelegate textSelectionDelegate = null,
GlobalKeyEventHandlerDelegate globalKeyEventHandler = null) {
TextSelectionDelegate textSelectionDelegate = null)
//GlobalKeyEventHandlerDelegate globalKeyEventHandler = null)
{
D.assert(textSelectionDelegate != null);
D.assert(textDirection != null, () => "RenderEditable created without a textDirection.");
D.assert(maxLines == null || maxLines > 0);
D.assert(maxLines == null || maxLines > 0);
D.assert((maxLines == null) || (minLines == null) || maxLines >= minLines,
() => "minLines can't be greater than maxLines");
D.assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines), ()=>
"minLines can't be greater than maxLines"
);
D.assert(
!expands || (maxLines == null && minLines == null),()=>
"minLines and maxLines must be null when expands is true."
);
D.assert(cursorWidth >= 0.0f);
D.assert(textSelectionDelegate != null);
D.assert( cursorWidth >= 0.0);
textDirection: textDirection,
textDirection: textDirection ?? TextDirection.ltr,
locale: locale,
textWidthBasis: textWidthBasis);
textWidthBasis: textWidthBasis
);
_hasFocus = hasFocus ?? false;
_obscureText = obscureText;
_paintCursorOnTop = paintCursorAboveText;
_cursorOffset = cursorOffset;
_floatingCursorAddedMargin = floatingCursorAddedMargin;
_devicePixelRatio = devicePixelRatio;
_obscureText = obscureText;
D.assert(_showCursor != null);
D.assert(!_showCursor.value || cursorColor != null);
this.hasFocus = hasFocus ?? false;
this.globalKeyEventHandler = globalKeyEventHandler;
_paintCursorOnTop = paintCursorAboveText;
_cursorOffset = cursorOffset;
_floatingCursorAddedMargin = floatingCursorAddedMargin;
_devicePixelRatio = devicePixelRatio;
}
public static readonly char obscuringCharacter = '•';

}
}
public TextAlign textAlign {
public TextAlign? textAlign {
get { return _textPainter.textAlign; }
set {
if (_textPainter.textAlign == value) {

markNeedsPaint();
}
}
public Locale locale {
get { return _textPainter.locale;
}
set {
if (_textPainter.locale == value)
return;
_textPainter.locale = value;
markNeedsTextLayout();
}
}
Color _backgroundCursorColor;

properties.add(new DiagnosticsProperty<float>("textScaleFactor", textScaleFactor));
properties.add(new DiagnosticsProperty<TextSelection>("selection", selection));
properties.add(new DiagnosticsProperty<ViewportOffset>("offset", offset));
properties.add(new DiagnosticsProperty<Locale>("locale", locale, defaultValue: null));
}
public override List<DiagnosticsNode> debugDescribeChildren() {

59
com.unity.uiwidgets/Runtime/widgets/color_filter.cs


namespace Unity.UIWidgets.widgets {
public class ColorFiltered : SingleChildRenderObjectWidget {
protected ColorFiltered(ColorFilter colorFilter = null, Widget child = null, Key key = null)
protected ColorFiltered(
ColorFilter colorFilter = null,
Widget child = null,
Key key = null)
this.colorFilter = colorFilter;
public override RenderObject createRenderObject(BuildContext context) => new _ColorFilterRenderObject(colorFilter);
public override RenderObject createRenderObject(BuildContext context) {
return new _ColorFilterRenderObject(colorFilter);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
((_ColorFilterRenderObject)renderObject).colorFilter = colorFilter;
}

properties.add(new DiagnosticsProperty<ColorFilter>("colorFilter", colorFilter));
}
}
public class _ColorFilterRenderObject : RenderProxyBox {
public _ColorFilterRenderObject(ColorFilter _colorFilter) {
this._colorFilter = _colorFilter;
}
public class _ColorFilterRenderObject : RenderProxyBox {
public _ColorFilterRenderObject(ColorFilter _colorFilter) {
this._colorFilter = _colorFilter;
}
public ColorFilter colorFilter {
get { return _colorFilter; }
set {
D.assert(value != null);
if (value != _colorFilter) {
_colorFilter = value;
markNeedsPaint();
}
}
}
public ColorFilter colorFilter {
get { return _colorFilter; }
set {
D.assert(value != null);
if (value != _colorFilter) {
_colorFilter = value;
markNeedsPaint();
ColorFilter _colorFilter;
public bool alwaysNeedsCompositing {
get { return child != null; }
}
public override void paint(PaintingContext context, Offset offset) {
layer = context.pushColorFilter(offset, colorFilter, base.paint, oldLayer: layer as ColorFilterLayer);
}
ColorFilter _colorFilter;
public bool alwaysNeedsCompositing {
get { return child != null; }
}
public override void paint(PaintingContext context, Offset offset) {
layer = context.pushColorFilter(offset, colorFilter, base.paint, oldLayer: layer as ColorFilterLayer);
}
}
}

32
com.unity.uiwidgets/Runtime/widgets/container.cs


public class Container : StatelessWidget {
public Container(
Key key = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
Decoration forgroundDecoration = null,
Decoration foregroundDecoration = null,
Matrix4 transfrom = null,
Matrix4 transform = null,
Widget child = null,
Clip clipBehavior = Clip.none
) : base(key: key) {

this.alignment = alignment;
this.padding = padding;
foregroundDecoration = forgroundDecoration;
this.margin = margin;
transform = transfrom;
this.child = child;
this.foregroundDecoration = foregroundDecoration;
this.decoration = decoration ?? (color != null ? new BoxDecoration(color) : null);
this.decoration = decoration;// ?? (color != null ? new BoxDecoration(color) : null);
this.margin = margin;
this.transform = transform;
this.child = child;
this.clipBehavior = clipBehavior ;
this.clipBehavior = clipBehavior;
public readonly Alignment alignment;
public readonly AlignmentGeometry alignment;
public readonly EdgeInsets padding;
public readonly Decoration decoration;
public readonly Decoration foregroundDecoration;

if (decoration == null || decoration.padding == null) {
return padding;
}
Debug.LogError("EdgeInsets needs to be update to EdgeInsetsGeometry");
//Debug.LogError("EdgeInsets needs to be update to EdgeInsetsGeometry");
return padding.add(decorationPadding);
}
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Alignment>("alignment",
properties.add(new DiagnosticsProperty<AlignmentGeometry>("alignment",
alignment, showName: false, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding",
padding, defaultValue: foundation_.kNullDefaultValue));

/// A clipper that uses [Decoration.getClipPath] to clip.
public class _DecorationClipper : CustomClipper<Path> {
public _DecorationClipper(
TextDirection textDirection = TextDirection.rtl,
TextDirection? textDirection = null,
textDirection = TextDirection.ltr;
this.textDirection = textDirection ?? TextDirection.ltr;
this.decoration = decoration;
}
public readonly TextDirection textDirection;

28
com.unity.uiwidgets/Runtime/widgets/debug.cs


public static bool debugPrintGlobalKeyedWidgetLifecycle = false;
public static bool debugPrintScheduleBuildForStacks = false;
public static bool debugProfileBuildsEnabled = false;
public static bool debugHighlightDeprecatedWidgets = false;
static Key _firstNonUniqueKey(IEnumerable<Widget> widgets) {
var keySet = new HashSet<Key>();

throw new UIWidgetsError(
"Duplicate keys found.\n" +
"If multiple keyed nodes exist as children of another node, they must have unique keys.\n" +
parent + " has multiple children with key " + children + "."
parent + " has multiple children with key " + nonUniqueKey + "."
);
}

if (widget == built) {
throw new UIWidgetsError(
"A build function returned context.widget.\n" +
"The offending widget is: $widget\n" +
$"The offending widget is: {widget}\n" +
"Build functions must never return their BuildContext parameter\'s widget or a child that contains 'context.widget'. " +
"Doing so introduces a loop in the widget tree that can cause the app to crash."
);

context.findAncestorWidgetOfExactType<Directionality>() == null) {
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("No Directionality widget found."),
new ErrorDescription("${context.widget.runtimeType} widgets require a Directionality widget ancestor.\n"),
new ErrorDescription($"{context.widget.GetType()} widgets require a Directionality widget ancestor.\n"),
context.describeWidget("The specific widget that could not find a Directionality ancestor was"),
context.describeOwnershipChain("The ownership chain for the affected widget is"),
new ErrorHint(

UIWidgetsError.reportError(details);
return details;
}
/// See [the widgets library](widgets/widgets-library.html) for a complete list.
public static bool debugAssertAllWidgetVarsUnset(string reason) {
D.assert(()=> {
if (debugPrintRebuildDirtyWidgets ||
debugPrintBuildScope ||
debugPrintScheduleBuildForStacks ||
debugPrintGlobalKeyedWidgetLifecycle ||
debugProfileBuildsEnabled ||
debugHighlightDeprecatedWidgets) {
throw new UIWidgetsError(reason);
}
return true;
});
return true;
}
}
}

7
com.unity.uiwidgets/Runtime/widgets/dismissible.cs


Axis axis,
Animation<Offset> moveAnimation
) : base(reclip: moveAnimation) {
D.assert(moveAnimation != null);
this.axis = axis;
this.moveAnimation = moveAnimation;
}

}
public override bool shouldReclip(CustomClipper<Rect> oldClipper) {
D.assert(oldClipper is _DismissibleClipper);
//D.assert(oldClipper is _DismissibleClipper);
_DismissibleClipper clipper = oldClipper as _DismissibleClipper;
return clipper.axis != axis
|| clipper.moveAnimation.value != moveAnimation.value;

}
_FlingGestureKind _describeFlingGesture(Velocity velocity) {
D.assert(widget.direction != null);
if (_dragExtent == 0.0f) {
return _FlingGestureKind.none;
}

);
if (background != null) {
List<Widget> children = new List<Widget> { };
List<Widget> children = new List<Widget>();
if (!_moveAnimation.isDismissed) {
children.Add(Positioned.fill(

children.Add(content);
content = new Stack(children: children);
}
return new GestureDetector(

32
com.unity.uiwidgets/Runtime/widgets/drag_target.cs


public class Draggable<T> : StatefulWidget {
public Draggable(
T data,
T data = default,
Axis? axis = null,
Widget childWhenDragging = null,
Offset feedbackOffset = null,

VoidCallback onDragStarted = null,
DraggableCanceledCallback onDraggableCanceled = null,
DragEndCallback onDragEnd = null,
VoidCallback onDragCompleted = null) : base(key) {
VoidCallback onDragCompleted = null
) : base(key) {
D.assert(child != null);
D.assert(feedback != null);
D.assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0);

this.data = data;
this.axis = axis;
this.childWhenDragging = childWhenDragging;
if (feedbackOffset == null) {
feedbackOffset = Offset.zero;
}
this.feedbackOffset = feedbackOffset;
this.feedbackOffset = feedbackOffset ?? Offset.zero;
this.dragAnchor = dragAnchor;
this.affinity = affinity;
this.maxSimultaneousDrags = maxSimultaneousDrags;

public class LongPressDraggable<T> : Draggable<T> {
public LongPressDraggable(
T data,
T data = default,
Axis? axis = null,
Widget childWhenDragging = null,
Offset feedbackOffset = null,

if (_activeCount > 0) {
return;
}
_recognizer.dispose();
_recognizer = null;
}

public class _DragAvatar<T> : Drag {
public _DragAvatar(
T data,
T data = default,
Axis? axis = null,
Offset initialPosition = null,
Offset dragStartPoint = null,

) {
if (initialPosition == null) {
initialPosition = Offset.zero;
}
if (dragStartPoint == null) {
dragStartPoint = Offset.zero;
}
if (feedbackOffset == null) {
feedbackOffset = Offset.zero;
}

this.data = data;
this.axis = axis;
this.dragStartPoint = dragStartPoint;
this.dragStartPoint = dragStartPoint ?? Offset.zero;
this.feedbackOffset = feedbackOffset;
this.feedbackOffset = feedbackOffset ?? Offset.zero;
_position = initialPosition;
_position = initialPosition ?? Offset.zero;
updateDrag(initialPosition);
}

165
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


StrutStyle strutStyle = null,
Color cursorColor = null,
Color backgroundCursorColor = null,
TextAlign textAlign = TextAlign.left,
TextAlign textAlign = TextAlign.start,
TextDirection? textDirection = null,
Locale locale = null,
float? textScaleFactor = null,

bool forceLine = false,
bool forceLine = true,
bool showCursor = false,
bool? showCursor = null,
bool showSelectionHandles = false,
Color selectionColor = null,
TextSelectionControls selectionControls = null,

VoidCallback onSelectionHandleTapped = null,
List<TextInputFormatter> inputFormatters = null,
bool rendererIgnoresPointer = false,
float? cursorWidth = 2.0f,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
bool cursorOpacityAnimates = false,
Offset cursorOffset = null,

(maxLines == null) || (minLines == null) || (maxLines >= minLines),
()=>"minLines can't be greater than maxLines"
);
D.assert(expands != null);
D.assert(
!expands || (maxLines == null && minLines == null),()=>
"minLines and maxLines must be null when expands is true."

this.keyboardAppearance = keyboardAppearance;
this.enableInteractiveSelection = enableInteractiveSelection;
this.dragStartBehavior = dragStartBehavior;
this.scrollPhysics = scrollPhysics;
// this.globalKeyEventHandler = globalKeyEventHandler;
this.scrollPhysics = scrollPhysics;
}
public readonly bool readOnly;

public readonly TextWidthBasis textWidthBasis;
public readonly VoidCallback onSelectionHandleTapped;
public readonly ScrollController scrollController;
public readonly bool showCursor;
public readonly bool? showCursor;
public readonly ui.BoxHeightStyle selectionHeightStyle;
public readonly ui.BoxWidthStyle selectionWidthStyle;
public readonly bool forceLine;

if (_strutStyle == null) {
return style != null
? StrutStyle.fromTextStyle(style, forceStrutHeight: true)
: StrutStyle.disabled;
: new StrutStyle();
}
return _strutStyle.inheritFromTextStyle(style);

public class EditableTextState : AutomaticKeepAliveClientWithTickerProviderStateMixin<EditableText>,
WidgetsBindingObserver, TextInputClient,
TextSelectionDelegate {
TextSelectionDelegate
{
const int _kObscureShowLatestCharCursorTicks = 3;
static TimeSpan _kCursorBlinkHalfPeriod = TimeSpan.FromMilliseconds(500);
static TimeSpan _kCursorBlinkWaitForStart = TimeSpan.FromMilliseconds(150);

_cursorBlinkOpacityController.addListener(_onCursorColorTick);
_floatingCursorResetController = new AnimationController(vsync: this);
_floatingCursorResetController.addListener(_onFloatingCursorResetTick);
_cursorVisibilityNotifier.value = widget.showCursor;
_cursorVisibilityNotifier.value = widget.showCursor ?? false;
}
public override void didChangeDependencies() {

oldWidget.controller.removeListener(_didChangeTextEditingValue);
widget.controller.addListener(_didChangeTextEditingValue);
_updateRemoteEditingValueIfNeeded();
//_updateImePosIfNeed();
}
if (widget.controller.selection != oldWidget.controller.selection) {
_selectionOverlay?.update(_value);

fontFamily: style.fontFamily,
fontSize: style.fontSize,
fontWeight: style.fontWeight,
textDirection: _textDirection.Value,
textDirection: (TextDirection)_textDirection,
textAlign: widget.textAlign
);
}

_obscureLatestCharIndex = _value.selection.baseOffset;
}
}
_stopCursorTimer(resetCharTicks: false);
_startCursorTimer();
}

void _onCursorColorTick() {
renderEditable.cursorColor =
widget.cursorColor.withOpacity(_cursorBlinkOpacityController.value);
_cursorVisibilityNotifier.value = widget.showCursor && _cursorBlinkOpacityController.value > 0;
_cursorVisibilityNotifier.value = widget.showCursor.Value && _cursorBlinkOpacityController.value > 0;
}
public bool cursorCurrentlyVisible {

link: _toolbarLayerLink,
child: new _Editable(
key: _editableKey,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
textSpan: buildTextSpan(),
value: _value,
cursorColor: _cursorColor,
backgroundCursorColor: widget.backgroundCursorColor,
showCursor: EditableText.debugDeterministicCursor
? new ValueNotifier<bool>(widget.showCursor)
: _cursorVisibilityNotifier,
forceLine: widget.forceLine,
readOnly: widget.readOnly,
hasFocus: _hasFocus,
maxLines: widget.maxLines,
minLines: widget.minLines,
expands: widget.expands,
strutStyle: widget.strutStyle,
selectionColor: widget.selectionColor,
textScaleFactor: widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textAlign: widget.textAlign,
textDirection: _textDirection,
textWidthBasis: widget.textWidthBasis,
obscureText: widget.obscureText,
autocorrect: widget.autocorrect,
smartDashesType: widget.smartDashesType,
smartQuotesType: widget.smartQuotesType,
enableSuggestions: widget.enableSuggestions,
offset: offset,
onSelectionChanged: _handleSelectionChanged,
onCaretChanged: _handleCaretChanged,
rendererIgnoresPointer: widget.rendererIgnoresPointer,
cursorWidth: widget.cursorWidth,
cursorRadius: widget.cursorRadius,
cursorOffset: widget.cursorOffset,
selectionHeightStyle: widget.selectionHeightStyle,
selectionWidthStyle: widget.selectionWidthStyle,
paintCursorAboveText: widget.paintCursorAboveText,
enableInteractiveSelection: widget.enableInteractiveSelection == true,
textSelectionDelegate: this,
devicePixelRatio: _devicePixelRatio,
globalKeyEventHandler : widget.globalKeyEventHandler
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
textSpan: buildTextSpan(),
value: _value,
cursorColor: _cursorColor,
backgroundCursorColor: widget.backgroundCursorColor,
showCursor: EditableText.debugDeterministicCursor
? new ValueNotifier<bool>(widget.showCursor ?? false)
: _cursorVisibilityNotifier,
forceLine: widget.forceLine,
readOnly: widget.readOnly,
hasFocus: _hasFocus,
maxLines: widget.maxLines,
minLines: widget.minLines,
expands: widget.expands,
strutStyle: widget.strutStyle,
selectionColor: widget.selectionColor,
textScaleFactor: widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textAlign: widget.textAlign,
textDirection: _textDirection,
locale: widget.locale,
textWidthBasis: widget.textWidthBasis,
obscureText: widget.obscureText,
autocorrect: widget.autocorrect,
smartDashesType: widget.smartDashesType,
smartQuotesType: widget.smartQuotesType,
enableSuggestions: widget.enableSuggestions,
offset: offset,
onSelectionChanged: _handleSelectionChanged,
onCaretChanged: _handleCaretChanged,
rendererIgnoresPointer: widget.rendererIgnoresPointer,
cursorWidth: widget.cursorWidth,
cursorRadius: widget.cursorRadius,
cursorOffset: widget.cursorOffset,
selectionHeightStyle: widget.selectionHeightStyle,
selectionWidthStyle: widget.selectionWidthStyle,
paintCursorAboveText: widget.paintCursorAboveText,
enableInteractiveSelection: widget.enableInteractiveSelection ?? true,
textSelectionDelegate: this,
devicePixelRatio: _devicePixelRatio
)
)
);

public readonly StrutStyle strutStyle;
public readonly Color selectionColor;
public readonly float textScaleFactor;
public readonly TextAlign textAlign;
public readonly TextAlign? textAlign;
public readonly TextDirection? textDirection;
public readonly bool obscureText;
public readonly TextWidthBasis textWidthBasis;

public readonly TextSelectionDelegate textSelectionDelegate;
public readonly bool? paintCursorAboveText;
public readonly float? devicePixelRatio;
public readonly GlobalKeyEventHandlerDelegate globalKeyEventHandler;
public _Editable(TextSpan textSpan = null,
//public readonly GlobalKeyEventHandlerDelegate globalKeyEventHandler;
public readonly Locale locale;
public _Editable(
Key key = null,
TextSpan textSpan = null,
TextEditingValue value = null,
LayerLink startHandleLayerLink = null,
LayerLink endHandleLayerLink = null,

StrutStyle strutStyle = null,
Color selectionColor = null,
float textScaleFactor = 1.0f,
TextAlign? textAlign = null,
Locale locale = null,
TextAlign textAlign = TextAlign.left,
bool autocorrect = false,
SmartDashesType smartDashesType = SmartDashesType.disabled,
SmartQuotesType smartQuotesType = SmartQuotesType.disabled,

CaretChangedHandler onCaretChanged = null,
bool rendererIgnoresPointer = false,
Key key = null,
TextSelectionDelegate textSelectionDelegate = null,
bool? paintCursorAboveText = null,
bool? paintCursorAboveText = null,
float? devicePixelRatio = null,
GlobalKeyEventHandlerDelegate globalKeyEventHandler = null) : base(key) {
TextSelectionDelegate textSelectionDelegate = null,
float? devicePixelRatio = null
//GlobalKeyEventHandlerDelegate globalKeyEventHandler = null
) : base(key) {
this.locale = locale;
this.backgroundCursorColor = backgroundCursorColor;
this.showCursor = showCursor;
this.forceLine = forceLine;

this.selectionWidthStyle = selectionWidthStyle;
this.enableInteractiveSelection = enableInteractiveSelection;
this.devicePixelRatio = devicePixelRatio;
this.globalKeyEventHandler = globalKeyEventHandler;
//this.globalKeyEventHandler = globalKeyEventHandler;
textDirection: textDirection ?? TextDirection.ltr,
offset: offset,
showCursor: showCursor,
showCursor: showCursor,
forceLine: forceLine,
readOnly: readOnly,
hasFocus: hasFocus,

strutStyle: strutStyle,
selectionColor: selectionColor,
textScaleFactor: textScaleFactor,
textAlign: textAlign,
textAlign: textAlign ?? TextAlign.start,
textDirection: textDirection,
locale: locale ?? Localizations.localeOf(context, nullOk: true),
obscureText: obscureText,
textWidthBasis: textWidthBasis,
offset: offset,
obscureText: obscureText,
textWidthBasis: textWidthBasis,
paintCursorAboveText: paintCursorAboveText ?? false,
paintCursorAboveText: paintCursorAboveText == true,
devicePixelRatio: devicePixelRatio ?? 1.0f,
globalKeyEventHandler : globalKeyEventHandler
devicePixelRatio: devicePixelRatio ?? 1.0f
);
}

edit.cursorColor = cursorColor;
edit.startHandleLayerLink = startHandleLayerLink;
edit.endHandleLayerLink = endHandleLayerLink;
edit.backgroundCursorColor = backgroundCursorColor;
edit.minLines = minLines;
edit.expands = expands;
edit.locale = locale ?? Localizations.localeOf(context, nullOk: true);
edit.selection = value.selection;
edit.offset = offset;
edit.onSelectionChanged = onSelectionChanged;

edit.obscureText = obscureText;
edit.textSelectionDelegate = textSelectionDelegate;
edit.cursorWidth = cursorWidth ?? 1.0f;
edit.cursorWidth = cursorWidth ?? 0.0f;
edit.enableInteractiveSelection = enableInteractiveSelection;
edit.paintCursorAboveText = paintCursorAboveText == true;
edit.textSelectionDelegate = textSelectionDelegate;
edit.globalKeyEventHandler = globalKeyEventHandler;
edit.paintCursorAboveText = paintCursorAboveText ?? false;
}
}
}

154
com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs


ImageProvider placeholder,
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageProvider image,
ImageErrorWidgetBuilder imageErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder = null,
TimeSpan? fadeOutDuration = null,
Curve fadeOutCurve = null,
TimeSpan? fadeInDuration = null,

BoxFit? fit = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
Key key = null
Key key = null,
bool matchTextDirection = false
D.assert(placeholder != null);
D.assert(image != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);

this.fadeInCurve = fadeInCurve ?? Curves.easeIn;
this.alignment = alignment ?? Alignment.center;
this.repeat = repeat;
this.matchTextDirection = matchTextDirection;
byte[] placeholder,
ImageErrorWidgetBuilder placeholderErrorBuilder,
string image,
ImageErrorWidgetBuilder imageErrorBuilder,
byte[] placeholder ,
string image ,
Key key = null,
ImageErrorWidgetBuilder placeholderErrorBuilder = null,
ImageErrorWidgetBuilder imageErrorBuilder = null,
float placeholderScale = 1.0f,
float imageScale = 1.0f,
TimeSpan? fadeOutDuration = null,

float? width = null,
float? height = null,
BoxFit? fit = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
Key key = null,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
bool matchTextDirection = false,
int? placeholderCacheWidth = null,
int? placeholderCacheHeight = null,
int? imageCacheWidth = null,
int? imageCacheHeight = null
D.assert(placeholder != null);
D.assert(image != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);
D.assert(fadeInDuration != null);
D.assert(fadeInCurve != null);
D.assert(alignment != null);
var memoryImage = new MemoryImage(placeholder, placeholderScale);
var networkImage = new NetworkImage(image, imageScale);
/*placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
new MemoryImage(placeholder, scale: placeholderScale));
image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight,
new NetworkImage(image, scale: imageScale));*/
alignment = alignment ?? Alignment.center;
fadeOutDuration = fadeOutDuration ?? TimeSpan.FromMilliseconds( 300 );
fadeOutCurve = fadeOutCurve ?? Curves.easeOut;
fadeInDuration = fadeInDuration ?? TimeSpan.FromMilliseconds( 700 );
fadeInCurve = fadeInCurve ?? Curves.easeIn;
ImageProvider memoryImage = new MemoryImage(placeholder, placeholderScale);
ImageProvider networkImage = new NetworkImage(image, imageScale);
//placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage);
//image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage);
placeholder: memoryImage,
placeholder: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage),
image: networkImage,
image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage),
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,

fit: fit,
alignment: alignment,
repeat: repeat,
matchTextDirection: matchTextDirection,
key: key
);
}

ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
ImageErrorWidgetBuilder placeholderErrorBuilder = null,
ImageErrorWidgetBuilder imageErrorBuilder = null,
AssetBundle bundle = null,
float? placeholderScale = null,
float imageScale = 1.0f,

float? width = null,
float? height = null,
BoxFit? fit = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
bool matchTextDirection = false,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
int? placeholderCacheWidth = null,
int? placeholderCacheHeight = null,
int? imageCacheWidth = null,
int? imageCacheHeight = null
D.assert(placeholder != null);
D.assert(image != null);
var imageProvider = placeholderScale != null
? new ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale ?? 1.0f)
: (ImageProvider) new AssetImage(placeholder, bundle: bundle);
/*placeholder = placeholderScale != null
? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale))
: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, AssetImage(placeholder, bundle: bundle));*/
var networkImage = new NetworkImage(image, imageScale);
var holder = placeholderScale ?? 1.0f;
var _placeholder = placeholderScale != null
? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
new ExactAssetImage(placeholder, bundle: bundle, scale: holder))
: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
new AssetImage(placeholder, bundle: bundle));
placeholder: imageProvider,
placeholder: _placeholder,
image: networkImage,
image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, new NetworkImage(image, scale: imageScale)),
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,

fit: fit,
alignment: alignment,
repeat: repeat,
matchTextDirection: matchTextDirection,
key: key
);
}

public readonly float? width;
public readonly float? height;
public readonly BoxFit? fit;
public readonly Alignment alignment;
public readonly AlignmentGeometry alignment;
public readonly bool matchTextDirection;
public Image _image(
ImageProvider image = null,

D.assert(image != null);
return new Image(
image: image,
//errorBuilder: errorBuilder,
//frameBuilder: frameBuilder,
errorBuilder: errorBuilder,
frameBuilder: frameBuilder,
//matchTextDirection: matchTextDirection,
matchTextDirection: matchTextDirection,
);
}

errorBuilder: imageErrorBuilder,
frameBuilder: (BuildContext context1, Widget child, int frame, bool wasSynchronouslyLoaded) => {
if (wasSynchronouslyLoaded)
return child;
return new _AnimatedFadeOutFadeIn(
key: key,
target: child,
placeholder: _image(
image: placeholder,
errorBuilder: placeholderErrorBuilder
),
isTargetLoaded: frame != null,
fadeInDuration: fadeInDuration,
fadeOutDuration: fadeOutDuration,
fadeInCurve: fadeInCurve,
fadeOutCurve: fadeOutCurve
);
}
frameBuilder: (BuildContext context1, Widget child, int frame, bool wasSynchronouslyLoaded)=> {
if (wasSynchronouslyLoaded)
return child;
return new _AnimatedFadeOutFadeIn(
target: child,
placeholder: _image(image: placeholder, errorBuilder: placeholderErrorBuilder),
isTargetLoaded: frame != null,
fadeInDuration: fadeInDuration,
fadeOutDuration: fadeOutDuration,
fadeInCurve: fadeInCurve,
fadeOutCurve: fadeOutCurve
);
}
);
return result;
}

public _AnimatedFadeOutFadeIn(
Key key,
Widget target,
Widget placeholder,
bool isTargetLoaded,
Widget target ,
Widget placeholder ,
bool isTargetLoaded ,
Curve fadeInCurve
Curve fadeInCurve,
Key key = null
D.assert(target != null);
D.assert(placeholder != null);
D.assert(isTargetLoaded != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);
D.assert(fadeInDuration != null);
D.assert(fadeInCurve != null);
this.target = target;
this.placeholder = placeholder;
this.isTargetLoaded = isTargetLoaded;

36
com.unity.uiwidgets/Runtime/widgets/image.cs


Color color = null,
BlendMode colorBlendMode = BlendMode.srcIn,
BoxFit? fit = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
bool matchTextDirection = false,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
) : base(key: key) {

this.centerSlice = centerSlice;
this.gaplessPlayback = gaplessPlayback;
this.filterQuality = filterQuality;
this.matchTextDirection = matchTextDirection;
}
public static Image network(

Color color = null,
BlendMode colorBlendMode = BlendMode.srcIn,
BoxFit? fit = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
bool matchTextDirection = false,
FilterQuality filterQuality = FilterQuality.low,
IDictionary<string, string> headers = null,
int? cacheWidth = null,

alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
matchTextDirection : matchTextDirection,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);

Color color = null,
BlendMode colorBlendMode = BlendMode.srcIn,
BoxFit? fit = null,
Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
AlignmentGeometry alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
bool matchTextDirection = false,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,

alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
matchTextDirection: matchTextDirection,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);

Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool matchTextDirection = false,
string package = null,
/*image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, scale != null
? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)
: AssetImage(name, bundle: bundle, package: package)
);*/
var image = scale != null
var _image = scale != null
image: image,
image: _image,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,

alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
matchTextDirection: matchTextDirection,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);

Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool matchTextDirection = false,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
int? cacheWidth = default,

var memoryImage = new MemoryImage(bytes, scale);
return new Image(
key: key,
image: memoryImage,
image: ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, new MemoryImage(bytes, scale: scale)),
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,

alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
matchTextDirection : matchTextDirection,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);

public readonly FilterQuality filterQuality;
public readonly BlendMode colorBlendMode;
public readonly BoxFit? fit;
public readonly Alignment alignment;
public readonly AlignmentGeometry alignment;
public readonly bool matchTextDirection;
public override State createState() {
return new _ImageState();

properties.add(new EnumProperty<BlendMode>("colorBlendMode", colorBlendMode,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<BoxFit?>("fit", fit, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Alignment>("alignment", alignment,
properties.add(new DiagnosticsProperty<AlignmentGeometry>("alignment", alignment,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<ImageRepeat>("repeat", repeat, defaultValue: ImageRepeat.noRepeat));
properties.add(new DiagnosticsProperty<Rect>("centerSlice", centerSlice,

properties.add(new FlagProperty("matchTextDirection", value: matchTextDirection, ifTrue: "match text direction"));
}
}

正在加载...
取消
保存