ver1.00.00
update2
This commit is contained in:
@@ -77,6 +77,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
return Scaffold(
|
||||
// 关键修复1:resizeToAvoidBottomInset = false,防止键盘弹出重绘崩溃
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
appBar: AppBar(
|
||||
title: Text(isRegisterMode ? '创建账号' : '欢迎回来'),
|
||||
@@ -96,215 +98,217 @@ class _LoginPageState extends State<LoginPage> {
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Transform.translate(
|
||||
offset: const Offset(0, -30),
|
||||
child: SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: _pinkColor.withOpacity(0.3),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
color: isDark ? Colors.grey[850] : Colors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 头像/图标区域 - 已修改为黑白粉主题
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: _pinkColor.withOpacity(0.15),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
// 更换为更美观的人物头像类图标
|
||||
isRegisterMode ? Icons.person_add_rounded : Icons.person_rounded,
|
||||
size: 48,
|
||||
color: _pinkColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
Text(
|
||||
isRegisterMode ? '注册新账号' : '账号登录',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
isRegisterMode ? '请填写以下信息' : '请输入您的凭证以继续',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
if (errorMessage.isNotEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.red.withOpacity(0.3)),
|
||||
child: SingleChildScrollView(
|
||||
// 关键修复2:让滚动视图正常工作
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: MediaQuery.of(context).size.height - 100,
|
||||
),
|
||||
child: Center(
|
||||
child: Transform.translate(
|
||||
offset: const Offset(0, -30),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: Card(
|
||||
elevation: 8, shadowColor: _pinkColor.withOpacity(0.3),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
color: isDark ? Colors.grey[850] : Colors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: _pinkColor.withOpacity(0.15),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
isRegisterMode ? Icons.person_add_rounded : Icons.person_rounded,
|
||||
size: 48,
|
||||
color: _pinkColor,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.red, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
errorMessage,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 13),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
Text(
|
||||
isRegisterMode ? '注册新账号' : '账号登录',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
isRegisterMode ? '请填写以下信息' : '请输入您的凭证以继续',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
if (errorMessage.isNotEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.red.withOpacity(0.3)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.red, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
errorMessage,
|
||||
style: const TextStyle(color: Colors.red, fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
TextField(
|
||||
controller: usernameController,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: '用户名',
|
||||
prefixIcon: const Icon(Icons.person_outline, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: isRegisterMode ? '设置密码' : '密码 / TOTP验证码',
|
||||
prefixIcon: const Icon(Icons.lock_outline, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
),
|
||||
|
||||
if (isRegisterMode) ...[
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: inviterController,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: '邀请人 ID (可选)',
|
||||
prefixIcon: const Icon(Icons.card_giftcard_outlined, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: isLoading ? null : submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _pinkColor,
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
isRegisterMode ? '立即注册' : '登录',
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 用户名输入框
|
||||
TextField(
|
||||
controller: usernameController,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: '用户名',
|
||||
prefixIcon: const Icon(Icons.person_outline, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
isRegisterMode = !isRegisterMode;
|
||||
errorMessage = '';
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
isRegisterMode
|
||||
? '已有账号?去登录'
|
||||
: '没有账号?去注册',
|
||||
style: const TextStyle(
|
||||
color: _pinkColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 密码输入框
|
||||
TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: isRegisterMode ? '设置密码' : '密码 / TOTP验证码',
|
||||
prefixIcon: const Icon(Icons.lock_outline, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
),
|
||||
|
||||
if (isRegisterMode) ...[
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: inviterController,
|
||||
enabled: !isLoading,
|
||||
decoration: InputDecoration(
|
||||
labelText: '邀请人 ID (可选)',
|
||||
prefixIcon: const Icon(Icons.card_giftcard_outlined, color: _pinkColor),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: _pinkColor.withOpacity(0.5)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _pinkColor, width: 2),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: isDark ? Colors.grey[800] : Colors.grey[50],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 登录/注册按钮
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: isLoading ? null : submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _pinkColor,
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
isRegisterMode ? '立即注册' : '登录',
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 切换登录/注册
|
||||
TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
isRegisterMode = !isRegisterMode;
|
||||
errorMessage = '';
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
isRegisterMode
|
||||
? '已有账号?去登录'
|
||||
: '没有账号?去注册',
|
||||
style: const TextStyle(
|
||||
color: _pinkColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user