浏览代码

refix widgets F E

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
6212441e
共有 6 个文件被更改,包括 334 次插入168 次删除
  1. 2
      com.unity.uiwidgets/Runtime/cupertino/text_field.cs
  2. 127
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  3. 275
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  4. 48
      com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
  5. 24
      com.unity.uiwidgets/Runtime/widgets/focus_scope.cs
  6. 26
      com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs

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


padding: widget.padding,
child: new RepaintBoundary(
child: new EditableText(
smartDashesType: SmartDashesType.disabled,
smartQuotesType:SmartQuotesType.disabled,
key: _editableTextKey,
controller: controller,
focusNode: _effectiveFocusNode,

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


Color backgroundCursorColor = null,
ValueNotifier<bool> showCursor = null,
bool? hasFocus = null,
LayerLink startHandleLayerLink = null,
LayerLink endHandleLayerLink = null,
int? maxLines = 1,
int? minLines = null,
bool expands = false,

SelectionChangedHandler onSelectionChanged = null,
CaretChangedHandler onCaretChanged = null,
bool ignorePointer = false,
bool readOnly = false,
bool forceLine = true,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
bool obscureText = false,
float cursorWidth = 1.0f,
Radius cursorRadius = null,

ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
bool? enableInteractiveSelection = null,
EdgeInsets floatingCursorAddedMargin = null,
TextSelectionDelegate textSelectionDelegate = null,

D.assert(minLines == null || minLines > 0);
D.assert(maxLines == null || maxLines > 0);
D.assert(startHandleLayerLink != null);
D.assert(endHandleLayerLink != null);
D.assert((maxLines == null) || (minLines == null) || maxLines >= minLines,
() => "minLines can't be greater than maxLines");
D.assert(offset != null);

textAlign: textAlign,
textDirection: textDirection,
textScaleFactor: textScaleFactor,
strutStyle: strutStyle);
strutStyle: strutStyle,
textWidthBasis: textWidthBasis);
_cursorColor = cursorColor;
_backgroundCursorColor = backgroundCursorColor;
_showCursor = showCursor ?? new ValueNotifier<bool>(false);

_cursorWidth = cursorWidth;
_cursorRadius = cursorRadius;
_enableInteractiveSelection = enableInteractiveSelection;
_selectionHeightStyle = selectionHeightStyle;
_selectionWidthStyle = selectionWidthStyle;
_startHandleLayerLink = startHandleLayerLink;
_endHandleLayerLink = endHandleLayerLink;
_readOnly = readOnly;
_forceLine = forceLine;
this.ignorePointer = ignorePointer;
this.onCaretChanged = onCaretChanged;
this.onSelectionChanged = onSelectionChanged;

D.assert(_maxLines == null || _maxLines > 0);
D.assert(_showCursor != null);
D.assert(!_showCursor.value || cursorColor != null);
_tap = new TapGestureRecognizer(this);
_tap.onTapDown = _handleTapDown;
_tap.onTap = _handleTap;
_longPress = new LongPressGestureRecognizer(debugOwner: this);
_longPress.onLongPress = _handleLongPress;
_paintCursorOnTop = paintCursorAboveText;
_cursorOffset = cursorOffset;

public static readonly char obscuringCharacter = '•';
public SelectionChangedHandler onSelectionChanged;
float _textLayoutLastMaxWidth;
float _textLayoutLastMinWidth;
public TextWidthBasis textWidthBasis {
get {
return _textPainter.textWidthBasis;
}
set {
D.assert(value != null);
if (_textPainter.textWidthBasis == value)
return;
_textPainter.textWidthBasis = value;
markNeedsTextLayout();
}
}
public ui.BoxHeightStyle selectionHeightStyle {
get {
return _selectionHeightStyle;
}
set {
D.assert(value != null);
if (_selectionHeightStyle == value)
return;
_selectionHeightStyle = value;
markNeedsPaint();
}
}
ui.BoxHeightStyle _selectionHeightStyle;
public ui.BoxWidthStyle selectionWidthStyle {
get {
return _selectionWidthStyle;
}
set {
D.assert(value != null);
if (_selectionWidthStyle == value)
return;
_selectionWidthStyle = value;
markNeedsPaint();
}
}
ui.BoxWidthStyle _selectionWidthStyle;
public LayerLink startHandleLayerLink {
get {
return _startHandleLayerLink;
}
set {
if (_startHandleLayerLink == value)
return;
_startHandleLayerLink = value;
markNeedsPaint();
}
}
LayerLink _startHandleLayerLink;
public LayerLink endHandleLayerLink {
get {
return _endHandleLayerLink;
}
set {
if (_endHandleLayerLink == value)
return;
_endHandleLayerLink = value;
markNeedsPaint();
}
}
LayerLink _endHandleLayerLink;
public bool forceLine {
get {
return _forceLine;
}
set {
D.assert(value != null);
if (_forceLine == value)
return;
_forceLine = value;
markNeedsLayout();
}
}
bool _forceLine = false;
public bool readOnly {
get {
return _readOnly;
}
set {
D.assert(value != null);
if (_readOnly == value)
return;
_readOnly = value;
markNeedsSemanticsUpdate();
}
}
bool _readOnly = false;
float _devicePixelRatio;

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


public void clearComposing() {
value = value.copyWith(composing: TextRange.empty);
}
public bool isSelectionWithinTextBounds(TextSelection selection) {
return selection.start <= text.Length && selection.end <= text.Length;
}
}
public class ToolbarOptions {

bool paste = false,
bool selectAll = false
) {
D.assert(copy != null);
D.assert(cut != null);
D.assert(paste != null);
D.assert(selectAll != null);
this.copy = copy;
this.cut = cut;
this.paste = paste;

public class EditableText : StatefulWidget {
public EditableText(
SmartDashesType smartDashesType,
SmartQuotesType smartQuotesType,
Key key = null,
TextEditingController controller = null,
FocusNode focusNode = null,

//SmartDashesType smartDashesType,
//SmartQuotesType smartQuotesType,
bool enableSuggestions = true,
TextStyle style = null,
StrutStyle strutStyle = null,

bool forceLine = false,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
bool autofocus = false,
bool? showCursor = null,
bool showCursor = false,
bool showSelectionHandles = false,
Color selectionColor = null,
TextSelectionControls selectionControls = null,

ToolbarOptions toolbarOptions = null,
bool unityTouchKeyboard = false
) : base(key) {
toolbarOptions = toolbarOptions ?? new ToolbarOptions(
copy: true,
cut: true,
paste: true,
selectAll: true
);
D.assert(obscureText != null);
D.assert(autocorrect != null);
//smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
//smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
D.assert(enableSuggestions != null);
D.assert(showSelectionHandles != null);
smartDashesType = (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
smartQuotesType = (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
D.assert(readOnly != null);
D.assert(forceLine != null);
D.assert(cursorOpacityAnimates != null);
D.assert(paintCursorAboveText != null);
D.assert(selectionHeightStyle != null);
D.assert(selectionWidthStyle != null);
D.assert(textAlign != null);
D.assert(maxLines == null || maxLines > 0);
D.assert(minLines == null || minLines > 0);
D.assert(

"minLines and maxLines must be null when expands is true."
);
D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline.");
D.assert(autofocus != null);
D.assert(rendererIgnoresPointer != null);
D.assert(dragStartBehavior != null);
D.assert(toolbarOptions != null);
_strutStyle = strutStyle;
toolbarOptions = toolbarOptions ?? new ToolbarOptions(
copy: true,
cut: true,
paste: true,
selectAll: true
);
inputFormatters = inputFormatters ?? new List<TextInputFormatter>();
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
List<TextInputFormatter> formatters = new List<TextInputFormatter>();

}
}
this.readOnly = readOnly;
this.showCursor = showCursor ?? !readOnly;
this.showCursor = !readOnly;
this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
this.locale = locale;
this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f);

this.autocorrect = autocorrect;
this.style = style;
this.smartDashesType = smartDashesType;
this.smartQuotesType = smartQuotesType;
this.showCursor = showCursor;
this.textWidthBasis = textWidthBasis;
this.onSelectionHandleTapped = onSelectionHandleTapped;
this.scrollController = scrollController;

public readonly FocusNode focusNode;
public readonly bool obscureText;
public readonly bool autocorrect;
public readonly SmartDashesType smartDashesType;
public readonly SmartQuotesType smartQuotesType;
public readonly bool enableSuggestions;
public readonly TextWidthBasis textWidthBasis;
public readonly VoidCallback onSelectionHandleTapped;

properties.add( new DiagnosticsProperty<FocusNode>("focusNode", focusNode));
properties.add( new DiagnosticsProperty<bool>("obscureText", obscureText, defaultValue: false));
properties.add( new DiagnosticsProperty<bool>("autocorrect", autocorrect, defaultValue: true));
// properties.add( new EnumProperty<SmartDashesType>("smartDashesType", smartDashesType, defaultValue: obscureText ? SmartDashesType.disabled : SmartDashesType.enabled));
// properties.add( new EnumProperty<SmartQuotesType>("smartQuotesType", smartQuotesType, defaultValue: obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled));
properties.add( new EnumProperty<SmartDashesType>("smartDashesType", smartDashesType, defaultValue: obscureText ? SmartDashesType.disabled : SmartDashesType.enabled));
properties.add( new EnumProperty<SmartQuotesType>("smartQuotesType", smartQuotesType, defaultValue: obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled));
properties.add( new DiagnosticsProperty<bool>("enableSuggestions", enableSuggestions, defaultValue: true));
style?.debugFillProperties(properties);
properties.add( new EnumProperty<TextAlign>("textAlign", textAlign, defaultValue: null));

const int _kObscureShowLatestCharCursorTicks = 3;
static TimeSpan _kCursorBlinkHalfPeriod = TimeSpan.FromMilliseconds(500);
static TimeSpan _kCursorBlinkWaitForStart = TimeSpan.FromMilliseconds(150);
const float kMinInteractiveDimension = 48.0f;
Timer _cursorTimer;
bool _targetCursorVisibility = false;
ValueNotifier<bool> _cursorVisibilityNotifier = new ValueNotifier<bool>(false);

public ScrollController _scrollController = new ScrollController();
AnimationController _cursorBlinkOpacityController;
LayerLink _layerLink = new LayerLink();
bool _didAutoFocus = false;
FocusAttachment _focusAttachment;

widget.controller.addListener(_didChangeTextEditingValue);
_focusAttachment = widget.focusNode.attach(context);
widget.focusNode.addListener(_handleFocusChanged);
_scrollController = widget.scrollController ?? new ScrollController();
_cursorVisibilityNotifier.value = widget.showCursor;
FocusScope.of(context).autofocus(widget.focusNode);
SchedulerBinding.instance.addPostFrameCallback((_) => {
if (mounted) {
FocusScope.of(context).autofocus(widget.focusNode);
}
});
}
}

_updateRemoteEditingValueIfNeeded();
//_updateImePosIfNeed();
}
if (widget.controller.selection != oldWidget.controller.selection) {
_selectionOverlay?.update(_value);
}
_selectionOverlay.handlesVisible = widget.showSelectionHandles;
if (widget.focusNode != oldWidget.focusNode) {
oldWidget.focusNode.removeListener(_handleFocusChanged);
_focusAttachment?.detach();

}
if (widget.readOnly) {
_closeInputConnectionIfNeeded();
} else {
if (oldWidget.readOnly && _hasFocus)
_openInputConnection();
}
if (widget.style != oldWidget.style) {
TextStyle style = widget.style;
if (_textInputConnection != null && _textInputConnection.attached) {
_textInputConnection.setStyle(
fontFamily: style.fontFamily,
fontSize: style.fontSize,
fontWeight: style.fontWeight,
textDirection: _textDirection.Value,
textAlign: widget.textAlign
);
}
}
}
public override void dispose() {

widget.focusNode.removeListener(_handleFocusChanged);
base.dispose();
}
if (widget.readOnly) {
return;
}
_receivedRemoteTextEditingValue = value;
_hideSelectionOverlayIfNeeded();
hideToolbar();
_showCaretOnScreen();
if (widget.obscureText && value.text.Length == _value.text.Length + 1) {
_obscureShowCharTicksPending = !_unityKeyboard() ? _kObscureShowLatestCharCursorTicks : 0;

_lastKnownRemoteTextEditingValue = value;
_formatAndSetValue(value, isIMEInput);
_stopCursorTimer(resetCharTicks: false);

break;
case FloatingCursorDragState.End:
_floatingCursorResetController.setValue(0.0f);
_floatingCursorResetController.animateTo(1.0f, duration: _floatingCursorResetTime,
curve: Curves.decelerate);
if (_lastTextPosition != null && _lastBoundedOffset != null) {
_floatingCursorResetController.setValue(0.0f);
_floatingCursorResetController.animateTo(1.0f, duration: _floatingCursorResetTime,
curve: Curves.decelerate);
}
break;
}
}

}
var localValue = _value;
if (localValue == _lastKnownRemoteTextEditingValue) {
if (localValue == _receivedRemoteTextEditingValue) {
_lastKnownRemoteTextEditingValue = localValue;
_textInputConnection.setEditingState(localValue);
}

else if (caretEnd >= viewportExtent) {
scrollOffset += caretEnd - viewportExtent;
}
if (_isMultiline) {
//scrollOffset = scrollOffset.clamp(0.0f, renderEditable.maxScrollExtent) as float;[!!!]
}
return scrollOffset;
}

inputType: widget.keyboardType,
obscureText: widget.obscureText,
autocorrect: widget.autocorrect,
//smartDashesType: widget.smartDashesType ?? (widget.obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
//smartQuotesType: widget.smartQuotesType ?? (widget.obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
smartDashesType: widget.obscureText ? SmartDashesType.disabled : SmartDashesType.enabled,
smartQuotesType: widget.obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled,
enableSuggestions: widget.enableSuggestions,
inputAction: widget.textInputAction ?? (widget.keyboardType == TextInputType.multiline
? TextInputAction.newline

if (_hasInputConnection) {
_textInputConnection.close();
_textInputConnection = null;
_lastKnownRemoteTextEditingValue = null;
_lastFormattedUnmodifiedTextEditingValue = null;
_receivedRemoteTextEditingValue = null;
}
}

widget.controller.clearComposing();
}
}
public void requestKeyboard() {
if (_hasFocus) {
_openInputConnection();

void _handleSelectionChanged(TextSelection selection, RenderEditable renderObject,
SelectionChangedCause cause) {
if (!widget.controller.isSelectionWithinTextBounds(selection))
return;
_hideSelectionOverlayIfNeeded();
_selectionOverlay?.hide();
_selectionOverlay = null;
if (widget.selectionControls != null && Application.isMobilePlatform && !_unityKeyboard()) {
_selectionOverlay = new TextSelectionOverlay(

if (longPress || cause == SelectionChangedCause.doubleTap) {
_selectionOverlay.showToolbar();
}*/
}
if (widget.onSelectionChanged != null) {
widget.onSelectionChanged(selection, cause);
if (widget.onSelectionChanged != null) {
widget.onSelectionChanged(selection, cause);
}
}
}

curve: _caretAnimationCurve);
Rect newCaretRect = _getCaretRectAtScrollOffset(_currentCaretRect, scrollOffsetForCaret);
// Enlarge newCaretRect by scrollPadding to ensure that caret is not positioned directly at the edge after scrolling.
float bottomSpacing = widget.scrollPadding.bottom;
if (_selectionOverlay?.selectionControls != null) {
float handleHeight = _selectionOverlay.selectionControls
.getHandleSize(renderEditable.preferredLineHeight).height;
float interactiveHandleHeight = Mathf.Max(
handleHeight,
kMinInteractiveDimension
);
Offset anchor = _selectionOverlay.selectionControls
.getHandleAnchor(
TextSelectionHandleType.collapsed,
renderEditable.preferredLineHeight
);
float handleCenter = handleHeight / 2 - anchor.dy;
bottomSpacing = Mathf.Max(
handleCenter + interactiveHandleHeight / 2,
bottomSpacing
);
}
newCaretRect.bottom + widget.scrollPadding.bottom
newCaretRect.bottom + bottomSpacing
);
_editableKey.currentContext.findRenderObject().showOnScreen(
rect: inflatedRect,

public Future<bool> didPushRoute(string route) {
return Future.value(false).to<bool>();
}
void _formatAndSetValue(TextEditingValue value, bool isIMEInput = false) {
var textChanged = _value?.text != value?.text || isIMEInput;
if (textChanged && widget.inputFormatters != null && widget.inputFormatters.isNotEmpty()) {

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

updateKeepAlive();
}
TextDirection? _textDirection {
get {
TextDirection? result = widget.textDirection ?? Directionality.of(context);

}
}
public bool showToolbar() {
if (_selectionOverlay == null) {
if (foundation_.kIsWeb) {
return false;
}
if (_selectionOverlay == null || _selectionOverlay.toolbarIsVisible) {
return false;
}

public override Widget build(BuildContext context) {
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
_focusAttachment.reparent();
//FocusScope.of(context).reparentIfNeeded(widget.focusNode);
base.build(context); // See AutomaticKeepAliveClientMixin.
base.build(context);
return new Scrollable(
axisDirection: _isMultiline ? AxisDirection.down : AxisDirection.right,

viewportBuilder: (BuildContext _context, ViewportOffset offset) =>
new CompositedTransformTarget(
link: _layerLink,
link: _toolbarLayerLink,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
? new ValueNotifier<bool>(true)
? new ValueNotifier<bool>(widget.showCursor)
forceLine: widget.forceLine,
readOnly: widget.readOnly,
hasFocus: _hasFocus,
maxLines: widget.maxLines,
minLines: widget.minLines,

textScaleFactor: widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textAlign: widget.textAlign,
textDirection: _textDirection,
textWidthBasis: widget.textWidthBasis,
smartDashesType: widget.smartDashesType,
smartQuotesType: widget.smartQuotesType,
enableSuggestions: widget.enableSuggestions,
offset: offset,
onSelectionChanged: _handleSelectionChanged,
onCaretChanged: _handleCaretChanged,

cursorOffset: widget.cursorOffset,
selectionHeightStyle: widget.selectionHeightStyle,
selectionWidthStyle: widget.selectionWidthStyle,
paintCursorAboveText: widget.paintCursorAboveText,
enableInteractiveSelection: widget.enableInteractiveSelection == true,
textSelectionDelegate: this,

}
public TextSpan buildTextSpan() {
if (!widget.obscureText && _value.composing.isValid) {
TextStyle composingStyle = widget.style.merge(
new TextStyle(decoration: TextDecoration.underline)
);
return new TextSpan(
style: widget.style,
children: new List<InlineSpan> {
new TextSpan(text: _value.composing.textBefore(_value.text)),
new TextSpan(
style: composingStyle,
text: _value.composing.textInside(_value.text)
),
new TextSpan(text: _value.composing.textAfter(_value.text)),
});
}
var text = _value.text;
text = new string(RenderEditable.obscuringCharacter, text.Length);
int o = _obscureShowCharTicksPending > 0 ? _obscureLatestCharIndex : -1;
if (o >= 0 && o < text.Length) {
text = text.Substring(0, o) + _value.text.Substring(o, 1) + text.Substring(o + 1);
var text = _value.text;
if (widget.obscureText) {
text = new string(RenderEditable.obscuringCharacter, text.Length);
int o = _obscureShowCharTicksPending > 0 ? _obscureLatestCharIndex : -1;
if (o >= 0 && o < text.Length) {
text = text.Substring(0, o) + _value.text.Substring(o, 1) + text.Substring(o + 1);
}
return new TextSpan(style: widget.style, text: text);
return new TextSpan(style: widget.style, text: text);
return widget.controller.buildTextSpan(
style: widget.style,
withComposing: !widget.readOnly
);
}
// unity keyboard has a preview view with editing function, text selection & cursor function of this widget is disable

public readonly TextSpan textSpan;
public readonly TextEditingValue value;
public readonly Color cursorColor;
public readonly LayerLink startHandleLayerLink;
public readonly LayerLink endHandleLayerLink;
public readonly bool forceLine;
public readonly bool readOnly;
public readonly bool hasFocus;
public readonly int? maxLines;
public readonly int? minLines;

public readonly TextAlign textAlign;
public readonly TextDirection? textDirection;
public readonly bool obscureText;
public readonly TextWidthBasis textWidthBasis;
public readonly SmartDashesType smartDashesType;
public readonly SmartQuotesType smartQuotesType;
public readonly bool? enableSuggestions;
public readonly ViewportOffset offset;
public readonly SelectionChangedHandler onSelectionChanged;
public readonly CaretChangedHandler onCaretChanged;

public readonly Offset cursorOffset;
public readonly ui.BoxHeightStyle selectionHeightStyle;
public readonly ui.BoxWidthStyle selectionWidthStyle;
public readonly bool enableInteractiveSelection;
public readonly TextSelectionDelegate textSelectionDelegate;
public readonly bool? paintCursorAboveText;

public _Editable(TextSpan textSpan = null,
TextEditingValue value = null,
LayerLink startHandleLayerLink = null,
LayerLink endHandleLayerLink = null,
bool forceLine = false,
bool readOnly = false,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
bool hasFocus = false,
int? maxLines = null,
int? minLines = null,

bool obscureText = false,
TextAlign textAlign = TextAlign.left,
bool autocorrect = false,
SmartDashesType smartDashesType = SmartDashesType.disabled,
SmartQuotesType smartQuotesType = SmartQuotesType.disabled,
bool? enableSuggestions = null,
ViewportOffset offset = null,
SelectionChangedHandler onSelectionChanged = null,
CaretChangedHandler onCaretChanged = null,

float? cursorWidth = null,
Radius cursorRadius = null,
Offset cursorOffset = null,
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
bool enableInteractiveSelection = true,
bool? paintCursorAboveText = null,
float? devicePixelRatio = null,

this.startHandleLayerLink = startHandleLayerLink;
this.endHandleLayerLink = endHandleLayerLink;
this.forceLine = forceLine;
this.readOnly = readOnly;
this.textWidthBasis = textWidthBasis;
this.hasFocus = hasFocus;
this.maxLines = maxLines;
this.minLines = minLines;

this.textDirection = textDirection;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.smartDashesType = smartDashesType;
this.smartQuotesType = smartQuotesType;
this.enableSuggestions = enableSuggestions;
this.offset = offset;
this.onSelectionChanged = onSelectionChanged;
this.onCaretChanged = onCaretChanged;

this.cursorRadius = cursorRadius;
this.cursorOffset = cursorOffset;
this.enableInteractiveSelection = enableInteractiveSelection;
this.selectionHeightStyle = selectionHeightStyle;
this.selectionWidthStyle = selectionWidthStyle;
this.enableInteractiveSelection = enableInteractiveSelection;
this.devicePixelRatio = devicePixelRatio;
this.globalKeyEventHandler = globalKeyEventHandler;
}

offset: offset,
showCursor: showCursor,
cursorColor: cursorColor,
startHandleLayerLink: startHandleLayerLink,
endHandleLayerLink: endHandleLayerLink,
forceLine: forceLine,
readOnly: readOnly,
hasFocus: hasFocus,
maxLines: maxLines,
minLines: minLines,

textAlign: textAlign,
selection: value.selection,
obscureText: obscureText,
textWidthBasis: textWidthBasis,
onSelectionChanged: onSelectionChanged,
onCaretChanged: onCaretChanged,
ignorePointer: rendererIgnoresPointer,

selectionHeightStyle: selectionHeightStyle,
selectionWidthStyle: selectionWidthStyle,
enableInteractiveSelection: enableInteractiveSelection,
textSelectionDelegate: textSelectionDelegate,
paintCursorAboveText: paintCursorAboveText == true,

var edit = (RenderEditable) renderObject;
edit.text = textSpan;
edit.cursorColor = cursorColor;
edit.startHandleLayerLink = startHandleLayerLink;
edit.endHandleLayerLink = endHandleLayerLink;
edit.forceLine = forceLine;
edit.readOnly = readOnly;
edit.hasFocus = hasFocus;
edit.maxLines = maxLines;
edit.strutStyle = strutStyle;

edit.onSelectionChanged = onSelectionChanged;
edit.onCaretChanged = onCaretChanged;
edit.ignorePointer = rendererIgnoresPointer;
edit.textWidthBasis = textWidthBasis;
edit.selectionHeightStyle = selectionHeightStyle;
edit.selectionWidthStyle = selectionWidthStyle;
edit.enableInteractiveSelection = enableInteractiveSelection;
edit.paintCursorAboveText = paintCursorAboveText == true;
edit.devicePixelRatio = devicePixelRatio ?? 1.0f;

48
com.unity.uiwidgets/Runtime/widgets/focus_manager.cs


if (_descendants == null) {
List<FocusNode> result = new List<FocusNode>();
foreach (FocusNode child in _children) {
foreach (var childDescendant in child.descendants) {
result.Add(childDescendant);
}
//result.addAll(child.descendants);
result.AddRange(child.descendants);
result.Add(child);
}

if (!node.skipTraversal && node.canRequestFocus) {
nodes.Add(node);
}
// descendants.where((FocusNode node) => !node.skipTraversal && node.canRequestFocus);
return nodes;
}

public void _notify() {
if (_parent == null) {
return;
}

notifyListeners();
}

}
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<BuildContext>("context", context, defaultValue: null));

}
return child.toDiagnosticsNode(name: "Child ${count++}");
return child.toDiagnosticsNode(name: $"Child {count++}");
public override string toStringShort() {//override
bool hasDebugLabel = debugLabel != null && debugLabel.isNotEmpty();
string nullStr = "";

onKey: onKey,
canRequestFocus: canRequestFocus,
skipTraversal: skipTraversal
) {
D.assert(skipTraversal != null);
D.assert(canRequestFocus != null);
}
) {}
get { return enclosingScope; }
get { return this; }
}
public bool isFirstFocus {

// It is possible that a previously focused child is no longer focusable.
while (focusedChild != null && !focusedChild.canRequestFocus)
_focusedChildren.removeLast();
if (!findFirstFocus) {
if (canRequestFocus) {
_setAsFocusedChildForScope();

_markNextFocus(this);
}
} else {
primaryFocus._doRequestFocus(findFirstFocus: findFirstFocus);
primaryFocus._doRequestFocus(findFirstFocus: findFirstFocus);
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

childList = _focusedChildren.Select((FocusNode child)=> {
return child.toStringShort();
}).ToList();
// properties.add(new IEnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
properties.add(new EnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
}
}

24
com.unity.uiwidgets/Runtime/widgets/focus_scope.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
class _FocusScopeMarker : InheritedWidget {
public _FocusScopeMarker(FocusScopeNode node, Widget child, Key key = null) : base(key, child) {
D.assert(node != null);
this.node = node;
}
public readonly FocusScopeNode node;
public override bool updateShouldNotify(InheritedWidget oldWidget) {
return node != ((_FocusScopeMarker) oldWidget).node;
}
}
public class FocusScope : Focus {
public FocusScope(

onKey: onKey,
debugLabel: debugLabel) {
D.assert(child != null);
D.assert(autofocus != null);
}
public static FocusScopeNode of(BuildContext context) {
D.assert(context != null);

bool includeSemantics = true
) :base(key:key) {
D.assert(child != null);
D.assert(autofocus != null);
D.assert(includeSemantics != null);
this.child = child;
this.focusNode = focusNode;
this.autofocus = autofocus;

public static FocusNode of(BuildContext context, bool nullOk = false, bool scopeOk = false ) {
D.assert(context != null);
D.assert(nullOk != null);
D.assert(scopeOk != null);
_FocusMarker marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
FocusNode node = marker?.notifier;
if (node == null) {

public override Widget build(BuildContext context) {
_focusAttachment.reparent();
Widget child = widget.child;
/*if (widget.includeSemantics) {
child = Semantics(
focusable: _canRequestFocus,
focused: _hasPrimaryFocus,
child: widget.child,
);
}*/
return new _FocusMarker(
node: focusNode,
child: child

26
com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs


D.assert(currentNode != null);
FocusScopeNode scope = currentNode.nearestScope;
FocusNode candidate = scope.focusedChild;
if (candidate == null && scope.descendants.Count() != 0) {
List<FocusNode> sorted = _sortAllDescendants(scope);
candidate = sorted.isNotEmpty() ? sorted.First() : null;
if (candidate == null && scope.descendants.Any()) {
IEnumerable<FocusNode> sorted = _sortAllDescendants(scope);
candidate = sorted.Any() ? sorted.First() : null;
}
candidate = candidate ?? currentNode;

}
HashSet<FocusNode> groupKeys = new HashSet<FocusNode>(groups.Keys);
foreach ( FocusNode key in groups.Keys) {
List<FocusNode> sortedMembers = groups[key].policy.sortDescendants(groups[key].members).ToList();
List<FocusNode> sortedMembers = groups.getOrDefault(key).policy.sortDescendants(groups.getOrDefault(key).members).ToList();
groups[key].members.Clear();
groups[key].members.AddRange(sortedMembers);
}

FocusNode node ) {
this.direction = direction;
this.node = node;
}
public readonly TraversalDirection direction;
public readonly FocusNode node;

public class _DirectionalPolicyData {
public _DirectionalPolicyData(List<_DirectionalPolicyDataEntry> history) {
D.assert(history != null);
this.history = history;
}

public class OrderedTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy {
public OrderedTraversalPolicy(FocusTraversalPolicy secondary) {
this.secondary = secondary;
}
public readonly FocusTraversalPolicy secondary;

public class FocusTraversalOrder : InheritedWidget {
public FocusTraversalOrder(Key key = null, FocusOrder order = null, Widget child = null)
: base(key: key, child: child) {
this.order = order;
}
public readonly FocusOrder order;

D.assert(nullOk != null);
FocusTraversalOrder marker = context.getElementForInheritedWidgetOfExactType<FocusTraversalOrder>()?.widget as FocusTraversalOrder;
FocusOrder order = marker?.order;
if (order == null && !nullOk) {

properties.add(new DiagnosticsProperty<FocusNode>("previous", _previousFocus));
}
}
public class RequestFocusAction : _RequestFocusActionBase {
/// Creates a [RequestFocusAction] with a fixed [key].
public RequestFocusAction(LocalKey key) : base(key) {
}
/// The [LocalKey] that uniquely identifies this action to an [Intent].
static readonly LocalKey key = new ValueKey<Type>(typeof(RequestFocusAction));
public override void invoke(FocusNode node, Intent intent) => FocusTravesalUtils._focusAndEnsureVisible(node);
}
public class NextFocusAction : _RequestFocusActionBase {
public NextFocusAction() : base(key) {

正在加载...
取消
保存