Changes a hard-coded value to a controllable parameter.
This commit is contained in:
committed by
Justin McCandless
parent
09f6515b73
commit
1a5e4a5d7f
@@ -72,12 +72,14 @@ class _AccountDetails extends StatefulWidget {
|
||||
@required this.accountEmail,
|
||||
this.onTap,
|
||||
this.isOpen,
|
||||
this.arrowColor,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget accountName;
|
||||
final Widget accountEmail;
|
||||
final VoidCallback onTap;
|
||||
final bool isOpen;
|
||||
final Color arrowColor;
|
||||
|
||||
@override
|
||||
_AccountDetailsState createState() => _AccountDetailsState();
|
||||
@@ -179,7 +181,7 @@ class _AccountDetailsState extends State<_AccountDetails> with SingleTickerProvi
|
||||
angle: _animation.value * math.pi,
|
||||
child: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
color: Colors.white,
|
||||
color: widget.arrowColor,
|
||||
semanticLabel: widget.isOpen
|
||||
? localizations.hideAccountsLabel
|
||||
: localizations.showAccountsLabel,
|
||||
@@ -314,6 +316,7 @@ class UserAccountsDrawerHeader extends StatefulWidget {
|
||||
@required this.accountName,
|
||||
@required this.accountEmail,
|
||||
this.onDetailsPressed,
|
||||
this.arrowColor = Colors.white,
|
||||
}) : super(key: key);
|
||||
|
||||
/// The header's background. If decoration is null then a [BoxDecoration]
|
||||
@@ -344,6 +347,9 @@ class UserAccountsDrawerHeader extends StatefulWidget {
|
||||
/// [accountName] and [accountEmail] is tapped.
|
||||
final VoidCallback onDetailsPressed;
|
||||
|
||||
/// The [Color] of the arrow icon.
|
||||
final Color arrowColor;
|
||||
|
||||
@override
|
||||
_UserAccountsDrawerHeaderState createState() => _UserAccountsDrawerHeaderState();
|
||||
}
|
||||
@@ -390,6 +396,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
|
||||
accountEmail: widget.accountEmail,
|
||||
isOpen: _isOpen,
|
||||
onTap: widget.onDetailsPressed == null ? null : _handleDetailsPressed,
|
||||
arrowColor: widget.arrowColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -216,6 +216,37 @@ void main() {
|
||||
expect(transformWidget.transform.getRotation()[4], 1.0);
|
||||
});
|
||||
|
||||
testWidgets('UserAccountsDrawerHeader icon color changes', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(
|
||||
child: UserAccountsDrawerHeader(
|
||||
onDetailsPressed: () {},
|
||||
accountName: const Text('name'),
|
||||
accountEmail: const Text('email'),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
Icon iconWidget = tester.firstWidget(find.byType(Icon));
|
||||
// Default icon color is white.
|
||||
expect(iconWidget.color, Colors.white);
|
||||
|
||||
const Color arrowColor = Colors.red;
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(
|
||||
child: UserAccountsDrawerHeader(
|
||||
onDetailsPressed: () { },
|
||||
accountName: const Text('name'),
|
||||
accountEmail: const Text('email'),
|
||||
arrowColor: arrowColor,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
iconWidget = tester.firstWidget(find.byType(Icon));
|
||||
expect(iconWidget.color, arrowColor);
|
||||
});
|
||||
|
||||
testWidgets('UserAccountsDrawerHeader null parameters LTR', (WidgetTester tester) async {
|
||||
Widget buildFrame({
|
||||
Widget currentAccountPicture,
|
||||
|
||||
Reference in New Issue
Block a user