Skip to content

Commit

Permalink
Revert to soon-to-be-deprecated subhead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylled committed Feb 24, 2020
1 parent adc3df8 commit 68aff69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lib/expansion_tile_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class _ExpansionTileCardState extends State<ExpansionTileCard> with SingleTicker
void didChangeDependencies() {
final ThemeData theme = Theme.of(context);
_headerColorTween
..begin = theme.textTheme.subtitle1.color
..begin = theme.textTheme.subhead.color
..end = theme.accentColor;
_iconColorTween
..begin = theme.unselectedWidgetColor
Expand Down
56 changes: 21 additions & 35 deletions test/expansion_tile_card_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Originally based on expansion_tile_test.dart from Flutter.
//
// Copyright 2014 The Flutter Authors. All rights reserved.
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -60,6 +60,7 @@ void main() {

await tester.pumpWidget(MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
dividerColor: _dividerColor,
),
home: Material(
Expand Down Expand Up @@ -105,27 +106,23 @@ void main() {

double getHeight(Key key) => tester.getSize(find.byKey(key)).height;
Container getContainer(Key key) => tester.firstWidget(find.descendant(
of: find.byKey(key),
matching: find.byType(Container),
));
of: find.byKey(key),
matching: find.byType(Container),
));

expect(
getHeight(topKey), getHeight(expandedKey) - getHeight(tileKey) - 2.0);
expect(getHeight(topKey), getHeight(expandedKey) - getHeight(tileKey) - 2.0);
expect(getHeight(topKey), getHeight(collapsedKey) - 2.0);
expect(getHeight(topKey), getHeight(defaultKey) - 2.0);

BoxDecoration expandedContainerDecoration =
getContainer(expandedKey).decoration as BoxDecoration;
BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration;
expect(expandedContainerDecoration.color, Colors.red);
expect(expandedContainerDecoration.border.top.color, _dividerColor);
expect(expandedContainerDecoration.border.bottom.color, _dividerColor);

BoxDecoration collapsedContainerDecoration =
getContainer(collapsedKey).decoration as BoxDecoration;
BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration;
expect(collapsedContainerDecoration.color, Colors.transparent);
expect(collapsedContainerDecoration.border.top.color, Colors.transparent);
expect(
collapsedContainerDecoration.border.bottom.color, Colors.transparent);
expect(collapsedContainerDecoration.border.bottom.color, Colors.transparent);

await tester.tap(find.text('Expanded'));
await tester.tap(find.text('Collapsed'));
Expand All @@ -135,39 +132,31 @@ void main() {

// Pump to the middle of the animation for expansion.
await tester.pump(const Duration(milliseconds: 100));
final BoxDecoration collapsingContainerDecoration =
getContainer(collapsedKey).decoration as BoxDecoration;
final BoxDecoration collapsingContainerDecoration = getContainer(collapsedKey).decoration;
expect(collapsingContainerDecoration.color, Colors.transparent);
// Opacity should change but color component should remain the same.
expect(collapsingContainerDecoration.border.top.color,
const Color(0x15333333));
expect(collapsingContainerDecoration.border.bottom.color,
const Color(0x15333333));
expect(collapsingContainerDecoration.border.top.color, const Color(0x15333333));
expect(collapsingContainerDecoration.border.bottom.color, const Color(0x15333333));

// Pump all the way to the end now.
await tester.pump(const Duration(seconds: 1));

expect(getHeight(topKey), getHeight(expandedKey) - 2.0);
expect(
getHeight(topKey), getHeight(collapsedKey) - getHeight(tileKey) - 2.0);
expect(getHeight(topKey), getHeight(collapsedKey) - getHeight(tileKey) - 2.0);
expect(getHeight(topKey), getHeight(defaultKey) - getHeight(tileKey) - 2.0);

// Expanded should be collapsed now.
expandedContainerDecoration =
getContainer(expandedKey).decoration as BoxDecoration;
expandedContainerDecoration = getContainer(expandedKey).decoration;
expect(expandedContainerDecoration.color, Colors.transparent);
expect(expandedContainerDecoration.border.top.color, Colors.transparent);
expect(expandedContainerDecoration.border.bottom.color, Colors.transparent);

// Collapsed should be expanded now.
collapsedContainerDecoration =
getContainer(collapsedKey).decoration as BoxDecoration;
collapsedContainerDecoration = getContainer(collapsedKey).decoration;
expect(collapsedContainerDecoration.color, Colors.transparent);
expect(collapsedContainerDecoration.border.top.color, _dividerColor);
expect(collapsedContainerDecoration.border.bottom.color, _dividerColor);
},
variant: const TargetPlatformVariant(
<TargetPlatform>{TargetPlatform.iOS, TargetPlatform.macOS}));
});

testWidgets('ListTileTheme', (WidgetTester tester) async {
final Key expandedTitleKey = UniqueKey();
Expand All @@ -178,9 +167,10 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
accentColor: _accentColor,
unselectedWidgetColor: _unselectedWidgetColor,
textTheme: const TextTheme(subtitle1: TextStyle(color: _headerColor)),
textTheme: const TextTheme(subhead: TextStyle(color: _headerColor)),
),
home: Material(
child: SingleChildScrollView(
Expand All @@ -207,10 +197,8 @@ void main() {
),
);

Color iconColor(Key key) =>
tester.state<TestIconState>(find.byKey(key)).iconTheme.color;
Color textColor(Key key) =>
tester.state<TestTextState>(find.byKey(key)).textStyle.color;
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color;
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color;

expect(textColor(expandedTitleKey), _accentColor);
expect(textColor(collapsedTitleKey), _headerColor);
Expand All @@ -228,9 +216,7 @@ void main() {
expect(textColor(collapsedTitleKey), _accentColor);
expect(iconColor(expandedIconKey), _unselectedWidgetColor);
expect(iconColor(collapsedIconKey), _accentColor);
},
variant: const TargetPlatformVariant(
<TargetPlatform>{TargetPlatform.iOS, TargetPlatform.macOS}));
});

testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down

0 comments on commit 68aff69

Please sign in to comment.