Support activeIcon in CupertinoTabBar (#22323)

This commit is contained in:
xster 2018-09-27 11:17:00 -07:00 committed by GitHub
parent d5b21997f4
commit 79dae000c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -172,7 +172,12 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget> [
Expanded(child: Center(child: items[index].icon)),
Expanded(child:
Center(child: active
? items[index].activeIcon
: items[index].icon
),
),
items[index].title,
],
),

View File

@ -68,6 +68,39 @@ void main() {
expect(actualActive.text.style.color, const Color(0xFF123456));
});
testWidgets('Use active icon', (WidgetTester tester) async {
const TestImageProvider activeIcon = TestImageProvider(16, 16);
const TestImageProvider inactiveIcon = TestImageProvider(24, 24);
await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(),
child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)),
title: Text('Tab 1'),
),
BottomNavigationBarItem(
icon: ImageIcon(inactiveIcon),
activeIcon: ImageIcon(activeIcon),
title: Text('Tab 2'),
),
],
currentIndex: 1,
activeColor: const Color(0xFF123456),
inactiveColor: const Color(0xFF654321),
),
));
final Image image = tester.widget(find.descendant(
of: find.widgetWithText(GestureDetector, 'Tab 2'),
matching: find.byType(Image)
));
expect(image.color, const Color(0xFF123456));
expect(image.image, activeIcon);
});
testWidgets('Adjusts height to account for bottom padding', (WidgetTester tester) async {
final CupertinoTabBar tabBar = CupertinoTabBar(
items: const <BottomNavigationBarItem>[