Skip to content
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

Added disableDoubleTap property #567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_classes_with_only_static_members
- avoid_empty_else
Expand All @@ -27,10 +26,8 @@ linter:
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
Expand All @@ -46,7 +43,6 @@ linter:
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_final_locals
- prefer_foreach
Expand Down
4 changes: 0 additions & 4 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_classes_with_only_static_members
- avoid_empty_else
Expand All @@ -27,10 +26,8 @@ linter:
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
Expand All @@ -46,7 +43,6 @@ linter:
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_final_locals
- prefer_foreach
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void main() => runApp(MyApp());

ThemeData theme = ThemeData(
primaryColor: Colors.black,
backgroundColor: Colors.white10,
scaffoldBackgroundColor: Colors.white10,
fontFamily: 'PTSans',
);

Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/common/example_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ExampleButtonNode extends StatelessWidget {
onPressed: onPressed,
child: const Text("Open example"),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.amber),
backgroundColor: WidgetStateProperty.all(Colors.amber),
),
),
)
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class HomeScreen extends StatelessWidget {
{required String text, required VoidCallback onPressed}) {
return TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(vertical: 25.0, horizontal: 20.0),
),
),
Expand Down
13 changes: 11 additions & 2 deletions lib/photo_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class PhotoView extends StatefulWidget {
this.tightMode,
this.filterQuality,
this.disableGestures,
this.disableDoubleTap,
this.errorBuilder,
this.enablePanAlways,
this.strictScale,
Expand Down Expand Up @@ -297,6 +298,7 @@ class PhotoView extends StatefulWidget {
this.tightMode,
this.filterQuality,
this.disableGestures,
this.disableDoubleTap,
this.enablePanAlways,
this.strictScale,
}) : errorBuilder = null,
Expand Down Expand Up @@ -404,10 +406,15 @@ class PhotoView extends StatefulWidget {
/// Quality levels for image filters.
final FilterQuality? filterQuality;

// Removes gesture detector if `true`.
// Useful when custom gesture detector is used in child widget.
/// Removes the gesture detector when 'true', disabling all gesture-based commands.
/// This is useful if a custom gesture detector is implemented in a child widget.
final bool? disableGestures;

/// Disables double-tap gesture when `true`. This disables the scale state cycle.
/// Useful for assigning another command to the double-tap gesture.
/// This property is ignored if [disableGestures] is true.
final bool? disableDoubleTap;

/// Enable pan the widget even if it's smaller than the hole parent widget.
/// Useful when you want to drag a widget without restrictions.
final bool? enablePanAlways;
Expand Down Expand Up @@ -534,6 +541,7 @@ class _PhotoViewState extends State<PhotoView>
tightMode: widget.tightMode,
filterQuality: widget.filterQuality,
disableGestures: widget.disableGestures,
disableDoubleTap: widget.disableDoubleTap,
enablePanAlways: widget.enablePanAlways,
strictScale: widget.strictScale,
)
Expand Down Expand Up @@ -561,6 +569,7 @@ class _PhotoViewState extends State<PhotoView>
tightMode: widget.tightMode,
filterQuality: widget.filterQuality,
disableGestures: widget.disableGestures,
disableDoubleTap: widget.disableDoubleTap,
errorBuilder: widget.errorBuilder,
enablePanAlways: widget.enablePanAlways,
strictScale: widget.strictScale,
Expand Down
5 changes: 4 additions & 1 deletion lib/src/core/photo_view_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PhotoViewCore extends StatefulWidget {
required this.tightMode,
required this.filterQuality,
required this.disableGestures,
required this.disableDoubleTap,
required this.enablePanAlways,
required this.strictScale,
}) : customChild = null,
Expand All @@ -64,6 +65,7 @@ class PhotoViewCore extends StatefulWidget {
required this.tightMode,
required this.filterQuality,
required this.disableGestures,
required this.disableDoubleTap,
required this.enablePanAlways,
required this.strictScale,
}) : imageProvider = null,
Expand Down Expand Up @@ -92,6 +94,7 @@ class PhotoViewCore extends StatefulWidget {
final HitTestBehavior? gestureDetectorBehavior;
final bool tightMode;
final bool disableGestures;
final bool disableDoubleTap;
final bool enablePanAlways;
final bool strictScale;

Expand Down Expand Up @@ -355,7 +358,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>

return PhotoViewGestureDetector(
child: child,
onDoubleTap: nextScaleState,
onDoubleTap: widget.disableDoubleTap == true ? null : nextScaleState,
onScaleStart: onScaleStart,
onScaleUpdate: onScaleUpdate,
onScaleEnd: onScaleEnd,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/photo_view_wrappers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ImageWrapper extends StatefulWidget {
required this.tightMode,
required this.filterQuality,
required this.disableGestures,
required this.disableDoubleTap,
required this.errorBuilder,
required this.enablePanAlways,
required this.strictScale,
Expand Down Expand Up @@ -60,6 +61,7 @@ class ImageWrapper extends StatefulWidget {
final bool? tightMode;
final FilterQuality? filterQuality;
final bool? disableGestures;
final bool? disableDoubleTap;
final bool? enablePanAlways;
final bool? strictScale;

Expand Down Expand Up @@ -203,6 +205,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
tightMode: widget.tightMode ?? false,
filterQuality: widget.filterQuality ?? FilterQuality.none,
disableGestures: widget.disableGestures ?? false,
disableDoubleTap: widget.disableDoubleTap ?? false,
enablePanAlways: widget.enablePanAlways ?? false,
);
}
Expand Down Expand Up @@ -253,6 +256,7 @@ class CustomChildWrapper extends StatelessWidget {
required this.tightMode,
required this.filterQuality,
required this.disableGestures,
required this.disableDoubleTap,
required this.enablePanAlways,
required this.strictScale,
}) : super(key: key);
Expand Down Expand Up @@ -281,6 +285,7 @@ class CustomChildWrapper extends StatelessWidget {
final bool? tightMode;
final FilterQuality? filterQuality;
final bool? disableGestures;
final bool? disableDoubleTap;
final bool? enablePanAlways;
final bool? strictScale;

Expand Down Expand Up @@ -312,6 +317,7 @@ class CustomChildWrapper extends StatelessWidget {
tightMode: tightMode ?? false,
filterQuality: filterQuality ?? FilterQuality.none,
disableGestures: disableGestures ?? false,
disableDoubleTap: disableDoubleTap ?? false,
enablePanAlways: enablePanAlways ?? false,
);
}
Expand Down