Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
17d31797
Unverified
Commit
17d31797
authored
Aug 03, 2020
by
Hans Muller
Committed by
GitHub
Aug 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use OverflowBar instead of ButtonBar in TimePicker (#62601)
parent
e3c3d6eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
63 deletions
+112
-63
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+18
-15
time_picker_test.dart
packages/flutter/test/material/time_picker_test.dart
+94
-48
No files found.
packages/flutter/lib/src/material/time_picker.dart
View file @
17d31797
...
@@ -11,8 +11,6 @@ import 'package:flutter/rendering.dart';
...
@@ -11,8 +11,6 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'color_scheme.dart'
;
import
'color_scheme.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'constants.dart'
;
...
@@ -1827,19 +1825,24 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
...
@@ -1827,19 +1825,24 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
:
MaterialLocalizations
.
of
(
context
).
dialModeButtonLabel
,
:
MaterialLocalizations
.
of
(
context
).
dialModeButtonLabel
,
),
),
Expanded
(
Expanded
(
// TODO(rami-a): Move away from ButtonBar to avoid https://github.com/flutter/flutter/issues/53378.
child:
Container
(
child:
ButtonBar
(
alignment:
AlignmentDirectional
.
centerEnd
,
layoutBehavior:
ButtonBarLayoutBehavior
.
constrained
,
constraints:
const
BoxConstraints
(
minHeight:
52.0
),
children:
<
Widget
>[
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8
),
TextButton
(
child:
OverflowBar
(
onPressed:
_handleCancel
,
spacing:
8
,
child:
Text
(
widget
.
cancelText
??
localizations
.
cancelButtonLabel
),
overflowAlignment:
OverflowBarAlignment
.
end
,
),
children:
<
Widget
>[
TextButton
(
TextButton
(
onPressed:
_handleOk
,
onPressed:
_handleCancel
,
child:
Text
(
widget
.
confirmText
??
localizations
.
okButtonLabel
),
child:
Text
(
widget
.
cancelText
??
localizations
.
cancelButtonLabel
),
),
),
],
TextButton
(
onPressed:
_handleOk
,
child:
Text
(
widget
.
confirmText
??
localizations
.
okButtonLabel
),
),
],
),
),
),
),
),
],
],
...
...
packages/flutter/test/material/time_picker_test.dart
View file @
17d31797
...
@@ -643,54 +643,100 @@ void _tests() {
...
@@ -643,54 +643,100 @@ void _tests() {
expect
(
find
.
text
(
helperText
),
findsOneWidget
);
expect
(
find
.
text
(
helperText
),
findsOneWidget
);
});
});
// TODO(rami-a): Re-enable and fix test.
testWidgets
(
'OK Cancel button layout'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'text scale affects certain elements and not others'
,
Widget
buildFrame
(
TextDirection
textDirection
)
{
(
WidgetTester
tester
)
async
{
return
MaterialApp
(
await
mediaQueryBoilerplate
(
home:
Material
(
tester
,
child:
Center
(
false
,
child:
Builder
(
textScaleFactor:
1.0
,
builder:
(
BuildContext
context
)
{
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
return
ElevatedButton
(
);
child:
const
Text
(
'X'
),
await
tester
.
tap
(
find
.
text
(
'X'
));
onPressed:
()
{
await
tester
.
pumpAndSettle
();
showTimePicker
(
context:
context
,
final
double
minutesDisplayHeight
=
tester
.
getSize
(
find
.
text
(
'41'
)).
height
;
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
0
),
final
double
amHeight
=
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
;
builder:
(
BuildContext
context
,
Widget
child
)
{
return
Directionality
(
await
tester
.
tap
(
find
.
text
(
'OK'
));
// dismiss the dialog
textDirection:
textDirection
,
await
tester
.
pumpAndSettle
();
child:
child
,
);
// Verify that the time display is not affected by text scale.
},
await
mediaQueryBoilerplate
(
);
tester
,
},
false
,
);
textScaleFactor:
2.0
,
},
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
),
);
),
await
tester
.
tap
(
find
.
text
(
'X'
));
),
await
tester
.
pumpAndSettle
();
);
}
final
double
amHeight2x
=
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
;
expect
(
tester
.
getSize
(
find
.
text
(
'41'
)).
height
,
equals
(
minutesDisplayHeight
));
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
ltr
));
expect
(
amHeight2x
,
greaterThanOrEqualTo
(
amHeight
*
2
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'OK'
));
// dismiss the dialog
expect
(
tester
.
getBottomRight
(
find
.
text
(
'OK'
)).
dx
,
638
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getBottomLeft
(
find
.
text
(
'OK'
)).
dx
,
610
);
expect
(
tester
.
getBottomRight
(
find
.
text
(
'CANCEL'
)).
dx
,
576
);
// Verify that text scale for AM/PM is at most 2x.
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
mediaQueryBoilerplate
(
await
tester
.
pumpAndSettle
();
tester
,
false
,
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
rtl
));
textScaleFactor:
3.0
,
await
tester
.
tap
(
find
.
text
(
'X'
));
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
await
tester
.
pumpAndSettle
();
);
expect
(
tester
.
getBottomLeft
(
find
.
text
(
'OK'
)).
dx
,
162
);
await
tester
.
tap
(
find
.
text
(
'X'
));
expect
(
tester
.
getBottomRight
(
find
.
text
(
'OK'
)).
dx
,
190
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getBottomLeft
(
find
.
text
(
'CANCEL'
)).
dx
,
224
);
await
tester
.
tap
(
find
.
text
(
'OK'
));
expect
(
tester
.
getSize
(
find
.
text
(
'41'
)).
height
,
equals
(
minutesDisplayHeight
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
,
equals
(
amHeight2x
));
});
});
testWidgets
(
'text scale affects certain elements and not others'
,
(
WidgetTester
tester
)
async
{
await
mediaQueryBoilerplate
(
tester
,
false
,
textScaleFactor:
1.0
,
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
double
minutesDisplayHeight
=
tester
.
getSize
(
find
.
text
(
'41'
)).
height
;
final
double
amHeight
=
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
;
await
tester
.
tap
(
find
.
text
(
'OK'
));
// dismiss the dialog
await
tester
.
pumpAndSettle
();
// Verify that the time display is not affected by text scale.
await
mediaQueryBoilerplate
(
tester
,
false
,
textScaleFactor:
2.0
,
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
double
amHeight2x
=
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
;
expect
(
tester
.
getSize
(
find
.
text
(
'41'
)).
height
,
equals
(
minutesDisplayHeight
));
expect
(
amHeight2x
,
greaterThanOrEqualTo
(
amHeight
*
2
));
await
tester
.
tap
(
find
.
text
(
'OK'
));
// dismiss the dialog
await
tester
.
pumpAndSettle
();
// Verify that text scale for AM/PM is at most 2x.
await
mediaQueryBoilerplate
(
tester
,
false
,
textScaleFactor:
3.0
,
initialTime:
const
TimeOfDay
(
hour:
7
,
minute:
41
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getSize
(
find
.
text
(
'41'
)).
height
,
equals
(
minutesDisplayHeight
));
expect
(
tester
.
getSize
(
find
.
text
(
'AM'
)).
height
,
equals
(
amHeight2x
));
});
}
}
void
_testsInput
(
)
{
void
_testsInput
(
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment