2026-10-24 09:08:33 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2026-11-11 17:00:51 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/components/legal_document.dart';
|
2026-10-24 09:08:33 +08:00
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
2026-11-11 16:33:04 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/components/app_logo.dart';
|
2026-10-24 09:08:33 +08:00
|
|
|
|
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/core/localization/locale_cubit.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/components/language_selection_dialog.dart';
|
|
|
|
|
|
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../core/router/route_paths.dart';
|
|
|
|
|
|
import '../bloc/login_cubit.dart';
|
|
|
|
|
|
import '../bloc/login_state.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// 登录页 V2 —— 按最新设计稿实现(账号 + 密码登录)。
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 说明:
|
|
|
|
|
|
/// - 视觉:背景纵向浅蓝渐变、主按钮横向蓝色渐变胶囊、顶部 logo + 语言胶囊、
|
2026-11-11 16:33:04 +08:00
|
|
|
|
/// 中部机器人 Hero 卡片、白色登录表单卡片。
|
2026-10-24 09:08:33 +08:00
|
|
|
|
/// - 逻辑:完全复用现有 [LoginCubit](账号密码登录,sourceType=2),未改动数据层。
|
2026-11-11 16:33:04 +08:00
|
|
|
|
/// - 上架版暂时隐藏注册入口。
|
2026-10-24 09:08:33 +08:00
|
|
|
|
/// - 旧登录页 login_page.dart 原样保留,路由默认指向本页。
|
|
|
|
|
|
class LoginPageV2 extends StatefulWidget {
|
|
|
|
|
|
const LoginPageV2({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<LoginPageV2> createState() => _LoginPageV2State();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _LoginPageV2State extends State<LoginPageV2>
|
|
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
|
|
final _userCtrl = TextEditingController();
|
|
|
|
|
|
final _pwdCtrl = TextEditingController();
|
|
|
|
|
|
bool _isAgreed = false; // 协议勾选状态
|
|
|
|
|
|
bool _obscurePwd = true; // 密码可见性
|
|
|
|
|
|
int _selectedTab = 0; // 0=登录, 1=注册(注册仅提示,不切换内容)
|
|
|
|
|
|
|
|
|
|
|
|
// 进场动画控制器
|
|
|
|
|
|
late final AnimationController _entranceController;
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 设计稿配色 =====
|
|
|
|
|
|
static const _bgTop = Color(0xFFFAFCFF);
|
|
|
|
|
|
static const _bgMid = Color(0xFFF0F6FE);
|
|
|
|
|
|
// 底部蓝比设计稿基准色 #EDF6FE 加深:原稿中/底两色几乎无差,渐变看不出层次
|
|
|
|
|
|
static const _bgBottom = Color(0xFFD6E9FB);
|
|
|
|
|
|
static const _navy = Color(0xFF1A2B4A); // 主标题/标签深色
|
|
|
|
|
|
static const _grayText = Color(0xFF86909C); // 次要文字
|
|
|
|
|
|
static const _primaryBlue = Color(0xFF1C96F6);
|
|
|
|
|
|
static const _inputBorder = Color(0xFFE5EDF7);
|
|
|
|
|
|
static const _tabBg = Color(0xFFEEF3FA);
|
|
|
|
|
|
static const _tabUnselectedText = Color(0xFF4E5969);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
_entranceController = AnimationController(
|
|
|
|
|
|
vsync: this,
|
|
|
|
|
|
duration: const Duration(milliseconds: 900),
|
|
|
|
|
|
);
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
_maybeShowLanguageDialog();
|
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 120), () {
|
|
|
|
|
|
if (mounted) _entranceController.forward();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 进入登录页:弹出语言选择框,由用户当场决定(与旧页保持一致的强制选择体验)。
|
|
|
|
|
|
void _maybeShowLanguageDialog() {
|
|
|
|
|
|
showDialog(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
|
builder: (_) => const LanguageSelectionDialog(mandatory: true),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
_entranceController.dispose();
|
|
|
|
|
|
_userCtrl.dispose();
|
|
|
|
|
|
_pwdCtrl.dispose();
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Animation<double> _interval(double begin, double end) {
|
|
|
|
|
|
return CurvedAnimation(
|
|
|
|
|
|
parent: _entranceController,
|
|
|
|
|
|
curve: Interval(begin, end, curve: Curves.easeOut),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 执行登录逻辑(复用现有 LoginCubit:账号 + 密码,sourceType=2)
|
|
|
|
|
|
void _handleLogin() {
|
|
|
|
|
|
context.read<LoginCubit>().login(_userCtrl.text, _pwdCtrl.text, 2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _onTabTap(int index) {
|
|
|
|
|
|
if (index == 1) {
|
|
|
|
|
|
// 注册暂不支持:仅提示,不切换内容
|
|
|
|
|
|
CapsuleToast.show('注册功能暂未开放', showCheck: false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setState(() => _selectedTab = 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-11-11 16:33:04 +08:00
|
|
|
|
final l10n = AppLocalizations.of(context);
|
2026-10-24 09:08:33 +08:00
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: _bgTop,
|
|
|
|
|
|
body: DecoratedBox(
|
|
|
|
|
|
// 底色:纵向浅蓝渐变
|
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
|
|
colors: [_bgTop, _bgMid, _bgBottom],
|
|
|
|
|
|
stops: [0.0, 0.4, 1.0],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: DecoratedBox(
|
|
|
|
|
|
// 左上角蓝色晕(对应设计稿 logo 一侧的淡蓝)
|
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
|
gradient: RadialGradient(
|
|
|
|
|
|
center: Alignment(-1.1, -1.0),
|
|
|
|
|
|
radius: 1.1,
|
|
|
|
|
|
colors: [Color(0xFFD6E8FC), Color(0x00D6E8FC)],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: DecoratedBox(
|
|
|
|
|
|
// 右上角蓝色晕(对应设计稿顶部右侧的淡蓝)
|
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
|
gradient: RadialGradient(
|
|
|
|
|
|
center: Alignment(1.1, -0.9),
|
|
|
|
|
|
radius: 1.25,
|
|
|
|
|
|
colors: [Color(0xFFC7DFF8), Color(0x00C7DFF8)],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
|
bottom: false,
|
|
|
|
|
|
child: BlocListener<LoginCubit, LoginState>(
|
|
|
|
|
|
listener: (context, state) {
|
|
|
|
|
|
if (state is LoginSuccess) {
|
|
|
|
|
|
context.go(RoutePaths.home);
|
|
|
|
|
|
} else if (state is LoginFailure) {
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
content: Text(
|
|
|
|
|
|
'${AppLocalizations.of(context).translate('login.login_failed')},${state.message}',
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
child: LayoutBuilder(
|
|
|
|
|
|
builder: (context, constraints) {
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
|
|
child: ConstrainedBox(
|
|
|
|
|
|
constraints:
|
|
|
|
|
|
BoxConstraints(minHeight: constraints.maxHeight),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
// 顶部:logo + 语言胶囊
|
|
|
|
|
|
_Entrance(
|
|
|
|
|
|
animation: _interval(0.00, 0.35),
|
|
|
|
|
|
child: _buildTopBar(),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
// 欢迎标题 + 副标题
|
|
|
|
|
|
_Entrance(
|
|
|
|
|
|
animation: _interval(0.08, 0.43),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
2026-11-11 16:33:04 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
l10n.translate('login.welcome_title'),
|
|
|
|
|
|
style: const TextStyle(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
fontSize: 22,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
color: _navy,
|
|
|
|
|
|
height: 1.2,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 4),
|
2026-11-11 16:33:04 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
l10n.translate('login.welcome_subtitle'),
|
|
|
|
|
|
style: const TextStyle(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
fontSize: 13,
|
|
|
|
|
|
color: _grayText,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
// 机器人 Hero 卡片
|
|
|
|
|
|
_Entrance(
|
|
|
|
|
|
animation: _interval(0.16, 0.51),
|
|
|
|
|
|
child: _buildHeroCard(),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
// 白色表单卡片
|
|
|
|
|
|
_Entrance(
|
|
|
|
|
|
animation: _interval(0.26, 0.63),
|
|
|
|
|
|
child: _buildFormCard(),
|
|
|
|
|
|
),
|
2026-11-11 16:33:04 +08:00
|
|
|
|
// 暂时隐藏登录页的帮助与客服入口。
|
|
|
|
|
|
// const SizedBox(height: 12),
|
|
|
|
|
|
// _Entrance(
|
|
|
|
|
|
// animation: _interval(0.40, 0.75),
|
|
|
|
|
|
// child: Center(child: _buildHelpRow()),
|
|
|
|
|
|
// ),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 顶部栏:logo(左)+ 语言胶囊(右)=====
|
|
|
|
|
|
// 注意:本页 LayoutBuilder 的 builder 在布局回调阶段执行,
|
|
|
|
|
|
// 不能在其子树里直接调用 context.select/watch(Provider 会断言失败)。
|
|
|
|
|
|
// 因此用 BlocBuilder 包裹 LocaleCubit 的读取,让它在正常 build 阶段取值。
|
|
|
|
|
|
Widget _buildTopBar() {
|
|
|
|
|
|
return BlocBuilder<LocaleCubit, Locale>(
|
|
|
|
|
|
builder: (context, locale) {
|
|
|
|
|
|
final langName = AppLanguages.instance.nameOf(locale);
|
|
|
|
|
|
return Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
2026-11-11 16:33:04 +08:00
|
|
|
|
const AppLogo(size: 40),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
showDialog(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (_) =>
|
|
|
|
|
|
const LanguageSelectionDialog(mandatory: false),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 9),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
|
|
border: Border.all(color: _inputBorder),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
const Icon(Icons.language, size: 16, color: _primaryBlue),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
langName,
|
|
|
|
|
|
style: const TextStyle(fontSize: 13, color: _navy),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
|
const Icon(Icons.expand_more, size: 16, color: _grayText),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 机器人 Hero 卡片 =====
|
|
|
|
|
|
Widget _buildHeroCard() {
|
|
|
|
|
|
return ClipRRect(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
height: 130,
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
child: Stack(
|
|
|
|
|
|
fit: StackFit.expand,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Image.asset(
|
2026-11-11 16:33:04 +08:00
|
|
|
|
'assets/images/img.png',
|
2026-10-24 09:08:33 +08:00
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
|
),
|
|
|
|
|
|
// 底部渐变遮罩,衬托文字
|
|
|
|
|
|
DecoratedBox(
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
|
begin: Alignment.bottomCenter,
|
|
|
|
|
|
end: Alignment.center,
|
|
|
|
|
|
colors: [
|
|
|
|
|
|
Colors.black.withValues(alpha: 0.35),
|
|
|
|
|
|
Colors.transparent,
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-11-11 16:33:04 +08:00
|
|
|
|
Positioned(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
left: 12,
|
|
|
|
|
|
bottom: 8,
|
|
|
|
|
|
child: Text(
|
2026-11-11 16:33:04 +08:00
|
|
|
|
AppLocalizations.of(context).translate('login.hero_caption'),
|
|
|
|
|
|
style: const TextStyle(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
letterSpacing: 1.5,
|
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 白色表单卡片 =====
|
|
|
|
|
|
Widget _buildFormCard() {
|
2026-11-11 16:33:04 +08:00
|
|
|
|
final l10n = AppLocalizations.of(context);
|
2026-10-24 09:08:33 +08:00
|
|
|
|
return Container(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 18),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
|
boxShadow: [
|
|
|
|
|
|
BoxShadow(
|
|
|
|
|
|
color: const Color(0xFF1C96F6).withValues(alpha: 0.06),
|
|
|
|
|
|
blurRadius: 20,
|
|
|
|
|
|
offset: const Offset(0, 6),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
_buildSegmentTab(),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
// 账号
|
2026-11-11 16:33:04 +08:00
|
|
|
|
_buildFieldLabel(l10n.translate('login.username')),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
_buildTextField(
|
|
|
|
|
|
controller: _userCtrl,
|
|
|
|
|
|
icon: Icons.person_outline,
|
2026-11-11 16:33:04 +08:00
|
|
|
|
hint: l10n.translate('login.username_hint'),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
// 密码
|
2026-11-11 16:33:04 +08:00
|
|
|
|
_buildFieldLabel(l10n.translate('login.password')),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
_buildTextField(
|
|
|
|
|
|
controller: _pwdCtrl,
|
|
|
|
|
|
icon: Icons.lock_outline,
|
2026-11-11 16:33:04 +08:00
|
|
|
|
hint: l10n.translate('login.password_hint'),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
obscureText: _obscurePwd,
|
|
|
|
|
|
suffix: IconButton(
|
|
|
|
|
|
icon: Icon(
|
|
|
|
|
|
_obscurePwd
|
|
|
|
|
|
? Icons.visibility_off_outlined
|
|
|
|
|
|
: Icons.visibility_outlined,
|
|
|
|
|
|
size: 20,
|
|
|
|
|
|
color: _grayText,
|
|
|
|
|
|
),
|
|
|
|
|
|
onPressed: () => setState(() => _obscurePwd = !_obscurePwd),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
|
_buildProtocolSection(),
|
2026-11-11 16:33:04 +08:00
|
|
|
|
// 注册入口隐藏时同时隐藏注册专用协议提示。
|
|
|
|
|
|
/*
|
2026-10-24 09:08:33 +08:00
|
|
|
|
const SizedBox(height: 4),
|
2026-11-06 08:41:44 +08:00
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 32),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
child: Text(
|
2026-11-06 08:41:44 +08:00
|
|
|
|
AppLocalizations.of(context).translate('register.agree_hint'),
|
|
|
|
|
|
style: const TextStyle(fontSize: 12, color: _grayText),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-11-11 16:33:04 +08:00
|
|
|
|
*/
|
2026-10-24 09:08:33 +08:00
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
// 登录按钮
|
|
|
|
|
|
BlocBuilder<LoginCubit, LoginState>(
|
|
|
|
|
|
builder: (context, state) {
|
|
|
|
|
|
final isLoading = state is LoginLoading;
|
|
|
|
|
|
return _GradientButton(
|
|
|
|
|
|
isLoading: isLoading,
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
if (!_isAgreed) {
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
content: Text(AppLocalizations.of(context)
|
|
|
|
|
|
.translate('login.agree_first')),
|
|
|
|
|
|
duration: const Duration(seconds: 1),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_handleLogin();
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 登录 / 注册 分段 Tab =====
|
|
|
|
|
|
Widget _buildSegmentTab() {
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
height: 42,
|
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: _tabBg,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
children: [
|
2026-11-11 16:33:04 +08:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: _buildTabItem(
|
|
|
|
|
|
0,
|
|
|
|
|
|
AppLocalizations.of(context).translate('login.title'),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
// Expanded(child: _buildTabItem(1, '注册')),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildTabItem(int index, String label) {
|
|
|
|
|
|
final selected = _selectedTab == index;
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: () => _onTabTap(index),
|
|
|
|
|
|
child: AnimatedContainer(
|
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
gradient: selected
|
|
|
|
|
|
? const LinearGradient(
|
|
|
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
|
|
end: Alignment.centerRight,
|
|
|
|
|
|
colors: [Color(0xFF2BAFFE), Color(0xFF0B7DEE)],
|
|
|
|
|
|
)
|
|
|
|
|
|
: null,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
label,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
|
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
|
|
|
|
|
|
color: selected ? Colors.white : _tabUnselectedText,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildFieldLabel(String text) {
|
|
|
|
|
|
return Text(
|
|
|
|
|
|
text,
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
color: _navy,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildTextField({
|
|
|
|
|
|
required TextEditingController controller,
|
|
|
|
|
|
required IconData icon,
|
|
|
|
|
|
required String hint,
|
|
|
|
|
|
bool obscureText = false,
|
|
|
|
|
|
Widget? suffix,
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return TextField(
|
|
|
|
|
|
controller: controller,
|
|
|
|
|
|
obscureText: obscureText,
|
|
|
|
|
|
style: const TextStyle(fontSize: 14, color: _navy),
|
|
|
|
|
|
cursorColor: _primaryBlue,
|
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
|
hintText: hint,
|
|
|
|
|
|
hintStyle: const TextStyle(color: _grayText, fontSize: 14),
|
|
|
|
|
|
filled: true,
|
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
|
prefixIcon: Icon(icon, size: 20, color: _primaryBlue),
|
|
|
|
|
|
prefixIconConstraints:
|
|
|
|
|
|
const BoxConstraints(minWidth: 44, minHeight: 48),
|
|
|
|
|
|
suffixIcon: suffix,
|
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
borderSide: const BorderSide(color: _inputBorder),
|
|
|
|
|
|
),
|
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
borderSide: const BorderSide(color: _primaryBlue, width: 1.2),
|
|
|
|
|
|
),
|
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
borderSide: const BorderSide(color: _inputBorder),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===== 协议勾选 =====
|
|
|
|
|
|
Widget _buildProtocolSection() {
|
|
|
|
|
|
final loc = AppLocalizations.of(context);
|
|
|
|
|
|
return Row(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 24,
|
|
|
|
|
|
width: 24,
|
|
|
|
|
|
child: Checkbox(
|
|
|
|
|
|
value: _isAgreed,
|
|
|
|
|
|
activeColor: _primaryBlue,
|
|
|
|
|
|
checkColor: Colors.white,
|
|
|
|
|
|
side: const BorderSide(color: _inputBorder),
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
onChanged: (val) => setState(() => _isAgreed = val!),
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(4),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Wrap(
|
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
loc.translate('login.agree_prefix'),
|
|
|
|
|
|
style: const TextStyle(fontSize: 13, color: _grayText),
|
|
|
|
|
|
),
|
|
|
|
|
|
_protocolText(loc.translate('login.user_agreement_link'),
|
2026-11-11 17:00:51 +08:00
|
|
|
|
() => openLegalDocument(context, LegalDocument.terms)),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
loc.translate('login.agree_and'),
|
|
|
|
|
|
style: const TextStyle(fontSize: 13, color: _grayText),
|
|
|
|
|
|
),
|
|
|
|
|
|
_protocolText(loc.translate('login.privacy_policy_link'),
|
2026-11-11 17:00:51 +08:00
|
|
|
|
() => openLegalDocument(context, LegalDocument.privacy)),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _protocolText(String text, VoidCallback onTap) {
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
text,
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
|
color: _primaryBlue,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-11 16:33:04 +08:00
|
|
|
|
/*
|
2026-10-24 09:08:33 +08:00
|
|
|
|
Widget _buildHelpRow() {
|
|
|
|
|
|
return Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
const Icon(Icons.help_outline, size: 16, color: _grayText),
|
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () => CapsuleToast.show('帮助与客服功能开发中', showCheck: false),
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
'帮助与客服',
|
|
|
|
|
|
style: TextStyle(fontSize: 13, color: _grayText),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-11-11 16:33:04 +08:00
|
|
|
|
*/
|
2026-10-24 09:08:33 +08:00
|
|
|
|
|
2026-11-11 17:00:51 +08:00
|
|
|
|
|
2026-10-24 09:08:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 主按钮:横向蓝色渐变胶囊(#2BAFFE → #1C96F6 → #0B7DEE),带前置箭头。
|
|
|
|
|
|
class _GradientButton extends StatelessWidget {
|
|
|
|
|
|
const _GradientButton({required this.onPressed, required this.isLoading});
|
|
|
|
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-11-11 16:33:04 +08:00
|
|
|
|
final l10n = AppLocalizations.of(context);
|
2026-10-24 09:08:33 +08:00
|
|
|
|
final enabled = !isLoading;
|
|
|
|
|
|
return Opacity(
|
|
|
|
|
|
opacity: enabled ? 1 : 0.7,
|
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
|
onTap: enabled ? onPressed : null,
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
height: 46,
|
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(14),
|
|
|
|
|
|
gradient: const LinearGradient(
|
|
|
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
|
|
end: Alignment.centerRight,
|
|
|
|
|
|
colors: [Color(0xFF2BAFFE), Color(0xFF1C96F6), Color(0xFF0B7DEE)],
|
|
|
|
|
|
stops: [0.0, 0.5, 1.0],
|
|
|
|
|
|
),
|
|
|
|
|
|
boxShadow: [
|
|
|
|
|
|
BoxShadow(
|
|
|
|
|
|
color: const Color(0xFF1C96F6).withValues(alpha: 0.30),
|
|
|
|
|
|
blurRadius: 14,
|
|
|
|
|
|
offset: const Offset(0, 6),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
child: isLoading
|
|
|
|
|
|
? const SizedBox(
|
|
|
|
|
|
width: 22,
|
|
|
|
|
|
height: 22,
|
|
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
|
|
strokeWidth: 2.4,
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
2026-11-11 16:33:04 +08:00
|
|
|
|
: Row(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
2026-11-11 16:33:04 +08:00
|
|
|
|
const Icon(
|
|
|
|
|
|
Icons.arrow_forward_rounded,
|
|
|
|
|
|
size: 20,
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 8),
|
2026-10-24 09:08:33 +08:00
|
|
|
|
Text(
|
2026-11-11 16:33:04 +08:00
|
|
|
|
l10n.translate('login.login_button'),
|
|
|
|
|
|
style: const TextStyle(
|
2026-10-24 09:08:33 +08:00
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
letterSpacing: 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 进场动画包装:淡入 + 上滑。
|
|
|
|
|
|
class _Entrance extends StatelessWidget {
|
|
|
|
|
|
const _Entrance({required this.animation, required this.child});
|
|
|
|
|
|
|
|
|
|
|
|
final Animation<double> animation;
|
|
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final curved =
|
|
|
|
|
|
CurvedAnimation(parent: animation, curve: Curves.easeOutCubic);
|
|
|
|
|
|
final slideAnim = Tween<Offset>(
|
|
|
|
|
|
begin: const Offset(0, 0.12),
|
|
|
|
|
|
end: Offset.zero,
|
|
|
|
|
|
).animate(curved);
|
|
|
|
|
|
return FadeTransition(
|
|
|
|
|
|
opacity: animation,
|
|
|
|
|
|
child: SlideTransition(position: slideAnim, child: child),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|