Files
swiftcontrol/lib/widgets/ui/setting_tile.dart
Jonas Bark 25268df00d refactor(setting-tile): add onTap field; use Button.card for hover feedback
Replace the site-specific GestureDetector wrapping the Gear Settings
tile with an onTap on SettingTile itself. When set, the tile renders
via Button.card — giving the user proper hover feedback — instead of
the static Container. Other (non-tappable) tiles keep the existing
Container look.
2026-04-21 09:14:53 +02:00

88 lines
2.2 KiB
Dart

import 'package:shadcn_flutter/shadcn_flutter.dart';
class SettingTile extends StatelessWidget {
final IconData? icon;
final String title;
final String subtitle;
final Widget? trailing;
final Widget? child;
final VoidCallback? onTap;
const SettingTile({
super.key,
this.icon,
required this.title,
required this.subtitle,
this.trailing,
this.child,
this.onTap,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final content = Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 12,
children: [
Row(
children: [
if (icon != null) ...[
Icon(icon!, size: 18),
const Gap(12),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 2,
children: [
Text(
title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
Text(
subtitle,
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
),
if (trailing != null) trailing!,
],
),
if (child != null) child!,
],
);
if (onTap != null) {
return SizedBox(
width: double.infinity,
child: Button.card(
style: ButtonStyle.card()
.withPadding(padding: const EdgeInsets.all(16))
.withBackgroundColor(hoverColor: cs.border.withLuminance(0.94)),
onPressed: onTap,
child: content,
),
);
}
return Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: cs.card,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: cs.border),
),
child: content,
);
}
}