617b43083d
B2 持久化:localeProvider 由 StateProvider 改 StateNotifier(LocaleNotifier), 默认英文,选择存 shared_preferences(key pg_lang),重启保留;新增 appTextFor(lang) helper 供非 Consumer 场景复用。两处切换 .state= 改 .set()。 B1 硬编码 UI 文案 6 语化(AppLangMisc 扩展,exhaustive switch 不会漏): - 不可用 / 流媒体优化 / 节点未就绪 / 连接失败 / 加载失败 / 暂无设备 / 改邮箱 - 相对时间(刚刚/X分钟前/…)relativeTime(Duration) - 修 auth_screen 错误消息 bug:原 _errorZh 永远显示中文(连英文用户都中招)→ 按当前语言取 messageZh/En(非中文显英文) 仍回退英文(服务端数据,需服务端多语字段):节点/套餐名(nameZh/nameEn)、 API 错误消息(messageZh/En)。flutter analyze 仅 2 个既有 withOpacity info。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
88 lines
2.8 KiB
Dart
88 lines
2.8 KiB
Dart
// server_tile.dart — 节点列表行(国家码块 · 名称 · 延迟 · 信号条 · 选中态)
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../l10n/app_text.dart';
|
|
import '../models/node.dart';
|
|
import '../pangolin_theme.dart';
|
|
import 'country_code.dart';
|
|
import 'pangolin_icons.dart';
|
|
|
|
class ServerInfo {
|
|
const ServerInfo({
|
|
required this.code,
|
|
required this.name,
|
|
required this.sub,
|
|
required this.ping,
|
|
this.nodeId = '',
|
|
});
|
|
|
|
final String code, name, sub;
|
|
final int ping;
|
|
|
|
/// 控制面节点 ID,对应 POST /v1/nodes/:nodeId/connect 路径参数。
|
|
/// 留空时降级为使用 [code] 小写值(仅限 mock 联调)。
|
|
final String nodeId;
|
|
|
|
String get effectiveNodeId => nodeId.isEmpty ? code.toLowerCase() : nodeId;
|
|
}
|
|
|
|
class ServerTile extends StatelessWidget {
|
|
const ServerTile({
|
|
super.key,
|
|
required this.node,
|
|
required this.lang,
|
|
this.active = false,
|
|
this.onTap,
|
|
});
|
|
|
|
final Node node;
|
|
final AppLang lang;
|
|
final bool active;
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = context.pangolin;
|
|
final down = node.isDown; // 节点不可用(agent 离线):置灰 + 「不可用」+ 禁选。
|
|
final unavail = lang.unavailable;
|
|
return InkWell(
|
|
onTap: down ? null : onTap,
|
|
child: Opacity(
|
|
opacity: down ? 0.55 : 1.0,
|
|
child: Container(
|
|
color: (active && !down) ? c.accentSubtle : Colors.transparent,
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
|
child: Row(
|
|
children: [
|
|
CountryCode(code: node.code, active: active && !down),
|
|
const SizedBox(width: 13),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(node.localizedName(lang),
|
|
style: PangolinText.sm
|
|
.copyWith(color: c.fg1, fontWeight: FontWeight.w600, fontSize: 15)),
|
|
const SizedBox(height: 2),
|
|
Text(node.localizedSub(lang),
|
|
style: PangolinText.caption.copyWith(color: c.fg3, fontWeight: FontWeight.w400)),
|
|
],
|
|
),
|
|
),
|
|
if (down)
|
|
Text(unavail,
|
|
style: PangolinText.caption.copyWith(color: c.danger, fontWeight: FontWeight.w600, fontSize: 12))
|
|
else ...[
|
|
Text(node.pingLabel, style: PangolinText.mono.copyWith(color: c.fg2, fontSize: 12)),
|
|
const SizedBox(width: 8),
|
|
SignalBars(ping: node.ping),
|
|
if (active) ...[const SizedBox(width: 10), Icon(PangolinIcons.check, size: 18, color: c.accent)],
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|