Use OverflowBar instead of ButtonBar in DateRangePicker (#62695)
This commit is contained in:
parent
ddeb5bb9c8
commit
26f976f569
@ -12,7 +12,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import '../app_bar.dart';
|
import '../app_bar.dart';
|
||||||
import '../back_button.dart';
|
import '../back_button.dart';
|
||||||
import '../button_bar.dart';
|
|
||||||
import '../button_theme.dart';
|
import '../button_theme.dart';
|
||||||
import '../color_scheme.dart';
|
import '../color_scheme.dart';
|
||||||
import '../debug.dart';
|
import '../debug.dart';
|
||||||
@ -655,19 +654,23 @@ class _InputDateRangePickerDialog extends StatelessWidget {
|
|||||||
onIconPressed: onToggleEntryMode,
|
onIconPressed: onToggleEntryMode,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Widget actions = ButtonBar(
|
final Widget actions = Container(
|
||||||
buttonTextTheme: ButtonTextTheme.primary,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
layoutBehavior: ButtonBarLayoutBehavior.constrained,
|
constraints: const BoxConstraints(minHeight: 52.0),
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
TextButton(
|
child: OverflowBar(
|
||||||
child: Text(cancelText ?? localizations.cancelButtonLabel),
|
spacing: 8,
|
||||||
onPressed: onCancel,
|
children: <Widget>[
|
||||||
),
|
TextButton(
|
||||||
TextButton(
|
child: Text(cancelText ?? localizations.cancelButtonLabel),
|
||||||
child: Text(confirmText ?? localizations.okButtonLabel),
|
onPressed: onCancel,
|
||||||
onPressed: onConfirm,
|
),
|
||||||
),
|
TextButton(
|
||||||
],
|
child: Text(confirmText ?? localizations.okButtonLabel),
|
||||||
|
onPressed: onConfirm,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
|
@ -207,6 +207,62 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('OK Cancel button layout', (WidgetTester tester) async {
|
||||||
|
Widget buildFrame(TextDirection textDirection) {
|
||||||
|
return MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ElevatedButton(
|
||||||
|
child: const Text('X'),
|
||||||
|
onPressed: () {
|
||||||
|
showDateRangePicker(
|
||||||
|
context: context,
|
||||||
|
firstDate:DateTime(2001, DateTime.january, 1),
|
||||||
|
lastDate: DateTime(2031, DateTime.december, 31),
|
||||||
|
builder: (BuildContext context, Widget child) {
|
||||||
|
return Directionality(
|
||||||
|
textDirection: textDirection,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> showOkCancelDialog(TextDirection textDirection) async {
|
||||||
|
await tester.pumpWidget(buildFrame(textDirection));
|
||||||
|
await tester.tap(find.text('X'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byIcon(Icons.edit));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> dismissOkCancelDialog() async {
|
||||||
|
await tester.tap(find.text('CANCEL'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
await showOkCancelDialog(TextDirection.ltr);
|
||||||
|
expect(tester.getBottomRight(find.text('OK')).dx, 622);
|
||||||
|
expect(tester.getBottomLeft(find.text('OK')).dx, 594);
|
||||||
|
expect(tester.getBottomRight(find.text('CANCEL')).dx, 560);
|
||||||
|
await dismissOkCancelDialog();
|
||||||
|
|
||||||
|
await showOkCancelDialog(TextDirection.rtl);
|
||||||
|
expect(tester.getBottomRight(find.text('OK')).dx, 206);
|
||||||
|
expect(tester.getBottomLeft(find.text('OK')).dx, 178);
|
||||||
|
expect(tester.getBottomRight(find.text('CANCEL')).dx, 324);
|
||||||
|
await dismissOkCancelDialog();
|
||||||
|
});
|
||||||
|
|
||||||
group('Haptic feedback', () {
|
group('Haptic feedback', () {
|
||||||
const Duration hapticFeedbackInterval = Duration(milliseconds: 10);
|
const Duration hapticFeedbackInterval = Duration(milliseconds: 10);
|
||||||
FeedbackTester feedback;
|
FeedbackTester feedback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user