Commit d5a8a7d0 authored by 胡曲's avatar 胡曲

fix bugs

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