Skip to content

Commit

Permalink
Change LicensePage's loading color from scaffoldBackgroundColor to ca…
Browse files Browse the repository at this point in the history
…rdColor (flutter#64639)

* wrap LicensePage's loading widget with cardColor

* Set AnimatedSwitcer's duration in LicensePage to zero

* Remove AnimatedSwitcher

* Add test code for checking color is same
  • Loading branch information
gusghrlrl101 authored Sep 18, 2020
1 parent 84aae22 commit d26268b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 29 deletions.
57 changes: 28 additions & 29 deletions packages/flutter/lib/src/material/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -611,41 +611,40 @@ class _PackagesViewState extends State<_PackagesView> {
return FutureBuilder<_LicenseData>(
future: licenses,
builder: (BuildContext context, AsyncSnapshot<_LicenseData> snapshot) {
return AnimatedSwitcher(
transitionBuilder: (Widget child, Animation<double> animation) => FadeTransition(opacity: animation, child: child),
duration: kThemeAnimationDuration,
child: LayoutBuilder(
key: ValueKey<ConnectionState>(snapshot.connectionState),
builder: (BuildContext context, BoxConstraints constraints) {
switch (snapshot.connectionState) {
case ConnectionState.done:
_initDefaultDetailPage(snapshot.data, context);
return ValueListenableBuilder<int>(
valueListenable: widget.selectedId,
builder: (BuildContext context, int selectedId, Widget _) {
return Center(
child: Material(
color: Theme.of(context).cardColor,
elevation: 4.0,
child: Container(
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
child: _packagesList(context, selectedId, snapshot.data, widget.isLateral),
),
return LayoutBuilder(
key: ValueKey<ConnectionState>(snapshot.connectionState),
builder: (BuildContext context, BoxConstraints constraints) {
switch (snapshot.connectionState) {
case ConnectionState.done:
_initDefaultDetailPage(snapshot.data, context);
return ValueListenableBuilder<int>(
valueListenable: widget.selectedId,
builder: (BuildContext context, int selectedId, Widget _) {
return Center(
child: Material(
color: Theme.of(context).cardColor,
elevation: 4.0,
child: Container(
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
child: _packagesList(context, selectedId, snapshot.data, widget.isLateral),
),
);
},
);
default:
return Column(
),
);
},
);
default:
return Material(
color: Theme.of(context).cardColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
widget.about,
const Center(child: CircularProgressIndicator()),
],
);
}
},
),
),
);
}
},
);
},
);
Expand Down
47 changes: 47 additions & 0 deletions packages/flutter/test/material/about_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,53 @@ void main() {

expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0)));
});

testWidgets("LicensePage's color must be same whether loading or done", (WidgetTester tester) async {
const Color scaffoldColor = Color(0xFF123456);
const Color cardColor = Color(0xFF654321);

await tester.pumpWidget(MaterialApp(
theme: ThemeData.light().copyWith(
scaffoldBackgroundColor: scaffoldColor,
cardColor: cardColor,
),
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) => GestureDetector(
child: const Text('Show licenses'),
onTap: () {
showLicensePage(
context: context,
applicationName: 'MyApp',
applicationVersion: '1.0.0',
);
}
),
),
),
),
));

await tester.tap(find.text('Show licenses'));
await tester.pump();
await tester.pump();

// Check color when loading.
final List<Material> materialLoadings = tester.widgetList<Material>(find.byType(Material)).toList();
expect(materialLoadings.length, equals(4));
expect(materialLoadings[1].color, scaffoldColor);
expect(materialLoadings[2].color, cardColor);

await tester.pumpAndSettle();

// Check color when done.
expect(find.byKey(const ValueKey<ConnectionState>(ConnectionState.done)), findsOneWidget);
final List<Material> materialDones = tester.widgetList<Material>(find.byType(Material)).toList();
expect(materialDones.length, equals(3));
expect(materialDones[0].color, scaffoldColor);
expect(materialDones[1].color, cardColor);
});
}

class FakeLicenseEntry extends LicenseEntry {
Expand Down

0 comments on commit d26268b

Please sign in to comment.