extract ClideTappable shared widget
Encapsulates the hover + click + cursor pattern repeated across the codebase. Builder receives (context, hovered) so callers control their own hover styling. Refactored _ThemeLink to use it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class ClideTappable extends StatefulWidget {
|
||||
const ClideTappable({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.builder,
|
||||
this.cursor = SystemMouseCursors.click,
|
||||
});
|
||||
|
||||
final VoidCallback onTap;
|
||||
final Widget Function(BuildContext context, bool hovered) builder;
|
||||
final MouseCursor cursor;
|
||||
|
||||
@override
|
||||
State<ClideTappable> createState() => _ClideTappableState();
|
||||
}
|
||||
|
||||
class _ClideTappableState extends State<ClideTappable> {
|
||||
bool _hover = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
cursor: widget.cursor,
|
||||
onEnter: (_) => setState(() => _hover = true),
|
||||
onExit: (_) => setState(() => _hover = false),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: widget.onTap,
|
||||
child: widget.builder(context, _hover),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user