Commit d5a8a7d0 authored by 胡曲's avatar 胡曲

fix bugs

parent e0fb3687
......@@ -14,10 +14,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
}) : _authService = authService,
_storageService = storageService,
super(AuthInitial()) {
on<AuthLoginRequested>(_onLoginRequested);
on<AuthTokenExpiredEvent>(_onTokenExpired);
on<AuthLogoutRequestedEvent>(_onLogoutRequested);
on<AuthFetchUserInfo>(_onFetchUserInfo);
on<AuthLoginRequested>(_onLoginRequested);/// 登录
on<AuthTokenExpiredEvent>(_onTokenExpired);/// token过期
on<AuthLogoutRequestedEvent>(_onLogoutRequested);/// 退出登录
on<AuthFetchUserInfo>(_onFetchUserInfo);/// 获取用户信息
}
Future<void> _onLoginRequested(
......@@ -80,4 +80,5 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
}
}
}
}
\ No newline at end of file
......@@ -157,7 +157,7 @@ class _HomeViewState extends State<HomeView> with AutoRouteAwareStateMixin<HomeV
voltageAlarmLocation: location,
voltageValue: DealUtils.formatVoltage(alert.voltage),
alertContent: alert.alertContent.isNotEmpty ?
'(${alert.alertContent})' : '',
'${alert.alertContent}·' : '',
voltageWaitTime: alert.waitingDurationDesc,
voltageAlarmLevel: alert.alertLevelText,
alertCategory: alert.alertCategory,
......
......@@ -100,7 +100,7 @@ class VoltageOperateBlock extends StatelessWidget {
width: double.infinity,
margin: EdgeInsets.only(left: 80.w, bottom: 20.h),
child: Text(
'电压$voltageValue $alertContent·$voltageWaitTime',
'$alertContent$voltageWaitTime',
style: TextStyle(
fontSize: 24.sp,
color: const Color.fromRGBO(100, 116, 139, 1.0),
......
......@@ -49,11 +49,7 @@ class LoginCubit extends Cubit<LoginState> {
emit(state.copyWith(rememberPassword: value));
}
void login({
required String username,
required String password,
bool rememberPassword = false,
}) {
void login(String username, String password, bool rememberPassword) {
if (rememberPassword) {
storageService.saveRememberCredentials(
username: username,
......@@ -83,7 +79,7 @@ class LoginCubit extends Cubit<LoginState> {
}
void forgotPwd() {
// TODO: 跳转到忘记密码页面
}
@override
......
......@@ -73,53 +73,46 @@ class LoginView extends StatelessWidget {
return Column(
children: [
SizedBox(height: 150.h),
SizedBox(height: 208.h),
Container(
margin: EdgeInsets.only(bottom: 80.h),
child: Column(
children: [
Container(
width: 160.w,
height: 160.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.w),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF00C6FF),
Color(0xFF0072FF),
],
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(40.w),
child: Image.asset(
'lib/assets/login/logo@2x.png',
fit: BoxFit.cover,
),
),
),
SizedBox(height: 40.h),
const Text(
'智能酒店管理系统',
style: TextStyle(
color: Color(0xFF333333),
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10.h),
const Text(
'Intelligent Hotel Management System',
style: TextStyle(
color: Color(0xFF999999),
fontSize: 14,
),
),
],
width: 160.w,
height: 160.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(32.r),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF00C6FF),
Color(0xFF0072FF),
],
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(32.r),
child: Image.asset(
'lib/assets/login/logo@2x.png',
fit: BoxFit.cover,
),
),
),
SizedBox(height: 30.h),
const Text(
'智能酒店管理系统',
style: TextStyle(
color: Color(0xFF333333),
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const Text(
'Intelligent Hotel Management System',
style: TextStyle(
color: Color(0xFF999999),
fontSize: 14,
),
),
SizedBox(height: 60.h),
Form(
key: _frmGlobalKey,
child: Column(
......@@ -128,7 +121,6 @@ class LoginView extends StatelessWidget {
UsernameField(
controller: _txtUserNameController,
),
SizedBox(height: 20.h),
PasswordField(
controller: _txtPwdController,
),
......@@ -159,16 +151,11 @@ class LoginView extends StatelessWidget {
return BtnLogin(
isLoading: authState is AuthLoading,
onPressed: () {
if (_frmGlobalKey.currentState!
.validate()) {
if (_frmGlobalKey.currentState!.validate()) {
cubit.login(
username:
_txtUserNameController.text
.trim(),
password:
_txtPwdController.text.trim(),
rememberPassword:
state.rememberPassword,
_txtUserNameController.text.trim(),
_txtPwdController.text.trim(),
state.rememberPassword,
);
}
},
......
......@@ -15,10 +15,10 @@ class BtnLogin extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 104.h,
height: 83.h,
decoration: BoxDecoration(
color: const Color.fromRGBO(73, 149, 234, 1),
borderRadius: BorderRadius.circular(40.w),
borderRadius: BorderRadius.circular(50.r),
),
child: ElevatedButton(
onPressed: isLoading ? null : onPressed,
......
......@@ -28,7 +28,7 @@ class _PasswordFieldState extends State<PasswordField> {
return TextFormField(
controller: widget.controller,
obscureText: _obscureText,
style: TextStyle(color: const Color(0xFF333333), fontSize: 28.sp),
style: TextStyle(color: const Color(0xFF333333), fontSize: 32.sp),
validator: (val) {
if (val == null || val.isEmpty) {
return "密码不能为空";
......@@ -38,7 +38,7 @@ class _PasswordFieldState extends State<PasswordField> {
decoration: InputDecoration(
filled: true,
hintText: "password",
hintStyle: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
hintStyle: TextStyle(color: const Color(0xFF999999), fontSize: 32.sp),
prefixIcon: Icon(Icons.lock, color: const Color(0xFF999999), size: 40.w),
prefixIconConstraints: BoxConstraints(minWidth: 80.w, minHeight: 80.w),
suffixIcon: IconButton(
......@@ -52,8 +52,8 @@ class _PasswordFieldState extends State<PasswordField> {
suffixIconConstraints: BoxConstraints(minWidth: 80.w, minHeight: 80.w),
contentPadding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
helperText: " ",
helperStyle: TextStyle(height: 1, fontSize: 24.sp),
errorStyle: TextStyle(color: Colors.red, fontSize: 24.sp, height: 1),
helperStyle: TextStyle(height: 1, fontSize: 28.sp),
errorStyle: TextStyle(color: Colors.red, fontSize: 28.sp, height: 1),
errorMaxLines: 1,
fillColor: Colors.white,
border: OutlineInputBorder(
......
......@@ -47,6 +47,7 @@ class RememberPasswordRow extends StatelessWidget {
style: TextStyle(
color: const Color(0xFF0A0D14),
fontSize: 24.sp,
fontWeight: FontWeight.w600,
),
),
],
......
......@@ -13,7 +13,7 @@ class UsernameField extends StatelessWidget {
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
style: TextStyle(color: const Color(0xFF333333), fontSize: 28.sp),
style: TextStyle(color: const Color(0xFF333333), fontSize: 32.sp),
validator: (val) {
if (val == null || val.isEmpty) {
return "用户名不能为空哦";
......@@ -23,13 +23,13 @@ class UsernameField extends StatelessWidget {
decoration: InputDecoration(
filled: true,
hintText: "admin",
hintStyle: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
hintStyle: TextStyle(color: const Color(0xFF999999), fontSize: 32.sp),
prefixIcon: Icon(Icons.person, color: const Color(0xFF999999), size: 40.w),
prefixIconConstraints: BoxConstraints(minWidth: 80.w, minHeight: 80.w),
contentPadding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
helperText: " ",
helperStyle: TextStyle(height: 1, fontSize: 24.sp),
errorStyle: TextStyle(color: Colors.red, fontSize: 24.sp, height: 1),
helperStyle: TextStyle(height: 1, fontSize: 28.sp),
errorStyle: TextStyle(color: Colors.red, fontSize: 28.sp, height: 1),
errorMaxLines: 1,
fillColor: Colors.white,
border: OutlineInputBorder(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment