bluefireteam / photo_view

📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.
MIT License
1.9k stars 546 forks source link

customChild is unable to receive touch event #88

Open cbenhagen opened 5 years ago

cbenhagen commented 5 years ago

In the following simple example I am unable to press the left or right button:

import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final List<String> buttonNames = ['left', 'middle', 'right'];

  @override
  Widget build(BuildContext context) {
    return PhotoView.customChild(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: buttonNames
            .map((n) => Container(
                  width: 100,
                  child: RaisedButton(
                      child: Text(n),
                      onPressed: () {
                        print('pressed $n');
                      }),
                ))
            .toList(),
      ),
      childSize: Size(1000, 200),
    );
  }
}
renancaraujo commented 5 years ago

The whole child of PhotoView.customChild will be wrapped in a GestureDetector. This bug is related to GestureArenaManager prioritizing the gestures in the built inGestureDetector. We should use RawGestureDetector.

cbenhagen commented 5 years ago

So why doesn't this happen with the middle button? Seemed more like a transform issue to me.

jvictorsoto commented 5 years ago

Any update on this?

renancaraujo commented 5 years ago

@jvictorsoto Unfortunately I have been unable to apply so much time working on PhotoView in the last month. So... nope, not much progress on this. But every bug tagged issue is a priority right now, including this very one.

renancaraujo commented 5 years ago

After some investigation, I've reached into https://github.com/flutter/flutter/issues/27587 and https://github.com/flutter/flutter/issues/25702

Hence it seems like a Flutter issue.

renancaraujo commented 5 years ago

It seems like will be solved at https://github.com/flutter/flutter/pull/32192

mendieta commented 5 years ago

Any idea if this issue on flutter has been solved? I'm using Channel beta, v1.6.3, and still can't tap on widgets inside the custom child

thomasostfeld commented 5 years ago

It seems like it wasn't related to that bugfix. This was merged into flutter master on Jun 1. But even now on the master channel the same issue keeps happening. Tested it with flutter v1.10.15-pre.23.

renancaraujo commented 4 years ago

No, it was not. But flutter/flutter#27587 and flutter/flutter#25702 are still open. I will try some workaround, but since this is a framework bug, I don't think we can do much here.

ueman commented 4 years ago

I don't really think this is a framework bug. For example

SingleChildScrollView(
  scrollDirection: Axis.horizontal,
  controller: horizontalScrollController,
  child: SingleChildScrollView(
    scrollDirection: Axis.vertical,
    controller: verticalScrollController,
    child: child, // must be big enough to be scrollable
  ),
)

This also hides Buttons which are not visible but you can scroll to them and click them. I guess one would need to adapt whatever is done in the SingleChildScrollViews and adapt it to this library.

renancaraujo commented 3 years ago

This also hides Buttons which are not visible but you can scroll to them and click them. I guess one would need to adapt whatever is done in the SingleChildScrollViews and adapt it to this library.

That is because scroll views work on a totally different way for a very different purpose. Scrolls uses the sliver protocol, that are basically made for that: scrolls in one axis.

Photo view uses simple matrix transformations, that happens after layout.

renancaraujo commented 3 years ago

Since there is no intention for the framework team to fix transformed gesture detectors, here is a tip for anyone facing this problem: try to wrap photo view with a gesture detector externally.

taskindrp commented 5 months ago

Since there is no intention for the framework team to fix transformed gesture detectors, here is a tip for anyone facing this problem: try to wrap photo view with a gesture detector externally.

what do you mean externally? can you give example?