浏览代码

format clean up

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
9f593ec7
共有 4 个文件被更改,包括 337 次插入277 次删除
  1. 271
      com.unity.uiwidgets/Runtime/material/input_decorator.cs
  2. 33
      com.unity.uiwidgets/Runtime/material/material_localizations.cs
  3. 10
      com.unity.uiwidgets/Runtime/material/text_form_field.cs
  4. 300
      com.unity.uiwidgets/Runtime/material/text_selection.cs

271
com.unity.uiwidgets/Runtime/material/input_decorator.cs


using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

D.assert(fillColor != null);
D.assert(hoverAnimation != null);
D.assert(hoverColorTween != null);
this.borderAnimation = borderAnimation;
this.border = border;
this.gapAnimation = gapAnimation;

public readonly Color fillColor;
public readonly ColorTween hoverColorTween;
public readonly Animation<float> hoverAnimation;
Color blendedColor => Color.alphaBlend(hoverColorTween.evaluate(hoverAnimation), fillColor);
Color blendedColor {
get { return Color.alphaBlend(hoverColorTween.evaluate(hoverAnimation), fillColor); }
}
public override void paint(Canvas canvas, Size size) {
InputBorder borderValue = border.evaluate(borderAnimation);

class _BorderContainerState : TickerProviderStateMixin<_BorderContainer> {
readonly static TimeSpan _kHoverDuration = new TimeSpan(0, 0, 0, 0, 15);
AnimationController _controller;
AnimationController _hoverColorController;
Animation<float> _borderAnimation;

public override void initState() {
base.initState();
_hoverColorController = new AnimationController(
duration: _kHoverDuration,
value: widget.isHovering ? 1.0f : 0.0f,
vsync: this
);
duration: _kHoverDuration,
value: widget.isHovering ? 1.0f : 0.0f,
vsync: this
);
_controller = new AnimationController(
duration: InputDecoratorConstants._kTransitionDuration,
vsync: this

_controller.setValue(0.0f);
_controller.forward();
}
} else {
}
else {
_hoverColorController.reverse();
}
}

return new CustomPaint(
foregroundPainter: new _InputBorderPainter(
repaint: ListenableUtils.merge(new List<Listenable> {_borderAnimation, widget.gap, _hoverColorController}),
repaint: ListenableUtils.merge(new List<Listenable>
{_borderAnimation, widget.gap, _hoverColorController}),
borderAnimation: _borderAnimation,
border: _border,
gapAnimation: widget.gapAnimation,

return Equals(contentPadding, other.contentPadding) && isCollapsed == other.isCollapsed &&
floatingLabelHeight.Equals(other.floatingLabelHeight) &&
floatingLabelProgress.Equals(other.floatingLabelProgress) &&
Equals(border, other.border) && Equals(borderGap, other.borderGap) &&
Equals(border, other.border) && Equals(borderGap, other.borderGap) &&
Equals(alignLabelWithHint, other.alignLabelWithHint) &&
Equals(isDense, other.isDense) && Equals(visualDensity, other.visualDensity) &&
Equals(icon, other.icon) && Equals(input, other.input) &&

hashCode = (hashCode * 397) ^ (helperError != null ? helperError.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (counter != null ? counter.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (container != null ? container.GetHashCode() : 0);
return hashCode;
}
}

markNeedsLayout();
}
}
TextDirection _textDirection;
public TextBaseline? textBaseline {

markNeedsLayout();
}
}
TextAlignVertical _textAlignVertical;
public bool isFocused {

}
bool _expands = false;
bool _isOutlineAligned {
get { return !decoration.isCollapsed && decoration.border.isOutline; }
}

D.assert(
layoutConstraints.maxWidth < float.PositiveInfinity,
() => "An InputDecorator, which is typically created by a TextField, cannot " +
"have an unbounded width.\n" +
"This happens when the parent widget does not provide a finite width " +
"constraint. For example, if the InputDecorator is contained by a Row, " +
"then its width must be constrained. An Expanded widget or a SizedBox " +
"can be used to constrain the width of the InputDecorator or the " +
"TextField that contains it."
);
"have an unbounded width.\n" +
"This happens when the parent widget does not provide a finite width " +
"constraint. For example, if the InputDecorator is contained by a Row, " +
"then its width must be constrained. An Expanded widget or a SizedBox " +
"can be used to constrain the width of the InputDecorator or the " +
"TextField that contains it."
);
Dictionary<RenderBox, float> boxToBaseline = new Dictionary<RenderBox, float>();
BoxConstraints boxConstraints = layoutConstraints.loosen();
if (prefix != null) {

}
float inputWidth = Math.Max(0.0f, constraints.maxWidth - (
_boxSize(icon).width
+ contentPadding.left
+ _boxSize(prefixIcon).width
+ _boxSize(prefix).width
+ _boxSize(suffix).width
+ _boxSize(suffixIcon).width
+ contentPadding.right));
_boxSize(icon).width
+ contentPadding.left
+ _boxSize(prefixIcon).width
+ _boxSize(prefix).width
+ _boxSize(suffix).width
+ _boxSize(suffixIcon).width
+ contentPadding.right));
if (label != null) {
boxToBaseline[label] = _layoutLineBox(label,
boxConstraints.copyWith(maxWidth: inputWidth)

+ contentPadding.bottom
+ densityOffset.dy
);
float minContainerHeight = decoration.isDense.Value || expands ? 0.0f : Constants.kMinInteractiveDimension + densityOffset.dy;
float minContainerHeight = decoration.isDense.Value || expands
? 0.0f
: Constants.kMinInteractiveDimension + densityOffset.dy;
float maxContainerHeight = boxConstraints.maxHeight - bottomHeight + densityOffset.dy;
float containerHeight = expands
? maxContainerHeight

// The baselines that will be used to draw the actual input text content.
float topInputBaseline = contentPadding.top
+ topHeight
+ inputInternalBaseline
+ baselineAdjustment
+ interactiveAdjustment;
+ topHeight
+ inputInternalBaseline
+ baselineAdjustment
+ interactiveAdjustment;
- contentPadding.top
- topHeight
- contentPadding.bottom;
- contentPadding.top
- topHeight
- contentPadding.bottom;
+ baselineAdjustment / 2.0f
+ (containerHeight - (2.0f + inputHeight)) / 2.0f;
+ baselineAdjustment / 2.0f
+ (containerHeight - (2.0f + inputHeight)) / 2.0f;
float outlineTopBaseline = topInputBaseline;
float outlineBottomBaseline = topInputBaseline + maxVerticalOffset;
float outlineBaseline = _interpolateThree(

if (begin >= middle) {
return middle;
}
t = textAlignVertical.y + 1;
return begin + (middle - begin) * t;
}

}
t = textAlignVertical.y;
return middle + (end - middle) * t;
}

renderObject.label = child;
break;
case _DecorationSlot.hint:
renderObject.hint = child;
renderObject.hint = child;
renderObject.suffix = child;
renderObject.suffix = child;
break;
case _DecorationSlot.prefixIcon:
renderObject.prefixIcon = child;

public override void initState() {
base.initState();
(widget.decoration.hasFloatingPlaceholder == true && widget._labelShouldWithdraw);
(widget.decoration.hasFloatingPlaceholder == true &&
widget._labelShouldWithdraw);
_floatingLabelController = new AnimationController(
duration: InputDecoratorConstants._kTransitionDuration,
vsync: this,

public InputDecoration decoration {
get {
_effectiveDecoration = _effectiveDecoration ?? widget.decoration.applyDefaults(
Theme.of(context).inputDecorationTheme
);
Theme.of(context).inputDecorationTheme
);
return _effectiveDecoration;
}
}

}
bool isFocused => widget.isFocused && decoration.enabled == true;
bool isHovering => widget.isHovering && decoration.enabled == true;
bool isFocused {
get { return widget.isFocused && decoration.enabled == true; }
}
bool isHovering {
get { return widget.isHovering && decoration.enabled == true; }
}
return decoration.hasFloatingPlaceholder == true && decoration.floatingLabelBehavior != FloatingLabelBehavior.never;
return decoration.hasFloatingPlaceholder == true &&
decoration.floatingLabelBehavior != FloatingLabelBehavior.never;
}
}

if (widget.decoration != old.decoration) {
_effectiveDecoration = null;
}
bool floatBehaviourChanged = widget.decoration.floatingLabelBehavior != old.decoration.floatingLabelBehavior ||
widget.decoration.hasFloatingPlaceholder != old.decoration.hasFloatingPlaceholder;
bool floatBehaviourChanged =
widget.decoration.floatingLabelBehavior != old.decoration.floatingLabelBehavior ||
widget.decoration.hasFloatingPlaceholder != old.decoration.hasFloatingPlaceholder;
if (_floatingLabelEnabled && (widget._labelShouldWithdraw || widget.decoration.floatingLabelBehavior == FloatingLabelBehavior.always)){
if (_floatingLabelEnabled && (widget._labelShouldWithdraw ||
widget.decoration.floatingLabelBehavior ==
FloatingLabelBehavior.always)) {
_floatingLabelController.forward();
}
else {

return themeData.hintColor;
}
Color _getDefaultBorderColor(ThemeData themeData) {
if (isFocused) {
switch (themeData.brightness) {

return themeData.primaryColor;
}
}
Color hoverColor = decoration.hoverColor ?? themeData.inputDecorationTheme?.hoverColor ?? themeData.hoverColor;
Color hoverColor = decoration.hoverColor ??
themeData.inputDecorationTheme?.hoverColor ?? themeData.hoverColor;
return enabledColor;
}

return lightEnabled;
}
Color _getHoverColor(ThemeData themeData) {
if (decoration.filled == null || !decoration.filled.Value || isFocused || decoration.enabled != true) {
return Colors.transparent;

heightFactor: 1.0f,
child: new ConstrainedBox(
constraints: decoration.prefixIconConstraints ?? themeData.visualDensity.effectiveConstraints(
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
)),
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
)),
child: IconTheme.merge(
data: new IconThemeData(
color: iconColor,

heightFactor: 1.0f,
child: new ConstrainedBox(
constraints: decoration.suffixIconConstraints ?? themeData.visualDensity.effectiveConstraints(
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
)),
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
)),
child: IconTheme.merge(
data: new IconThemeData(
color: iconColor,

(4.0f + 0.75f * inlineLabelStyle.fontSize) * MediaQuery.textScaleFactorOf(context);
if (decoration.filled == true) {
contentPadding = decorationContentPadding ?? (decorationIsDense
? EdgeInsets.fromLTRB(12.0f, 8.0f, 12.0f, 8.0f)
: EdgeInsets.fromLTRB(12.0f, 12.0f, 12.0f, 12.0f));
? EdgeInsets.fromLTRB(12.0f, 8.0f, 12.0f, 8.0f)
: EdgeInsets.fromLTRB(12.0f, 12.0f, 12.0f, 12.0f));
? EdgeInsets.fromLTRB(0.0f, 8.0f, 0.0f, 8.0f)
: EdgeInsets.fromLTRB(0.0f, 12.0f, 0.0f, 12.0f));
? EdgeInsets.fromLTRB(0.0f, 8.0f, 0.0f, 8.0f)
: EdgeInsets.fromLTRB(0.0f, 12.0f, 0.0f, 12.0f));
? EdgeInsets.fromLTRB(12.0f, 20.0f, 12.0f, 12.0f)
: EdgeInsets.fromLTRB(12.0f, 24.0f, 12.0f, 16.0f));
? EdgeInsets.fromLTRB(12.0f, 20.0f, 12.0f, 12.0f)
: EdgeInsets.fromLTRB(12.0f, 24.0f, 12.0f, 16.0f));
}
return new _Decorator(

border = border ?? InputBorder.none;
D.assert(!(!hasFloatingPlaceholder && floatingLabelBehavior == FloatingLabelBehavior.always),
() => "hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always");
InputDecoration decoration = new InputDecoration(
icon: null,
labelText: null,

public readonly int? errorMaxLines;
public readonly bool? hasFloatingPlaceholder;
public readonly FloatingLabelBehavior? floatingLabelBehavior;
public readonly bool? isDense;

public bool isCollapsed;
public readonly Widget prefixIcon;
public readonly BoxConstraints prefixIconConstraints;
public readonly Widget prefix;

public readonly TextStyle prefixStyle;
public readonly Widget suffixIcon;
public readonly BoxConstraints suffixIconConstraints;
public readonly Widget suffix;

public readonly bool? filled;
public readonly Color fillColor;
public readonly Color hoverColor;
public readonly InputBorder errorBorder;

labelStyle: labelStyle ?? this.labelStyle,
helperText: helperText ?? this.helperText,
helperStyle: helperStyle ?? this.helperStyle,
helperMaxLines : helperMaxLines ?? this.helperMaxLines,
helperMaxLines: helperMaxLines ?? this.helperMaxLines,
hintText: hintText ?? this.hintText,
hintStyle: hintStyle ?? this.hintStyle,
hintMaxLines: hintMaxLines ?? this.hintMaxLines,

labelStyle: labelStyle ?? theme.labelStyle,
helperStyle: helperStyle ?? theme.helperStyle,
hintStyle: hintStyle ?? theme.hintStyle,
helperMaxLines : helperMaxLines ?? theme.helperMaxLines,
helperMaxLines: helperMaxLines ?? theme.helperMaxLines,
errorStyle: errorStyle ?? theme.errorStyle,
errorMaxLines: errorMaxLines ?? theme.errorMaxLines,
hasFloatingPlaceholder: hasFloatingPlaceholder ?? theme.hasFloatingPlaceholder,

if (hasFloatingPlaceholder == false) {
description.Add($"hasFloatingPlaceholder: false");
}
if (floatingLabelBehavior != null) {
description.Add($"floatingLabelBehavior: {floatingLabelBehavior}");
}

if (prefixStyle != null) {
description.Add($"prefixStyle: ${prefixStyle}");
}
if (prefixIconConstraints != null) {
description.Add($"prefixIconConstraints: ${prefixIconConstraints}");
}

if (suffixStyle != null) {
description.Add($"suffixStyle: ${suffixStyle}");
}
if (suffixIconConstraints != null) {
description.Add($"suffixIconConstraints: ${suffixIconConstraints}");
}

if (fillColor != null) {
description.Add($"fillColor: ${fillColor}");
}
if (hoverColor != null) {
description.Add($"hoverColor: ${hoverColor}");
}

D.assert(filled != null);
D.assert(!(hasFloatingPlaceholder != true && floatingLabelBehavior == FloatingLabelBehavior.always),
() => "hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always");
this.labelStyle = labelStyle;
this.helperStyle = helperStyle;
this.helperMaxLines = helperMaxLines;

public readonly int? errorMaxLines;
public readonly bool? hasFloatingPlaceholder;
public readonly FloatingLabelBehavior? floatingLabelBehavior;
public readonly bool? isDense;

public readonly bool? filled;
public readonly Color fillColor;
public readonly Color hoverColor;
public readonly InputBorder errorBorder;

public readonly InputBorder border;
public readonly bool alignLabelWithHint;
InputDecorationTheme copyWith(
TextStyle labelStyle = null,
TextStyle helperStyle = null,

int? errorMaxLines = null,
int? errorMaxLines = null,
bool? hasFloatingPlaceholder = null,
FloatingLabelBehavior? floatingLabelBehavior = null,
bool? isDense = null,

InputBorder enabledBorder = null,
InputBorder border = null,
bool? alignLabelWithHint = null
) {
) {
labelStyle: labelStyle ?? this.labelStyle,
helperStyle: helperStyle ?? this.helperStyle,
helperMaxLines: helperMaxLines ?? this.helperMaxLines,
hintStyle: hintStyle ?? this.hintStyle,
errorStyle: errorStyle ?? this.errorStyle,
errorMaxLines: errorMaxLines ?? this.errorMaxLines,
hasFloatingPlaceholder: hasFloatingPlaceholder ?? this.hasFloatingPlaceholder,
floatingLabelBehavior: floatingLabelBehavior ?? this.floatingLabelBehavior,
isDense: isDense ?? this.isDense,
contentPadding: contentPadding ?? this.contentPadding,
isCollapsed: isCollapsed ?? this.isCollapsed,
prefixStyle: prefixStyle ?? this.prefixStyle,
suffixStyle: suffixStyle ?? this.suffixStyle,
counterStyle: counterStyle ?? this.counterStyle,
filled: filled ?? this.filled,
fillColor: fillColor ?? this.fillColor,
focusColor: focusColor ?? this.focusColor,
hoverColor: hoverColor ?? this.hoverColor,
errorBorder: errorBorder ?? this.errorBorder,
focusedBorder: focusedBorder ?? this.focusedBorder,
focusedErrorBorder: focusedErrorBorder ?? this.focusedErrorBorder,
disabledBorder: disabledBorder ?? this.disabledBorder,
enabledBorder: enabledBorder ?? this.enabledBorder,
border: border ?? this.border,
alignLabelWithHint: alignLabelWithHint ?? this.alignLabelWithHint
labelStyle: labelStyle ?? this.labelStyle,
helperStyle: helperStyle ?? this.helperStyle,
helperMaxLines: helperMaxLines ?? this.helperMaxLines,
hintStyle: hintStyle ?? this.hintStyle,
errorStyle: errorStyle ?? this.errorStyle,
errorMaxLines: errorMaxLines ?? this.errorMaxLines,
hasFloatingPlaceholder: hasFloatingPlaceholder ?? this.hasFloatingPlaceholder,
floatingLabelBehavior: floatingLabelBehavior ?? this.floatingLabelBehavior,
isDense: isDense ?? this.isDense,
contentPadding: contentPadding ?? this.contentPadding,
isCollapsed: isCollapsed ?? this.isCollapsed,
prefixStyle: prefixStyle ?? this.prefixStyle,
suffixStyle: suffixStyle ?? this.suffixStyle,
counterStyle: counterStyle ?? this.counterStyle,
filled: filled ?? this.filled,
fillColor: fillColor ?? this.fillColor,
focusColor: focusColor ?? this.focusColor,
hoverColor: hoverColor ?? this.hoverColor,
errorBorder: errorBorder ?? this.errorBorder,
focusedBorder: focusedBorder ?? this.focusedBorder,
focusedErrorBorder: focusedErrorBorder ?? this.focusedErrorBorder,
disabledBorder: disabledBorder ?? this.disabledBorder,
enabledBorder: enabledBorder ?? this.enabledBorder,
border: border ?? this.border,
alignLabelWithHint: alignLabelWithHint ?? this.alignLabelWithHint
public static bool operator ==(InputDecorationTheme left, InputDecorationTheme right) {
return Equals(left, right);
}

defaultValue: defaultTheme.labelStyle));
properties.add(new DiagnosticsProperty<TextStyle>("helperStyle", helperStyle,
defaultValue: defaultTheme.helperStyle));
properties.add(new IntProperty("helperMaxLines", helperMaxLines, defaultValue: defaultTheme.helperMaxLines));
properties.add(new IntProperty("helperMaxLines", helperMaxLines,
defaultValue: defaultTheme.helperMaxLines));
properties.add(new DiagnosticsProperty<TextStyle>("hintStyle", hintStyle,
defaultValue: defaultTheme.hintStyle));
properties.add(new DiagnosticsProperty<TextStyle>("errorStyle", errorStyle,

defaultValue: defaultTheme.hasFloatingPlaceholder));
properties.add(new DiagnosticsProperty<FloatingLabelBehavior?>("floatingLabelBehavior", floatingLabelBehavior, defaultValue: defaultTheme.floatingLabelBehavior));
properties.add(new DiagnosticsProperty<FloatingLabelBehavior?>("floatingLabelBehavior",
floatingLabelBehavior, defaultValue: defaultTheme.floatingLabelBehavior));
properties.add(new DiagnosticsProperty<bool?>("isDense", isDense, defaultValue: defaultTheme.isDense));
properties.add(new DiagnosticsProperty<EdgeInsets>("contentPadding", contentPadding,
defaultValue: defaultTheme.contentPadding));

properties.add(new DiagnosticsProperty<TextStyle>("counterStyle", counterStyle,
defaultValue: defaultTheme.counterStyle));
properties.add(new DiagnosticsProperty<bool?>("filled", filled, defaultValue: defaultTheme.filled));
properties.add(new ColorProperty("fillColor", fillColor, defaultValue: defaultTheme.fillColor));
properties.add(new ColorProperty("fillColor", fillColor, defaultValue: defaultTheme.fillColor));
properties.add(new ColorProperty("focusColor", focusColor, defaultValue: defaultTheme.focusColor));
properties.add(new ColorProperty("hoverColor", hoverColor, defaultValue: defaultTheme.hoverColor));
properties.add(new DiagnosticsProperty<InputBorder>("errorBorder", errorBorder,

33
com.unity.uiwidgets/Runtime/material/material_localizations.cs


public abstract string formatYear(DateTime date);
public abstract string formatCompactDate(DateTime date);
public abstract DateTime? parseCompactDate(string inputString);
public abstract string formatMediumDate(DateTime date);

public abstract List<string> narrowWeekdays { get; }
public abstract int firstDayOfWeekIndex { get; }
public abstract string modalBarrierDismissLabel { get; }
public static MaterialLocalizations of(BuildContext context) {

"Sun",
};
static readonly List<String> _weekdays = new List<string>() {
static readonly List<string> _weekdays = new List<string>() {
"Monday",
"Tuesday",
"Wednesday",

"Sunday",
};
static readonly List<String> _narrowWeekdays = new List<string>() {
static readonly List<string> _narrowWeekdays = new List<string>() {
"S",
"M",
"T",

"S",
};
static readonly List<String> _shortMonths = new List<string>() {
static readonly List<string> _shortMonths = new List<string>() {
"Jan",
"Feb",
"Mar",

"Dec",
};
static readonly List<String> _months = new List<string>() {
static readonly List<string> _months = new List<string>() {
"January",
"February",
"March",

"November",
"December",
};
(year % 400 == 0);
(year % 400 == 0);
int[] daysInMonth = new int[] { 31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int[] daysInMonth = new int[] {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
return daysInMonth[month - 1];
}

string year = date.Year.ToString().PadLeft(4, '0');
return $"{month}/{day}/{year}";
}
public override string formatShortDate(DateTime date) {
string month = _shortMonths[date.Month - 1];
return $"{month} {date.Day}, {date.Year}";

if (!success || day < 1 || day > _getDaysInMonth(year, month)) {
return null;
}
return new DateTime(year, month, day);
}

case DayPeriod.pm:
return postMeridiemAbbreviation;
}
return null;
}

result.Append(',');
}
}
return result.ToString();
}

}
public override string modalBarrierDismissLabel {
get { return "Dismiss"; }
get { return "Dismiss"; }
}
public override ScriptCategory scriptCategory {

public static readonly LocalizationsDelegate<MaterialLocalizations> del = new _MaterialLocalizationsDelegate();
}
}
}

10
com.unity.uiwidgets/Runtime/material/text_form_field.cs


_TextFormFieldState state = (_TextFormFieldState) field;
InputDecoration effectiveDecoration = (decoration ?? new InputDecoration())
.applyDefaults(Theme.of(field.context).inputDecorationTheme);
return new TextField(
controller: state._effectiveController,
focusNode: focusNode,

showCursor: showCursor,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
smartQuotesType: smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
smartDashesType: smartDashesType ??
(obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
smartQuotesType: smartQuotesType ??
(obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
enableSuggestions: enableSuggestions,
maxLengthEnforced: maxLengthEnforced,
maxLines: maxLines,

300
com.unity.uiwidgets/Runtime/material/text_selection.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;

public static class MaterialUtils {
public static readonly TextSelectionControls materialTextSelectionControls =
new _MaterialTextSelectionControls();
internal const float _kToolbarContentDistance = 8.0f;
internal const float _kToolbarContentDistance = 8.0f;
VoidCallback handleCopy = null, VoidCallback handlePaste = null, VoidCallback handleSelectAll = null, bool isAbove = false) : base(key: key) {
VoidCallback handleCopy = null, VoidCallback handlePaste = null, VoidCallback handleSelectAll = null,
bool isAbove = false) : base(key: key) {
this.handleCut = handleCut;
this.handleCopy = handleCopy;
this.handlePaste = handlePaste;

public class _TextSelectionToolbarState : TickerProviderStateMixin<_TextSelectionToolbar> {
bool _overflowOpen = false;
FlatButton _getItem(VoidCallback onPressed, String label) {
FlatButton _getItem(VoidCallback onPressed, string label) {
D.assert(onPressed != null);
return new FlatButton(
child: new Text(label),

public override void didUpdateWidget(StatefulWidget oldWidget) {
var _oldWidget = (_TextSelectionToolbar)oldWidget;
var _oldWidget = (_TextSelectionToolbar) oldWidget;
if (((widget.handleCut == null) != (_oldWidget.handleCut == null))
|| ((widget.handleCopy == null) != (_oldWidget.handleCopy == null))
|| ((widget.handlePaste == null) != (_oldWidget.handlePaste == null))

}
public override Widget build(BuildContext context) {
MaterialLocalizations localizations = MaterialLocalizations.of(context);
List<Widget> items = new List<Widget>();

}
icon: new Icon(_overflowOpen ? Icons.arrow_back : Icons.more_vert),
onPressed: () => {
setState(() => {
_overflowOpen = !_overflowOpen;
});
},
tooltip: _overflowOpen
? localizations.backButtonTooltip
: localizations.moreButtonTooltip
icon: new Icon(_overflowOpen ? Icons.arrow_back : Icons.more_vert),
onPressed: () => { setState(() => { _overflowOpen = !_overflowOpen; }); },
tooltip: _overflowOpen
? localizations.backButtonTooltip
: localizations.moreButtonTooltip
)
);

Key key = null,
Widget child = null,
bool overflowOpen = false
) : base(key: key, child: child) {
) : base(key: key, child: child) {
public readonly bool overflowOpen;
public override RenderObject createRenderObject(BuildContext context) {

class _TextSelectionToolbarContainerRenderBox : RenderProxyBox {
public _TextSelectionToolbarContainerRenderBox(
bool overflowOpen = false
) : base() {
) : base() {
float? _closedWidth;
public bool overflowOpen {

markNeedsLayout();
}
}
if (!overflowOpen && _closedWidth == null) {
_closedWidth = child.size.width;
}

child.size.height
child.size.height
));
_ToolbarParentData childParentData = child.parentData as _ToolbarParentData;

offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxResult, Offset boxTransformed) => {
D.assert(boxTransformed == position - childParentData.offset);
return child.hitTest(boxResult, position: boxTransformed);
}
D.assert(boxTransformed == position - childParentData.offset);
return child.hitTest(boxResult, position: boxTransformed);
}
);
}

this.isAbove = isAbove;
this.overflowOpen = overflowOpen;
}
public readonly bool isAbove;
public readonly bool overflowOpen;

_renderObject.overflowOpen = overflowOpen;
}
public override Element createElement() => new _TextSelectionToolbarItemsElement(this);
public override Element createElement() {
return new _TextSelectionToolbarItemsElement(this);
}
public override string ToString() => $"{base.ToString()}; shouldPaint={shouldPaint}";
public override string ToString() {
return $"{base.ToString()}; shouldPaint={shouldPaint}";
}
MultiChildRenderObjectWidget widget) :
MultiChildRenderObjectWidget widget) :
foreach(var child in children.Where(_shouldPaint)) {
foreach (var child in children.Where(_shouldPaint)) {
visitor(child);
}
}

public _TextSelectionToolbarItemsRenderBox(
bool isAbove = false,
bool overflowOpen = false
) : base() {
) : base() {
int _lastIndexThatFits = -1;
public bool isAbove {

markNeedsLayout();
}
}
bool _isAbove;
public bool overflowOpen {

markNeedsLayout();
}
}
void _layoutChildren() {
BoxConstraints sizedConstraints = _overflowOpen
? constraints

float width = 0.0f;
visitChildren((RenderObject renderObjectChild) => {
i++;
if (_lastIndexThatFits != -1 && !overflowOpen) {
return;
}

_lastIndexThatFits = i - 1;
}
});
RenderBox navButton = firstChild;
if (_lastIndexThatFits != -1
&& _lastIndexThatFits == childCount - 2

}
if (_lastIndexThatFits == -1) {
return true;
}

int i = -1;
Size nextSize = new Size(0.0f, 0.0f);
float fitWidth = 0.0f;
RenderBox navButton = firstChild;
float overflowHeight = overflowOpen && !isAbove ? navButton.size.height : 0.0f;
visitChildren((RenderObject renderObjectChild) => {
i++;
int i = -1;
Size nextSize = new Size(0.0f, 0.0f);
float fitWidth = 0.0f;
RenderBox navButton = firstChild;
float overflowHeight = overflowOpen && !isAbove ? navButton.size.height : 0.0f;
visitChildren((RenderObject renderObjectChild) => {
i++;
RenderBox child = renderObjectChild as RenderBox;
_ToolbarParentData childParentData = child.parentData as _ToolbarParentData;
RenderBox child = renderObjectChild as RenderBox;
_ToolbarParentData childParentData = child.parentData as _ToolbarParentData;
if (renderObjectChild == navButton) {
return;
}
if (!_shouldPaintChild(renderObjectChild, i)) {
childParentData.shouldPaint = false;
return;
}
childParentData.shouldPaint = true;
if (renderObjectChild == navButton) {
return;
}
if (!overflowOpen) {
childParentData.offset = new Offset(fitWidth, 0.0f);
fitWidth += child.size.width;
nextSize = new Size(
fitWidth,
Mathf.Max(child.size.height, nextSize.height)
);
} else {
childParentData.offset = new Offset(0.0f, overflowHeight);
overflowHeight += child.size.height;
nextSize = new Size(
Mathf.Max(child.size.width, nextSize.width),
overflowHeight
);
}
});
_ToolbarParentData navButtonParentData = navButton.parentData as _ToolbarParentData;
if (_shouldPaintChild(firstChild, 0)) {
navButtonParentData.shouldPaint = true;
if (overflowOpen) {
navButtonParentData.offset = isAbove
? new Offset(0.0f, overflowHeight)
: Offset.zero;
nextSize = new Size(
nextSize.width,
isAbove ? nextSize.height + navButton.size.height : nextSize.height
);
} else {
navButtonParentData.offset = new Offset(fitWidth, 0.0f);
nextSize = new Size(nextSize.width + navButton.size.width, nextSize.height);
}
} else {
navButtonParentData.shouldPaint = false;
}
if (!_shouldPaintChild(renderObjectChild, i)) {
childParentData.shouldPaint = false;
return;
}
childParentData.shouldPaint = true;
if (!overflowOpen) {
childParentData.offset = new Offset(fitWidth, 0.0f);
fitWidth += child.size.width;
nextSize = new Size(
fitWidth,
Mathf.Max(child.size.height, nextSize.height)
);
}
else {
childParentData.offset = new Offset(0.0f, overflowHeight);
overflowHeight += child.size.height;
nextSize = new Size(
Mathf.Max(child.size.width, nextSize.width),
overflowHeight
);
}
});
_ToolbarParentData navButtonParentData = navButton.parentData as _ToolbarParentData;
if (_shouldPaintChild(firstChild, 0)) {
navButtonParentData.shouldPaint = true;
if (overflowOpen) {
navButtonParentData.offset = isAbove
? new Offset(0.0f, overflowHeight)
: Offset.zero;
nextSize = new Size(
nextSize.width,
isAbove ? nextSize.height + navButton.size.height : nextSize.height
);
}
else {
navButtonParentData.offset = new Offset(fitWidth, 0.0f);
nextSize = new Size(nextSize.width + navButton.size.width, nextSize.height);
}
}
else {
navButtonParentData.shouldPaint = false;
}
size = nextSize;
}
size = nextSize;
}
protected override void performLayout() {
_lastIndexThatFits = -1;

RenderBox child = lastChild;
while (child != null) {
_ToolbarParentData childParentData = child.parentData as _ToolbarParentData;
if (!childParentData.shouldPaint) {
child = childParentData.previousSibling;
continue;

offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxResult, Offset boxTransformed) => {
D.assert(boxTransformed == position - childParentData.offset);
return child.hitTest(boxResult, position: boxTransformed);
}
D.assert(boxTransformed == position - childParentData.offset);
return child.hitTest(boxResult, position: boxTransformed);
}
return false;
}
}

if (position - width / 2.0f < min) {
return min;
}
return position - width / 2.0f;
}

}
class _MaterialTextSelectionControls : TextSelectionControls {
public static readonly TextSelectionControls materialTextSelectionControls = new _MaterialTextSelectionControls();
public static readonly TextSelectionControls materialTextSelectionControls =
new _MaterialTextSelectionControls();
public override Size getHandleSize(float textLineHeight) {
return new Size(MaterialUtils._kHandleSize,
MaterialUtils._kHandleSize);

Offset selectionMidpoint, List<TextSelectionPoint> endpoints, TextSelectionDelegate selectionDelegate) {
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
D.assert(material_.debugCheckHasMaterialLocalizations(context));
+ MaterialUtils._kToolbarHeight
+ MaterialUtils._kToolbarContentDistance;
+ MaterialUtils._kToolbarHeight
+ MaterialUtils._kToolbarContentDistance;
+ startTextSelectionPoint.point.dy
- textLineHeight
- paddingTop;
+ startTextSelectionPoint.point.dy
- textLineHeight
- paddingTop;
? globalEditableRegion.top + startTextSelectionPoint.point.dy - textLineHeight - MaterialUtils._kToolbarContentDistance
: globalEditableRegion.top + endTextSelectionPoint.point.dy + MaterialUtils._kToolbarContentDistanceBelow
? globalEditableRegion.top + startTextSelectionPoint.point.dy - textLineHeight -
MaterialUtils._kToolbarContentDistance
: globalEditableRegion.top + endTextSelectionPoint.point.dy +
MaterialUtils._kToolbarContentDistanceBelow
children: new List<Widget>(){
new CustomSingleChildLayout(
layoutDelegate: new _TextSelectionToolbarLayout(
anchor,
MaterialUtils._kToolbarScreenPadding + paddingTop,
fitsAbove
),
child: new _TextSelectionToolbar(
handleCut: canCut(selectionDelegate) ? () => handleCut(selectionDelegate) : (VoidCallback)null,
handleCopy: canCopy(selectionDelegate) ? () => handleCopy(selectionDelegate) : (VoidCallback)null,
handlePaste: canPaste(selectionDelegate) ? () => handlePaste(selectionDelegate) : (VoidCallback)null,
handleSelectAll: canSelectAll(selectionDelegate) ? () => handleSelectAll(selectionDelegate) : (VoidCallback)null,
isAbove: fitsAbove
)
),
children: new List<Widget>() {
new CustomSingleChildLayout(
layoutDelegate: new _TextSelectionToolbarLayout(
anchor,
MaterialUtils._kToolbarScreenPadding + paddingTop,
fitsAbove
),
child: new _TextSelectionToolbar(
handleCut: canCut(selectionDelegate)
? () => handleCut(selectionDelegate)
: (VoidCallback) null,
handleCopy: canCopy(selectionDelegate)
? () => handleCopy(selectionDelegate)
: (VoidCallback) null,
handlePaste: canPaste(selectionDelegate)
? () => handlePaste(selectionDelegate)
: (VoidCallback) null,
handleSelectAll: canSelectAll(selectionDelegate)
? () => handleSelectAll(selectionDelegate)
: (VoidCallback) null,
isAbove: fitsAbove
)
),
);
);
}
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) {

)
)
);
switch (type) {
case TextSelectionHandleType.left: // points up-right
return new Transform(

return new Offset(MaterialUtils._kHandleSize / 2, -4);
}
}
new bool canSelectAll(TextSelectionDelegate selectionDelegate) {
TextEditingValue value = selectionDelegate.textEditingValue;
return selectionDelegate.selectAllEnabled &&

正在加载...
取消
保存