72 lines
2.0 KiB
Dart
72 lines
2.0 KiB
Dart
// AUTO-GENERATED widget — matches web .badge
|
|
import 'package:flutter/material.dart';
|
|
import 'package:inou_app/design/inou_theme.dart';
|
|
import 'package:inou_app/design/inou_text.dart';
|
|
|
|
enum BadgeVariant { normal, care, comingSoon, processing }
|
|
|
|
class InouBadge extends StatelessWidget {
|
|
final String text;
|
|
final BadgeVariant variant;
|
|
|
|
const InouBadge({
|
|
super.key,
|
|
required this.text,
|
|
this.variant = BadgeVariant.normal,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final style = _getStyle();
|
|
final isUppercase = variant == BadgeVariant.comingSoon;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), // 2v, 8h per styleguide
|
|
decoration: BoxDecoration(
|
|
color: style.background,
|
|
borderRadius: BorderRadius.circular(InouTheme.radiusSm),
|
|
),
|
|
child: Text(
|
|
isUppercase ? text.toUpperCase() : text,
|
|
style: InouTheme.badgeText.copyWith(
|
|
fontSize: variant == BadgeVariant.comingSoon ? 10 : 15, // 15px (1rem) per styleguide
|
|
color: style.foreground,
|
|
letterSpacing: isUppercase ? 0.5 : 0,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_BadgeStyle _getStyle() {
|
|
switch (variant) {
|
|
case BadgeVariant.normal:
|
|
return _BadgeStyle(
|
|
background: InouTheme.accentLight,
|
|
foreground: InouTheme.accent,
|
|
);
|
|
case BadgeVariant.care:
|
|
return _BadgeStyle(
|
|
background: InouTheme.successLight,
|
|
foreground: InouTheme.success,
|
|
);
|
|
case BadgeVariant.comingSoon:
|
|
return _BadgeStyle(
|
|
background: InouTheme.bg,
|
|
foreground: InouTheme.textMuted,
|
|
);
|
|
case BadgeVariant.processing:
|
|
return _BadgeStyle(
|
|
background: InouTheme.accentLight,
|
|
foreground: InouTheme.accent,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
class _BadgeStyle {
|
|
final Color background;
|
|
final Color foreground;
|
|
|
|
_BadgeStyle({required this.background, required this.foreground});
|
|
}
|