feat:some changes done in login
This commit is contained in:
@@ -7,14 +7,15 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
|||||||
final Color iconColor;
|
final Color iconColor;
|
||||||
final Color buttonInactiveColor;
|
final Color buttonInactiveColor;
|
||||||
final Color borderColor;
|
final Color borderColor;
|
||||||
|
final Color inActiveColor;
|
||||||
|
|
||||||
AppThemeColors({
|
AppThemeColors({
|
||||||
required this.onBoardingColor,
|
required this.onBoardingColor,
|
||||||
required this.boxShadow,
|
required this.boxShadow,
|
||||||
required this.iconColor,
|
required this.iconColor,
|
||||||
required this.buttonInactiveColor,
|
required this.buttonInactiveColor,
|
||||||
required this.borderColor
|
required this.borderColor,
|
||||||
|
required this.inActiveColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
static AppThemeColors light = AppThemeColors(
|
static AppThemeColors light = AppThemeColors(
|
||||||
@@ -22,8 +23,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
|||||||
boxShadow: AppColors.cD6D4D4,
|
boxShadow: AppColors.cD6D4D4,
|
||||||
buttonInactiveColor: AppColors.cE2E4EA,
|
buttonInactiveColor: AppColors.cE2E4EA,
|
||||||
iconColor: AppColors.cFFFFFF,
|
iconColor: AppColors.cFFFFFF,
|
||||||
borderColor:AppColors.cE2E4EA
|
borderColor: AppColors.cE2E4EA,
|
||||||
|
inActiveColor: AppColors.cE2E4EA,
|
||||||
);
|
);
|
||||||
|
|
||||||
static AppThemeColors dark = AppThemeColors(
|
static AppThemeColors dark = AppThemeColors(
|
||||||
@@ -31,7 +32,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
|||||||
boxShadow: AppColors.c524242,
|
boxShadow: AppColors.c524242,
|
||||||
buttonInactiveColor: AppColors.c292F3D,
|
buttonInactiveColor: AppColors.c292F3D,
|
||||||
iconColor: AppColors.c131720,
|
iconColor: AppColors.c131720,
|
||||||
borderColor: AppColors.c292F3D
|
borderColor: AppColors.c292F3D,
|
||||||
|
inActiveColor: AppColors.c292F3D,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,21 +42,24 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
|||||||
Color? boxShadow,
|
Color? boxShadow,
|
||||||
Color? iconColor,
|
Color? iconColor,
|
||||||
Color? buttonInactiveColor,
|
Color? buttonInactiveColor,
|
||||||
Color? borderColor
|
Color? borderColor,
|
||||||
|
Color? inActiveColor,
|
||||||
}) {
|
}) {
|
||||||
return AppThemeColors(
|
return AppThemeColors(
|
||||||
onBoardingColor: onBoardingColor ?? this.onBoardingColor,
|
onBoardingColor: onBoardingColor ?? this.onBoardingColor,
|
||||||
boxShadow: boxShadow ?? this.boxShadow,
|
boxShadow: boxShadow ?? this.boxShadow,
|
||||||
iconColor: iconColor ?? this.iconColor,
|
iconColor: iconColor ?? this.iconColor,
|
||||||
buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor,
|
buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor,
|
||||||
borderColor: borderColor??this.borderColor
|
borderColor: borderColor ?? this.borderColor,
|
||||||
|
inActiveColor: inActiveColor ?? this.inActiveColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ThemeExtension<AppThemeColors> lerp(
|
ThemeExtension<AppThemeColors> lerp(
|
||||||
covariant ThemeExtension<AppThemeColors>? other,
|
covariant ThemeExtension<AppThemeColors>? other,
|
||||||
double t,) {
|
double t,
|
||||||
|
) {
|
||||||
if (other is! AppThemeColors) return this;
|
if (other is! AppThemeColors) return this;
|
||||||
return t < 0.5 ? this : other;
|
return t < 0.5 ? this : other;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/auth/presentation/login_page/widgets/welcome_text.dart';
|
||||||
import 'package:food_delivery_client/feature/common/presentation/widgets/app_text_form_field.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 _phoneNumberController;
|
||||||
late TextEditingController _passwordController;
|
late TextEditingController _passwordController;
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
bool _isValidForm = false;
|
||||||
|
|
||||||
|
void _validateForm() {
|
||||||
|
final isValid = _formKey.currentState?.validate() ?? false;
|
||||||
|
if (isValid != _isValidForm) {
|
||||||
|
setState(() {
|
||||||
|
_isValidForm = isValid;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_phoneNumberController = TextEditingController();
|
_phoneNumberController = TextEditingController();
|
||||||
_passwordController = TextEditingController();
|
_passwordController = TextEditingController();
|
||||||
|
_passwordController.addListener(_validateForm);
|
||||||
|
_phoneNumberController.addListener(_validateForm);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_phoneNumberController.removeListener(_validateForm);
|
||||||
|
_passwordController.removeListener(_validateForm);
|
||||||
_phoneNumberController.dispose();
|
_phoneNumberController.dispose();
|
||||||
_passwordController.dispose();
|
_passwordController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -36,20 +52,28 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: WLayout(
|
child: WLayout(
|
||||||
top: false,
|
top: false,
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(AppIcons.icLogin),
|
SizedBox(
|
||||||
|
width: context.w,
|
||||||
|
child: SvgPicture.asset(AppIcons.icLogin, fit: BoxFit.fitWidth),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
child: Material(
|
child: Material(
|
||||||
color: AppColors.cTransparent,
|
color: AppColors.cTransparent,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
keyboardDismissBehavior:
|
||||||
|
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
child:
|
child:
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
30.verticalSpace,
|
30.verticalSpace,
|
||||||
WBackButton(),
|
//WBackButton(),
|
||||||
20.verticalSpace,
|
60.verticalSpace,
|
||||||
WelcomeText(
|
WelcomeText(
|
||||||
text: context.loc.welcome_to_volt(
|
text: context.loc.welcome_to_volt(
|
||||||
AppLocaleKeys.appName,
|
AppLocaleKeys.appName,
|
||||||
@@ -70,8 +94,19 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
),
|
),
|
||||||
10.verticalSpace,
|
10.verticalSpace,
|
||||||
AppTextFormField(
|
AppTextFormField(
|
||||||
|
prefixIcon: Text("+ 998"),
|
||||||
controller: _phoneNumberController,
|
controller: _phoneNumberController,
|
||||||
hintText: context.loc.enter_email_or_phone,
|
hintText: context.loc.enter_email_or_phone,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
|
Formatters.phoneFormatter,
|
||||||
|
LengthLimitingTextInputFormatter(12),
|
||||||
|
],
|
||||||
|
validator: (value) {
|
||||||
|
return Validators.validatePhoneNumber(
|
||||||
|
_phoneNumberController.text.trim(),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
20.verticalSpace,
|
20.verticalSpace,
|
||||||
Text(
|
Text(
|
||||||
@@ -83,6 +118,11 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
obscureText: true,
|
obscureText: true,
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
hintText: context.loc.enter_password,
|
hintText: context.loc.enter_password,
|
||||||
|
validator: (value) {
|
||||||
|
return Validators.validatePassword(
|
||||||
|
_passwordController.text.trim(),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
10.verticalSpace,
|
10.verticalSpace,
|
||||||
Align(
|
Align(
|
||||||
@@ -100,8 +140,11 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
60.verticalSpace,
|
60.verticalSpace,
|
||||||
AppButton(
|
AppButton(
|
||||||
name: context.loc.login,
|
name: context.loc.login,
|
||||||
|
isActive: _isValidForm,
|
||||||
|
isLoading: false,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState?.validate() ?? false) {}
|
if (_formKey.currentState?.validate() ??
|
||||||
|
false) {}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
15.verticalSpace,
|
15.verticalSpace,
|
||||||
@@ -110,26 +153,30 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
child: RichText(
|
child: RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: context.loc.dont_have_account,
|
text: context.loc.dont_have_account,
|
||||||
style: context.appThemeTextStyles.size14Regular,
|
style:
|
||||||
|
context.appThemeTextStyles.size14Regular,
|
||||||
children: [
|
children: [
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
baseline: TextBaseline.alphabetic,
|
baseline: TextBaseline.alphabetic,
|
||||||
alignment: PlaceholderAlignment.baseline,
|
alignment: PlaceholderAlignment.baseline,
|
||||||
|
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
shadowColor: WidgetStatePropertyAll(
|
shadowColor: WidgetStatePropertyAll(
|
||||||
AppColors.cFF6F00.newWithOpacity(.2),
|
AppColors.cFF6F00.newWithOpacity(
|
||||||
|
.2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
padding: WidgetStatePropertyAll(
|
padding: WidgetStatePropertyAll(
|
||||||
EdgeInsets.zero,
|
EdgeInsets.symmetric(horizontal: 4),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
context.loc.register,
|
context.loc.register,
|
||||||
style: AppTextStyles.size14Bold
|
style: AppTextStyles.size14Bold
|
||||||
.copyWith(color: AppColors.cFF6F00),
|
.copyWith(
|
||||||
|
color: AppColors.cFF6F00,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -146,6 +193,7 @@ class _WLoginBodyState extends State<WLoginBody> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class AppButton extends StatelessWidget {
|
|||||||
this.leading,
|
this.leading,
|
||||||
this.trailing,
|
this.trailing,
|
||||||
this.mainAxisAlignment,
|
this.mainAxisAlignment,
|
||||||
|
this.isActive = true,
|
||||||
this.isLoading = false,
|
this.isLoading = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,12 +29,14 @@ class AppButton extends StatelessWidget {
|
|||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final Widget? trailing;
|
final Widget? trailing;
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
final MainAxisAlignment? mainAxisAlignment;
|
final MainAxisAlignment? mainAxisAlignment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Bounceable(
|
return Bounceable(
|
||||||
onTap: onPressed,
|
onTap: isActive ? onPressed : null,
|
||||||
duration: TimeDelayConst.durationMill150,
|
duration: TimeDelayConst.durationMill150,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: width ?? double.infinity,
|
width: width ?? double.infinity,
|
||||||
@@ -42,7 +45,9 @@ class AppButton extends StatelessWidget {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: backgroundColor ?? AppColors.cFF6F00,
|
color: isActive
|
||||||
|
? backgroundColor ?? AppColors.cFF6F00
|
||||||
|
: context.appThemeColors.inActiveColor,
|
||||||
borderRadius: BorderRadius.circular(borderRadius ?? 12),
|
borderRadius: BorderRadius.circular(borderRadius ?? 12),
|
||||||
),
|
),
|
||||||
child: isLoading
|
child: isLoading
|
||||||
|
|||||||
@@ -6,19 +6,29 @@ class WLayout extends StatelessWidget {
|
|||||||
this.bgColor,
|
this.bgColor,
|
||||||
this.bottom = true,
|
this.bottom = true,
|
||||||
this.top = true,
|
this.top = true,
|
||||||
|
this.left = true,
|
||||||
|
this.right = true,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Color? bgColor;
|
final Color? bgColor;
|
||||||
final bool bottom;
|
final bool bottom;
|
||||||
final bool top;
|
final bool top;
|
||||||
|
final bool right;
|
||||||
|
final bool left;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: bgColor ?? context.theme.scaffoldBackgroundColor,
|
color: bgColor ?? context.theme.scaffoldBackgroundColor,
|
||||||
child: SafeArea(top: top, bottom: bottom, child: child),
|
child: SafeArea(
|
||||||
|
top: top,
|
||||||
|
bottom: bottom,
|
||||||
|
right: right,
|
||||||
|
left: left,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ class SplashBloc extends Bloc<SplashEvent, SplashState> {
|
|||||||
_onStarted(_Started event, Emitter<SplashState> emit) async {
|
_onStarted(_Started event, Emitter<SplashState> emit) async {
|
||||||
await Future.delayed(TimeDelayConst.duration2);
|
await Future.delayed(TimeDelayConst.duration2);
|
||||||
final token = _storageService.getString(key: AppLocaleKeys.token);
|
final token = _storageService.getString(key: AppLocaleKeys.token);
|
||||||
|
log("Token:$token");
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
emit(state.copyWith(status: RequestStatus.loaded));
|
emit(state.copyWith(status: RequestStatus.error));
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(status: RequestStatus.error));
|
emit(state.copyWith(status: RequestStatus.error));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: AppTheme.lightTheme,
|
theme: AppTheme.lightTheme,
|
||||||
darkTheme: AppTheme.darkTheme,
|
darkTheme: AppTheme.darkTheme,
|
||||||
themeMode: ThemeMode.dark,
|
themeMode: ThemeMode.light,
|
||||||
routerConfig: sl<AppRoutes>().router,
|
routerConfig: sl<AppRoutes>().router,
|
||||||
locale: state.currentLocale,
|
locale: state.currentLocale,
|
||||||
supportedLocales: L10n.locales,
|
supportedLocales: L10n.locales,
|
||||||
|
|||||||
Reference in New Issue
Block a user