-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zoom): add zoom functionality to Paint-Editor and Main-Editor
Refer to the example implementation [here](https://github.com/hm21/pro_image_editor/blob/74982d6c8e3e3d2d16e8f77821f9bcd839863c23/example/lib/pages/zoom_move_editor_example.dart) for details on enabling the zoom feature.
- Loading branch information
Showing
26 changed files
with
863 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Flutter imports: | ||
import 'package:flutter/material.dart'; | ||
import 'package:pro_image_editor/models/editor_configs/main_editor_configs.dart'; | ||
|
||
// Package imports: | ||
import 'package:pro_image_editor/pro_image_editor.dart'; | ||
|
||
// Project imports: | ||
import '../utils/example_constants.dart'; | ||
import '../utils/example_helper.dart'; | ||
|
||
class ZoomMoveEditorExample extends StatefulWidget { | ||
const ZoomMoveEditorExample({super.key}); | ||
|
||
@override | ||
State<ZoomMoveEditorExample> createState() => _ZoomMoveEditorExampleState(); | ||
} | ||
|
||
class _ZoomMoveEditorExampleState extends State<ZoomMoveEditorExample> | ||
with ExampleHelperState<ZoomMoveEditorExample> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return ListTile( | ||
onTap: () async { | ||
await precacheImage( | ||
AssetImage(ExampleConstants.of(context)!.demoAssetPath), context); | ||
if (!context.mounted) return; | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => _buildEditor(), | ||
), | ||
); | ||
}, | ||
leading: const Icon(Icons.zoom_in), | ||
title: const Text('Zoom in Paint and Main Editor'), | ||
trailing: const Icon(Icons.chevron_right), | ||
); | ||
} | ||
|
||
Widget _buildEditor() { | ||
return ProImageEditor.asset( | ||
ExampleConstants.of(context)!.demoAssetPath, | ||
key: editorKey, | ||
callbacks: ProImageEditorCallbacks( | ||
onImageEditingStarted: onImageEditingStarted, | ||
onImageEditingComplete: onImageEditingComplete, | ||
onCloseEditor: onCloseEditor, | ||
), | ||
configs: ProImageEditorConfigs( | ||
designMode: platformDesignMode, | ||
mainEditorConfigs: const MainEditorConfigs( | ||
editorIsZoomable: true, | ||
), | ||
paintEditorConfigs: const PaintEditorConfigs( | ||
editorIsZoomable: true, | ||
), | ||
icons: const ImageEditorIcons( | ||
paintingEditor: IconsPaintingEditor( | ||
moveAndZoom: Icons.pinch_outlined, | ||
), | ||
), | ||
i18n: const I18n( | ||
paintEditor: I18nPaintingEditor( | ||
moveAndZoom: 'Zoom', | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// Configuration options for a main editor. | ||
class MainEditorConfigs { | ||
/// Indicates whether the editor supports zoom functionality. | ||
/// | ||
/// When set to `true`, the editor allows users to zoom in and out, providing | ||
/// enhanced accessibility and usability, especially on smaller screens or for | ||
/// users with visual impairments. If set to `false`, the zoom functionality | ||
/// is disabled, and the editor's content remains at a fixed scale. | ||
/// | ||
/// Default value is `false`. | ||
final bool editorIsZoomable; | ||
|
||
/// The minimum scale factor for the editor. | ||
/// | ||
/// This value determines the lowest level of zoom that can be applied to the | ||
/// editor content. It only has an effect when [editorIsZoomable] is set to `true`. | ||
/// If [editorIsZoomable] is `false`, this value is ignored. | ||
/// | ||
/// Default value is 1.0. | ||
final double editorMinScale; | ||
|
||
/// The maximum scale factor for the editor. | ||
/// | ||
/// This value determines the highest level of zoom that can be applied to the | ||
/// editor content. It only has an effect when [editorIsZoomable] is set to `true`. | ||
/// If [editorIsZoomable] is `false`, this value is ignored. | ||
/// | ||
/// Default value is 5.0. | ||
final double editorMaxScale; | ||
|
||
/// Creates an instance of MainEditorConfigs with optional settings. | ||
const MainEditorConfigs({ | ||
this.editorIsZoomable = false, | ||
this.editorMinScale = 1.0, | ||
this.editorMaxScale = 5.0, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.