Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 00c951f

Browse files
author
Yuncong Zhang
committed
[1.5.4] Upgrade chip and chip theme.
1 parent 4bf9ea7 commit 00c951f

File tree

4 files changed

+126
-8
lines changed

4 files changed

+126
-8
lines changed

Runtime/material/button_theme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public Color getFillColor(MaterialButton button) {
279279
return fillColor;
280280
}
281281

282-
if (button is FlatButton || button is OutlineButton) {
282+
if (button is FlatButton || button is OutlineButton || button.GetType() == typeof(MaterialButton)) {
283283
return null;
284284
}
285285

Runtime/material/chip.cs

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public interface ChipAttributes {
5252
MaterialTapTargetSize? materialTapTargetSize { get; }
5353

5454
float? elevation { get; }
55+
56+
Color shadowColor { get; }
5557
}
5658

5759
public interface DeletableChipAttributes {
@@ -76,6 +78,8 @@ public interface SelectableChipAttributes {
7678
string tooltip { get; }
7779

7880
ShapeBorder avatarBorder { get; }
81+
82+
Color selectedShadowColor { get; }
7983
}
8084

8185
public interface DisabledChipAttributes {
@@ -108,7 +112,8 @@ public Chip(
108112
Color backgroundColor = null,
109113
EdgeInsets padding = null,
110114
MaterialTapTargetSize? materialTapTargetSize = null,
111-
float? elevation = null
115+
float? elevation = null,
116+
Color shadowColor = null
112117
) : base(key: key) {
113118
D.assert(label != null);
114119
D.assert(elevation == null || elevation >= 0.0f);
@@ -126,6 +131,7 @@ public Chip(
126131
this._padding = padding;
127132
this._materialTapTargetSize = materialTapTargetSize;
128133
this._elevation = elevation;
134+
this._shadowColor = shadowColor;
129135
}
130136

131137
public Widget avatar {
@@ -212,6 +218,12 @@ public float? elevation {
212218

213219
float? _elevation;
214220

221+
public Color shadowColor {
222+
get { return this._shadowColor; }
223+
}
224+
225+
Color _shadowColor;
226+
215227
public override Widget build(BuildContext context) {
216228
D.assert(MaterialD.debugCheckHasMaterial(context));
217229
return new RawChip(
@@ -230,6 +242,7 @@ public override Widget build(BuildContext context) {
230242
padding: this.padding,
231243
materialTapTargetSize: this.materialTapTargetSize,
232244
elevation: this.elevation,
245+
shadowColor: this.shadowColor,
233246
isEnabled: true
234247
);
235248
}
@@ -265,6 +278,7 @@ public InputChip(
265278
EdgeInsets padding = null,
266279
MaterialTapTargetSize? materialTapTargetSize = null,
267280
float? elevation = null,
281+
Color shadowColor = null,
268282
Color selectedShadowColor = null,
269283
ShapeBorder avatarBorder = null
270284
) : base(key: key) {
@@ -294,6 +308,8 @@ public InputChip(
294308
this._padding = padding;
295309
this._materialTapTargetSize = materialTapTargetSize;
296310
this._elevation = elevation;
311+
this._shadowColor = shadowColor;
312+
this._selectedShadowColor = selectedShadowColor;
297313
}
298314

299315
public Widget avatar {
@@ -428,6 +444,18 @@ public float? elevation {
428444

429445
float? _elevation;
430446

447+
public Color shadowColor {
448+
get { return this._shadowColor; }
449+
}
450+
451+
Color _shadowColor;
452+
453+
public Color selectedShadowColor {
454+
get { return this._selectedShadowColor; }
455+
}
456+
457+
Color _selectedShadowColor;
458+
431459
public ShapeBorder avatarBorder {
432460
get { return this._avatarBorder; }
433461
}
@@ -459,6 +487,8 @@ public override Widget build(BuildContext context) {
459487
padding: this.padding,
460488
materialTapTargetSize: this.materialTapTargetSize,
461489
elevation: this.elevation,
490+
shadowColor: this.shadowColor,
491+
selectedShadowColor: this.selectedShadowColor,
462492
isEnabled: this.isEnabled == true &&
463493
(this.onSelected != null || this.onDeleted != null || this.onPressed != null),
464494
avatarBorder: this.avatarBorder
@@ -488,6 +518,8 @@ public ChoiceChip(
488518
EdgeInsets padding = null,
489519
MaterialTapTargetSize? materialTapTargetSize = null,
490520
float? elevation = null,
521+
Color shadowColor = null,
522+
Color selectedShadowColor = null,
491523
ShapeBorder avatarBorder = null
492524
) : base(key: key) {
493525
D.assert(selected != null);
@@ -511,6 +543,8 @@ public ChoiceChip(
511543
this._padding = padding;
512544
this._materialTapTargetSize = materialTapTargetSize;
513545
this._elevation = elevation;
546+
this._shadowColor = shadowColor;
547+
this._selectedShadowColor = selectedShadowColor;
514548
}
515549

516550
public Widget avatar {
@@ -609,6 +643,18 @@ public float? elevation {
609643

610644
float? _elevation;
611645

646+
public Color shadowColor {
647+
get { return this._shadowColor; }
648+
}
649+
650+
Color _shadowColor;
651+
652+
public Color selectedShadowColor {
653+
get { return this._selectedShadowColor; }
654+
}
655+
656+
Color _selectedShadowColor;
657+
612658
public ShapeBorder avatarBorder {
613659
get { return this._avatarBorder; }
614660
}
@@ -642,6 +688,8 @@ public override Widget build(BuildContext context) {
642688
isEnabled: this.isEnabled,
643689
materialTapTargetSize: this.materialTapTargetSize,
644690
elevation: this.elevation,
691+
shadowColor: this.shadowColor,
692+
selectedShadowColor: this.selectedShadowColor,
645693
avatarBorder: this.avatarBorder
646694
);
647695
}
@@ -669,6 +717,8 @@ public FilterChip(
669717
EdgeInsets padding = null,
670718
MaterialTapTargetSize? materialTapTargetSize = null,
671719
float? elevation = null,
720+
Color shadowColor = null,
721+
Color selectedShadowColor = null,
672722
ShapeBorder avatarBorder = null
673723
) : base(key: key) {
674724
D.assert(label != null);
@@ -691,6 +741,8 @@ public FilterChip(
691741
this._padding = padding;
692742
this._materialTapTargetSize = materialTapTargetSize;
693743
this._elevation = elevation;
744+
this._shadowColor = shadowColor;
745+
this._selectedShadowColor = selectedShadowColor;
694746
}
695747

696748
public Widget avatar {
@@ -789,6 +841,18 @@ public float? elevation {
789841

790842
float? _elevation;
791843

844+
public Color shadowColor {
845+
get { return this._shadowColor; }
846+
}
847+
848+
Color _shadowColor;
849+
850+
public Color selectedShadowColor {
851+
get { return this._selectedShadowColor; }
852+
}
853+
854+
Color _selectedShadowColor;
855+
792856
public ShapeBorder avatarBorder {
793857
get { return this._avatarBorder; }
794858
}
@@ -819,6 +883,8 @@ public override Widget build(BuildContext context) {
819883
isEnabled: this.isEnabled,
820884
materialTapTargetSize: this.materialTapTargetSize,
821885
elevation: this.elevation,
886+
shadowColor: this.shadowColor,
887+
selectedShadowColor: this.selectedShadowColor,
822888
avatarBorder: this.avatarBorder
823889
);
824890
}
@@ -839,7 +905,8 @@ public ActionChip(
839905
Color backgroundColor = null,
840906
EdgeInsets padding = null,
841907
MaterialTapTargetSize? materialTapTargetSize = null,
842-
float? elevation = null
908+
float? elevation = null,
909+
Color shadowColor = null
843910
) : base(key: key) {
844911
D.assert(label != null);
845912
D.assert(
@@ -862,6 +929,7 @@ public ActionChip(
862929
this._padding = padding;
863930
this._materialTapTargetSize = materialTapTargetSize;
864931
this._elevation = elevation;
932+
this._shadowColor = shadowColor;
865933
}
866934

867935

@@ -943,6 +1011,12 @@ public float? elevation {
9431011

9441012
float? _elevation;
9451013

1014+
public Color shadowColor {
1015+
get { return this._shadowColor; }
1016+
}
1017+
1018+
Color _shadowColor;
1019+
9461020
public override Widget build(BuildContext context) {
9471021
D.assert(MaterialD.debugCheckHasMaterial(context));
9481022
return new RawChip(
@@ -959,7 +1033,8 @@ public override Widget build(BuildContext context) {
9591033
labelPadding: this.labelPadding,
9601034
isEnabled: true,
9611035
materialTapTargetSize: this.materialTapTargetSize,
962-
elevation: this.elevation
1036+
elevation: this.elevation,
1037+
shadowColor: this._shadowColor
9631038
);
9641039
}
9651040
}
@@ -996,6 +1071,8 @@ public RawChip(
9961071
Color backgroundColor = null,
9971072
MaterialTapTargetSize? materialTapTargetSize = null,
9981073
float? elevation = null,
1074+
Color shadowColor = null,
1075+
Color selectedShadowColor = null,
9991076
ShapeBorder avatarBorder = null
10001077
) : base(key: key) {
10011078
D.assert(label != null);
@@ -1028,6 +1105,8 @@ public RawChip(
10281105
this._backgroundColor = backgroundColor;
10291106
this._materialTapTargetSize = materialTapTargetSize;
10301107
this._elevation = elevation;
1108+
this._shadowColor = shadowColor;
1109+
this._selectedShadowColor = selectedShadowColor;
10311110
}
10321111

10331112

@@ -1163,6 +1242,18 @@ public float? elevation {
11631242

11641243
float? _elevation;
11651244

1245+
public Color shadowColor {
1246+
get { return this._shadowColor; }
1247+
}
1248+
1249+
Color _shadowColor;
1250+
1251+
public Color selectedShadowColor {
1252+
get { return this._selectedShadowColor; }
1253+
}
1254+
1255+
Color _selectedShadowColor;
1256+
11661257
public ShapeBorder avatarBorder {
11671258
get { return this._avatarBorder; }
11681259
}
@@ -1426,16 +1517,21 @@ public override Widget build(BuildContext context) {
14261517
ShapeBorder shape = this.widget.shape ?? chipTheme.shape;
14271518
float elevation = this.widget.elevation ?? (chipTheme.elevation ?? _defaultElevation);
14281519
float pressElevation = this.widget.pressElevation ?? (chipTheme.pressElevation ?? _defaultPressElevation);
1520+
Color shadowColor = this.widget.shadowColor ?? chipTheme.shadowColor ?? _defaultShadowColor;
1521+
Color selectedShadowColor = this.widget.selectedShadowColor ?? chipTheme.selectedShadowColor ?? _defaultShadowColor;
1522+
bool selected = this.widget.selected ?? false;
14291523

14301524
Widget result = new Material(
14311525
elevation: this.isTapping ? pressElevation : elevation,
1526+
shadowColor: selected ? selectedShadowColor : shadowColor,
14321527
animationDuration: pressedAnimationDuration,
14331528
shape: shape,
14341529
clipBehavior: this.widget.clipBehavior,
1435-
child: new InkResponse(
1530+
child: new InkWell(
14361531
onTap: this.canTap ? this._handleTap : (GestureTapCallback) null,
14371532
onTapDown: this.canTap ? this._handleTapDown : (GestureTapDownCallback) null,
1438-
onTapCancel: this.canTap ? this._handleTapCancel : (GestureTapCallback) null,
1533+
onTapCancel: this.canTap ? this._handleTapCancel : (GestureTapCancelCallback) null,
1534+
customBorder: shape,
14391535
child: new AnimatedBuilder(
14401536
animation: ListenableUtils.merge(new List<Listenable>
14411537
{this.selectController, this.enableController}),

Runtime/material/chip_theme.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public ChipThemeData(
3737
Color disabledColor = null,
3838
Color selectedColor = null,
3939
Color secondarySelectedColor = null,
40+
Color shadowColor = null,
41+
Color selectedShadowColor = null,
4042
EdgeInsets labelPadding = null,
4143
EdgeInsets padding = null,
4244
ShapeBorder shape = null,
@@ -61,6 +63,8 @@ public ChipThemeData(
6163
this.disabledColor = disabledColor;
6264
this.selectedColor = selectedColor;
6365
this.secondarySelectedColor = secondarySelectedColor;
66+
this.shadowColor = shadowColor;
67+
this.selectedShadowColor = selectedShadowColor;
6468
this.labelPadding = labelPadding;
6569
this.padding = padding;
6670
this.shape = shape;
@@ -133,6 +137,10 @@ public static ChipThemeData fromDefaults(
133137

134138
public readonly Color secondarySelectedColor;
135139

140+
public readonly Color shadowColor;
141+
142+
public readonly Color selectedShadowColor;
143+
136144
public readonly EdgeInsets labelPadding;
137145

138146
public readonly EdgeInsets padding;
@@ -155,6 +163,8 @@ public ChipThemeData copyWith(
155163
Color disabledColor = null,
156164
Color selectedColor = null,
157165
Color secondarySelectedColor = null,
166+
Color shadowColor = null,
167+
Color selectedShadowColor = null,
158168
EdgeInsets labelPadding = null,
159169
EdgeInsets padding = null,
160170
ShapeBorder shape = null,
@@ -170,6 +180,8 @@ public ChipThemeData copyWith(
170180
disabledColor: disabledColor ?? this.disabledColor,
171181
selectedColor: selectedColor ?? this.selectedColor,
172182
secondarySelectedColor: secondarySelectedColor ?? this.secondarySelectedColor,
183+
shadowColor: shadowColor ?? this.shadowColor,
184+
selectedShadowColor: selectedShadowColor ?? this.selectedShadowColor,
173185
labelPadding: labelPadding ?? this.labelPadding,
174186
padding: padding ?? this.padding,
175187
shape: shape ?? this.shape,
@@ -192,6 +204,8 @@ public static ChipThemeData lerp(ChipThemeData a, ChipThemeData b, float t) {
192204
disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t),
193205
selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t),
194206
secondarySelectedColor: Color.lerp(a?.secondarySelectedColor, b?.secondarySelectedColor, t),
207+
shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
208+
selectedShadowColor: Color.lerp(a?.selectedShadowColor, b?.selectedShadowColor, t),
195209
labelPadding: EdgeInsets.lerp(a?.labelPadding, b?.labelPadding, t),
196210
padding: EdgeInsets.lerp(a?.padding, b?.padding, t),
197211
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
@@ -209,6 +223,8 @@ public override int GetHashCode() {
209223
hashCode = (hashCode * 397) ^ this.disabledColor.GetHashCode();
210224
hashCode = (hashCode * 397) ^ this.selectedColor.GetHashCode();
211225
hashCode = (hashCode * 397) ^ this.secondarySelectedColor.GetHashCode();
226+
hashCode = (hashCode * 397) ^ this.shadowColor.GetHashCode();
227+
hashCode = (hashCode * 397) ^ this.selectedShadowColor.GetHashCode();
212228
hashCode = (hashCode * 397) ^ this.labelPadding.GetHashCode();
213229
hashCode = (hashCode * 397) ^ this.padding.GetHashCode();
214230
hashCode = (hashCode * 397) ^ this.shape.GetHashCode();
@@ -226,6 +242,8 @@ public bool Equals(ChipThemeData other) {
226242
&& other.disabledColor == this.disabledColor
227243
&& other.selectedColor == this.selectedColor
228244
&& other.secondarySelectedColor == this.secondarySelectedColor
245+
&& other.shadowColor == this.shadowColor
246+
&& other.selectedShadowColor == this.selectedShadowColor
229247
&& other.labelPadding == this.labelPadding
230248
&& other.padding == this.padding
231249
&& other.shape == this.shape
@@ -278,6 +296,10 @@ public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
278296
defaultValue: defaultData.selectedColor));
279297
properties.add(new DiagnosticsProperty<Color>("secondarySelectedColor", this.secondarySelectedColor,
280298
defaultValue: defaultData.secondarySelectedColor));
299+
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor,
300+
defaultValue: defaultData.shadowColor));
301+
properties.add(new DiagnosticsProperty<Color>("selectedShadowColor", this.selectedShadowColor,
302+
defaultValue: defaultData.selectedShadowColor));
281303
properties.add(new DiagnosticsProperty<EdgeInsets>("labelPadding", this.labelPadding,
282304
defaultValue: defaultData.labelPadding));
283305
properties.add(

0 commit comments

Comments
 (0)