浏览代码

Update button and card.

/main
Yuncong Zhang 6 年前
当前提交
1f09df0c
共有 7 个文件被更改,包括 156 次插入18 次删除
  1. 1
      Runtime/material/bottom_sheet.cs
  2. 37
      Runtime/material/button.cs
  3. 2
      Runtime/material/button_theme.cs
  4. 26
      Runtime/material/card.cs
  5. 15
      Runtime/material/theme_data.cs
  6. 90
      Runtime/material/card_theme.cs
  7. 3
      Runtime/material/card_theme.cs.meta

1
Runtime/material/bottom_sheet.cs


) : base(key: key) {
D.assert(onClosing != null);
D.assert(builder != null);
D.assert(elevation >= 0.0f);
this.animationController = animationController;
this.enableDrag = enableDrag;
this.elevation = elevation;

37
Runtime/material/button.cs


Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget child = null) : base(key: key) {
D.assert(elevation >= 0.0);
D.assert(highlightElevation >= 0.0);
D.assert(disabledElevation >= 0.0);
MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
shape = shape ?? new RoundedRectangleBorder();
padding = padding ?? EdgeInsets.zero;

bool _highlight = false;
void _handleHighlightChanged(bool value) {
this.setState(() => {
this._highlight = value;
if (this._highlight != value) {
this.setState(() => {
this._highlight = value;
if (this.widget.onHighlightChanged != null) {
this.widget.onHighlightChanged(value);
}
});
}
}
public override void didUpdateWidget(StatefulWidget _oldWidget) {
RawMaterialButton oldWidget = _oldWidget as RawMaterialButton;
base.didUpdateWidget(oldWidget);
if (this._highlight && !this.widget.enabled) {
this._highlight = false;
this.widget.onHighlightChanged(value);
this.widget.onHighlightChanged(false);
});
}
}
public override Widget build(BuildContext context) {

onHighlightChanged: this._handleHighlightChanged,
splashColor: this.widget.splashColor,
highlightColor: this.widget.highlightColor,
onTap: this.widget.onPressed == null ? (GestureTapCallback) null : () => {
if (this.widget.onPressed != null) {
this.widget.onPressed();
}
},
onTap: this.widget.onPressed == null
? (GestureTapCallback) null
: () => {
if (this.widget.onPressed != null) {
this.widget.onPressed();
}
},
customBorder: this.widget.shape,
child: IconTheme.merge(
data: new IconThemeData(color: this.widget.textStyle?.color),

2
Runtime/material/button_theme.cs


}
if (button is OutlineButton) {
return 2.0f;
return 0.0f;
}
return 8.0f;
}

26
Runtime/material/card.cs


Color color = null,
float? elevation = null,
ShapeBorder shape = null,
bool borderOnForeground = true,
Clip clipBehavior = Clip.none,
Clip? clipBehavior = null,
D.assert(elevation == null || elevation >= 0.0f);
this.margin = margin ?? EdgeInsets.all(4.0f);
this.borderOnForeground = borderOnForeground;
this.margin = margin;
this.clipBehavior = clipBehavior;
this.child = child;
}

public readonly ShapeBorder shape;
public readonly Clip clipBehavior;
public readonly bool borderOnForeground;
public readonly Clip? clipBehavior;
const double _defaultElevation = 1.0;
const Clip _defaultClipBehavior = Clip.none;
CardTheme cardTheme = CardTheme.of(context);
margin: this.margin ?? EdgeInsets.all(4.0f),
margin: this.margin ?? cardTheme.margin ?? EdgeInsets.all(4.0f),
color: this.color ?? Theme.of(context).cardColor,
elevation: this.elevation ?? 1.0f,
shape: this.shape ?? new RoundedRectangleBorder(
color: this.color ?? cardTheme.color ?? Theme.of(context).cardColor,
elevation: this.elevation ?? cardTheme.elevation ?? 1.0f,
shape: this.shape ?? cardTheme.shape ?? new RoundedRectangleBorder(
clipBehavior: this.clipBehavior,
clipBehavior: this.clipBehavior ?? cardTheme.clipBehavior ?? _defaultClipBehavior,
child: this.child)
);
}

15
Runtime/material/theme_data.cs


IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
TabBarTheme tabBarTheme = null,
CardTheme cardTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,

: ThemeDataUtils._kLightThemeSplashColor);
tabBarTheme = tabBarTheme ?? new TabBarTheme();
cardTheme = cardTheme ?? new CardTheme();
dialogTheme = dialogTheme ?? new DialogTheme();
D.assert(brightness != null);

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

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

IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
TabBarTheme tabBarTheme = null,
CardTheme cardTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,

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

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

public readonly IconThemeData accentIconTheme;
public readonly TabBarTheme tabBarTheme;
public readonly CardTheme cardTheme;
public readonly RuntimePlatform platform;

IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
TabBarTheme tabBarTheme = null,
CardTheme cardTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,

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

primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
tabBarTheme: TabBarTheme.lerp(a.tabBarTheme, b.tabBarTheme, t),
cardTheme: CardTheme.lerp(a.cardTheme, b.cardTheme, t),
platform: t < 0.5 ? a.platform : b.platform,
materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
pageTransitionsTheme: t < 0.5 ? a.pageTransitionsTheme : b.pageTransitionsTheme,

other.primaryIconTheme == this.primaryIconTheme &&
other.accentIconTheme == this.accentIconTheme &&
other.tabBarTheme == this.tabBarTheme &&
other.cardTheme == this.cardTheme &&
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.cardTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.platform.GetHashCode();
hashCode = (hashCode * 397) ^ this.materialTapTargetSize.GetHashCode();
hashCode = (hashCode * 397) ^ this.pageTransitionsTheme.GetHashCode();

properties.add(new DiagnosticsProperty<IconThemeData>("primaryIconTheme", this.primaryIconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("accentIconTheme", this.accentIconTheme));
properties.add(new DiagnosticsProperty<TabBarTheme>("tabBarTheme", this.tabBarTheme));
properties.add(new DiagnosticsProperty<CardTheme>("cardTheme", this.cardTheme));
properties.add(
new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this.materialTapTargetSize));
properties.add(

90
Runtime/material/card_theme.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class CardTheme : Diagnosticable {
public CardTheme(
Clip? clipBehavior = null,
Color color = null,
float? elevation = null,
EdgeInsets margin = null,
ShapeBorder shape = null
) {
D.assert(elevation == null || elevation >= 0.0f);
this.clipBehavior = clipBehavior;
this.color = color;
this.elevation = elevation;
this.margin = margin;
this.shape = shape;
}
public readonly Clip? clipBehavior;
public readonly Color color;
public readonly float? elevation;
public readonly EdgeInsets margin;
public readonly ShapeBorder shape;
CardTheme copyWith(
Clip? clipBehavior = null,
Color color = null,
float? elevation = null,
EdgeInsets margin = null,
ShapeBorder shape = null
) {
return new CardTheme(
clipBehavior: this.clipBehavior ?? this.clipBehavior,
color: color ?? this.color,
elevation: this.elevation ?? this.elevation,
margin: margin ?? this.margin,
shape: shape ?? this.shape
);
}
public static CardTheme of(BuildContext context) {
return Theme.of(context).cardTheme;
}
public static CardTheme lerp(CardTheme a, CardTheme b, float t) {
D.assert(t != null);
return new CardTheme(
clipBehavior: t < 0.5f ? a?.clipBehavior : b?.clipBehavior,
color: Color.lerp(a?.color, b?.color, t),
elevation: MathUtils.lerpFloat(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),
margin: EdgeInsets.lerp(a?.margin, b?.margin, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
);
}
public override int GetHashCode() {
var hashCode = this.clipBehavior?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ this.color?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ this.elevation?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ this.margin?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ this.shape?.GetHashCode() ?? 0;
return hashCode;
}
public bool Equals(CardTheme other) {
return other.clipBehavior == this.clipBehavior
&& other.color == this.color
&& other.elevation == this.elevation
&& other.margin == this.margin
&& other.shape == this.shape;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Clip?>("clipBehavior", this.clipBehavior, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("elevation", this.elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin", this.margin, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null));
}
}
}

3
Runtime/material/card_theme.cs.meta


fileFormatVersion: 2
guid: d74c4f94f0994a3880425c80ec3d9ba3
timeCreated: 1556187816
正在加载...
取消
保存