Skip to content

Commit

Permalink
ported zoom logic from aves fork, upper flutter limit, fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NANI-SORE committed Oct 13, 2024
1 parent 562c040 commit 410b4c2
Show file tree
Hide file tree
Showing 20 changed files with 737 additions and 1,017 deletions.
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
4 changes: 2 additions & 2 deletions example/lib/screens/examples/dialog_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _DialogExampleState extends State<DialogExample> {
shape: const ContinuousRectangleBorder(),
builder: (BuildContext context) {
return PhotoViewGestureDetectorScope(
axis: Axis.vertical,
axis: const [Axis.vertical],
child: PhotoView(
backgroundDecoration: BoxDecoration(
color: Colors.black.withAlpha(240),
Expand All @@ -49,7 +49,7 @@ class _DialogExampleState extends State<DialogExample> {
child: Container(
height: 250,
child: PhotoViewGestureDetectorScope(
axis: Axis.vertical,
axis: const [Axis.vertical],
child: PhotoView(
tightMode: true,
imageProvider: const AssetImage("assets/large-image.jpg"),
Expand Down
7 changes: 4 additions & 3 deletions example/lib/screens/examples/gallery/gallery_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class _GalleryExampleState extends State<GalleryExample> {
color: Colors.black,
),
initialIndex: index,
scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal,
scrollDirection:
verticalGallery ? [Axis.vertical] : [Axis.horizontal],
),
),
);
Expand All @@ -90,7 +91,7 @@ class GalleryPhotoViewWrapper extends StatefulWidget {
this.maxScale,
this.initialIndex = 0,
required this.galleryItems,
this.scrollDirection = Axis.horizontal,
this.scrollDirection = const [Axis.horizontal],
}) : pageController = PageController(initialPage: initialIndex);

final LoadingBuilder? loadingBuilder;
Expand All @@ -100,7 +101,7 @@ class GalleryPhotoViewWrapper extends StatefulWidget {
final int initialIndex;
final PageController pageController;
final List<GalleryExampleItem> galleryItems;
final Axis scrollDirection;
final List<Axis> scrollDirection;

@override
State<StatefulWidget> createState() {
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
18 changes: 0 additions & 18 deletions lib/photo_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ class PhotoView extends StatefulWidget {
this.onTapUp,
this.onTapDown,
this.onScaleEnd,
this.enableDoubleTapZoom,
this.onDoubleTapZoomEnd,
this.enableTapDragZoom,
this.customSize,
this.gestureDetectorBehavior,
this.tightMode,
Expand Down Expand Up @@ -295,9 +292,6 @@ class PhotoView extends StatefulWidget {
this.onTapUp,
this.onTapDown,
this.onScaleEnd,
this.enableDoubleTapZoom,
this.onDoubleTapZoomEnd,
this.enableTapDragZoom,
this.customSize,
this.gestureDetectorBehavior,
this.tightMode,
Expand Down Expand Up @@ -400,12 +394,6 @@ class PhotoView extends StatefulWidget {
/// particular location.
final PhotoViewImageScaleEndCallback? onScaleEnd;

final bool? enableDoubleTapZoom;

final bool? enableTapDragZoom;

final PhotoViewDoubleTapZoomEndCallback? onDoubleTapZoomEnd;

/// [HitTestBehavior] to be passed to the internal gesture detector.
final HitTestBehavior? gestureDetectorBehavior;

Expand Down Expand Up @@ -541,9 +529,6 @@ class _PhotoViewState extends State<PhotoView>
onTapUp: widget.onTapUp,
onTapDown: widget.onTapDown,
onScaleEnd: widget.onScaleEnd,
enableDoubleTapZoom: widget.enableDoubleTapZoom,
onDoubleTapZoomEnd: widget.onDoubleTapZoomEnd,
enableTapDragZoom: widget.enableTapDragZoom,
outerSize: computedOuterSize,
gestureDetectorBehavior: widget.gestureDetectorBehavior,
tightMode: widget.tightMode,
Expand Down Expand Up @@ -571,9 +556,6 @@ class _PhotoViewState extends State<PhotoView>
onTapUp: widget.onTapUp,
onTapDown: widget.onTapDown,
onScaleEnd: widget.onScaleEnd,
enableDoubleTapZoom: widget.enableDoubleTapZoom,
onDoubleTapZoomEnd: widget.onDoubleTapZoomEnd,
enableTapDragZoom: widget.enableTapDragZoom,
outerSize: computedOuterSize,
gestureDetectorBehavior: widget.gestureDetectorBehavior,
tightMode: widget.tightMode,
Expand Down
28 changes: 4 additions & 24 deletions lib/photo_view_gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:photo_view/photo_view.dart'
show
LoadingBuilder,
PhotoView,
PhotoViewDoubleTapZoomEndCallback,
PhotoViewImageScaleEndCallback,
PhotoViewImageTapDownCallback,
PhotoViewImageTapUpCallback,
Expand Down Expand Up @@ -117,7 +116,7 @@ class PhotoViewGallery extends StatefulWidget {
this.scaleStateChangedCallback,
this.enableRotation = false,
this.scrollPhysics,
this.scrollDirection = Axis.horizontal,
this.scrollDirection = const [Axis.horizontal],
this.customSize,
this.allowImplicitScrolling = false,
}) : itemCount = null,
Expand All @@ -142,7 +141,7 @@ class PhotoViewGallery extends StatefulWidget {
this.scaleStateChangedCallback,
this.enableRotation = false,
this.scrollPhysics,
this.scrollDirection = Axis.horizontal,
this.scrollDirection = const [Axis.horizontal],
this.customSize,
this.allowImplicitScrolling = false,
}) : pageOptions = null,
Expand Down Expand Up @@ -195,7 +194,7 @@ class PhotoViewGallery extends StatefulWidget {
final Size? customSize;

/// The axis along which the [PageView] scrolls. Mirror to [PageView.scrollDirection]
final Axis scrollDirection;
final List<Axis> scrollDirection;

/// When user attempts to move it to the next element, focus will traverse to the next page in the page view.
final bool allowImplicitScrolling;
Expand Down Expand Up @@ -241,7 +240,7 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
onPageChanged: widget.onPageChanged,
itemCount: itemCount,
itemBuilder: _buildItem,
scrollDirection: widget.scrollDirection,
scrollDirection: widget.scrollDirection.first,
physics: widget.scrollPhysics,
allowImplicitScrolling: widget.allowImplicitScrolling,
),
Expand Down Expand Up @@ -272,9 +271,6 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
onTapUp: pageOption.onTapUp,
onTapDown: pageOption.onTapDown,
onScaleEnd: pageOption.onScaleEnd,
enableDoubleTapZoom: pageOption.enableDoubleTapZoom,
onDoubleTapZoomEnd: pageOption.onDoubleTapZoomEnd,
enableTapDragZoom: pageOption.enableTapDragZoom,
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
tightMode: pageOption.tightMode,
filterQuality: pageOption.filterQuality,
Expand Down Expand Up @@ -302,9 +298,6 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
onTapUp: pageOption.onTapUp,
onTapDown: pageOption.onTapDown,
onScaleEnd: pageOption.onScaleEnd,
enableDoubleTapZoom: pageOption.enableDoubleTapZoom,
onDoubleTapZoomEnd: pageOption.onDoubleTapZoomEnd,
enableTapDragZoom: pageOption.enableTapDragZoom,
gestureDetectorBehavior: pageOption.gestureDetectorBehavior,
tightMode: pageOption.tightMode,
filterQuality: pageOption.filterQuality,
Expand Down Expand Up @@ -347,9 +340,6 @@ class PhotoViewGalleryPageOptions {
this.onTapUp,
this.onTapDown,
this.onScaleEnd,
this.enableDoubleTapZoom,
this.onDoubleTapZoomEnd,
this.enableTapDragZoom,
this.gestureDetectorBehavior,
this.tightMode,
this.filterQuality,
Expand All @@ -374,9 +364,6 @@ class PhotoViewGalleryPageOptions {
this.onTapUp,
this.onTapDown,
this.onScaleEnd,
this.enableDoubleTapZoom,
this.onDoubleTapZoomEnd,
this.enableTapDragZoom,
this.gestureDetectorBehavior,
this.tightMode,
this.filterQuality,
Expand Down Expand Up @@ -429,13 +416,6 @@ class PhotoViewGalleryPageOptions {
/// Mirror to [PhotoView.onScaleEnd]
final PhotoViewImageScaleEndCallback? onScaleEnd;

final bool? enableDoubleTapZoom;

final bool? enableTapDragZoom;

/// Mirror to [PhotoView.onDoubleTapZoomEnd]
final PhotoViewDoubleTapZoomEndCallback? onDoubleTapZoomEnd;

/// Mirror to [PhotoView.gestureDetectorBehavior]
final HitTestBehavior? gestureDetectorBehavior;

Expand Down
Loading

0 comments on commit 410b4c2

Please sign in to comment.