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

Mouse hover event detection implementation #52

Open
wants to merge 2 commits into
base: master
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
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:example/screens/screen1.dart';
import 'package:example/screens/screen2.dart';
import 'package:example/screens/screen3.dart';
import 'package:flutter/material.dart';
import 'package:touchable/touchable.dart';

void main() {
runApp(MaterialApp(
Expand Down
22 changes: 13 additions & 9 deletions example/lib/screens/screen1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ class MyPainter extends CustomPainter {
void paint(Canvas _canvas, Size size) {
TouchyCanvas canvas = TouchyCanvas(context, _canvas);

canvas.drawCircle(Offset(0, 0), 60, Paint()..color = Colors.deepOrange, onTapDown: (_) {
print("orange Circle touched");
canvas.drawCircle(Offset(0, 0), 60, Paint()..color = Colors.deepOrange,
onTapDown: (_) {
print('orange Circle touched');
setState('orange');
});

Expand All @@ -87,7 +88,7 @@ class MyPainter extends CustomPainter {
..strokeWidth = 200
..style = PaintingStyle.stroke, onTapDown: (detail) {
setState('black');
print("black line touched");
print('black line touched');
});

canvas.drawOval(
Expand All @@ -96,7 +97,7 @@ class MyPainter extends CustomPainter {
..color = Colors.deepPurple
..style = PaintingStyle.stroke
..strokeWidth = 70, onTapDown: (_) {
print("purple oval touched");
print('purple oval touched');
setState('purple');
});

Expand All @@ -106,7 +107,7 @@ class MyPainter extends CustomPainter {
..color = Colors.deepOrange
..style = PaintingStyle.stroke
..strokeWidth = 50, onTapDown: (_) {
print("orange rect touched");
print('orange rect touched');
setState('orange');
});

Expand All @@ -115,11 +116,13 @@ class MyPainter extends CustomPainter {
..style = PaintingStyle.stroke
..strokeWidth = 10;
canvas.drawCircle(Offset(150, 50), 60, paint, onTapDown: (_) {
print("green Circle touched");
print('green Circle touched');
setState('green');
});

canvas.drawCircle(Offset(150, 250), 70, Paint()..color = Colors.lightBlueAccent, onTapDown: (_) {
canvas.drawCircle(
Offset(150, 250), 70, Paint()..color = Colors.lightBlueAccent,
onTapDown: (_) {
print('light blue Circle tap down');
setState('white');
}, onTapUp: (detail) {
Expand All @@ -145,11 +148,12 @@ class MyPainter extends CustomPainter {
..strokeWidth = 40
..color = Colors.grey, onTapDown: (_) {
setState('grey');
print("grey RRect touched");
print('grey RRect touched');
});

canvas.drawRRect(
RRect.fromLTRBR(100 - 20.0, 340 - 20.0, 300 + 20.0, 650 + 20.0, Radius.elliptical(100 + 20.0, 150 + 20.0)),
RRect.fromLTRBR(100 - 20.0, 340 - 20.0, 300 + 20.0, 650 + 20.0,
Radius.elliptical(100 + 20.0, 150 + 20.0)),
Paint()
..strokeWidth = 1
..style = PaintingStyle.stroke
Expand Down
23 changes: 11 additions & 12 deletions example/lib/screens/screen2.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:math';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:touchable/touchable.dart';

Expand Down Expand Up @@ -106,7 +104,7 @@ class MyPainter extends CustomPainter {
pi,
false,
Paint()..color = Colors.black, onTapDown: (detail) {
print("clicked");
print('clicked');
if (smileAnimation.value == 90) {
smileAnimationController.reverse();
}
Expand All @@ -116,11 +114,11 @@ class MyPainter extends CustomPainter {
void drawNose(TouchyCanvas canvas, Size size) {
var center = Offset(size.width / 2, size.height / 2);
var noseColor =
ColorTween(begin: Colors.blueGrey, end: Colors.lightBlueAccent).animate(
CurvedAnimation(
parent: noseAnimationController, curve: Curves.bounceOut));
ColorTween(begin: Colors.blueGrey, end: Colors.lightBlueAccent).animate(
CurvedAnimation(
parent: noseAnimationController, curve: Curves.bounceOut));
var noseLength =
Tween<double>(begin: 0, end: 100).animate(noseAnimationController);
Tween<double>(begin: 0, end: 100).animate(noseAnimationController);
var upperbound = noseAnimationController.upperBound;

void drawNose(Color color, double extraLength) {
Expand All @@ -132,12 +130,13 @@ class MyPainter extends CustomPainter {
Offset(center.dx + 15, center.dy + 25 + extraLength)
], true),
Paint()..color = color, onTapDown: (_) {
print("On Pan Down");
print('On Pan Down');
if (noseAnimationController.value == upperbound ||
noseAnimationController.status == AnimationStatus.forward) {
noseAnimationController.reverse();
} else
} else {
noseAnimationController.forward();
}
});
}

Expand All @@ -161,8 +160,8 @@ class MyPainter extends CustomPainter {
Offset(center.dx - xOffset, center.dy - 40), 10, Paint());
canvas.drawCircle(Offset(center.dx + xOffset, center.dy - 50), 20,
Paint()..color = Colors.transparent, onTapDown: (_) {
eyeAnimationController.reverse();
});
eyeAnimationController.reverse();
});
}

void drawEyeLid(double xOffset) {
Expand All @@ -186,4 +185,4 @@ class MyPainter extends CustomPainter {
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
}
5 changes: 2 additions & 3 deletions example/lib/screens/screen3.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ui';

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

Expand Down Expand Up @@ -73,7 +71,8 @@ class MyPainter extends CustomPainter {
void paint(Canvas _canvas, Size size) {
TouchyCanvas canvas = TouchyCanvas(context, _canvas);

canvas.drawRect(Rect.fromLTWH(0, 0, 100, 300), Paint()..color = Colors.blue, onTapDown: (_) {
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 300), Paint()..color = Colors.blue,
onTapDown: (_) {
setState('blue');
});
}
Expand Down
51 changes: 22 additions & 29 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,28 +21,21 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,7 +49,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,21 +66,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -99,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -120,41 +120,34 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.12"
touchable:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.0.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.18.1 <3.0.0"
14 changes: 0 additions & 14 deletions example/test/widget_test.dart

This file was deleted.

Loading