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

Commit 26be857

Browse files
author
Yuncong Zhang
committed
[1.5.4] Upgrade app and app_bar.
1 parent 8645bed commit 26be857

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

Runtime/material/app.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void _updateNavigator() {
133133
this._navigatorObservers.Add(this._heroController);
134134
}
135135
else {
136-
this._navigatorObservers = null;
136+
this._navigatorObservers = new List<NavigatorObserver>();
137137
}
138138
}
139139

Runtime/material/app_bar.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ public AppBar(
4747
Widget flexibleSpace = null,
4848
PreferredSizeWidget bottom = null,
4949
float? elevation = null,
50+
ShapeBorder shape = null,
5051
Color backgroundColor = null,
5152
Brightness? brightness = null,
5253
IconThemeData iconTheme = null,
54+
IconThemeData actionsIconTheme = null,
5355
TextTheme textTheme = null,
5456
bool primary = true,
5557
bool? centerTitle = null,
@@ -65,9 +67,11 @@ public AppBar(
6567
this.flexibleSpace = flexibleSpace;
6668
this.bottom = bottom;
6769
this.elevation = elevation;
70+
this.shape = shape;
6871
this.backgroundColor = backgroundColor;
6972
this.brightness = brightness;
7073
this.iconTheme = iconTheme;
74+
this.actionsIconTheme = actionsIconTheme;
7175
this.textTheme = textTheme;
7276
this.primary = primary;
7377
this.centerTitle = centerTitle;
@@ -91,12 +95,16 @@ public AppBar(
9195

9296
public readonly float? elevation;
9397

98+
public readonly ShapeBorder shape;
99+
94100
public readonly Color backgroundColor;
95101

96102
public readonly Brightness? brightness;
97103

98104
public readonly IconThemeData iconTheme;
99105

106+
public readonly IconThemeData actionsIconTheme;
107+
100108
public readonly TextTheme textTheme;
101109

102110
public readonly bool primary;
@@ -153,9 +161,12 @@ public override Widget build(BuildContext context) {
153161
bool canPop = parentRoute?.canPop ?? false;
154162
bool useCloseButton = parentRoute is PageRoute && ((PageRoute) parentRoute).fullscreenDialog;
155163

156-
IconThemeData appBarIconTheme = this.widget.iconTheme
164+
IconThemeData overallIconTheme = this.widget.iconTheme
157165
?? appBarTheme.iconTheme
158166
?? themeData.primaryIconTheme;
167+
IconThemeData actionsIconTheme = this.widget.actionsIconTheme
168+
?? appBarTheme.actionsIconTheme
169+
?? overallIconTheme;
159170
TextStyle centerStyle = this.widget.textTheme?.title
160171
?? appBarTheme.textTheme?.title
161172
?? themeData.primaryTextTheme.title;
@@ -174,8 +185,11 @@ public override Widget build(BuildContext context) {
174185
sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity));
175186
}
176187

177-
appBarIconTheme = appBarIconTheme.copyWith(
178-
opacity: opacity * (appBarIconTheme.opacity ?? 1.0f)
188+
overallIconTheme = overallIconTheme.copyWith(
189+
opacity: opacity * (overallIconTheme.opacity ?? 1.0f)
190+
);
191+
actionsIconTheme = actionsIconTheme.copyWith(
192+
opacity: opacity * (actionsIconTheme.opacity ?? 1.0f)
179193
);
180194
}
181195

@@ -223,6 +237,13 @@ public override Widget build(BuildContext context) {
223237
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
224238
}
225239

240+
if (actions != null) {
241+
actions = IconTheme.merge(
242+
data: actionsIconTheme,
243+
child: actions
244+
);
245+
}
246+
226247
Widget toolbar = new NavigationToolbar(
227248
leading: leading,
228249
middle: title,
@@ -234,7 +255,7 @@ public override Widget build(BuildContext context) {
234255
child: new CustomSingleChildLayout(
235256
layoutDelegate: new _ToolbarContainerLayout(),
236257
child: IconTheme.merge(
237-
data: appBarIconTheme,
258+
data: overallIconTheme,
238259
child: new DefaultTextStyle(
239260
style: sideStyle,
240261
child: toolbar)
@@ -299,6 +320,7 @@ public override Widget build(BuildContext context) {
299320
elevation: this.widget.elevation
300321
?? appBarTheme.elevation
301322
?? _defaultElevation,
323+
shape: this.widget.shape,
302324
child: appBar
303325
));
304326
}
@@ -379,6 +401,7 @@ public _SliverAppBarDelegate(
379401
Color backgroundColor,
380402
Brightness? brightness,
381403
IconThemeData iconTheme,
404+
IconThemeData actionsIconTheme,
382405
TextTheme textTheme,
383406
bool primary,
384407
bool? centerTitle,
@@ -402,6 +425,7 @@ FloatingHeaderSnapConfiguration snapConfiguration
402425
this.backgroundColor = backgroundColor;
403426
this.brightness = brightness;
404427
this.iconTheme = iconTheme;
428+
this.actionsIconTheme = actionsIconTheme;
405429
this.textTheme = textTheme;
406430
this.primary = primary;
407431
this.centerTitle = centerTitle;
@@ -426,6 +450,7 @@ FloatingHeaderSnapConfiguration snapConfiguration
426450
public readonly Color backgroundColor;
427451
public readonly Brightness? brightness;
428452
public readonly IconThemeData iconTheme;
453+
public readonly IconThemeData actionsIconTheme;
429454
public readonly TextTheme textTheme;
430455
public readonly bool primary;
431456
public readonly bool? centerTitle;
@@ -506,6 +531,7 @@ public override bool shouldRebuild(SliverPersistentHeaderDelegate _oldDelegate)
506531
|| this.backgroundColor != oldDelegate.backgroundColor
507532
|| this.brightness != oldDelegate.brightness
508533
|| this.iconTheme != oldDelegate.iconTheme
534+
|| this.actionsIconTheme != oldDelegate.actionsIconTheme
509535
|| this.textTheme != oldDelegate.textTheme
510536
|| this.primary != oldDelegate.primary
511537
|| this.centerTitle != oldDelegate.centerTitle
@@ -537,6 +563,7 @@ public SliverAppBar(
537563
Color backgroundColor = null,
538564
Brightness? brightness = null,
539565
IconThemeData iconTheme = null,
566+
IconThemeData actionsIconTheme = null,
540567
TextTheme textTheme = null,
541568
bool primary = true,
542569
bool? centerTitle = null,
@@ -558,6 +585,7 @@ public SliverAppBar(
558585
this.backgroundColor = backgroundColor;
559586
this.brightness = brightness;
560587
this.iconTheme = iconTheme;
588+
this.actionsIconTheme = actionsIconTheme;
561589
this.textTheme = textTheme;
562590
this.primary = primary;
563591
this.centerTitle = centerTitle;
@@ -590,6 +618,8 @@ public SliverAppBar(
590618
public readonly Brightness? brightness;
591619

592620
public readonly IconThemeData iconTheme;
621+
622+
public readonly IconThemeData actionsIconTheme;
593623

594624
public readonly TextTheme textTheme;
595625

@@ -666,6 +696,7 @@ public override Widget build(BuildContext context) {
666696
backgroundColor: this.widget.backgroundColor,
667697
brightness: this.widget.brightness,
668698
iconTheme: this.widget.iconTheme,
699+
actionsIconTheme: this.widget.actionsIconTheme,
669700
textTheme: this.widget.textTheme,
670701
primary: this.widget.primary,
671702
centerTitle: this.widget.centerTitle,

Runtime/material/app_bar_theme.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ public AppBarTheme(
1010
Color color = null,
1111
float? elevation = null,
1212
IconThemeData iconTheme = null,
13+
IconThemeData actionsIconTheme = null,
1314
TextTheme textTheme = null
1415
) {
1516
this.brightness = brightness;
1617
this.color = color;
1718
this.elevation = elevation;
1819
this.iconTheme = iconTheme;
20+
this.actionsIconTheme = actionsIconTheme;
1921
this.textTheme = textTheme;
2022
}
2123

@@ -27,20 +29,24 @@ public AppBarTheme(
2729

2830
public readonly IconThemeData iconTheme;
2931

32+
public readonly IconThemeData actionsIconTheme;
33+
3034
public readonly TextTheme textTheme;
3135

3236
AppBarTheme copyWith(
3337
Brightness? brightness = null,
3438
Color color = null,
3539
float? elevation = null,
3640
IconThemeData iconTheme = null,
41+
IconThemeData actionsIconTheme = null,
3742
TextTheme textTheme = null
3843
) {
3944
return new AppBarTheme(
4045
brightness: brightness ?? this.brightness,
4146
color: color ?? this.color,
4247
elevation: elevation ?? this.elevation,
4348
iconTheme: iconTheme ?? this.iconTheme,
49+
actionsIconTheme: actionsIconTheme ?? this.actionsIconTheme,
4450
textTheme: textTheme ?? this.textTheme
4551
);
4652
}
@@ -55,6 +61,7 @@ public static AppBarTheme lerp(AppBarTheme a, AppBarTheme b, float t) {
5561
color: Color.lerp(a?.color, b?.color, t),
5662
elevation: MathUtils.lerpFloat(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),
5763
iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
64+
actionsIconTheme: IconThemeData.lerp(a?.actionsIconTheme, b?.actionsIconTheme, t),
5865
textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t)
5966
);
6067
}
@@ -64,6 +71,7 @@ public override int GetHashCode() {
6471
hashCode = (hashCode * 397) ^ this.color?.GetHashCode() ?? 0;
6572
hashCode = (hashCode * 397) ^ this.elevation?.GetHashCode() ?? 0;
6673
hashCode = (hashCode * 397) ^ this.iconTheme?.GetHashCode() ?? 0;
74+
hashCode = (hashCode * 397) ^ this.actionsIconTheme?.GetHashCode() ?? 0;
6775
hashCode = (hashCode * 397) ^ this.textTheme?.GetHashCode() ?? 0;
6876
return hashCode;
6977
}
@@ -97,6 +105,7 @@ public bool Equals(AppBarTheme other) {
97105
&& other.color == this.color
98106
&& other.elevation == this.elevation
99107
&& other.iconTheme == this.iconTheme
108+
&& other.actionsIconTheme == this.actionsIconTheme
100109
&& other.textTheme == this.textTheme;
101110
}
102111

@@ -106,6 +115,7 @@ public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
106115
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
107116
properties.add(new DiagnosticsProperty<float?>("elevation", this.elevation, defaultValue: null));
108117
properties.add(new DiagnosticsProperty<IconThemeData>("iconTheme", this.iconTheme, defaultValue: null));
118+
properties.add(new DiagnosticsProperty<IconThemeData>("actionsIconTheme", this.actionsIconTheme, defaultValue: null));
109119
properties.add(new DiagnosticsProperty<TextTheme>("textTheme", this.textTheme, defaultValue: null));
110120
}
111121
}

0 commit comments

Comments
 (0)