feat:重构模块
This commit is contained in:
@@ -83,7 +83,7 @@ class _LoginPage extends State<LoginPage> {
|
||||
handleRememberState();
|
||||
handleTokenState(session.saToken.tokenValue);
|
||||
handleUserInfo(session.userInfo);
|
||||
|
||||
|
||||
LoadingDialog.hide(context);
|
||||
Navigator.pushNamed(context, '/home');
|
||||
} catch (e) {
|
||||
@@ -104,12 +104,12 @@ class _LoginPage extends State<LoginPage> {
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: buildLoginForm()),
|
||||
Expanded(child: buildLoginForm(context)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 50),
|
||||
child: Column(
|
||||
children: [
|
||||
buildOtherLoginText(),
|
||||
buildOtherLoginText(context),
|
||||
const SizedBox(height: 15),
|
||||
buildOtherMethod(context),
|
||||
const SizedBox(height: 20),
|
||||
@@ -131,29 +131,29 @@ class _LoginPage extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildLoginForm() {
|
||||
Widget buildLoginForm(BuildContext context) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
children: [
|
||||
const SizedBox(height: kToolbarHeight),
|
||||
buildTitle(),
|
||||
const SizedBox(height: 60),
|
||||
buildUsernameTextField(),
|
||||
buildUsernameTextField(context),
|
||||
const SizedBox(height: 20),
|
||||
buildPasswordTextField(),
|
||||
buildPasswordTextField(context),
|
||||
const SizedBox(height: 10),
|
||||
buildRememberPasswordCheckbox(),
|
||||
buildRememberPasswordCheckbox(context),
|
||||
const SizedBox(height: 20),
|
||||
buildLoginButton(),
|
||||
buildLoginButton(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildUsernameTextField() {
|
||||
Widget buildUsernameTextField(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
formLabelText(labelText: "账号:"),
|
||||
Text("账号:", style: Theme.of(context).textTheme.bodyLarge),
|
||||
const SizedBox(height: 10),
|
||||
FormBuilderTextField(
|
||||
name: 'username',
|
||||
@@ -171,11 +171,11 @@ class _LoginPage extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildPasswordTextField() {
|
||||
Widget buildPasswordTextField(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
formLabelText(labelText: "密码:"),
|
||||
Text("密码:", style: Theme.of(context).textTheme.bodyLarge),
|
||||
const SizedBox(height: 10),
|
||||
FormBuilderTextField(
|
||||
name: 'password',
|
||||
@@ -205,7 +205,7 @@ class _LoginPage extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRememberPasswordCheckbox() {
|
||||
Widget buildRememberPasswordCheckbox(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
@@ -218,12 +218,12 @@ class _LoginPage extends State<LoginPage> {
|
||||
});
|
||||
},
|
||||
),
|
||||
const Text('记住密码', style: TextStyle(color: Colors.grey, fontSize: 14)),
|
||||
Text('记住密码', style: Theme.of(context).textTheme.bodyMedium),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildLoginButton() {
|
||||
Widget buildLoginButton(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 45,
|
||||
width: double.infinity,
|
||||
@@ -243,23 +243,20 @@ class _LoginPage extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildOtherLoginText() {
|
||||
Widget buildOtherLoginText(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Divider(color: Colors.grey[300], thickness: 1)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
'其他方式登录',
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
child: Text('其他方式登录', style: Theme.of(context).textTheme.bodyMedium),
|
||||
),
|
||||
Expanded(child: Divider(color: Colors.grey[300], thickness: 1)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildOtherMethod(context) {
|
||||
Widget buildOtherMethod(BuildContext context) {
|
||||
return OverflowBar(
|
||||
alignment: MainAxisAlignment.center,
|
||||
children:
|
||||
@@ -292,16 +289,19 @@ class _LoginPage extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRegisterText(context) {
|
||||
Widget buildRegisterText(BuildContext context) {
|
||||
return Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('没有账号?', style: TextStyle(fontSize: 18)),
|
||||
Text('没有账号?', style: Theme.of(context).textTheme.bodyMedium),
|
||||
GestureDetector(
|
||||
child: const Text(
|
||||
child: Text(
|
||||
'点击注册',
|
||||
style: TextStyle(fontSize: 18, color: Colors.green),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
print("点击注册");
|
||||
|
||||
Reference in New Issue
Block a user