Step 1.5 of 3: AboutDialog uses scrollable AlertDialog (#49913)
This commit is contained in:
parent
8600d2305e
commit
e10df3c1a6
@ -362,31 +362,29 @@ class AboutDialog extends StatelessWidget {
|
|||||||
final String version = applicationVersion ?? _defaultApplicationVersion(context);
|
final String version = applicationVersion ?? _defaultApplicationVersion(context);
|
||||||
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
content: SingleChildScrollView(
|
content: ListBody(
|
||||||
child: ListBody(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Row(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
if (icon != null) IconTheme(data: Theme.of(context).iconTheme, child: icon),
|
||||||
if (icon != null) IconTheme(data: Theme.of(context).iconTheme, child: icon),
|
Expanded(
|
||||||
Expanded(
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
child: ListBody(
|
||||||
child: ListBody(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Text(name, style: Theme.of(context).textTheme.headline5),
|
||||||
Text(name, style: Theme.of(context).textTheme.headline5),
|
Text(version, style: Theme.of(context).textTheme.bodyText2),
|
||||||
Text(version, style: Theme.of(context).textTheme.bodyText2),
|
Container(height: 18.0),
|
||||||
Container(height: 18.0),
|
Text(applicationLegalese ?? '', style: Theme.of(context).textTheme.caption),
|
||||||
Text(applicationLegalese ?? '', style: Theme.of(context).textTheme.caption),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
...?children,
|
),
|
||||||
],
|
...?children,
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -408,6 +406,7 @@ class AboutDialog extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
scrollable: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,6 +469,54 @@ void main() {
|
|||||||
findsNothing,
|
findsNothing,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets("AboutDialog's contents are scrollable", (WidgetTester tester) async {
|
||||||
|
final Key contentKey = UniqueKey();
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
home: Navigator(
|
||||||
|
onGenerateRoute: (RouteSettings settings) {
|
||||||
|
return MaterialPageRoute<dynamic>(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return RaisedButton(
|
||||||
|
onPressed: () {
|
||||||
|
showAboutDialog(
|
||||||
|
context: context,
|
||||||
|
useRootNavigator: false,
|
||||||
|
applicationName: 'A',
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
key: contentKey,
|
||||||
|
color: Colors.orange,
|
||||||
|
height: 500,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Show About Dialog'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
await tester.tap(find.text('Show About Dialog'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Try dragging by the [AboutDialog]'s title.
|
||||||
|
RenderBox box = tester.renderObject(find.text('A'));
|
||||||
|
Offset originalOffset = box.localToGlobal(Offset.zero);
|
||||||
|
await tester.drag(find.byKey(contentKey), const Offset(0.0, -20.0));
|
||||||
|
|
||||||
|
expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0)));
|
||||||
|
|
||||||
|
// Try dragging by the additional children in contents.
|
||||||
|
box = tester.renderObject(find.byKey(contentKey));
|
||||||
|
originalOffset = box.localToGlobal(Offset.zero);
|
||||||
|
await tester.drag(find.byKey(contentKey), const Offset(0.0, -20.0));
|
||||||
|
|
||||||
|
expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeLicenseEntry extends LicenseEntry {
|
class FakeLicenseEntry extends LicenseEntry {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user