Files
pangolin/client/lib/widgets/quota_card.dart
T
wangjia f97ae8186b feat(client): Flutter 逐屏还原 + iPad ≥900 断点 (tsk_gpPXi-icyeOE)
对照 design/ui_kits mobile+tablet 原型逐屏补齐 Flutter 客户端:

- l10n 资源层(strings_zh/en,单显)+ Riverpod 状态层(连接状态机/免费额度/
  节点选择/语言/主题),UI 与数据解耦,mock 数据接 API 不动 UI。
- 连接键严格三态(off 虚线轨道环 / connecting 旋转弧 / on 满环+计时+光晕),
  状态来自 connectionProvider,点击只派发事件——禁止乐观显示。
- 节点页置顶「智能选择」推荐卡(clay 渐变 zap + 推荐胶囊,默认选中);
  免费额度卡(剩余分钟+进度条 ≤3 分钟切 warning + 看广告解锁变绿)。
- Tab 左右滑动切换(手势竞技场仲裁,子页滚动不误触发,200ms 方向感知滑入)。
- iPad/宽屏 ≥900 LayoutBuilder 切侧栏分栏(导航行高 ≥48,连接页双栏/节点双列网格),
  复用同一批原子组件,不 fork 页面。
- 语义 token 零硬编码;文案全部走 l10n;套餐数字对齐 §7;无支付表单/emoji 国旗。
- CI 红线词扫描扩展到 client/lib;新增 Flutter analyze+test CI 任务。
- 测试:连接状态机/额度/节点单测、连接键三态与卡片组件测试、
  golden(连接键三态/推荐卡/额度卡 × 明暗)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 14:32:36 +08:00

121 lines
4.4 KiB
Dart

// quota_card.dart — 免费版每日额度卡(纯展示)
//
// 今日剩余分钟 + 进度条(≤3 分钟切 warning 色)+「看广告开始使用」;
// 解锁后变绿「已解锁 · 今日可用」。状态由 quota_provider 注入,本地仅展示。
import 'package:flutter/material.dart';
import '../l10n/app_text.dart';
import '../pangolin_theme.dart';
import '../state/quota_provider.dart';
import 'pangolin_icons.dart';
class QuotaCard extends StatelessWidget {
const QuotaCard({super.key, required this.quota, required this.t, required this.onWatchAd});
final FreeQuotaState quota;
final AppText t;
final VoidCallback onWatchAd;
@override
Widget build(BuildContext context) {
final c = context.pangolin;
final barColor = quota.isLow ? c.warning : c.accent;
return Container(
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
decoration: BoxDecoration(
color: c.surface,
borderRadius: BorderRadius.circular(PangolinRadius.lg),
border: Border.all(color: c.border),
boxShadow: PangolinShadow.sm,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(children: [
Icon(PangolinIcons.clock, size: 15, color: c.accent),
const SizedBox(width: 7),
Text(t.quotaToday,
style: PangolinText.caption.copyWith(color: c.fg2, fontWeight: FontWeight.w600, fontSize: 12)),
const SizedBox(width: 7),
Text('${quota.remainingMinutes} ${t.minutes}',
style: PangolinText.mono.copyWith(color: c.fg1, fontSize: 14, fontWeight: FontWeight.w600)),
const Spacer(),
Container(
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
decoration: BoxDecoration(color: c.bgSubtle, borderRadius: BorderRadius.circular(PangolinRadius.full)),
child: Text(t.quotaFree,
style: PangolinText.caption.copyWith(color: c.fg3, fontWeight: FontWeight.w600, fontSize: 10.5)),
),
]),
const SizedBox(height: 9),
// 进度条:剩余比例;≤3 分钟切 warning 色(满宽轨道 + 比例填充)
ClipRRect(
borderRadius: BorderRadius.circular(3),
child: SizedBox(
height: 6,
child: Stack(children: [
Positioned.fill(child: ColoredBox(color: c.bgSubtle)),
FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: quota.progress,
child: AnimatedContainer(
duration: PangolinMotion.base,
curve: PangolinMotion.easeOut,
decoration: BoxDecoration(color: barColor, borderRadius: BorderRadius.circular(3)),
),
),
]),
),
),
const SizedBox(height: 11),
if (quota.adUnlocked)
SizedBox(
height: 38,
child: Center(
child: Row(mainAxisSize: MainAxisSize.min, children: [
Icon(PangolinIcons.checkCircle, size: 16, color: c.success),
const SizedBox(width: 7),
Text(t.adUnlocked,
style: PangolinText.sm.copyWith(color: c.success, fontWeight: FontWeight.w700, fontSize: 13)),
]),
),
)
else
_WatchAdButton(t: t, onTap: onWatchAd),
],
),
);
}
}
class _WatchAdButton extends StatelessWidget {
const _WatchAdButton({required this.t, required this.onTap});
final AppText t;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final c = context.pangolin;
return Material(
color: c.accentSubtle,
shape: StadiumBorder(side: BorderSide(color: c.accentBorder, width: 1.5)),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: SizedBox(
height: 38,
child: Center(
child: Row(mainAxisSize: MainAxisSize.min, children: [
Icon(PangolinIcons.playCircle, size: 16, color: c.accent),
const SizedBox(width: 7),
Text(t.watchAd,
style: PangolinText.sm.copyWith(color: c.accent, fontWeight: FontWeight.w700, fontSize: 13)),
]),
),
),
),
);
}
}