浏览代码

Update InputDecorator and ListTile

/main
Yuncong Zhang 6 年前
当前提交
9a196283
共有 2 个文件被更改,包括 150 次插入75 次删除
  1. 206
      Runtime/material/input_decorator.cs
  2. 19
      Runtime/material/list_tile.cs

206
Runtime/material/input_decorator.cs


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using RSG.Promises;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;

}
void _handleChange() {
this.setState(() => {
});
this.setState(() => { });
}
public override void didUpdateWidget(StatefulWidget _old) {

Widget suffixIcon = null,
Widget helperError = null,
Widget counter = null,
Widget container = null
Widget container = null,
bool? alignLabelWithHint = null
) {
D.assert(contentPadding != null);
this.contentPadding = contentPadding;

this.helperError = helperError;
this.counter = counter;
this.container = container;
this.alignLabelWithHint = alignLabelWithHint;
}
public readonly EdgeInsets contentPadding;

public readonly InputBorder border;
public readonly _InputBorderGap borderGap;
public readonly bool? alignLabelWithHint;
public readonly Widget icon;
public readonly Widget input;
public readonly Widget label;

Equals(this.prefix, other.prefix) && Equals(this.suffix, other.suffix) &&
Equals(this.prefixIcon, other.prefixIcon) && Equals(this.suffixIcon, other.suffixIcon) &&
Equals(this.helperError, other.helperError) && Equals(this.counter, other.counter) &&
Equals(this.container, other.container);
Equals(this.container, other.container) && Equals(this.alignLabelWithHint, other.alignLabelWithHint);
}
public override bool Equals(object obj) {

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

}
float inputWidth = Mathf.Max(0.0f, this.constraints.maxWidth - (
_boxSize(this.icon).width
+ this.contentPadding.left
+ _boxSize(this.prefixIcon).width
+ _boxSize(this.prefix).width
+ _boxSize(this.suffix).width
+ _boxSize(this.suffixIcon).width
+ this.contentPadding.right));
_boxSize(this.icon).width
+ this.contentPadding.left
+ _boxSize(this.prefixIcon).width
+ _boxSize(this.prefix).width
+ _boxSize(this.suffix).width
+ _boxSize(this.suffixIcon).width
+ this.contentPadding.right));
if (this.label != null)
{
this.label.layout(boxConstraints, parentUsesSize: true);
if (this.label != null) {
if (this.decoration.alignLabelWithHint == true) {
layoutLineBox(this.label);
}
else {
this.label.layout(boxConstraints, parentUsesSize: true);
}
}
boxConstraints = boxConstraints.copyWith(minWidth: inputWidth);

boxConstraints = boxConstraints.copyWith(
maxWidth: Mathf.Max(0.0f, boxConstraints.maxWidth
- _boxSize(this.icon).width
- _boxSize(this.counter).width
- this.contentPadding.horizontal
- _boxSize(this.icon).width
- _boxSize(this.counter).width
- this.contentPadding.horizontal
)
);
layoutLineBox(this.helperError);

}
if (this.label != null) {
centerLayout(this.label, start);
if (this.decoration.alignLabelWithHint == true) {
baselineLayout(this.label, start);
}
else {
centerLayout(this.label, start);
}
}
if (this.prefix != null) {

if (this.counter != null) {
baselineLayout(this.counter, right - this.counter.size.width);
}
}
if (this.label != null) {

}
void _handleChange() {
this.setState(() => {
});
this.setState(() => { });
}
InputDecoration _effectiveDecoration;

}
Color _getFillColor(ThemeData themeData) {
if (this.decoration.filled != true)
{
if (this.decoration.filled != true) {
return Colors.transparent;
}

child: new Text(this.decoration.hintText,
style: hintStyle,
overflow: TextOverflow.ellipsis,
textAlign: this.textAlign
textAlign: this.textAlign,
maxLines: this.decoration.hintMaxLines
)
);

errorMaxLines: this.decoration.errorMaxLines
);
Widget counter = this.decoration.counterText == null
? null
: new Text(this.decoration.counterText,
Widget counter = null;
if (this.decoration.counter != null) {
counter = this.decoration.counter;
}
else if (this.decoration.counterText != null && this.decoration.counterText != "") {
counter = new Text(this.decoration.counterText,
}
EdgeInsets decorationContentPadding = this.decoration.contentPadding;
EdgeInsets contentPadding;

icon: icon,
input: this.widget.child,
label: label,
alignLabelWithHint: this.decoration.alignLabelWithHint,
hint: hint,
prefix: prefix,
suffix: suffix,

TextStyle helperStyle = null,
string hintText = null,
TextStyle hintStyle = null,
int? hintMaxLines = null,
string errorText = null,
TextStyle errorStyle = null,
int? errorMaxLines = null,

Widget suffix = null,
string suffixText = null,
TextStyle suffixStyle = null,
Widget counter = null,
string counterText = null,
TextStyle counterStyle = null,
bool? filled = null,

InputBorder disabledBorder = null,
InputBorder enabledBorder = null,
InputBorder border = null,
bool? enabled = true
bool? enabled = true,
bool? alignLabelWithHint = null
D.assert(!(prefix != null && prefixText != null), "Declaring both prefix and prefixText is not allowed");
D.assert(!(suffix != null && suffixText != null), "Declaring both suffix and suffixText is not allowed");
D.assert(!(prefix != null && prefixText != null), "Declaring both prefix and prefixText is not supported");
D.assert(!(suffix != null && suffixText != null), "Declaring both suffix and suffixText is not supported");
this.isCollapsed = false;
this.icon = icon;
this.labelText = labelText;

this.hintText = hintText;
this.hintStyle = hintStyle;
this.hintMaxLines = hintMaxLines;
this.errorText = errorText;
this.errorStyle = errorStyle;
this.errorMaxLines = errorMaxLines;

this.prefixStyle = prefixStyle;
this.suffixIcon = suffixIcon;
this.suffixStyle = suffixStyle;
this.counter = counter;
this.counterText = counterText;
this.counterStyle = counterStyle;
this.filled = filled;

this.enabledBorder = enabledBorder;
this.border = border;
this.enabled = enabled;
this.alignLabelWithHint = alignLabelWithHint;
}
public static InputDecoration collapsed(

labelStyle: null,
helperText: null,
helperStyle: null,
hintMaxLines: null,
errorText: null,
errorStyle: null,
errorMaxLines: null,

suffixIcon: null,
suffixText: null,
suffixStyle: null,
counter: null,
counterText: null,
counterStyle: null,
errorBorder: null,

filled: filled,
fillColor: fillColor,
border: border,
enabled: enabled
enabled: enabled,
alignLabelWithHint: false
);
decoration.isCollapsed = true;
return decoration;

public readonly string hintText;
public readonly TextStyle hintStyle;
public readonly int? hintMaxLines;
public readonly string errorText;

public readonly TextStyle suffixStyle;
public readonly Widget counter;
public readonly string counterText;
public readonly TextStyle counterStyle;

public readonly InputBorder border;
public readonly bool? enabled;
public readonly bool? alignLabelWithHint;
public InputDecoration copyWith(
Widget icon = null,

TextStyle helperStyle = null,
string hintText = null,
TextStyle hintStyle = null,
int? hintMaxlines = null,
string errorText = null,
TextStyle errorStyle = null,
int? errorMaxLines = null,

Widget suffix = null,
string suffixText = null,
TextStyle suffixStyle = null,
Widget counter = null,
string counterText = null,
TextStyle counterStyle = null,
bool? filled = null,

InputBorder disabledBorder = null,
InputBorder enabledBorder = null,
InputBorder border = null,
bool? enabled = null
bool? enabled = null,
bool? alignLabelWithHint = null
) {
return new InputDecoration(
icon: icon ?? this.icon,

helperStyle: helperStyle ?? this.helperStyle,
hintText: hintText ?? this.hintText,
hintStyle: hintStyle ?? this.hintStyle,
hintMaxLines: hintMaxlines ?? this.hintMaxLines,
errorText: errorText ?? this.errorText,
errorStyle: errorStyle ?? this.errorStyle,
errorMaxLines: errorMaxLines ?? this.errorMaxLines,

suffix: suffix ?? this.suffix,
suffixText: suffixText ?? this.suffixText,
suffixStyle: suffixStyle ?? this.suffixStyle,
counter: counter ?? this.counter,
counterText: counterText ?? this.counterText,
counterStyle: counterStyle ?? this.counterStyle,
filled: filled ?? this.filled,

disabledBorder: disabledBorder ?? this.disabledBorder,
enabledBorder: enabledBorder ?? this.enabledBorder,
border: border ?? this.border,
enabled: enabled ?? this.enabled
enabled: enabled ?? this.enabled,
alignLabelWithHint: alignLabelWithHint ?? this.alignLabelWithHint
);
}

focusedErrorBorder: this.focusedErrorBorder ?? theme.focusedErrorBorder,
disabledBorder: this.disabledBorder ?? theme.disabledBorder,
enabledBorder: this.enabledBorder ?? theme.enabledBorder,
border: this.border ?? theme.border
border: this.border ?? theme.border,
alignLabelWithHint: this.alignLabelWithHint ?? theme.alignLabelWithHint
);
}

}
public bool Equals(InputDecoration other) {
return other.icon == this.icon
&& other.labelText == this.labelText
&& other.labelStyle == this.labelStyle
&& other.helperText == this.helperText
&& other.helperStyle == this.helperStyle
&& other.hintText == this.hintText
&& other.hintStyle == this.hintStyle
&& other.errorText == this.errorText
&& other.errorStyle == this.errorStyle
&& other.errorMaxLines == this.errorMaxLines
&& other.hasFloatingPlaceholder == this.hasFloatingPlaceholder
&& other.isDense == this.isDense
&& other.contentPadding == this.contentPadding
&& other.isCollapsed == this.isCollapsed
&& other.prefixIcon == this.prefixIcon
&& other.prefix == this.prefix
&& other.prefixText == this.prefixText
&& other.prefixStyle == this.prefixStyle
&& other.suffixIcon == this.suffixIcon
&& other.suffix == this.suffix
&& other.suffixText == this.suffixText
&& other.suffixStyle == this.suffixStyle
&& other.counterText == this.counterText
&& other.counterStyle == this.counterStyle
&& other.filled == this.filled
&& other.fillColor == this.fillColor
&& other.errorBorder == this.errorBorder
&& other.focusedBorder == this.focusedBorder
&& other.focusedErrorBorder == this.focusedErrorBorder
&& other.disabledBorder == this.disabledBorder
&& other.enabledBorder == this.enabledBorder
&& other.border == this.border
&& other.enabled == this.enabled;
return Equals(other.icon, this.icon)
&& Equals(other.labelText, this.labelText)
&& Equals(other.labelStyle, this.labelStyle)
&& Equals(other.helperText, this.helperText)
&& Equals(other.helperStyle, this.helperStyle)
&& Equals(other.hintText, this.hintText)
&& Equals(other.hintStyle, this.hintStyle)
&& Equals(other.hintMaxLines, this.hintMaxLines)
&& Equals(other.errorText, this.errorText)
&& Equals(other.errorStyle, this.errorStyle)
&& Equals(other.errorMaxLines, this.errorMaxLines)
&& Equals(other.hasFloatingPlaceholder, this.hasFloatingPlaceholder)
&& Equals(other.isDense, this.isDense)
&& Equals(other.contentPadding, this.contentPadding)
&& Equals(other.isCollapsed, this.isCollapsed)
&& Equals(other.prefixIcon, this.prefixIcon)
&& Equals(other.prefix, this.prefix)
&& Equals(other.prefixText, this.prefixText)
&& Equals(other.prefixStyle, this.prefixStyle)
&& Equals(other.suffixIcon, this.suffixIcon)
&& Equals(other.suffix, this.suffix)
&& Equals(other.suffixText, this.suffixText)
&& Equals(other.suffixStyle, this.suffixStyle)
&& Equals(other.counter, this.counter)
&& Equals(other.counterText, this.counterText)
&& Equals(other.counterStyle, this.counterStyle)
&& Equals(other.filled, this.filled)
&& Equals(other.fillColor, this.fillColor)
&& Equals(other.errorBorder, this.errorBorder)
&& Equals(other.focusedBorder, this.focusedBorder)
&& Equals(other.focusedErrorBorder, this.focusedErrorBorder)
&& Equals(other.disabledBorder, this.disabledBorder)
&& Equals(other.enabledBorder, this.enabledBorder)
&& Equals(other.border, this.border)
&& Equals(other.enabled, this.enabled)
&& Equals(other.alignLabelWithHint, this.alignLabelWithHint);
return this.Equals((InputDecoration) obj);
}

hashCode = (hashCode * 397) ^ this.helperStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.hintText.GetHashCode();
hashCode = (hashCode * 397) ^ this.hintStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.hintMaxLines.GetHashCode();
hashCode = (hashCode * 397) ^ this.errorText.GetHashCode();
hashCode = (hashCode * 397) ^ this.errorStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.errorMaxLines.GetHashCode();

hashCode = (hashCode * 397) ^ this.suffix.GetHashCode();
hashCode = (hashCode * 397) ^ this.suffixText.GetHashCode();
hashCode = (hashCode * 397) ^ this.suffixStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.counter.GetHashCode();
hashCode = (hashCode * 397) ^ this.counterText.GetHashCode();
hashCode = (hashCode * 397) ^ this.counterStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.filled.GetHashCode();

hashCode = (hashCode * 397) ^ this.enabledBorder.GetHashCode();
hashCode = (hashCode * 397) ^ this.border.GetHashCode();
hashCode = (hashCode * 397) ^ this.enabled.GetHashCode();
hashCode = (hashCode * 397) ^ this.alignLabelWithHint.GetHashCode();
return hashCode;
}
}

if (this.helperText != null) {
description.Add($"helperText: ${this.helperText}");
}
if (this.hintMaxLines != null) {
description.Add($"hintMaxLines: ${this.hintMaxLines}");
}
if (this.hintText != null) {

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

description.Add("enabled: false");
}
if (this.alignLabelWithHint != null) {
description.Add($"alignLabelWithHint: {this.alignLabelWithHint}");
}
return $"InputDecoration(${string.Join(", ", description)})";
}
}

InputBorder focusedErrorBorder = null,
InputBorder disabledBorder = null,
InputBorder enabledBorder = null,
InputBorder border = null
InputBorder border = null,
bool alignLabelWithHint = false
) {
D.assert(isDense != null);
D.assert(isCollapsed != null);

this.disabledBorder = disabledBorder;
this.enabledBorder = enabledBorder;
this.border = border;
this.alignLabelWithHint = alignLabelWithHint;
}
public readonly TextStyle labelStyle;

public readonly InputBorder border;
public readonly bool alignLabelWithHint;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
InputDecorationTheme defaultTheme = new InputDecorationTheme();

defaultValue: defaultTheme.errorBorder));
properties.add(new DiagnosticsProperty<InputBorder>("focusedBorder", this.focusedBorder,
defaultValue: defaultTheme.focusedErrorBorder));
properties.add(new DiagnosticsProperty<InputBorder>("focusedErrorborder", this.focusedErrorBorder,
properties.add(new DiagnosticsProperty<InputBorder>("focusedErrorBorder", this.focusedErrorBorder,
defaultValue: defaultTheme.focusedErrorBorder));
properties.add(new DiagnosticsProperty<InputBorder>("disabledBorder", this.disabledBorder,
defaultValue: defaultTheme.disabledBorder));

new DiagnosticsProperty<InputBorder>("border", this.border, defaultValue: defaultTheme.border));
properties.add(new DiagnosticsProperty<bool>("alignLabelWithHint", this.alignLabelWithHint,
defaultValue: defaultTheme.alignLabelWithHint));
}
}
}

19
Runtime/material/list_tile.cs


D.assert(isOneLine);
}
float defaultTileHeight = this._defaultTileHeight;
tileHeight = Mathf.Max(this._defaultTileHeight, titleSize.height + 2.0f * _minVerticalPadding);
tileHeight = Mathf.Max(defaultTileHeight, titleSize.height + 2.0f * _minVerticalPadding);
titleY = (tileHeight - titleSize.height) / 2.0f;
}
else {

_boxBaseline(this.subtitle, this.subtitleBaselineType ?? TextBaseline.alphabetic);
tileHeight = this._defaultTileHeight;
tileHeight = defaultTileHeight;
float titleOverlap = titleY + titleSize.height - subtitleY;
if (titleOverlap > 0.0f) {

}
}
float leadingY = (tileHeight - leadingSize.height) / 2.0f;
float trailingY = (tileHeight - trailingSize.height) / 2.0f;
float leadingY;
float trailingY;
if (tileHeight > 72.0f) {
leadingY = 16.0f;
trailingY = 16.0f;
}
else {
leadingY = Mathf.Min((tileHeight - leadingSize.height) / 2.0f, 16.0f);
trailingY = (tileHeight - trailingSize.height) / 2.0f;
}
if (hasLeading) {
_positionBox(this.leading, new Offset(0.0f, leadingY));

正在加载...
取消
保存