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

import features from jiangtian616 fork #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

yakagami
Copy link
Owner

@yakagami yakagami commented Dec 1, 2024

@jiangtian616 Thanks for adding these features. Could you explain what they do? Looks like you added a double tap to zoom feature and horizontal scrolling. Am I missing anything? Some questions:

  • What does TickerProviderStateMixin do here?
  • What is doubleTapScaleCircle? it seems to be a list of ints, but how does it work
  • I tried using double tap in your app but it didn't work for me, even after setting "Enable Double Tap to Scale Up"

Thanks!

(Also, I am thinking of expanding this package to include a fork of scrollable_positioned_list to make it easier for users. What do you think?)

@yakagami
Copy link
Owner Author

yakagami commented Dec 2, 2024

Ok, I realized the version I tested was still using PhotoViewGallery. I didn't know that package could handle zooming a ListView. I downloaded the latest github action apk and double tap does work, however there is a bug when you zoom in. Steps to reproduce:

  1. Zoom into an image regularly (eg. zoom in 3x)
  2. double-tap to zoom out (back to 1x)
  3. Zoom in again

Now when you do step 3. you will zoom in to the amount you were zoomed in at step 2. (3x) instead of 1x.

I also opened an issue here: jiangtian616/JHenTai#552

@jiangtian616
Copy link

I'm finding a way to deal with issue in bluefireteam/photo_view#392, and i notified your issue at flutter/flutter#135482, so i'm trying to figure out whether i can replace photo_view with zoom_view.

What i did:

  • Add Axis so it can provide a horizontal list.
  • Add a double tap gesture for zoom in.

What i'm doing:

  • Add an animation to the double tap gesture to make it smoother. I'm testing it with TickerProviderStateMixin.
  • Add a field doubleTapScaleCircle so developer can control the zoom circle. If we set it to [1, 2, 4], the zoom level will begin at 1x and cycle within 1x, 2x, 4x on double-tap.

I have not finished my code so there is still some bugs i think, so it can't be merged currently. Besides, I am busy with my real work so I might not have time to spend on this in December... If these features are implemented i think we can expand it to scrollable_positioned_list.

@yakagami
Copy link
Owner Author

yakagami commented Dec 2, 2024

I can try working on the double tap feature as I may have some free time soon. I think scrolling + zooming in flutter is really bad right now and I hope there will be a solution that everyone can use. I have opened multiple issues in the flutter repo (150598, 150963, 135482). It is not a priority for them right now, so I don't think we will get an official solution soon. That is why I want to improve this package so that others can use it.

(Also, feel free to ask me any question if you have any.)

@yakagami
Copy link
Owner Author

yakagami commented Dec 3, 2024

@jiangtian616 I added tap to zoom with animation and horizontal axis support (#4, #5) I also created a fork of scrollable_positioned_list here: https://github.com/yakagami/scrollable_positioned_list. The usage is a bit different from your version for double tap. Here is a full example:

Example
class ZoomViewExample extends StatefulWidget {
  const ZoomViewExample({super.key});

  @override
  State<ZoomViewExample> createState() => _ZoomViewExampleState();
}

class _ZoomViewExampleState extends State<ZoomViewExample> {
  ScrollController controller = ScrollController();
  //new
  ZoomViewGestureHandler handler = ZoomViewGestureHandler(zoomLevels: [2,1]);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ZoomView(
        controller: controller,
        //new
        onDoubleTapDown: (ZoomViewDetails zoomViewDetails){
          handler.onDoubleTap(zoomViewDetails);
        },
        child: ListView.builder(
            controller: controller,
            itemCount: 10000,
            itemBuilder: (context, index) {
              return Center(
                  child: Text("text $index")
              );
            }
        ),
      ),
    );
  }
}

When you have time and if you are interested, please let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants