feat: 重构认证页面使用 AuthPageScaffold 组件
This commit is contained in:
@@ -7,6 +7,7 @@ import '../../../../core/di/injection.dart';
|
|||||||
import '../../../../shared/widgets/app_button.dart';
|
import '../../../../shared/widgets/app_button.dart';
|
||||||
import '../../../../shared/widgets/banner/app_banner.dart';
|
import '../../../../shared/widgets/banner/app_banner.dart';
|
||||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||||
|
import '../widgets/auth_page_scaffold.dart';
|
||||||
import '../../presentation/cubits/login_cubit.dart';
|
import '../../presentation/cubits/login_cubit.dart';
|
||||||
import '../../presentation/bloc/auth_bloc.dart';
|
import '../../presentation/bloc/auth_bloc.dart';
|
||||||
import '../../presentation/bloc/auth_event.dart';
|
import '../../presentation/bloc/auth_event.dart';
|
||||||
@@ -59,36 +60,21 @@ class _LoginViewState extends State<LoginView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return AuthPageScaffold(
|
||||||
backgroundColor: AppColors.background,
|
mainContentKey: const Key('login_main_content'),
|
||||||
body: SafeArea(
|
footerKey: const Key('login_footer'),
|
||||||
child: Padding(
|
mainContent: Column(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
_buildAppIcon(),
|
||||||
Expanded(
|
const SizedBox(height: 24),
|
||||||
key: const Key('login_main_content'),
|
_buildAppTitle(),
|
||||||
child: Center(
|
const SizedBox(height: 32),
|
||||||
child: Column(
|
_buildFormContainer(),
|
||||||
mainAxisSize: MainAxisSize.min,
|
],
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildAppIcon(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
_buildAppTitle(),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
_buildFormContainer(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(key: const Key('login_footer'), child: _buildFooter()),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
footer: _buildFooter(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import '../../../../shared/widgets/toast/toast.dart';
|
|||||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||||
import '../../presentation/cubits/register_cubit.dart';
|
import '../../presentation/cubits/register_cubit.dart';
|
||||||
import '../../data/auth_repository.dart';
|
import '../../data/auth_repository.dart';
|
||||||
|
import '../widgets/auth_page_scaffold.dart';
|
||||||
|
|
||||||
class RegisterScreen extends StatelessWidget {
|
class RegisterScreen extends StatelessWidget {
|
||||||
const RegisterScreen({super.key});
|
const RegisterScreen({super.key});
|
||||||
@@ -79,35 +80,19 @@ class _RegisterViewState extends State<RegisterView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return AuthPageScaffold(
|
||||||
backgroundColor: AppColors.background,
|
mainContent: Column(
|
||||||
body: SafeArea(
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Padding(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
children: [
|
||||||
child: Column(
|
_buildAppIcon(),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
const SizedBox(height: 24),
|
||||||
children: [
|
_buildAppTitle(),
|
||||||
Expanded(
|
const SizedBox(height: 24),
|
||||||
child: Center(
|
_buildFormContainer(),
|
||||||
child: Column(
|
],
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildAppIcon(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
_buildAppTitle(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
_buildFormContainer(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_buildFooter(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
footer: _buildFooter(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +187,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF475569),
|
color: AppColors.slate600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
@@ -223,7 +208,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF475569),
|
color: AppColors.slate600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import '../../../../shared/widgets/toast/toast_type.dart';
|
|||||||
import '../../presentation/cubits/register_cubit.dart';
|
import '../../presentation/cubits/register_cubit.dart';
|
||||||
import '../../presentation/bloc/auth_bloc.dart';
|
import '../../presentation/bloc/auth_bloc.dart';
|
||||||
import '../../presentation/bloc/auth_event.dart';
|
import '../../presentation/bloc/auth_event.dart';
|
||||||
|
import '../widgets/auth_page_scaffold.dart';
|
||||||
|
|
||||||
class RegisterVerificationScreen extends StatelessWidget {
|
class RegisterVerificationScreen extends StatelessWidget {
|
||||||
final RegisterCubit? cubit;
|
final RegisterCubit? cubit;
|
||||||
@@ -125,35 +126,19 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return AuthPageScaffold(
|
||||||
backgroundColor: AppColors.background,
|
mainContent: Column(
|
||||||
body: SafeArea(
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Padding(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
children: [
|
||||||
child: Column(
|
_buildAppIcon(),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
const SizedBox(height: 24),
|
||||||
children: [
|
_buildAppTitle(),
|
||||||
Expanded(
|
const SizedBox(height: 24),
|
||||||
child: Center(
|
_buildFormContainer(),
|
||||||
child: Column(
|
],
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildAppIcon(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
_buildAppTitle(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
_buildFormContainer(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_buildFooter(),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
footer: _buildFooter(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +235,7 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF475569),
|
color: AppColors.slate600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import '../../../../shared/widgets/toast/toast.dart';
|
|||||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||||
import '../../presentation/cubits/reset_password_cubit.dart';
|
import '../../presentation/cubits/reset_password_cubit.dart';
|
||||||
import '../../data/auth_repository.dart';
|
import '../../data/auth_repository.dart';
|
||||||
|
import '../widgets/auth_page_scaffold.dart';
|
||||||
|
|
||||||
class ResetPasswordScreen extends StatelessWidget {
|
class ResetPasswordScreen extends StatelessWidget {
|
||||||
const ResetPasswordScreen({super.key});
|
const ResetPasswordScreen({super.key});
|
||||||
@@ -78,30 +79,15 @@ class _ResetPasswordViewState extends State<ResetPasswordView> {
|
|||||||
Toast.show(context, state.errorMessage!, type: ToastType.error);
|
Toast.show(context, state.errorMessage!, type: ToastType.error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: AuthPageScaffold(
|
||||||
backgroundColor: AppColors.background,
|
mainContent: Column(
|
||||||
body: SafeArea(
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Padding(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
children: [
|
||||||
child: Column(
|
_buildTitle(),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
const SizedBox(height: 32),
|
||||||
children: [
|
_buildFormContainer(),
|
||||||
Expanded(
|
],
|
||||||
child: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildTitle(),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
_buildFormContainer(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../core/theme/design_tokens.dart';
|
||||||
|
|
||||||
|
class AuthPageScaffold extends StatelessWidget {
|
||||||
|
const AuthPageScaffold({
|
||||||
|
super.key,
|
||||||
|
required this.mainContent,
|
||||||
|
this.footer,
|
||||||
|
this.mainContentKey,
|
||||||
|
this.footerKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget mainContent;
|
||||||
|
final Widget? footer;
|
||||||
|
final Key? mainContentKey;
|
||||||
|
final Key? footerKey;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.background,
|
||||||
|
body: SafeArea(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final viewportHeight = math.max(
|
||||||
|
constraints.maxHeight - keyboardInset,
|
||||||
|
AppSpacing.none,
|
||||||
|
);
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
AppSpacing.xxl,
|
||||||
|
AppSpacing.none,
|
||||||
|
AppSpacing.xxl,
|
||||||
|
keyboardInset + AppSpacing.xxl,
|
||||||
|
),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minHeight: viewportHeight),
|
||||||
|
child: IntrinsicHeight(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
key: mainContentKey,
|
||||||
|
child: Center(child: mainContent),
|
||||||
|
),
|
||||||
|
if (footer != null)
|
||||||
|
Container(key: footerKey, child: footer),
|
||||||
|
SizedBox(height: AppSpacing.xxl),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user