Changed DefaultTextStyle to consider the TextTheme defined in the context for Bottom Nav Bar (#7042)
* Changed DefaultTextStyle to consider the TextTheme defined in the context * added regression test for bottom nav bar text themes * added second regression test for fixed navbar
This commit is contained in:
committed by
Adam Barth
parent
ee5a80a6af
commit
28bfbd6c58
1
AUTHORS
1
AUTHORS
@@ -10,3 +10,4 @@ Wyatt Arent <hello@wyatt.ninja>
|
||||
Michael Perrotte <mikemimik@gmail.com>
|
||||
Günter Zöchbauer <guenter@gzoechbauer.com>
|
||||
Raju Bitter <rajubitter@gmail.com>
|
||||
Michael Beckler <mcbeckler@gmail.com>
|
||||
|
||||
@@ -341,7 +341,8 @@ class BottomNavigationBarState extends State<BottomNavigationBar> with TickerPro
|
||||
alignment: FractionalOffset.bottomCenter,
|
||||
child: new Container(
|
||||
margin: const EdgeInsets.only(bottom: 10.0),
|
||||
child: new DefaultTextStyle(
|
||||
child: new DefaultTextStyle.merge(
|
||||
context: context,
|
||||
style: new TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: colorTween.evaluate(animations[i]),
|
||||
@@ -411,7 +412,8 @@ class BottomNavigationBarState extends State<BottomNavigationBar> with TickerPro
|
||||
margin: const EdgeInsets.only(bottom: 10.0),
|
||||
child: new FadeTransition(
|
||||
opacity: animations[i],
|
||||
child: new DefaultTextStyle(
|
||||
child: new DefaultTextStyle.merge(
|
||||
context: context,
|
||||
style: new TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.white
|
||||
|
||||
@@ -164,4 +164,80 @@ void main() {
|
||||
actions = tester.renderObjectList(find.byType(InkResponse));
|
||||
expect(actions.elementAt(3).localToGlobal(Point.origin), equals(originalOrigin));
|
||||
});
|
||||
|
||||
testWidgets('BottomNavigationBar inherits shadowed app theme for shifting navbar', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
new MaterialApp(
|
||||
theme: new ThemeData(brightness: Brightness.light),
|
||||
home: new Theme(
|
||||
data: new ThemeData(brightness: Brightness.dark),
|
||||
child: new Scaffold(
|
||||
bottomNavigationBar: new BottomNavigationBar(
|
||||
type: BottomNavigationBarType.shifting,
|
||||
labels: <DestinationLabel>[
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.ac_unit),
|
||||
title: new Text('AC')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.access_alarm),
|
||||
title: new Text('Alarm')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.access_time),
|
||||
title: new Text('Time')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.add),
|
||||
title: new Text('Add')
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Alarm'));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark));
|
||||
});
|
||||
|
||||
testWidgets('BottomNavigationBar inherits shadowed app theme for fixed navbar', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
new MaterialApp(
|
||||
theme: new ThemeData(brightness: Brightness.light),
|
||||
home: new Theme(
|
||||
data: new ThemeData(brightness: Brightness.dark),
|
||||
child: new Scaffold(
|
||||
bottomNavigationBar: new BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
labels: <DestinationLabel>[
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.ac_unit),
|
||||
title: new Text('AC')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.access_alarm),
|
||||
title: new Text('Alarm')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.access_time),
|
||||
title: new Text('Time')
|
||||
),
|
||||
new DestinationLabel(
|
||||
icon: new Icon(Icons.add),
|
||||
title: new Text('Add')
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Alarm'));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user