This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
ExpansionTile
to support Material 3 & add an example (#119712)
- Loading branch information
1 parent
da36bd6
commit e8eac0d
Showing
6 changed files
with
228 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'template.dart'; | ||
|
||
class ExpansionTileTemplate extends TokenTemplate { | ||
const ExpansionTileTemplate(super.blockName, super.fileName, super.tokens, { | ||
super.colorSchemePrefix = '_colors.', | ||
}); | ||
|
||
@override | ||
String generate() => ''' | ||
class _${blockName}DefaultsM3 extends ExpansionTileThemeData { | ||
_${blockName}DefaultsM3(this.context); | ||
final BuildContext context; | ||
late final ThemeData _theme = Theme.of(context); | ||
late final ColorScheme _colors = _theme.colorScheme; | ||
@override | ||
Color? get textColor => ${textStyle("md.comp.list.list-item.label-text")}!.color; | ||
@override | ||
Color? get iconColor => ${componentColor('md.comp.list.list-item.selected.trailing-icon')}; | ||
@override | ||
Color? get collapsedTextColor => ${textStyle("md.comp.list.list-item.label-text")}!.color; | ||
@override | ||
Color? get collapsedIconColor => ${componentColor('md.comp.list.list-item.unselected.trailing-icon')}; | ||
} | ||
'''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
examples/api/test/material/expansion_tile/expansion_tile.0_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_api_samples/material/expansion_tile/expansion_tile.0.dart' as example; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('When expansion tiles are expanded tile numbers are revealed', (WidgetTester tester) async { | ||
const int totalTiles = 3; | ||
|
||
await tester.pumpWidget( | ||
const example.ExpansionTileApp(), | ||
); | ||
|
||
expect(find.byType(ExpansionTile), findsNWidgets(totalTiles)); | ||
|
||
const String tileOne = 'This is tile number 1'; | ||
expect(find.text(tileOne), findsNothing); | ||
|
||
await tester.tap(find.text('ExpansionTile 1')); | ||
await tester.pumpAndSettle(); | ||
expect(find.text(tileOne), findsOneWidget); | ||
|
||
const String tileTwo = 'This is tile number 2'; | ||
expect(find.text(tileTwo), findsNothing); | ||
|
||
await tester.tap(find.text('ExpansionTile 2')); | ||
await tester.pumpAndSettle(); | ||
expect(find.text(tileTwo), findsOneWidget); | ||
|
||
const String tileThree = 'This is tile number 3'; | ||
expect(find.text(tileThree), findsNothing); | ||
|
||
await tester.tap(find.text('ExpansionTile 3')); | ||
await tester.pumpAndSettle(); | ||
expect(find.text(tileThree), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters