128 lines
3.5 KiB
Dart
128 lines
3.5 KiB
Dart
/// Account Menu Item Widget
|
|
///
|
|
/// A reusable menu item component for the account page.
|
|
/// Displays an icon, title, optional subtitle, and trailing widget with tap interaction.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:worker/core/constants/ui_constants.dart';
|
|
import 'package:worker/core/theme/colors.dart';
|
|
|
|
/// Account Menu Item Widget
|
|
///
|
|
/// Creates a list item with:
|
|
/// - Circular icon background on the left
|
|
/// - Title and optional subtitle in the center
|
|
/// - Trailing widget (default: chevron right) on the right
|
|
/// - Tap ripple effect
|
|
class AccountMenuItem extends StatelessWidget {
|
|
/// Icon to display
|
|
final IconData icon;
|
|
|
|
/// Title text (required)
|
|
final String title;
|
|
|
|
/// Optional subtitle text
|
|
final String? subtitle;
|
|
|
|
/// Tap callback
|
|
final VoidCallback onTap;
|
|
|
|
/// Optional custom trailing widget (defaults to chevron right arrow)
|
|
final Widget? trailing;
|
|
|
|
/// Icon background color (defaults to light blue)
|
|
final Color? iconBackgroundColor;
|
|
|
|
/// Icon color (defaults to primary blue)
|
|
final Color? iconColor;
|
|
|
|
const AccountMenuItem({
|
|
super.key,
|
|
required this.icon,
|
|
required this.title,
|
|
this.subtitle,
|
|
required this.onTap,
|
|
this.trailing,
|
|
this.iconBackgroundColor,
|
|
this.iconColor,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.md,
|
|
vertical: AppSpacing.md,
|
|
),
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
bottom: BorderSide(color: AppColors.grey100, width: 1.0),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// Icon with circular background
|
|
Container(
|
|
width: 40,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color:
|
|
iconBackgroundColor ??
|
|
AppColors.lightBlue.withValues(alpha: 0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Center(
|
|
child: FaIcon(
|
|
icon,
|
|
size: 18,
|
|
color: iconColor ?? AppColors.primaryBlue,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
|
|
// Title and subtitle
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w500,
|
|
color: AppColors.grey900,
|
|
),
|
|
),
|
|
if (subtitle != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
subtitle!,
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
color: AppColors.grey500,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
|
|
// Trailing widget (default: chevron)
|
|
trailing ??
|
|
const FaIcon(
|
|
FontAwesomeIcons.chevronRight,
|
|
size: 18,
|
|
color: AppColors.grey500,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|