163 lines
5.0 KiB
Dart
163 lines
5.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/theme/app_typography.dart';
|
|
import '../../../../services/clubs/club_models.dart';
|
|
|
|
/// Renders a tactical officer rank badge for motorcycle club members.
|
|
class OfficerBadge extends StatelessWidget {
|
|
final String? rank;
|
|
final ClubRole? role;
|
|
final bool isCompact;
|
|
final double fontSize;
|
|
|
|
const OfficerBadge({
|
|
super.key,
|
|
this.rank,
|
|
this.role,
|
|
this.isCompact = false,
|
|
this.fontSize = 10.5,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final effectiveRank = _resolveEffectiveRank();
|
|
final badgeStyle = _resolveBadgeStyle(effectiveRank);
|
|
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: isCompact ? 6 : 8,
|
|
vertical: isCompact ? 2 : 3,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: badgeStyle.bgColor,
|
|
borderRadius: BorderRadius.circular(5),
|
|
border: Border.all(color: badgeStyle.borderColor, width: 0.8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(badgeStyle.icon, size: fontSize + 1.5, color: badgeStyle.textColor),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
badgeStyle.label,
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontHeadline,
|
|
fontSize: fontSize,
|
|
fontWeight: FontWeight.w700,
|
|
letterSpacing: 0.3,
|
|
color: badgeStyle.textColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String _resolveEffectiveRank() {
|
|
if (rank != null && rank!.trim().isNotEmpty) {
|
|
return rank!.trim();
|
|
}
|
|
if (role == ClubRole.owner) return 'President';
|
|
if (role == ClubRole.admin) return 'Officer';
|
|
return 'Member';
|
|
}
|
|
|
|
_OfficerBadgeStyle _resolveBadgeStyle(String rankName) {
|
|
final lower = rankName.toLowerCase();
|
|
|
|
if (lower.contains('president') || lower.contains('founder')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.shield,
|
|
textColor: const Color(0xFFFFB800),
|
|
bgColor: const Color(0xFFFFB800).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFFFFB800).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('vice') || lower.contains('vp')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.verified_user,
|
|
textColor: const Color(0xFFFF9500),
|
|
bgColor: const Color(0xFFFF9500).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFFFF9500).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('road captain') || lower.contains('captain')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.explore,
|
|
textColor: const Color(0xFF00F2FE),
|
|
bgColor: const Color(0xFF00F2FE).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFF00F2FE).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('tail gunner') || lower.contains('sweep') || lower.contains('gunner')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.security,
|
|
textColor: const Color(0xFFA855F7),
|
|
bgColor: const Color(0xFFA855F7).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFFA855F7).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('marshal') || lower.contains('safety')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.flag_outlined,
|
|
textColor: const Color(0xFF3B82F6),
|
|
bgColor: const Color(0xFF3B82F6).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFF3B82F6).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('treasurer') || lower.contains('secretary')) {
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.account_balance_wallet_outlined,
|
|
textColor: const Color(0xFF10B981),
|
|
bgColor: const Color(0xFF10B981).withValues(alpha: 0.15),
|
|
borderColor: const Color(0xFF10B981).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
|
|
if (lower.contains('prospect')) {
|
|
return _OfficerBadgeStyle(
|
|
label: 'PROSPECT',
|
|
icon: Icons.hourglass_top,
|
|
textColor: const Color(0xFF94A3B8),
|
|
bgColor: const Color(0xFF94A3B8).withValues(alpha: 0.10),
|
|
borderColor: const Color(0xFF94A3B8).withValues(alpha: 0.4),
|
|
);
|
|
}
|
|
|
|
// Default: Full Member
|
|
return _OfficerBadgeStyle(
|
|
label: rankName.toUpperCase(),
|
|
icon: Icons.person_outline,
|
|
textColor: const Color(0xFF94A3B8),
|
|
bgColor: const Color(0xFF334155).withValues(alpha: 0.3),
|
|
borderColor: const Color(0xFF475569).withValues(alpha: 0.5),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _OfficerBadgeStyle {
|
|
final String label;
|
|
final IconData icon;
|
|
final Color textColor;
|
|
final Color bgColor;
|
|
final Color borderColor;
|
|
|
|
const _OfficerBadgeStyle({
|
|
required this.label,
|
|
required this.icon,
|
|
required this.textColor,
|
|
required this.bgColor,
|
|
required this.borderColor,
|
|
});
|
|
}
|