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

fix: 🐛 Fixed target hit area #409

Merged
merged 1 commit into from
Mar 7, 2024
Merged
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
43 changes: 20 additions & 23 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class _ShowcaseState extends State<Showcase> {
if (_isScrollRunning) Center(child: widget.scrollLoadingWidget),
if (!_isScrollRunning) ...[
_TargetWidget(
offset: offset,
offset: rectBound.topLeft,
size: size,
onTap: _getOnTargetTap,
radius: widget.targetBorderRadius,
Expand Down Expand Up @@ -626,20 +626,20 @@ class _ShowcaseState extends State<Showcase> {

class _TargetWidget extends StatelessWidget {
final Offset offset;
final Size? size;
final Size size;
final VoidCallback? onTap;
final VoidCallback? onDoubleTap;
final VoidCallback? onLongPress;
final ShapeBorder? shapeBorder;
final ShapeBorder shapeBorder;
final BorderRadius? radius;
final bool disableDefaultChildGestures;

const _TargetWidget({
Key? key,
required this.offset,
this.size,
required this.size,
required this.shapeBorder,
this.onTap,
this.shapeBorder,
this.radius,
this.onDoubleTap,
this.onLongPress,
Expand All @@ -649,34 +649,31 @@ class _TargetWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Positioned(
//TODO: Add target padding in major version upgrade
top: offset.dy,
left: offset.dx,
child: disableDefaultChildGestures
? IgnorePointer(
? AbsorbPointer(
child: targetWidgetContent(),
)
: targetWidgetContent(),
);
}

Widget targetWidgetContent() {
return FractionalTranslation(
translation: const Offset(-0.5, -0.5),
child: GestureDetector(
onTap: onTap,
onLongPress: onLongPress,
onDoubleTap: onDoubleTap,
child: Container(
height: size!.height + 16,
width: size!.width + 16,
decoration: ShapeDecoration(
shape: radius != null
? RoundedRectangleBorder(borderRadius: radius!)
: shapeBorder ??
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
),
return GestureDetector(
onTap: onTap,
onLongPress: onLongPress,
onDoubleTap: onDoubleTap,
child: Container(
//TODO: Add target padding in major version upgrade and
// remove default 16 padding from this widget
height: size.height + 16,
width: size.width + 16,
decoration: ShapeDecoration(
shape: radius != null
? RoundedRectangleBorder(borderRadius: radius!)
: shapeBorder,
),
),
);
Expand Down
Loading