Unverified Commit d26268bb authored by GodHyum's avatar GodHyum Committed by GitHub

Change LicensePage's loading color from scaffoldBackgroundColor to cardColor (#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
parent 84aae22c
...@@ -611,41 +611,40 @@ class _PackagesViewState extends State<_PackagesView> { ...@@ -611,41 +611,40 @@ class _PackagesViewState extends State<_PackagesView> {
return FutureBuilder<_LicenseData>( return FutureBuilder<_LicenseData>(
future: licenses, future: licenses,
builder: (BuildContext context, AsyncSnapshot<_LicenseData> snapshot) { builder: (BuildContext context, AsyncSnapshot<_LicenseData> snapshot) {
return AnimatedSwitcher( return LayoutBuilder(
transitionBuilder: (Widget child, Animation<double> animation) => FadeTransition(opacity: animation, child: child), key: ValueKey<ConnectionState>(snapshot.connectionState),
duration: kThemeAnimationDuration, builder: (BuildContext context, BoxConstraints constraints) {
child: LayoutBuilder( switch (snapshot.connectionState) {
key: ValueKey<ConnectionState>(snapshot.connectionState), case ConnectionState.done:
builder: (BuildContext context, BoxConstraints constraints) { _initDefaultDetailPage(snapshot.data, context);
switch (snapshot.connectionState) { return ValueListenableBuilder<int>(
case ConnectionState.done: valueListenable: widget.selectedId,
_initDefaultDetailPage(snapshot.data, context); builder: (BuildContext context, int selectedId, Widget _) {
return ValueListenableBuilder<int>( return Center(
valueListenable: widget.selectedId, child: Material(
builder: (BuildContext context, int selectedId, Widget _) { color: Theme.of(context).cardColor,
return Center( elevation: 4.0,
child: Material( child: Container(
color: Theme.of(context).cardColor, constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
elevation: 4.0, child: _packagesList(context, selectedId, snapshot.data, widget.isLateral),
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, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
widget.about, widget.about,
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator()),
], ],
); ),
} );
}, }
), },
); );
}, },
); );
......
...@@ -664,6 +664,53 @@ void main() { ...@@ -664,6 +664,53 @@ void main() {
expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0))); 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 { class FakeLicenseEntry extends LicenseEntry {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment