fixed logout at refresh failed
This commit is contained in:
@@ -52,78 +52,90 @@ class _LoginTabletPageState extends State<LoginTabletPage> {
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: SizedBox(
|
||||
width: 364.0.w(),
|
||||
child: Consumer<AuthViewModel>(
|
||||
builder: (context, viewModel, _) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.logoBig,
|
||||
width: double.infinity,
|
||||
height: 50.0.h(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 72.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 40.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
LoginTextField(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 22.0.w()),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.logoBig,
|
||||
width: double.infinity,
|
||||
height: 50.0.h(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 72.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 40.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: LoginStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 24.0.h()),
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.obscurePassword,
|
||||
builder: (_, obscurePassword, __) {
|
||||
return LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: LoginStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
obscureText: obscurePassword,
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 70.0.h()),
|
||||
if (viewModel.isLoading)
|
||||
const BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
onPressed:
|
||||
viewModel.isLoginEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
SizedBox(height: 30.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 70.0.h()),
|
||||
|
||||
/// ✅ Only this part rebuilds now
|
||||
Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoading,
|
||||
builder: (_, isLoading, __) {
|
||||
return Selector<AuthViewModel, bool>(
|
||||
selector: (_, vm) => vm.isLoginEnabled,
|
||||
builder: (_, isEnabled, __) {
|
||||
if (isLoading) {
|
||||
return BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
textColor: AppColors.white,
|
||||
);
|
||||
}
|
||||
|
||||
return BaseButton(
|
||||
isEnabled: isEnabled,
|
||||
onPressed:
|
||||
isEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
}
|
||||
: null,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 30.0.h()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
const ForgotPasswordRouteData().push(context);
|
||||
},
|
||||
child: Text(
|
||||
LoginStrings.forgotPassword,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.mainBlue,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user