Unverified Commit e82454fb authored by MH Johnson's avatar MH Johnson Committed by GitHub

[Material] Added BottomNavigationBarTheme (#54714)

parent f050ee67
...@@ -28,6 +28,7 @@ export 'src/material/banner_theme.dart'; ...@@ -28,6 +28,7 @@ export 'src/material/banner_theme.dart';
export 'src/material/bottom_app_bar.dart'; export 'src/material/bottom_app_bar.dart';
export 'src/material/bottom_app_bar_theme.dart'; export 'src/material/bottom_app_bar_theme.dart';
export 'src/material/bottom_navigation_bar.dart'; export 'src/material/bottom_navigation_bar.dart';
export 'src/material/bottom_navigation_bar_theme.dart';
export 'src/material/bottom_sheet.dart'; export 'src/material/bottom_sheet.dart';
export 'src/material/bottom_sheet_theme.dart'; export 'src/material/bottom_sheet_theme.dart';
export 'src/material/button.dart'; export 'src/material/button.dart';
......
...@@ -12,6 +12,7 @@ import 'package:flutter/widgets.dart'; ...@@ -12,6 +12,7 @@ import 'package:flutter/widgets.dart';
import 'app_bar_theme.dart'; import 'app_bar_theme.dart';
import 'banner_theme.dart'; import 'banner_theme.dart';
import 'bottom_app_bar_theme.dart'; import 'bottom_app_bar_theme.dart';
import 'bottom_navigation_bar_theme.dart';
import 'bottom_sheet_theme.dart'; import 'bottom_sheet_theme.dart';
import 'button_bar_theme.dart'; import 'button_bar_theme.dart';
import 'button_theme.dart'; import 'button_theme.dart';
...@@ -266,6 +267,7 @@ class ThemeData with Diagnosticable { ...@@ -266,6 +267,7 @@ class ThemeData with Diagnosticable {
MaterialBannerThemeData bannerTheme, MaterialBannerThemeData bannerTheme,
DividerThemeData dividerTheme, DividerThemeData dividerTheme,
ButtonBarThemeData buttonBarTheme, ButtonBarThemeData buttonBarTheme,
BottomNavigationBarThemeData bottomNavigationBarTheme,
}) { }) {
brightness ??= Brightness.light; brightness ??= Brightness.light;
final bool isDark = brightness == Brightness.dark; final bool isDark = brightness == Brightness.dark;
...@@ -374,6 +376,7 @@ class ThemeData with Diagnosticable { ...@@ -374,6 +376,7 @@ class ThemeData with Diagnosticable {
bannerTheme ??= const MaterialBannerThemeData(); bannerTheme ??= const MaterialBannerThemeData();
dividerTheme ??= const DividerThemeData(); dividerTheme ??= const DividerThemeData();
buttonBarTheme ??= const ButtonBarThemeData(); buttonBarTheme ??= const ButtonBarThemeData();
bottomNavigationBarTheme ??= const BottomNavigationBarThemeData();
return ThemeData.raw( return ThemeData.raw(
brightness: brightness, brightness: brightness,
...@@ -440,6 +443,7 @@ class ThemeData with Diagnosticable { ...@@ -440,6 +443,7 @@ class ThemeData with Diagnosticable {
bannerTheme: bannerTheme, bannerTheme: bannerTheme,
dividerTheme: dividerTheme, dividerTheme: dividerTheme,
buttonBarTheme: buttonBarTheme, buttonBarTheme: buttonBarTheme,
bottomNavigationBarTheme: bottomNavigationBarTheme,
); );
} }
...@@ -518,6 +522,7 @@ class ThemeData with Diagnosticable { ...@@ -518,6 +522,7 @@ class ThemeData with Diagnosticable {
@required this.bannerTheme, @required this.bannerTheme,
@required this.dividerTheme, @required this.dividerTheme,
@required this.buttonBarTheme, @required this.buttonBarTheme,
@required this.bottomNavigationBarTheme,
}) : assert(brightness != null), }) : assert(brightness != null),
assert(visualDensity != null), assert(visualDensity != null),
assert(primaryColor != null), assert(primaryColor != null),
...@@ -578,7 +583,8 @@ class ThemeData with Diagnosticable { ...@@ -578,7 +583,8 @@ class ThemeData with Diagnosticable {
assert(popupMenuTheme != null), assert(popupMenuTheme != null),
assert(bannerTheme != null), assert(bannerTheme != null),
assert(dividerTheme != null), assert(dividerTheme != null),
assert(buttonBarTheme != null); assert(buttonBarTheme != null),
assert(bottomNavigationBarTheme != null);
/// Create a [ThemeData] based on the colors in the given [colorScheme] and /// Create a [ThemeData] based on the colors in the given [colorScheme] and
/// text styles of the optional [textTheme]. /// text styles of the optional [textTheme].
...@@ -1025,6 +1031,10 @@ class ThemeData with Diagnosticable { ...@@ -1025,6 +1031,10 @@ class ThemeData with Diagnosticable {
/// A theme for customizing the appearance and layout of [ButtonBar] widgets. /// A theme for customizing the appearance and layout of [ButtonBar] widgets.
final ButtonBarThemeData buttonBarTheme; final ButtonBarThemeData buttonBarTheme;
/// A theme for customizing the appearance and layout of [BottomNavigationBar]
/// widgets.
final BottomNavigationBarThemeData bottomNavigationBarTheme;
/// Creates a copy of this theme but with the given fields replaced with the new values. /// Creates a copy of this theme but with the given fields replaced with the new values.
ThemeData copyWith({ ThemeData copyWith({
Brightness brightness, Brightness brightness,
...@@ -1091,6 +1101,7 @@ class ThemeData with Diagnosticable { ...@@ -1091,6 +1101,7 @@ class ThemeData with Diagnosticable {
MaterialBannerThemeData bannerTheme, MaterialBannerThemeData bannerTheme,
DividerThemeData dividerTheme, DividerThemeData dividerTheme,
ButtonBarThemeData buttonBarTheme, ButtonBarThemeData buttonBarTheme,
BottomNavigationBarThemeData bottomNavigationBarTheme,
}) { }) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
return ThemeData.raw( return ThemeData.raw(
...@@ -1158,6 +1169,7 @@ class ThemeData with Diagnosticable { ...@@ -1158,6 +1169,7 @@ class ThemeData with Diagnosticable {
bannerTheme: bannerTheme ?? this.bannerTheme, bannerTheme: bannerTheme ?? this.bannerTheme,
dividerTheme: dividerTheme ?? this.dividerTheme, dividerTheme: dividerTheme ?? this.dividerTheme,
buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme, buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
); );
} }
...@@ -1303,6 +1315,7 @@ class ThemeData with Diagnosticable { ...@@ -1303,6 +1315,7 @@ class ThemeData with Diagnosticable {
bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t), bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t),
dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t), dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t),
buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t), buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t),
bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t),
); );
} }
...@@ -1375,7 +1388,8 @@ class ThemeData with Diagnosticable { ...@@ -1375,7 +1388,8 @@ class ThemeData with Diagnosticable {
&& other.popupMenuTheme == popupMenuTheme && other.popupMenuTheme == popupMenuTheme
&& other.bannerTheme == bannerTheme && other.bannerTheme == bannerTheme
&& other.dividerTheme == dividerTheme && other.dividerTheme == dividerTheme
&& other.buttonBarTheme == buttonBarTheme; && other.buttonBarTheme == buttonBarTheme
&& other.bottomNavigationBarTheme == bottomNavigationBarTheme;
} }
@override @override
...@@ -1448,6 +1462,7 @@ class ThemeData with Diagnosticable { ...@@ -1448,6 +1462,7 @@ class ThemeData with Diagnosticable {
bannerTheme, bannerTheme,
dividerTheme, dividerTheme,
buttonBarTheme, buttonBarTheme,
bottomNavigationBarTheme,
]; ];
return hashList(values); return hashList(values);
} }
...@@ -1516,6 +1531,7 @@ class ThemeData with Diagnosticable { ...@@ -1516,6 +1531,7 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<MaterialBannerThemeData>('bannerTheme', bannerTheme, defaultValue: defaultData.bannerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<MaterialBannerThemeData>('bannerTheme', bannerTheme, defaultValue: defaultData.bannerTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<DividerThemeData>('dividerTheme', dividerTheme, defaultValue: defaultData.dividerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<DividerThemeData>('dividerTheme', dividerTheme, defaultValue: defaultData.dividerTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ButtonBarThemeData>('buttonBarTheme', buttonBarTheme, defaultValue: defaultData.buttonBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ButtonBarThemeData>('buttonBarTheme', buttonBarTheme, defaultValue: defaultData.buttonBarTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<BottomNavigationBarThemeData>('bottomNavigationBarTheme', bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel.debug));
} }
} }
......
...@@ -280,6 +280,7 @@ void main() { ...@@ -280,6 +280,7 @@ void main() {
bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.black), bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.black),
dividerTheme: const DividerThemeData(color: Colors.black), dividerTheme: const DividerThemeData(color: Colors.black),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start), buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed),
); );
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors( final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
...@@ -360,6 +361,7 @@ void main() { ...@@ -360,6 +361,7 @@ void main() {
bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.white), bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.white),
dividerTheme: const DividerThemeData(color: Colors.white), dividerTheme: const DividerThemeData(color: Colors.white),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end), buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.shifting),
); );
final ThemeData themeDataCopy = theme.copyWith( final ThemeData themeDataCopy = theme.copyWith(
...@@ -426,6 +428,7 @@ void main() { ...@@ -426,6 +428,7 @@ void main() {
bannerTheme: otherTheme.bannerTheme, bannerTheme: otherTheme.bannerTheme,
dividerTheme: otherTheme.dividerTheme, dividerTheme: otherTheme.dividerTheme,
buttonBarTheme: otherTheme.buttonBarTheme, buttonBarTheme: otherTheme.buttonBarTheme,
bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme,
); );
expect(themeDataCopy.brightness, equals(otherTheme.brightness)); expect(themeDataCopy.brightness, equals(otherTheme.brightness));
...@@ -493,6 +496,7 @@ void main() { ...@@ -493,6 +496,7 @@ void main() {
expect(themeDataCopy.bannerTheme, equals(otherTheme.bannerTheme)); expect(themeDataCopy.bannerTheme, equals(otherTheme.bannerTheme));
expect(themeDataCopy.dividerTheme, equals(otherTheme.dividerTheme)); expect(themeDataCopy.dividerTheme, equals(otherTheme.dividerTheme));
expect(themeDataCopy.buttonBarTheme, equals(otherTheme.buttonBarTheme)); expect(themeDataCopy.buttonBarTheme, equals(otherTheme.buttonBarTheme));
expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme));
}); });
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async { testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment