119 lines
3.5 KiB
Dart
119 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||
|
||
/// 菜单项卡片组件(100% 还原设计稿)
|
||
class MenuItemCard extends StatelessWidget {
|
||
const MenuItemCard({
|
||
super.key,
|
||
required this.item,
|
||
this.onTap,
|
||
this.onSwitchChanged,
|
||
});
|
||
|
||
final MenuItemEntity item;
|
||
final VoidCallback? onTap;
|
||
final ValueChanged<bool>? onSwitchChanged;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Column(
|
||
children: [
|
||
SizedBox(
|
||
height: 56,
|
||
child: GestureDetector(
|
||
onTap: onTap,
|
||
behavior: HitTestBehavior.opaque,
|
||
child: Padding(
|
||
padding: const EdgeInsets.symmetric(
|
||
horizontal: 16,
|
||
),
|
||
child: Row(
|
||
children: [
|
||
// 图标
|
||
Icon(
|
||
_getIconData(item.icon),
|
||
size: 20,
|
||
color: const Color(0xFF4E5969),
|
||
),
|
||
const SizedBox(width: 12),
|
||
// 标题
|
||
Expanded(
|
||
child: Text(
|
||
item.title,
|
||
style: const TextStyle(
|
||
fontSize: 15,
|
||
fontWeight: FontWeight.w500,
|
||
color: Color(0xFF1D2129),
|
||
),
|
||
),
|
||
),
|
||
// 副标题或开关
|
||
if (item.subTitle != null) ...[
|
||
Text(
|
||
item.subTitle!,
|
||
style: const TextStyle(
|
||
fontSize: 13,
|
||
color: Color(0xFF86909C),
|
||
),
|
||
),
|
||
const SizedBox(width: 6),
|
||
],
|
||
if (item.hasSwitch) ...[
|
||
Transform.scale(
|
||
scale: 0.85,
|
||
child: Switch(
|
||
value: item.switchValue,
|
||
onChanged: onSwitchChanged,
|
||
activeColor: const Color(0xFF165DFF),
|
||
activeTrackColor: const Color(0xFF165DFF).withOpacity(0.3),
|
||
inactiveThumbColor: const Color(0xFFC9CDD4),
|
||
inactiveTrackColor: const Color(0xFFE5E6EB),
|
||
),
|
||
),
|
||
],
|
||
Icon(
|
||
Icons.chevron_right,
|
||
color: const Color(0xFFC9CDD4),
|
||
size: 20,
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
// 分割线
|
||
Padding(
|
||
padding: const EdgeInsets.only(left: 48),
|
||
child: Divider(
|
||
height: 1,
|
||
thickness: 0.5,
|
||
color: const Color(0xFFF0F0F0),
|
||
),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
|
||
/// 根据字符串获取 IconData
|
||
IconData _getIconData(String iconName) {
|
||
switch (iconName) {
|
||
case 'person':
|
||
return Icons.person_outline;
|
||
case 'notifications':
|
||
return Icons.notifications_outlined;
|
||
case 'cloud_download':
|
||
return Icons.cloud_download_outlined;
|
||
case 'dark_mode':
|
||
return Icons.dark_mode_outlined;
|
||
case 'settings':
|
||
return Icons.settings_outlined;
|
||
case 'help':
|
||
return Icons.help_outline;
|
||
case 'info':
|
||
return Icons.info_outline;
|
||
default:
|
||
return Icons.label_outline;
|
||
}
|
||
}
|
||
}
|