59 lines
1.4 KiB
Dart
59 lines
1.4 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../theme/app_theme.dart';
|
||
|
|
|
||
|
|
|
||
|
|
class MetadataChip extends StatelessWidget {
|
||
|
|
final IconData? icon;
|
||
|
|
final String label;
|
||
|
|
final Color? foreground;
|
||
|
|
final Color? background;
|
||
|
|
final bool dense;
|
||
|
|
|
||
|
|
const MetadataChip({
|
||
|
|
super.key,
|
||
|
|
required this.label,
|
||
|
|
this.icon,
|
||
|
|
this.foreground,
|
||
|
|
this.background,
|
||
|
|
this.dense = false,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final theme = Theme.of(context);
|
||
|
|
final tokens = context.appTokens;
|
||
|
|
final fg = foreground ?? tokens.mutedForeground;
|
||
|
|
final bg =
|
||
|
|
background ?? theme.colorScheme.onSurface.withValues(alpha: 0.07);
|
||
|
|
return Container(
|
||
|
|
padding: EdgeInsets.symmetric(horizontal: dense ? 6 : 7, vertical: 2),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: bg,
|
||
|
|
borderRadius: BorderRadius.circular(4),
|
||
|
|
),
|
||
|
|
child: Row(
|
||
|
|
mainAxisSize: MainAxisSize.min,
|
||
|
|
children: [
|
||
|
|
if (icon != null) ...[
|
||
|
|
Icon(icon, size: 12, color: fg),
|
||
|
|
const SizedBox(width: 3),
|
||
|
|
],
|
||
|
|
Flexible(
|
||
|
|
child: Text(
|
||
|
|
label,
|
||
|
|
maxLines: 1,
|
||
|
|
overflow: TextOverflow.ellipsis,
|
||
|
|
style: theme.textTheme.labelSmall?.copyWith(
|
||
|
|
color: fg,
|
||
|
|
fontSize: 10,
|
||
|
|
letterSpacing: 0.2,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|