CupertinoActionSheet
/CupertinoAlertDialog
: Add clickable cursor for web (#99548)
This commit is contained in:
parent
712abb08e2
commit
d2cb63c8fa
@ -703,25 +703,28 @@ class CupertinoActionSheetAction extends StatelessWidget {
|
|||||||
style = style.copyWith(fontWeight: FontWeight.w600);
|
style = style.copyWith(fontWeight: FontWeight.w600);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return MouseRegion(
|
||||||
onTap: onPressed,
|
cursor: onPressed != null && kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
|
||||||
behavior: HitTestBehavior.opaque,
|
child: GestureDetector(
|
||||||
child: ConstrainedBox(
|
onTap: onPressed,
|
||||||
constraints: const BoxConstraints(
|
behavior: HitTestBehavior.opaque,
|
||||||
minHeight: _kActionSheetButtonHeight,
|
child: ConstrainedBox(
|
||||||
),
|
constraints: const BoxConstraints(
|
||||||
child: Semantics(
|
minHeight: _kActionSheetButtonHeight,
|
||||||
button: true,
|
),
|
||||||
child: Container(
|
child: Semantics(
|
||||||
alignment: Alignment.center,
|
button: true,
|
||||||
padding: const EdgeInsets.symmetric(
|
child: Container(
|
||||||
vertical: 16.0,
|
alignment: Alignment.center,
|
||||||
horizontal: 10.0,
|
padding: const EdgeInsets.symmetric(
|
||||||
),
|
vertical: 16.0,
|
||||||
child: DefaultTextStyle(
|
horizontal: 10.0,
|
||||||
style: style,
|
),
|
||||||
textAlign: TextAlign.center,
|
child: DefaultTextStyle(
|
||||||
child: child,
|
style: style,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1751,18 +1754,21 @@ class CupertinoDialogAction extends StatelessWidget {
|
|||||||
content: child,
|
content: child,
|
||||||
);
|
);
|
||||||
|
|
||||||
return GestureDetector(
|
return MouseRegion(
|
||||||
excludeFromSemantics: true,
|
cursor: onPressed != null && kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
|
||||||
onTap: onPressed,
|
child: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
excludeFromSemantics: true,
|
||||||
child: ConstrainedBox(
|
onTap: onPressed,
|
||||||
constraints: const BoxConstraints(
|
behavior: HitTestBehavior.opaque,
|
||||||
minHeight: _kDialogMinButtonHeight,
|
child: ConstrainedBox(
|
||||||
),
|
constraints: const BoxConstraints(
|
||||||
child: Container(
|
minHeight: _kDialogMinButtonHeight,
|
||||||
alignment: Alignment.center,
|
),
|
||||||
padding: EdgeInsets.all(_calculatePadding(context)),
|
child: Container(
|
||||||
child: sizedContent,
|
alignment: Alignment.center,
|
||||||
|
padding: EdgeInsets.all(_calculatePadding(context)),
|
||||||
|
child: sizedContent,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -9,7 +9,10 @@
|
|||||||
@Tags(<String>['no-shuffle'])
|
@Tags(<String>['no-shuffle'])
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -1070,6 +1073,39 @@ void main() {
|
|||||||
// one for the content.
|
// one for the content.
|
||||||
expect(find.byType(CupertinoScrollbar), findsNWidgets(2));
|
expect(find.byType(CupertinoScrollbar), findsNWidgets(2));
|
||||||
}, variant: TargetPlatformVariant.all());
|
}, 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) {
|
RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) {
|
||||||
|
@ -12,6 +12,7 @@ import 'dart:ui';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
@ -1441,6 +1442,51 @@ void main() {
|
|||||||
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(390.0, 600.0));
|
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) {
|
RenderBox findActionButtonRenderBoxByTitle(WidgetTester tester, String title) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user