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
81ec553f
Commit
81ec553f
authored
May 11, 2017
by
xster
Committed by
GitHub
May 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Cupertino dialog UI tweaks (#9960)
* is default * hit target * correct test name * review note
parent
1a2d9b00
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
8 deletions
+43
-8
cupertino_dialog_demo.dart
...ter_gallery/lib/demo/cupertino/cupertino_dialog_demo.dart
+3
-2
dialog.dart
packages/flutter/lib/src/cupertino/dialog.dart
+13
-3
dialog_test.dart
packages/flutter/test/cupertino/dialog_test.dart
+27
-3
No files found.
examples/flutter_gallery/lib/demo/cupertino/cupertino_dialog_demo.dart
View file @
81ec553f
...
@@ -53,11 +53,12 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
...
@@ -53,11 +53,12 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
actions:
<
Widget
>[
actions:
<
Widget
>[
new
CupertinoDialogAction
(
new
CupertinoDialogAction
(
child:
const
Text
(
'Discard'
),
child:
const
Text
(
'Discard'
),
isDestructive:
true
,
isDestructive
Action
:
true
,
onPressed:
()
{
Navigator
.
pop
(
context
,
'Discard'
);
}
onPressed:
()
{
Navigator
.
pop
(
context
,
'Discard'
);
}
),
),
new
CupertinoDialogAction
(
new
CupertinoDialogAction
(
child:
const
Text
(
'Cancel'
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
w600
)),
child:
const
Text
(
'Cancel'
),
isDefaultAction:
true
,
onPressed:
()
{
Navigator
.
pop
(
context
,
'Cancel'
);
}
onPressed:
()
{
Navigator
.
pop
(
context
,
'Cancel'
);
}
),
),
]
]
...
...
packages/flutter/lib/src/cupertino/dialog.dart
View file @
81ec553f
...
@@ -191,7 +191,8 @@ class CupertinoDialogAction extends StatelessWidget {
...
@@ -191,7 +191,8 @@ class CupertinoDialogAction extends StatelessWidget {
/// Creates an action for an iOS-style dialog.
/// Creates an action for an iOS-style dialog.
const
CupertinoDialogAction
({
const
CupertinoDialogAction
({
this
.
onPressed
,
this
.
onPressed
,
this
.
isDestructive
:
false
,
this
.
isDefaultAction
:
false
,
this
.
isDestructiveAction
:
false
,
@required
this
.
child
,
@required
this
.
child
,
})
:
assert
(
child
!=
null
);
})
:
assert
(
child
!=
null
);
...
@@ -200,10 +201,15 @@ class CupertinoDialogAction extends StatelessWidget {
...
@@ -200,10 +201,15 @@ class CupertinoDialogAction extends StatelessWidget {
/// If this is set to null, the button will be disabled.
/// If this is set to null, the button will be disabled.
final
VoidCallback
onPressed
;
final
VoidCallback
onPressed
;
/// Set to true if button is the default choice in the dialog.
///
/// Default buttons are bolded.
final
bool
isDefaultAction
;
/// Whether this action destroys an object.
/// Whether this action destroys an object.
///
///
/// For example, an action that deletes an email is destructive.
/// For example, an action that deletes an email is destructive.
final
bool
isDestructive
;
final
bool
isDestructive
Action
;
/// The widget below this widget in the tree.
/// The widget below this widget in the tree.
///
///
...
@@ -218,7 +224,10 @@ class CupertinoDialogAction extends StatelessWidget {
...
@@ -218,7 +224,10 @@ class CupertinoDialogAction extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
TextStyle
style
=
_kCupertinoDialogActionStyle
;
TextStyle
style
=
_kCupertinoDialogActionStyle
;
if
(
isDestructive
)
if
(
isDefaultAction
)
style
=
style
.
copyWith
(
fontWeight:
FontWeight
.
w600
);
if
(
isDestructiveAction
)
style
=
style
.
copyWith
(
color:
_kDestructiveActionColor
);
style
=
style
.
copyWith
(
color:
_kDestructiveActionColor
);
if
(!
enabled
)
if
(!
enabled
)
...
@@ -226,6 +235,7 @@ class CupertinoDialogAction extends StatelessWidget {
...
@@ -226,6 +235,7 @@ class CupertinoDialogAction extends StatelessWidget {
return
new
GestureDetector
(
return
new
GestureDetector
(
onTap:
onPressed
,
onTap:
onPressed
,
behavior:
HitTestBehavior
.
opaque
,
child:
new
Center
(
child:
new
Center
(
child:
new
DefaultTextStyle
(
child:
new
DefaultTextStyle
(
style:
style
,
style:
style
,
...
...
packages/flutter/test/cupertino/dialog_test.dart
View file @
81ec553f
...
@@ -27,7 +27,7 @@ void main() {
...
@@ -27,7 +27,7 @@ void main() {
child:
const
Text
(
'Cancel'
),
child:
const
Text
(
'Cancel'
),
),
),
new
CupertinoDialogAction
(
new
CupertinoDialogAction
(
isDestructive:
true
,
isDestructive
Action
:
true
,
onPressed:
()
{
onPressed:
()
{
didDelete
=
true
;
didDelete
=
true
;
Navigator
.
pop
(
context
);
Navigator
.
pop
(
context
);
...
@@ -63,9 +63,9 @@ void main() {
...
@@ -63,9 +63,9 @@ void main() {
expect
(
find
.
text
(
'Delete'
),
findsNothing
);
expect
(
find
.
text
(
'Delete'
),
findsNothing
);
});
});
testWidgets
(
'Dialog action styles'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Dialog
destructive
action styles'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoDialogAction
(
await
tester
.
pumpWidget
(
const
CupertinoDialogAction
(
isDestructive:
true
,
isDestructive
Action
:
true
,
child:
const
Text
(
'Ok'
),
child:
const
Text
(
'Ok'
),
));
));
...
@@ -74,4 +74,28 @@ void main() {
...
@@ -74,4 +74,28 @@ void main() {
expect
(
widget
.
style
.
color
.
red
,
greaterThan
(
widget
.
style
.
color
.
blue
));
expect
(
widget
.
style
.
color
.
red
,
greaterThan
(
widget
.
style
.
color
.
blue
));
expect
(
widget
.
style
.
color
.
alpha
,
lessThan
(
255
));
expect
(
widget
.
style
.
color
.
alpha
,
lessThan
(
255
));
});
});
testWidgets
(
'Dialog default action styles'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoDialogAction
(
isDefaultAction:
true
,
child:
const
Text
(
'Ok'
),
));
final
DefaultTextStyle
widget
=
tester
.
widget
(
find
.
byType
(
DefaultTextStyle
));
expect
(
widget
.
style
.
fontWeight
,
equals
(
FontWeight
.
w600
));
});
testWidgets
(
'Default and destructive style'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoDialogAction
(
isDefaultAction:
true
,
isDestructiveAction:
true
,
child:
const
Text
(
'Ok'
),
));
final
DefaultTextStyle
widget
=
tester
.
widget
(
find
.
byType
(
DefaultTextStyle
));
expect
(
widget
.
style
.
fontWeight
,
equals
(
FontWeight
.
w600
));
expect
(
widget
.
style
.
color
.
red
,
greaterThan
(
widget
.
style
.
color
.
blue
));
});
}
}
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