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

touchable need to accpect canvas transform data. #57

Open
gzlock opened this issue Jul 10, 2023 · 3 comments
Open

touchable need to accpect canvas transform data. #57

gzlock opened this issue Jul 10, 2023 · 3 comments

Comments

@gzlock
Copy link

gzlock commented Jul 10, 2023

The canvas transform(translate, scale, clilpRect) has no effect on TouchyCanvas
demo

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

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CanvasTouchDetector(
        builder: (context) => CustomPaint(painter: MyPainter(context)));
  }
}

class MyPainter extends CustomPainter {
  final BuildContext context;

  MyPainter(this.context);

  @override
  void paint(Canvas canvas, Size size) {
    canvas.scale(10);
    canvas.translate(50, 50);
    /// set the transform before create the TouchyCanvas
    var myCanvas = TouchyCanvas(context, canvas);
    myCanvas.drawCircle(Offset(10, 10), 60, Paint()..color = Colors.orange,
        onTapDown: (tapdetail) {
      print("orange Circle touched");
    }, onPanDown: (tapdetail) {
      print("orange circle swiped");
    });
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
@gzlock
Copy link
Author

gzlock commented Jul 10, 2023

Sorry, I just saw the roadmap after posting this issue, hope can support canvas transform sooner.

@morgano86
Copy link

morgano86 commented Jul 12, 2023

Issue also reported here: #53

@sonnyvesali
Copy link

@gzlock If your painting isn't super complex you can wrap your canvas in a GestureDetector widget and make your paintings pseudo- interact-able that way, it's kind of a workaround and doesn't work for more complex use cases but figured I'd mention it for anyone else who's running into this bottleneck.

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

No branches or pull requests

3 participants