2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。 3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。 4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
147 lines
4.7 KiB
Dart
147 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:maibu_satabot_v2/core/localization/app_localizations.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(
|
||
_getLocalizedTitle(context, item),
|
||
style: const TextStyle(
|
||
fontSize: 15,
|
||
fontWeight: FontWeight.w500,
|
||
color: Color(0xFF1D2129),
|
||
),
|
||
maxLines: 1,
|
||
overflow: TextOverflow.ellipsis,
|
||
),
|
||
),
|
||
// 副标题或开关
|
||
if (item.subTitle != null) ...[
|
||
Flexible(
|
||
child: Text(
|
||
item.subTitle!,
|
||
style: const TextStyle(
|
||
fontSize: 13,
|
||
color: Color(0xFF86909C),
|
||
),
|
||
maxLines: 1,
|
||
overflow: TextOverflow.ellipsis,
|
||
),
|
||
),
|
||
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;
|
||
}
|
||
}
|
||
|
||
String _getLocalizedTitle(BuildContext context, MenuItemEntity item) {
|
||
switch (item.id) {
|
||
case 'personal_info':
|
||
return AppLocalizations.of(context).translate('my_v2.personal_info');
|
||
case 'message_settings':
|
||
return AppLocalizations.of(context).translate('my_v2.message_settings');
|
||
case 'offline_cache':
|
||
return AppLocalizations.of(context).translate('my_v2.offline_cache');
|
||
case 'night_mode':
|
||
return AppLocalizations.of(context).translate('my_v2.night_mode');
|
||
case 'system_settings':
|
||
return AppLocalizations.of(context).translate('my_v2.system_settings');
|
||
case 'help_feedback':
|
||
return AppLocalizations.of(context).translate('my_v2.help_feedback');
|
||
case 'about_us':
|
||
return AppLocalizations.of(context).translate('my_v2.about_us');
|
||
default:
|
||
return item.title;
|
||
}
|
||
}
|
||
}
|