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 buttonInactiveColor;
|
||||
final Color borderColor;
|
||||
|
||||
final Color inActiveColor;
|
||||
|
||||
AppThemeColors({
|
||||
required this.onBoardingColor,
|
||||
required this.boxShadow,
|
||||
required this.iconColor,
|
||||
required this.buttonInactiveColor,
|
||||
required this.borderColor
|
||||
required this.borderColor,
|
||||
required this.inActiveColor,
|
||||
});
|
||||
|
||||
static AppThemeColors light = AppThemeColors(
|
||||
@@ -22,8 +23,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
||||
boxShadow: AppColors.cD6D4D4,
|
||||
buttonInactiveColor: AppColors.cE2E4EA,
|
||||
iconColor: AppColors.cFFFFFF,
|
||||
borderColor:AppColors.cE2E4EA
|
||||
|
||||
borderColor: AppColors.cE2E4EA,
|
||||
inActiveColor: AppColors.cE2E4EA,
|
||||
);
|
||||
|
||||
static AppThemeColors dark = AppThemeColors(
|
||||
@@ -31,7 +32,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
||||
boxShadow: AppColors.c524242,
|
||||
buttonInactiveColor: AppColors.c292F3D,
|
||||
iconColor: AppColors.c131720,
|
||||
borderColor: AppColors.c292F3D
|
||||
borderColor: AppColors.c292F3D,
|
||||
inActiveColor: AppColors.c292F3D,
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -40,21 +42,24 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
|
||||
Color? boxShadow,
|
||||
Color? iconColor,
|
||||
Color? buttonInactiveColor,
|
||||
Color? borderColor
|
||||
Color? borderColor,
|
||||
Color? inActiveColor,
|
||||
}) {
|
||||
return AppThemeColors(
|
||||
onBoardingColor: onBoardingColor ?? this.onBoardingColor,
|
||||
boxShadow: boxShadow ?? this.boxShadow,
|
||||
iconColor: iconColor ?? this.iconColor,
|
||||
buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor,
|
||||
borderColor: borderColor??this.borderColor
|
||||
borderColor: borderColor ?? this.borderColor,
|
||||
inActiveColor: inActiveColor ?? this.inActiveColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ThemeExtension<AppThemeColors> lerp(
|
||||
covariant ThemeExtension<AppThemeColors>? other,
|
||||
double t,) {
|
||||
double t,
|
||||
) {
|
||||
if (other is! AppThemeColors) return this;
|
||||
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/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,20 +52,28 @@ 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: SingleChildScrollView(
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
child:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
30.verticalSpace,
|
||||
WBackButton(),
|
||||
20.verticalSpace,
|
||||
//WBackButton(),
|
||||
60.verticalSpace,
|
||||
WelcomeText(
|
||||
text: context.loc.welcome_to_volt(
|
||||
AppLocaleKeys.appName,
|
||||
@@ -70,8 +94,19 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
),
|
||||
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(
|
||||
@@ -83,6 +118,11 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
obscureText: true,
|
||||
controller: _passwordController,
|
||||
hintText: context.loc.enter_password,
|
||||
validator: (value) {
|
||||
return Validators.validatePassword(
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
Align(
|
||||
@@ -100,8 +140,11 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
60.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.login,
|
||||
isActive: _isValidForm,
|
||||
isLoading: false,
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {}
|
||||
if (_formKey.currentState?.validate() ??
|
||||
false) {}
|
||||
},
|
||||
),
|
||||
15.verticalSpace,
|
||||
@@ -110,26 +153,30 @@ class _WLoginBodyState extends State<WLoginBody> {
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: context.loc.dont_have_account,
|
||||
style: context.appThemeTextStyles.size14Regular,
|
||||
style:
|
||||
context.appThemeTextStyles.size14Regular,
|
||||
children: [
|
||||
WidgetSpan(
|
||||
baseline: TextBaseline.alphabetic,
|
||||
alignment: PlaceholderAlignment.baseline,
|
||||
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
style: ButtonStyle(
|
||||
shadowColor: WidgetStatePropertyAll(
|
||||
AppColors.cFF6F00.newWithOpacity(.2),
|
||||
AppColors.cFF6F00.newWithOpacity(
|
||||
.2,
|
||||
),
|
||||
),
|
||||
padding: WidgetStatePropertyAll(
|
||||
EdgeInsets.zero,
|
||||
EdgeInsets.symmetric(horizontal: 4),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
context.loc.register,
|
||||
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.trailing,
|
||||
this.mainAxisAlignment,
|
||||
this.isActive = true,
|
||||
this.isLoading = false,
|
||||
});
|
||||
|
||||
@@ -28,12 +29,14 @@ class AppButton extends StatelessWidget {
|
||||
final Widget? leading;
|
||||
final Widget? trailing;
|
||||
final bool isLoading;
|
||||
final bool isActive;
|
||||
|
||||
final MainAxisAlignment? mainAxisAlignment;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Bounceable(
|
||||
onTap: onPressed,
|
||||
onTap: isActive ? onPressed : null,
|
||||
duration: TimeDelayConst.durationMill150,
|
||||
child: Container(
|
||||
width: width ?? double.infinity,
|
||||
@@ -42,7 +45,9 @@ class AppButton extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? AppColors.cFF6F00,
|
||||
color: isActive
|
||||
? backgroundColor ?? AppColors.cFF6F00
|
||||
: context.appThemeColors.inActiveColor,
|
||||
borderRadius: BorderRadius.circular(borderRadius ?? 12),
|
||||
),
|
||||
child: isLoading
|
||||
|
||||
@@ -6,19 +6,29 @@ class WLayout extends StatelessWidget {
|
||||
this.bgColor,
|
||||
this.bottom = true,
|
||||
this.top = true,
|
||||
this.left = true,
|
||||
this.right = true,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Color? bgColor;
|
||||
final bool bottom;
|
||||
final bool top;
|
||||
final bool right;
|
||||
final bool left;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
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 {
|
||||
await Future.delayed(TimeDelayConst.duration2);
|
||||
final token = _storageService.getString(key: AppLocaleKeys.token);
|
||||
log("Token:$token");
|
||||
if (token != null) {
|
||||
emit(state.copyWith(status: RequestStatus.loaded));
|
||||
emit(state.copyWith(status: RequestStatus.error));
|
||||
} else {
|
||||
emit(state.copyWith(status: RequestStatus.error));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class _MyAppState extends State<MyApp> {
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
themeMode: ThemeMode.dark,
|
||||
themeMode: ThemeMode.light,
|
||||
routerConfig: sl<AppRoutes>().router,
|
||||
locale: state.currentLocale,
|
||||
supportedLocales: L10n.locales,
|
||||
|
||||
Reference in New Issue
Block a user