-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[cupertino_ui] fix material_ui cross imports in cupertino_ui samples #12228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7c0e7b9
93f470a
4fcedb9
03795d7
8ea52a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ dependencies: | |
| test: ^1.31.0 | ||
| vector_math: ^2.2.0 | ||
| web: ^1.1.1 | ||
| cupertino_icons: ^1.0.9 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the examples were relying on the Material |
||
| cupertino_ui: | ||
| path: .. | ||
| material_ui: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not true, since there are |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,24 +3,15 @@ | |
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/rendering.dart'; | ||
| import 'package:material_ui/material_ui.dart'; | ||
| import 'package:cupertino_ui/cupertino_ui.dart'; | ||
| import 'package:cupertino_ui_examples/magnifier/text_magnifier.0.dart' | ||
| as example; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| List<TextSelectionPoint> _globalize( | ||
| Iterable<TextSelectionPoint> points, | ||
| RenderBox box, | ||
| ) { | ||
| return points.map<TextSelectionPoint>((TextSelectionPoint point) { | ||
| return TextSelectionPoint(box.localToGlobal(point.point), point.direction); | ||
| }).toList(); | ||
| } | ||
|
|
||
| RenderEditable _findRenderEditable<T extends State<StatefulWidget>>( | ||
| WidgetTester tester, | ||
| ) { | ||
| return (tester.state(find.byType(TextField)) | ||
| return (tester.state(find.byType(CupertinoTextField)) | ||
| as TextSelectionGestureDetectorBuilderDelegate) | ||
| .editableTextKey | ||
| .currentState! | ||
|
|
@@ -47,40 +38,16 @@ Offset _textOffsetToPosition<T extends State<StatefulWidget>>( | |
| } | ||
|
|
||
| void main() { | ||
| const Duration durationBetweenActions = Duration(milliseconds: 20); | ||
| const String defaultText = 'I am a magnifier, fear me!'; | ||
|
|
||
| Future<void> showMagnifier(WidgetTester tester, int textOffset) async { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For CupertinoTextField, instead of double tapping the word, I had to use long press to make it show up. |
||
| assert(textOffset >= 0); | ||
| final Offset tapOffset = _textOffsetToPosition(tester, textOffset); | ||
|
|
||
| // Double tap 'Magnifier' word to show the selection handles. | ||
| // Long press to show the magnifier. | ||
| final TestGesture testGesture = await tester.startGesture(tapOffset); | ||
| await tester.pump(durationBetweenActions); | ||
| await testGesture.up(); | ||
| await tester.pump(durationBetweenActions); | ||
| await testGesture.down(tapOffset); | ||
| await tester.pump(durationBetweenActions); | ||
| await testGesture.up(); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| final TextEditingController controller = tester | ||
| .firstWidget<TextField>(find.byType(TextField)) | ||
| .controller!; | ||
|
|
||
| final TextSelection selection = controller.selection; | ||
| final RenderEditable renderEditable = _findRenderEditable(tester); | ||
| final List<TextSelectionPoint> endpoints = _globalize( | ||
| renderEditable.getEndpointsForSelection(selection), | ||
| renderEditable, | ||
| ); | ||
|
|
||
| final Offset handlePos = endpoints.last.point + const Offset(10.0, 10.0); | ||
|
|
||
| final TestGesture gesture = await tester.startGesture(handlePos); | ||
|
|
||
| await gesture.moveTo(_textOffsetToPosition(tester, defaultText.length - 2)); | ||
| await tester.pump(); | ||
| addTearDown(testGesture.removePointer); | ||
| await tester.pump(const Duration(milliseconds: 600)); | ||
| } | ||
|
|
||
| testWidgets( | ||
|
|
@@ -89,8 +56,10 @@ void main() { | |
| await tester.pumpWidget( | ||
| const example.TextMagnifierExampleApp(text: defaultText), | ||
| ); | ||
| final int textOffset = defaultText.indexOf('e'); | ||
|
|
||
| await showMagnifier(tester, textOffset); | ||
|
|
||
| await showMagnifier(tester, defaultText.indexOf('e')); | ||
| expect(find.byType(example.CustomMagnifier), findsOneWidget); | ||
|
|
||
| await expectLater( | ||
|
|
@@ -113,7 +82,9 @@ void main() { | |
| const example.TextMagnifierExampleApp(textDirection: .rtl, text: text), | ||
| ); | ||
|
|
||
| await showMagnifier(tester, text.indexOf(textToTapOn)); | ||
| final int textOffset = text.indexOf(textToTapOn); | ||
|
|
||
| await showMagnifier(tester, textOffset); | ||
|
|
||
| expect(find.byType(example.CustomMagnifier), findsOneWidget); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was not disposed :(