refactor(client): 删除死代码 PlansScreen + NavView.plans + choosePlan l10n(Renew→Purchase 直达后无调用者)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,6 @@ import '../services/auth_api.dart';
|
||||
import '../state/account_providers.dart';
|
||||
import 'pangolin_button.dart';
|
||||
import 'pangolin_icons.dart';
|
||||
import 'plan_card.dart';
|
||||
|
||||
/// 通用:带返回箭头的子页骨架。embedded=true 时只返回内容(desktop 内容区下钻,
|
||||
/// 返回/标题由外层 shell 顶栏提供),否则整页 Scaffold(mobile/tablet 全屏 push)。
|
||||
@@ -67,66 +66,6 @@ class SettingsScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// ── 套餐选择 ── (价格/额度来自 GET /v1/plans;当前档由 me.plan 判定;
|
||||
/// 功能清单仍取 l10n,后端无此字段)
|
||||
class PlansScreen extends ConsumerWidget {
|
||||
const PlansScreen({super.key, required this.t, this.onChoose, this.onBack, this.embedded = false});
|
||||
final AppText t;
|
||||
final ValueChanged<String>? onChoose;
|
||||
final VoidCallback? onBack;
|
||||
final bool embedded;
|
||||
|
||||
List<String> _feats(String code) => switch (code) {
|
||||
'free' => t.featsFree,
|
||||
'pro' => t.featsPro,
|
||||
'team' => t.featsTeam,
|
||||
_ => const [],
|
||||
};
|
||||
|
||||
// 套餐名是 UI 文案(后端 plans 表无名称列),按 code 取 l10n。
|
||||
String _name(String code) => switch (code) {
|
||||
'free' => t.freePlan,
|
||||
'pro' => t.proPlan,
|
||||
'team' => t.teamPlan,
|
||||
_ => code,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final c = context.pangolin;
|
||||
final plansAsync = ref.watch(plansProvider);
|
||||
final myPlan = ref.watch(meProvider).valueOrNull?.plan ?? 'free';
|
||||
|
||||
Widget body() => plansAsync.when(
|
||||
loading: () => const Center(child: Padding(padding: EdgeInsets.all(40), child: CircularProgressIndicator())),
|
||||
error: (_, __) => Center(
|
||||
child: Padding(padding: const EdgeInsets.all(40), child: Text(t.lang.loadFailedRetry, style: PangolinText.body.copyWith(color: c.fg3)))),
|
||||
data: (plans) => ListView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 14, 20, 24),
|
||||
children: [
|
||||
for (final p in plans)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 14, top: p.code == 'pro' ? 12 : 0),
|
||||
child: PlanCard(
|
||||
name: _name(p.code),
|
||||
price: p.priceLabel(),
|
||||
period: t.perMonth,
|
||||
features: _feats(p.code),
|
||||
ctaLabel: p.code == myPlan ? t.current : (p.code == 'team' ? t.choose : t.upgrade),
|
||||
featured: p.code == 'pro',
|
||||
isCurrent: p.code == myPlan,
|
||||
popularLabel: p.code == 'pro' ? t.mostPopular : null,
|
||||
onPressed: () => onChoose?.call(p.code),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return _SubScaffold(title: t.choosePlan, onBack: onBack, embedded: embedded, child: body());
|
||||
}
|
||||
}
|
||||
|
||||
/// ── 设备管理 ── (真实 GET /v1/me/devices;移除 = DELETE。本机高亮待 P6 设备 id)
|
||||
class DevicesScreen extends ConsumerWidget {
|
||||
const DevicesScreen({super.key, required this.t, this.onBack, this.embedded = false});
|
||||
|
||||
Reference in New Issue
Block a user