Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
8035964e1This file is pinned to the selected release. Download the original to open it in your design tool.
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../theme/app_theme.dart';
/// A quiet caption over a run of rail rows, with an optional `+` beside it.
///
/// Micro-type — [AppType.monoMeta], uppercase, faint — because it names a
/// group rather than competing with the rows under it. Both halves of the sidebar use it, which is the
/// point: "Projects" in Home and "Projects" in Code list entirely different
/// things, and the one thing they must not differ on is how a rail heading
/// looks.
class RailSectionHeader extends StatelessWidget {
const RailSectionHeader({
super.key,
required this.label,
this.onTap,
this.tooltip,
this.onAdd,
this.addTooltip,
});
final String label;
/// What tapping the label does. Null leaves it as plain text — a heading that
/// looks tappable and isn't is worse than one that never offered.
final VoidCallback? onTap;
final String? tooltip;
/// The `+` at the right end. Null draws none.
final VoidCallback? onAdd;
final String? addTooltip;
@override
Widget build(BuildContext context) {
// Reads AppPalette tokens — follow theme flips.
AppTheme.watch(context);
final text = Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
label.toUpperCase(),
semanticsLabel: label,
style: AppType.monoMeta(
color: AppPalette.textFaint,
fontWeight: AppFont.medium,
),
),
);
return Padding(
padding: const EdgeInsets.fromLTRB(10, 12, 2, 2),
child: Row(
children: [
Expanded(
child: onTap == null
? text
: tooltip == null ||
tooltip!.trim().isEmpty ||
tooltip!.trim() == label.trim()
? InkWell(onTap: onTap, child: text)
: Tooltip(
message: tooltip!,
child: InkWell(onTap: onTap, child: text),
),
),
if (onAdd != null)
IconButton(
tooltip: addTooltip,
iconSize: 18,
visualDensity: VisualDensity.compact,
constraints: const BoxConstraints.tightFor(width: 26, height: 26),
padding: EdgeInsets.zero,
color: AppPalette.textSecondary,
icon: const Icon(LucideIcons.plus300),
onPressed: onAdd,
),
],
),
);
}
}