mobile_skt/lib/screens/login/login.dart

199 lines
5.0 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class LoginScreen extends StatelessWidget {
LoginScreen({super.key});
final formKey = GlobalKey<FormState>();
late BuildContext theContext;
bool loading = false;
String? username;
String? password;
@override
Widget build(BuildContext context) {
return Scaffold(body: SafeArea(child: buildBody()));
}
buildBody() {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
// 触摸收起键盘
},
child: Padding(
padding: EdgeInsets.fromLTRB(0, 0, 10, 30),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Logo(size: 120),
SizedBox(height: 30),
buildForm(),
SizedBox(height: 30),
],
),
),
buildGoRegister(),
buildNotice(),
],
),
)));
}
Widget buildNotice() {
return Padding(
padding: EdgeInsets.fromLTRB(50, 5, 50, 5),
child: Text(
'If you have registered as a PLAYER, COACH, MANAGER or REFEREE, please use your login details provided.',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold)));
}
Widget buildForm() {
final children = [
buildUserNameInput(),
SizedBox(
height: 15,
),
buildPasswordInput(),
SizedBox(
height: 12,
),
buildForgotPassword(),
SizedBox(
height: 12,
),
buildSubmitButton(),
/* SizedBox(
height: 12,
),
buildRegistry() */
];
final child = Column(
mainAxisAlignment: MainAxisAlignment.start,
children: children,
);
return Form(
key: formKey,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 0, horizontal: 50),
child: child,
));
}
Widget buildGoRegister() => Container(
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Text('Don\'t have an account?'),
SizedBox(width: 5),
GestureDetector(
onTap: () {},
child: Text('Create',
style: TextStyle(
color: AppTheme.primaryColor,
decoration: TextDecoration.underline,
))),
]),
);
Widget buildSubmitButton() {
final color = AppTheme.primaryColor;
// final button = RaisedButton(
// shape: StadiumBorder(),
// child: loading
// ? SizedBox(
// child: CircularProgressIndicator(
// color: AppTheme.primaryColorDark,
// ),
// height: 18,
// width: 18,
// )
// : Text('Sign In'),
// onPressed: () {
// _submit();
// },
// color: color,
// /* elevation: 20, */
// padding: EdgeInsets.all(12),
// );
// final child = Expanded(
// child: button,
// );
return Row(
children: [],
);
}
Widget buildUserNameInput() {
return TextFormField(
initialValue: username,
decoration: InputDecoration(
labelText: 'Email / Reg ID',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(10))),
fillColor: Color(0xFFF8F8F8),
),
onChanged: (value) {
this.username = value;
},
validator: (String? value) {
if (value == null || value == '') {
return 'Email / Reg ID is required';
} else {
return null;
}
},
);
}
Widget buildPasswordInput() {
return TextFormField(
initialValue: password,
decoration: InputDecoration(
labelText: 'Password',
/* border: OutlineInputBorder(), */
fillColor: Color(0xFFF8F8F8),
),
obscureText: true,
onChanged: (value) {
this.password = value;
},
validator: (String? value) {
return (value ?? '').length >= 6 ? null : 'Invalid password';
},
);
}
Future<void> _submit() async {
if (!formKey.currentState!.validate()) {
return;
}
return;
}
Widget buildForgotPassword() {
return GestureDetector(
onTap: () {},
child: Container(
alignment: Alignment.centerRight,
child: Text(
'Forgot Password?',
style: TextStyle(
color: Colors.grey,
decoration: TextDecoration.underline,
),
)),
);
}
}