feat:some changes done in login
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:food_delivery_client/core/helpers/formatters.dart';
|
||||
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/login_page/widgets/welcome_text.dart';
|
||||
import 'package:food_delivery_client/feature/common/presentation/widgets/app_text_form_field.dart';
|
||||
|
||||
@@ -14,16 +16,30 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
late TextEditingController _phoneNumberController;
|
||||
late TextEditingController _passwordController;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _isValidForm = false;
|
||||
|
||||
void _validateForm() {
|
||||
final isValid = _formKey.currentState?.validate() ?? false;
|
||||
if (isValid != _isValidForm) {
|
||||
setState(() {
|
||||
_isValidForm = isValid;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_phoneNumberController = TextEditingController();
|
||||
_passwordController = TextEditingController();
|
||||
_passwordController.addListener(_validateForm);
|
||||
_phoneNumberController.addListener(_validateForm);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneNumberController.removeListener(_validateForm);
|
||||
_passwordController.removeListener(_validateForm);
|
||||
_phoneNumberController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
@@ -36,114 +52,146 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: WLayout(
|
||||
top: false,
|
||||
left: false,
|
||||
right: false,
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
SvgPicture.asset(AppIcons.icLogin),
|
||||
SizedBox(
|
||||
width: context.w,
|
||||
child: SvgPicture.asset(AppIcons.icLogin, fit: BoxFit.fitWidth),
|
||||
),
|
||||
Positioned(
|
||||
child: Material(
|
||||
color: AppColors.cTransparent,
|
||||
child:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
30.verticalSpace,
|
||||
WBackButton(),
|
||||
20.verticalSpace,
|
||||
WelcomeText(
|
||||
text: context.loc.welcome_to_volt(
|
||||
AppLocaleKeys.appName,
|
||||
child: SingleChildScrollView(
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
child:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
30.verticalSpace,
|
||||
//WBackButton(),
|
||||
60.verticalSpace,
|
||||
WelcomeText(
|
||||
text: context.loc.welcome_to_volt(
|
||||
AppLocaleKeys.appName,
|
||||
),
|
||||
),
|
||||
),
|
||||
8.verticalSpace,
|
||||
Text(
|
||||
context.loc.please_login,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.cA7AEC1,
|
||||
height: 1.6,
|
||||
8.verticalSpace,
|
||||
Text(
|
||||
context.loc.please_login,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.cA7AEC1,
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
),
|
||||
54.verticalSpace,
|
||||
Text(
|
||||
context.loc.email_or_phone,
|
||||
style: context.appThemeTextStyles.size16Medium,
|
||||
),
|
||||
10.verticalSpace,
|
||||
AppTextFormField(
|
||||
controller: _phoneNumberController,
|
||||
hintText: context.loc.enter_email_or_phone,
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.password,
|
||||
style: context.appThemeTextStyles.size16Medium,
|
||||
),
|
||||
10.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
controller: _passwordController,
|
||||
hintText: context.loc.enter_password,
|
||||
),
|
||||
10.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
context.loc.forgot_password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.cFF6F00,
|
||||
54.verticalSpace,
|
||||
Text(
|
||||
context.loc.email_or_phone,
|
||||
style: context.appThemeTextStyles.size16Medium,
|
||||
),
|
||||
10.verticalSpace,
|
||||
AppTextFormField(
|
||||
prefixIcon: Text("+ 998"),
|
||||
controller: _phoneNumberController,
|
||||
hintText: context.loc.enter_email_or_phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
Formatters.phoneFormatter,
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
],
|
||||
validator: (value) {
|
||||
return Validators.validatePhoneNumber(
|
||||
_phoneNumberController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.password,
|
||||
style: context.appThemeTextStyles.size16Medium,
|
||||
),
|
||||
10.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
controller: _passwordController,
|
||||
hintText: context.loc.enter_password,
|
||||
validator: (value) {
|
||||
return Validators.validatePassword(
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
context.loc.forgot_password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.cFF6F00,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
60.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.login,
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {}
|
||||
},
|
||||
),
|
||||
15.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: context.loc.dont_have_account,
|
||||
style: context.appThemeTextStyles.size14Regular,
|
||||
children: [
|
||||
WidgetSpan(
|
||||
baseline: TextBaseline.alphabetic,
|
||||
alignment: PlaceholderAlignment.baseline,
|
||||
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
style: ButtonStyle(
|
||||
shadowColor: WidgetStatePropertyAll(
|
||||
AppColors.cFF6F00.newWithOpacity(.2),
|
||||
60.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.login,
|
||||
isActive: _isValidForm,
|
||||
isLoading: false,
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ??
|
||||
false) {}
|
||||
},
|
||||
),
|
||||
15.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: context.loc.dont_have_account,
|
||||
style:
|
||||
context.appThemeTextStyles.size14Regular,
|
||||
children: [
|
||||
WidgetSpan(
|
||||
baseline: TextBaseline.alphabetic,
|
||||
alignment: PlaceholderAlignment.baseline,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
style: ButtonStyle(
|
||||
shadowColor: WidgetStatePropertyAll(
|
||||
AppColors.cFF6F00.newWithOpacity(
|
||||
.2,
|
||||
),
|
||||
),
|
||||
padding: WidgetStatePropertyAll(
|
||||
EdgeInsets.symmetric(horizontal: 4),
|
||||
),
|
||||
),
|
||||
padding: WidgetStatePropertyAll(
|
||||
EdgeInsets.zero,
|
||||
child: Text(
|
||||
context.loc.register,
|
||||
style: AppTextStyles.size14Bold
|
||||
.copyWith(
|
||||
color: AppColors.cFF6F00,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
context.loc.register,
|
||||
style: AppTextStyles.size14Bold
|
||||
.copyWith(color: AppColors.cFF6F00),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingOnly(
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: context.mq.viewPadding.top,
|
||||
bottom: context.mq.viewPadding.bottom,
|
||||
),
|
||||
],
|
||||
).paddingOnly(
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: context.mq.viewPadding.top,
|
||||
bottom: context.mq.viewPadding.bottom,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user