浏览代码

Fix chip.

/main
Yuncong Zhang 6 年前
当前提交
b6e3b5d4
共有 4 个文件被更改,包括 31 次插入29 次删除
  1. 37
      Runtime/material/chip.cs
  2. 4
      Runtime/material/chip_theme.cs
  3. 9
      Runtime/material/theme_data.cs
  4. 10
      Samples/UIWidgetsGallery/demo/material/chip_demo.cs

37
Runtime/material/chip.cs


float? elevation = null,
ShapeBorder avatarBorder = null
) : base(key: key) {
D.assert(selected != null);
D.assert(onSelected != null);
D.assert(clipBehavior != null);
D.assert(pressElevation == null || pressElevation >= 0.0f);
D.assert(elevation == null || elevation >= 0.0f);
this._avatarBorder = avatarBorder ?? new CircleBorder();

) : base(key: key) {
D.assert(label != null);
D.assert(isEnabled != null);
D.assert(clipBehavior != null);
D.assert(pressElevation == null || pressElevation >= 0.0f);
D.assert(elevation == null || elevation >= 0.0f);
deleteIcon = deleteIcon ?? ChipUtils._kDefaultDeleteIcon;

ChipThemeData chipTheme = ChipTheme.of(context);
TextDirection textDirection = Directionality.of(context);
ShapeBorder shape = this.widget.shape ?? chipTheme.shape;
float elevation = this.widget.elevation ?? chipTheme.elevation ?? _defaultElevation;
float pressElevation = this.widget.pressElevation ?? chipTheme.pressElevation ?? _defaultPressElevation;
float elevation = this.widget.elevation ?? (chipTheme.elevation ?? _defaultElevation);
float pressElevation = this.widget.pressElevation ?? (chipTheme.pressElevation ?? _defaultPressElevation);
Widget result = new Material(
elevation: this.isTapping ? pressElevation : elevation,

)
);
BoxConstraints constraints;
switch (this.widget.materialTapTargetSize) {
switch (this.widget.materialTapTargetSize ?? theme.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
constraints = new BoxConstraints(minHeight: 48.0f);
break;

}
void _mountChild(Widget widget, _ChipSlot slot) {
Element oldChild = this.slotToChild[slot];
Element oldChild = this.slotToChild.getOrDefault(slot);
Element newChild = this.updateChild(oldChild, widget, slot);
if (oldChild != null) {
this.slotToChild.Remove(slot);

}
}
protected override void insertChildRenderObject(RenderObject child, dynamic slotValue) {
protected override void insertChildRenderObject(RenderObject child, object slotValue) {
_ChipSlot slot = slotValue;
_ChipSlot slot = (_ChipSlot) slotValue;
this._updateRenderObject(child, slot);
D.assert(this.renderObject.childToSlot.ContainsKey((RenderBox) child));
D.assert(this.renderObject.slotToChild.ContainsKey(slot));

D.assert(!this.renderObject.slotToChild.ContainsKey((_ChipSlot) this.slot));
}
protected override void moveChildRenderObject(RenderObject child, dynamic slotValue) {
protected override void moveChildRenderObject(RenderObject child, object slotValue) {
D.assert(false, "not reachable");
}
}

}
public static bool operator ==(_ChipRenderTheme left, _ChipRenderTheme right) {
return left.Equals(right);
return Equals(left, right);
return !left.Equals(right);
return !Equals(left, right);
}
public override int GetHashCode() {

) {
D.assert(theme != null);
this._theme = theme;
this.checkmarkAnimation.addListener(this.markNeedsPaint);
checkmarkAnimation.addListener(this.markNeedsPaint);
this.deleteDrawerAnimation.addListener(this.markNeedsLayout);
deleteDrawerAnimation.addListener(this.markNeedsLayout);
enableAnimation.addListener(this.markNeedsPaint);
this.value = value;
this.isEnabled = isEnabled;

const float left = 0.0f;
float right = overallSize.width;
return new Offset(x - boxSize.width, (contentSize - boxSize.height) / 2.0f);
return new Offset(x, (contentSize - boxSize.height) / 2.0f);
}
Offset avatarOffset = Offset.zero;

);
this.size = this.constraints.constrain(paddedSize);
D.assert(this.size.height == this.constraints.constrainHeight(paddedSize.height),
"Constrained height ${size.height} doesn't match expected height " +
"${constraints.constrainWidth(paddedSize.height)}");
$"Constrained height {this.size.height} doesn't match expected height " +
$"{this.constraints.constrainWidth(paddedSize.height)}");
"Constrained width ${size.width} doesn't match expected width " +
"${constraints.constrainWidth(paddedSize.width)}");
$"Constrained width {this.size.width} doesn't match expected width " +
$"{this.constraints.constrainWidth(paddedSize.width)}");
}
static ColorTween selectionScrimTween = new ColorTween(

4
Runtime/material/chip_theme.cs


}
public static bool operator ==(ChipThemeData left, ChipThemeData right) {
return left.Equals(right);
return Equals(left, right);
return !left.Equals(right);
return !Equals(left, right);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

9
Runtime/material/theme_data.cs


D.assert(typography != null);
D.assert(buttonColor != null);
D.assert(tabBarTheme != null);
D.assert(chipTheme != null);
D.assert(dialogTheme != null);
this.brightness = brightness ?? Brightness.light;

this.primaryIconTheme = primaryIconTheme;
this.accentIconTheme = accentIconTheme;
this.tabBarTheme = tabBarTheme;
this.chipTheme = chipTheme;
this.platform = platform.Value;
this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
this.pageTransitionsTheme = pageTransitionsTheme;

D.assert(typography != null);
D.assert(buttonColor != null);
D.assert(tabBarTheme != null);
D.assert(chipTheme != null);
D.assert(dialogTheme != null);
return new ThemeData(

primaryIconTheme: primaryIconTheme,
accentIconTheme: accentIconTheme,
tabBarTheme: tabBarTheme,
chipTheme: chipTheme,
platform: platform,
materialTapTargetSize: materialTapTargetSize,
pageTransitionsTheme: pageTransitionsTheme,

IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
TabBarTheme tabBarTheme = null,
ChipThemeData chimpTheme = null,
ChipThemeData chipTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,

primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
accentIconTheme: accentIconTheme ?? this.accentIconTheme,
tabBarTheme: tabBarTheme ?? this.tabBarTheme,
chipTheme: chipTheme ?? this.chipTheme,
platform: platform ?? this.platform,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,

other.primaryIconTheme == this.primaryIconTheme &&
other.accentIconTheme == this.accentIconTheme &&
other.tabBarTheme == this.tabBarTheme &&
other.chipTheme == this.chipTheme &&
other.platform == this.platform &&
other.materialTapTargetSize == this.materialTapTargetSize &&
other.pageTransitionsTheme == this.pageTransitionsTheme &&

hashCode = (hashCode * 397) ^ this.primaryIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.tabBarTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.chipTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.platform.GetHashCode();
hashCode = (hashCode * 397) ^ this.materialTapTargetSize.GetHashCode();
hashCode = (hashCode * 397) ^ this.pageTransitionsTheme.GetHashCode();

10
Samples/UIWidgetsGallery/demo/material/chip_demo.cs


};
public static readonly Dictionary<string, string> _avatars = new Dictionary<string, string> {
{"hammer", "people/square/ali.png"},
{"chisel", "people/square/sandra.png"},
{"fryer", "people/square/trevor.png"},
{"fabricator", "people/square/stella.png"},
{"customer", "people/square/peter.png"}
{"hammer", "people/square/ali"},
{"chisel", "people/square/sandra"},
{"fryer", "people/square/trevor"},
{"fabricator", "people/square/stella"},
{"customer", "people/square/peter"}
};
public static readonly Dictionary<string, HashSet<string>> _toolActions =

正在加载...
取消
保存