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
d2cb63c8
Unverified
Commit
d2cb63c8
authored
Mar 28, 2022
by
Taha Tesser
Committed by
GitHub
Mar 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`CupertinoActionSheet`/`CupertinoAlertDialog`: Add clickable cursor for web (#99548)
parent
712abb08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
31 deletions
+119
-31
dialog.dart
packages/flutter/lib/src/cupertino/dialog.dart
+37
-31
action_sheet_test.dart
packages/flutter/test/cupertino/action_sheet_test.dart
+36
-0
dialog_test.dart
packages/flutter/test/cupertino/dialog_test.dart
+46
-0
No files found.
packages/flutter/lib/src/cupertino/dialog.dart
View file @
d2cb63c8
...
...
@@ -703,25 +703,28 @@ class CupertinoActionSheetAction extends StatelessWidget {
style
=
style
.
copyWith
(
fontWeight:
FontWeight
.
w600
);
}
return
GestureDetector
(
onTap:
onPressed
,
behavior:
HitTestBehavior
.
opaque
,
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
(
minHeight:
_kActionSheetButtonHeight
,
),
child:
Semantics
(
button:
true
,
child:
Container
(
alignment:
Alignment
.
center
,
padding:
const
EdgeInsets
.
symmetric
(
vertical:
16.0
,
horizontal:
10.0
,
),
child:
DefaultTextStyle
(
style:
style
,
textAlign:
TextAlign
.
center
,
child:
child
,
return
MouseRegion
(
cursor:
onPressed
!=
null
&&
kIsWeb
?
SystemMouseCursors
.
click
:
MouseCursor
.
defer
,
child:
GestureDetector
(
onTap:
onPressed
,
behavior:
HitTestBehavior
.
opaque
,
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
(
minHeight:
_kActionSheetButtonHeight
,
),
child:
Semantics
(
button:
true
,
child:
Container
(
alignment:
Alignment
.
center
,
padding:
const
EdgeInsets
.
symmetric
(
vertical:
16.0
,
horizontal:
10.0
,
),
child:
DefaultTextStyle
(
style:
style
,
textAlign:
TextAlign
.
center
,
child:
child
,
),
),
),
),
...
...
@@ -1751,18 +1754,21 @@ class CupertinoDialogAction extends StatelessWidget {
content:
child
,
);
return
GestureDetector
(
excludeFromSemantics:
true
,
onTap:
onPressed
,
behavior:
HitTestBehavior
.
opaque
,
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
(
minHeight:
_kDialogMinButtonHeight
,
),
child:
Container
(
alignment:
Alignment
.
center
,
padding:
EdgeInsets
.
all
(
_calculatePadding
(
context
)),
child:
sizedContent
,
return
MouseRegion
(
cursor:
onPressed
!=
null
&&
kIsWeb
?
SystemMouseCursors
.
click
:
MouseCursor
.
defer
,
child:
GestureDetector
(
excludeFromSemantics:
true
,
onTap:
onPressed
,
behavior:
HitTestBehavior
.
opaque
,
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
(
minHeight:
_kDialogMinButtonHeight
,
),
child:
Container
(
alignment:
Alignment
.
center
,
padding:
EdgeInsets
.
all
(
_calculatePadding
(
context
)),
child:
sizedContent
,
),
),
),
);
...
...
packages/flutter/test/cupertino/action_sheet_test.dart
View file @
d2cb63c8
...
...
@@ -9,7 +9,10 @@
@Tags
(<
String
>[
'no-shuffle'
])
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -1070,6 +1073,39 @@ void main() {
// one for the content.
expect
(
find
.
byType
(
CupertinoScrollbar
),
findsNWidgets
(
2
));
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'Hovering over Cupertino action sheet action updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
createAppWithButtonThatLaunchesActionSheet
(
CupertinoActionSheet
(
title:
const
Text
(
'The title'
),
message:
const
Text
(
'Message'
),
actions:
<
Widget
>[
CupertinoActionSheetAction
(
child:
const
Text
(
'One'
),
onPressed:
()
{
},
),
],
)
),
);
await
tester
.
tap
(
find
.
text
(
'Go'
));
await
tester
.
pump
();
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
const
Offset
(
10
,
10
));
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
final
Offset
actionSheetAction
=
tester
.
getCenter
(
find
.
text
(
'One'
));
await
gesture
.
moveTo
(
actionSheetAction
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
kIsWeb
?
SystemMouseCursors
.
click
:
SystemMouseCursors
.
basic
,
);
});
}
RenderBox
findScrollableActionsSectionRenderBox
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/cupertino/dialog_test.dart
View file @
d2cb63c8
...
...
@@ -12,6 +12,7 @@ import 'dart:ui';
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
...
...
@@ -1441,6 +1442,51 @@ void main() {
expect
(
tester
.
getBottomRight
(
find
.
byType
(
Placeholder
)),
const
Offset
(
390.0
,
600.0
));
});
});
testWidgets
(
'Hovering over Cupertino alert dialog action updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
createAppWithButtonThatLaunchesDialog
(
dialogBuilder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
3.0
),
child:
RepaintBoundary
(
child:
CupertinoAlertDialog
(
title:
const
Text
(
'Title'
),
content:
const
Text
(
'text'
),
actions:
<
Widget
>[
CupertinoDialogAction
(
onPressed:
()
{},
child:
const
Text
(
'NO'
),
),
CupertinoDialogAction
(
onPressed:
()
{},
child:
const
Text
(
'OK'
),
),
],
),
),
);
},
),
);
await
tester
.
tap
(
find
.
text
(
'Go'
));
await
tester
.
pumpAndSettle
();
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
const
Offset
(
10
,
10
));
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
final
Offset
dialogAction
=
tester
.
getCenter
(
find
.
text
(
'OK'
));
await
gesture
.
moveTo
(
dialogAction
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
kIsWeb
?
SystemMouseCursors
.
click
:
SystemMouseCursors
.
basic
,
);
});
}
RenderBox
findActionButtonRenderBoxByTitle
(
WidgetTester
tester
,
String
title
)
{
...
...
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