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:
2026-04-23 11:12:04 +02:00
co-authored by Claude Opus 4.6
parent 85b222efc3
commit c9870bb044
3 changed files with 45 additions and 21 deletions
+35
View File
@@ -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),
),
);
}
}