Add error haptic feedback to showErrorDialog - #2342
Conversation
|
Thank you for this PR @sharayuwadghule! This looks promising. Please make the following changes so that this PR is reviewable by the maintainers:
|
5209ea7 to
505e167
Compare
|
@Ruhdee Thanks for the review! I've updated the commit message to follow the commit-discipline guidelines and moved the haptic feedback verification into a dedicated test in the I've also reviewed the AI-use policy and verified the implementation and test behavior myself. The test suite passes successfully. Please let me know if there are any other changes needed. |
Ruhdee
left a comment
There was a problem hiding this comment.
Thank you for the revision! Some small comments below:
| return null; | ||
| }, | ||
| ); |
There was a problem hiding this comment.
nit:
| return null; | |
| }, | |
| ); | |
| return null; | |
| }); |
There was a problem hiding this comment.
Bumping this again, we generally prefer to avoid this code style pattern (unnecessary trailing comma + newline + closing-parenthesis).
| ..has((c) => c.method, 'method').equals('HapticFeedback.vibrate') | ||
| ..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification')); |
There was a problem hiding this comment.
It is more idiomatic to add extensions in this codebase so that we can cascade properties and check directly:
extension MethodCallChecks on Subject<MethodCall> {
Subject<String> get method => has((c) => c.method, 'method');
Subject<Object?> get arguments => has((c) => c.arguments as Object?, 'arguments');
}
I believe the 'flutter/services.dart' section of test/flutter_checks.dart would be the right location for it.
| check(calls).any((it) => it | ||
| ..has((c) => c.method, 'method').equals('HapticFeedback.vibrate') | ||
| ..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification')); |
There was a problem hiding this comment.
I think there is only one method call being received, so why not something like this:
| check(calls).any((it) => it | |
| ..has((c) => c.method, 'method').equals('HapticFeedback.vibrate') | |
| ..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification')); | |
| check(calls).single | |
| ..method.equals('HapticFeedback.vibrate') | |
| ..arguments.equals('HapticFeedbackType.errorNotification'); |
505e167 to
6965eaf
Compare
|
@Ruhdee Updated, thanks for the suggestion. |
|
There are a lot of unrelated formatting changes. Please revert them. |
51d9673 to
d4aa384
Compare
|
@Ruhdee Thanks! I've addressed the comments and reverted the unrelated formatting changes. |
Ruhdee
left a comment
There was a problem hiding this comment.
I strongly urge you to self-review your code before asking others for review. The changes given below could have easily been spotted in a self-review!🙂
| FirebaseInstallations: 4e6e162aa4abaaeeeb01dd00179dfc5ad9c2194e | ||
| FirebaseMessaging: 341004946fa7ffc741344b20f1b667514fc93e31 | ||
| Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 | ||
| Flutter: 71a624a5bc0c04062bf19101d501e466baf2fb47 |
There was a problem hiding this comment.
Revert this unrelated change.
| import 'package:flutter/services.dart'; | ||
|
|
||
|
|
||
| import '../generated/l10n/zulip_localizations.dart'; |
There was a problem hiding this comment.
nit:
| import 'package:flutter/services.dart'; | |
| import '../generated/l10n/zulip_localizations.dart'; | |
| import 'package:flutter/services.dart'; | |
| import '../generated/l10n/zulip_localizations.dart'; |
|
Also, the commit author email has a malformed domain. Please fix it or the commit won't be attributed to you. |
f0674cf to
f4c2a68
Compare
|
@Ruhdee Thanks! I've reverted the unintended |
|
Thanks! The CI failures do seem to be unrelated to this PR. Moving to maintainer review. |
rajveermalviya
left a comment
There was a problem hiding this comment.
Thanks for working on this @sharayuwadghule! Overall LGTM, just one nit below.
| final messenger = tester.binding.defaultBinaryMessenger; | ||
| messenger.setMockMethodCallHandler(SystemChannels.platform, (methodCall) async { | ||
| calls.add(methodCall); | ||
| return null; | ||
| }); |
There was a problem hiding this comment.
nit: inline variable
| final messenger = tester.binding.defaultBinaryMessenger; | |
| messenger.setMockMethodCallHandler(SystemChannels.platform, (methodCall) async { | |
| calls.add(methodCall); | |
| return null; | |
| }); | |
| tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( | |
| SystemChannels.platform, | |
| (methodCall) async { | |
| calls.add(methodCall); | |
| return null; | |
| }); |
f4c2a68 to
6c1064f
Compare
|
@rajveermalviya addressed! thanks. |
rajveermalviya
left a comment
There was a problem hiding this comment.
Thanks for the revision! And thanks @Ruhdee for previous reviews. Just one nit below, otherwise looks good.
Moving over to Chris's review.
| return null; | ||
| }, | ||
| ); |
There was a problem hiding this comment.
Bumping this again, we generally prefer to avoid this code style pattern (unnecessary trailing comma + newline + closing-parenthesis).
6c1064f to
b5e8358
Compare
|
@rajveermalviya Thanks for pointing this out. I've fixed the formatting issue and pushed the changes. |
chrisbobbe
left a comment
There was a problem hiding this comment.
Thanks @sharayuwadghule, and thanks @Ruhdee and @rajveermalviya for the reviews! Small comments below.
| String? message, | ||
| Uri? learnMoreButtonUrl, | ||
| }) { | ||
| HapticFeedback.errorNotification(); |
There was a problem hiding this comment.
Let's mention this new behavior in the dartdoc of showErrorDialog.
| check(calls).single | ||
| ..method.equals('HapticFeedback.vibrate') | ||
| ..arguments.equals('HapticFeedbackType.errorNotification'); |
There was a problem hiding this comment.
I think this can just be:
check(calls).single.isMethodCall('HapticFeedback.vibrate',
arguments: 'HapticFeedbackType.errorNotification');
with no need for our own MethodCallChecks in test/flutter_checks.dart.
| tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform, | ||
| (methodCall) async { | ||
| calls.add(methodCall); | ||
| return null; | ||
| }); |
There was a problem hiding this comment.
I think we need an addTearDown for this?
b5e8358 to
3fa6dbd
Compare
|
@chrisbobbe Thanks for the review! Addressed all the comments:
|
chrisbobbe
left a comment
There was a problem hiding this comment.
Thanks! Just a few nits below.
| /// Displays an [AlertDialog] with a dismiss button | ||
| /// and optional "Learn more" button. | ||
| /// | ||
| /// Triggers error haptic feedback notification when shown. |
There was a problem hiding this comment.
nit: can say the same thing in fewer words, e.g.:
| /// Displays an [AlertDialog] with a dismiss button | |
| /// and optional "Learn more" button. | |
| /// | |
| /// Triggers error haptic feedback notification when shown. | |
| /// Displays an [AlertDialog] with a dismiss button | |
| /// and optional "Learn more" button, and gives haptic feedback. |
| import 'package:zulip/model/settings.dart'; | ||
| import 'package:zulip/widgets/app.dart'; | ||
| import 'package:zulip/widgets/dialog.dart'; | ||
|
|
There was a problem hiding this comment.
Don't remove this blank line, which separates package: imports from relative imports.
| tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform, | ||
| null, | ||
| ); |
There was a problem hiding this comment.
nit: can use fewer lines:
| tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( | |
| SystemChannels.platform, | |
| null, | |
| ); | |
| tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( | |
| SystemChannels.platform, null); |
3fa6dbd to
ba220b2
Compare
|
@chrisbobbe Thanks! Done with the expected changes. |
| check(calls).single.isMethodCall( | ||
| 'HapticFeedback.vibrate', | ||
| arguments: 'HapticFeedbackType.errorNotification', | ||
| ); |
There was a problem hiding this comment.
Bump on code style from #2342 (comment) (use two lines instead of four)
|
@chrisbobbe dart format reformats this back to four lines. Is there a formatter setting or different style you'd prefer here? |
|
What does the project README say about |
ba220b2 to
6d72e05
Compare
|
@chrisbobbe I checked the README,it explicitly says not to use dart format and to follow the repository's existing style. I'll update this to match the two-line formatting from #2342. Thanks! |
|
If you rebase atop current |
|
@chrisbobbe I rebased onto the current main and confirmed that my branch was already up to date. The CI log I initially checked was for the older commit c086365 and failed because pod install modified ios/Podfile.lock. The latest CI run is now testing my updated commit, but the iOS job is still failing, so I'll check the latest job's error details. |
|
I triggered a rerun of the CI jobs; hopefully that fixes it. |
|
Did you |
Previously, showErrorDialog provided only visual feedback when displaying an error. This can make error notifications easier to miss on devices that support haptic feedback. Call HapticFeedback.errorNotification() when showing an error dialog so users receive platform-appropriate tactile feedback in addition to the visual dialog. Fixes zulip#2338.
6d72e05 to
30443ef
Compare
|
@chrisbobbe Thanks, fixed - I had fetched from |
Add error haptic feedback when displaying an error dialog.
Currently,
showErrorDialogprovides only visual feedback. This change callsHapticFeedback.errorNotification()when showing an error dialog, providing platform-appropriate tactile feedback on Android and iOS.As requested in the issue, the change is scoped only to
showErrorDialogand does not affectshowSuggestedActionDialog.Fixes #2338
Testing
test/widgets/dialog_test.dart.HapticFeedback.vibratecall withHapticFeedbackType.errorNotification.