Files
pangolin/client/lib/widgets/onboarding_screen.dart
T
wangjia 526e7f2f33 feat(tsk_iRa5iBC4v7Tu): Flutter 客户端工程搭建(演示态)
基于 design/flutter/ 起步包在 client/ 下建立 Flutter 工程:

- pubspec.yaml:flutter_svg / lucide_icons / google_fonts 依赖;
  SVG 资产注册;字体由 google_fonts 运行时加载,无需本地 ttf
- lib/pangolin_theme.dart:完整设计令牌(色阶 / 间距 / 圆角 /
  动效 / 文字阶),PangolinText 改用 GoogleFonts getter,
  PangolinTheme.light / .dark 开箱即用
- lib/main.dart:runApp + 明暗主题 + 登录 → 引导 → 主框架 RootFlow
- lib/widgets/:全套组件雏形
    pangolin_icons    Lucide 图标映射
    pangolin_button   胶囊按钮四态
    country_code      国家码块 + 信号条
    status_pill       色点胶囊
    connect_button    核心连接键三态(off/connecting/on + 动画)
    server_tile       服务器列表行
    plan_card         套餐卡(专业版渐变高亮)
    auth_screen       登录 / 注册(邮箱验证码 + 设密码)
    onboarding_screen 首次引导 PageView(3 屏可滑动 + 进度点)
    home_shell        底部 4 Tab(连接/节点/统计/账户 + 状态机)
    account_screens   套餐选择 / 设备管理 / 兑换 / 联系我们
    pangolin_logo     PangolinMark / BrandLockup / AppIcon(SVG)
- assets/:logo-mark / logo-mark-white / logo-wordmark / app-icon(SVG)
- android/:Kotlin 主 Activity + Manifest + Gradle 配置
- ios/:Runner.xcodeproj + xcscheme + Podfile + AppDelegate + storyboard

运行方式(cd client/):
  flutter pub get && flutter run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 02:15:42 +08:00

101 lines
4.2 KiB
Dart

// onboarding_screen.dart — 首次引导页(3 屏可滑动)
import 'package:flutter/material.dart';
import '../pangolin_theme.dart';
import 'pangolin_icons.dart';
import 'pangolin_button.dart';
class OnboardingStep {
const OnboardingStep({required this.icon, required this.title, required this.body, required this.cta, this.tint, this.tintBg});
final IconData icon;
final String title, body, cta;
final Color? tint, tintBg;
}
class OnboardingScreen extends StatefulWidget {
const OnboardingScreen({super.key, required this.onDone, this.steps});
final VoidCallback onDone;
final List<OnboardingStep>? steps;
@override
State<OnboardingScreen> createState() => _OnboardingScreenState();
}
class _OnboardingScreenState extends State<OnboardingScreen> {
int _i = 0;
final _pager = PageController();
List<OnboardingStep> _defaults(PangolinScheme c) => [
OnboardingStep(icon: PangolinIcons.globe, title: '一键连接全球', body: '80+ 节点,智能选择最快线路,稳定不掉线。', cta: '下一步'),
OnboardingStep(icon: PangolinIcons.shield, title: '授权网络配置', body: '系统会请求添加一个网络配置,用于建立加密隧道。', cta: '允许并继续'),
OnboardingStep(icon: PangolinIcons.shieldCheck, title: '安全 · 无日志', body: '端到端加密,我们不记录你的任何浏览数据。', cta: '开始使用',
tint: c.success, tintBg: c.successSubtle),
];
@override
void dispose() { _pager.dispose(); super.dispose(); }
@override
Widget build(BuildContext context) {
final c = context.pangolin;
final steps = widget.steps ?? _defaults(c);
final last = _i == steps.length - 1;
return Scaffold(
backgroundColor: c.bg,
body: SafeArea(
child: Column(children: [
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8),
child: TextButton(onPressed: widget.onDone, child: Text('跳过', style: PangolinText.sm.copyWith(color: c.fg3, fontWeight: FontWeight.w600))),
),
),
Expanded(
child: PageView.builder(
controller: _pager,
itemCount: steps.length,
onPageChanged: (v) => setState(() => _i = v),
itemBuilder: (_, idx) {
final s = steps[idx];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
width: 120, height: 120,
decoration: BoxDecoration(color: s.tintBg ?? c.accentSubtle, shape: BoxShape.circle),
child: Icon(s.icon, size: 52, color: s.tint ?? c.accent),
),
const SizedBox(height: 28),
Text(s.title, textAlign: TextAlign.center, style: PangolinText.h1.copyWith(color: c.fg1, fontSize: 26)),
const SizedBox(height: 12),
Text(s.body, textAlign: TextAlign.center, style: PangolinText.body.copyWith(color: c.fg2, height: 1.6)),
]),
);
},
),
),
Row(mainAxisAlignment: MainAxisAlignment.center, children: List.generate(steps.length, (k) {
final on = k == _i;
return AnimatedContainer(
duration: PangolinMotion.base, curve: PangolinMotion.easeOut,
width: on ? 22 : 7, height: 7, margin: const EdgeInsets.symmetric(horizontal: 4),
decoration: BoxDecoration(color: on ? c.accent : c.borderStrong, borderRadius: BorderRadius.circular(PangolinRadius.full)),
);
})),
Padding(
padding: const EdgeInsets.fromLTRB(28, 22, 28, 26),
child: PangolinButton(
label: steps[_i].cta, expand: true,
onPressed: () {
if (last) { widget.onDone(); }
else { _pager.nextPage(duration: PangolinMotion.base, curve: PangolinMotion.easeOut); }
},
),
),
]),
),
);
}
}