Skip to content

Commit

Permalink
fix(vibration): conditionally check Vibration.hasVibrator based on …
Browse files Browse the repository at this point in the history
…user settings

The `Vibration.hasVibrator` check will now only happen if the user has enabled hitVibration in the helperline configs. This resolves issue [#139](https://github.com/hm21/pro_image_editor/issue/139).
  • Loading branch information
hm21 committed Jun 26, 2024
1 parent 721f072 commit 90c848c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## Version 4.1.1
- **fix(vibration)**: The `Vibration.hasVibrator` check will now only happen if the user has enabled hitVibration in the helperline configs. This resolves issue [#139](https://github.com/hm21/pro_image_editor/issue/139).

## Version 4.1.0
- **feat(zoom)**: Paint-Editor and Main-Editor are now zoomable. An example of how to enable this can be found [here](https://github.com/hm21/pro_image_editor/blob/74982d6c8e3e3d2d16e8f77821f9bcd839863c23/example/lib/pages/zoom_move_editor_example.dart)
- **feat(zoom)**: Paint-Editor and Main-Editor are now zoomable. An example of how to enable this can be found [here](https://github.com/hm21/pro_image_editor/blob/stable/example/lib/pages/zoom_move_editor_example.dart)

## Version 4.0.10
- **feat(text-editor)**: Add autocorrect and enableSuggestions configs. This was requsted in [#132](https://github.com/hm21/pro_image_editor/issues/132)
Expand Down
17 changes: 13 additions & 4 deletions lib/modules/main_editor/main_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,19 @@ class ProImageEditorState extends State<ProImageEditor>
filters: [],
));

Vibration.hasVibrator().then(
(value) => layerInteractionManager.deviceCanVibrate = value ?? false);
Vibration.hasCustomVibrationsSupport().then((value) =>
layerInteractionManager.deviceCanCustomVibrate = value ?? false);
if (helperLines.hitVibration) {
Vibration.hasVibrator().then((hasVibrator) {
layerInteractionManager.deviceCanVibrate = hasVibrator ?? false;

if (layerInteractionManager.deviceCanVibrate) {
Vibration.hasCustomVibrationsSupport()
.then((hasCustomVibrationsSupport) {
layerInteractionManager.deviceCanCustomVibrate =
hasCustomVibrationsSupport ?? false;
});
}
});
}

ServicesBinding.instance.keyboard.addHandler(_onKeyEvent);
if (kIsWeb) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pro_image_editor
description: "A Flutter image editor: Seamlessly enhance your images with user-friendly editing features."
version: 4.1.0
version: 4.1.1
homepage: https://github.com/hm21/pro_image_editor/
repository: https://github.com/hm21/pro_image_editor/
issue_tracker: https://github.com/hm21/pro_image_editor/issues/
Expand Down
4 changes: 2 additions & 2 deletions test/widgets/layer_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void main() {
editorCenterY: 250,
layerData: layer,
configs: const ProImageEditorConfigs(),
onTap: (Layer layer) {
expect(layer, equals(layer));
onTap: (Layer tapLayer) {
expect(layer, equals(tapLayer));
},
),
],
Expand Down

0 comments on commit 90c848c

Please sign in to comment.