feat: splash page done
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class ForgotPasswordPage extends StatelessWidget {
|
||||
const ForgotPasswordPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WLayout(
|
||||
child: Scaffold(body: Column(children: [Text('Forgot password')])),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import 'package:food_delivery_client/feature/auth/presentation/blocs/login_bloc/login_bloc.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/widgets/login_body.dart';
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class LoginPage extends StatelessWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<LoginBloc>(),
|
||||
child: WLayout(
|
||||
top: false,
|
||||
child: Scaffold(resizeToAvoidBottomInset: true, body: WLoginBody()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
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/widgets/w_auth_background.dart';
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
import '../../../../domain/usecases/login_usecase.dart';
|
||||
import '../../../blocs/login_bloc/login_bloc.dart';
|
||||
|
||||
class WLoginBody extends StatefulWidget {
|
||||
const WLoginBody({super.key});
|
||||
|
||||
@override
|
||||
State<WLoginBody> createState() => _WLoginBodyState();
|
||||
}
|
||||
|
||||
class _WLoginBodyState extends State<WLoginBody> {
|
||||
late final TextEditingController _phoneController;
|
||||
late final TextEditingController _passwordController;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_phoneController = TextEditingController();
|
||||
_passwordController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<LoginBloc, LoginState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.go(Routes.main);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: WAuthBackground(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
25.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: Text(
|
||||
context.loc.login,
|
||||
style: AppTextStyles.size24Bold,
|
||||
),
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.phone_number,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
hintText: context.loc.enter_phone_number,
|
||||
prefixIcon: Text(
|
||||
"+ 998",
|
||||
style: AppTextStyles.size16Regular.copyWith(fontSize: 16),
|
||||
),
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
controller: _phoneController,
|
||||
keyBoardType: TextInputType.number,
|
||||
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
Formatters.phoneFormatter,
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
],
|
||||
validator: (value) {
|
||||
return Validators.validatePhoneNumber(
|
||||
_phoneController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
Text(
|
||||
context.loc.password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
height: 50,
|
||||
obscureText: true,
|
||||
hintText: context.loc.enter_password,
|
||||
keyBoardType: TextInputType.text,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
controller: _passwordController,
|
||||
validator: (value) {
|
||||
return Validators.validatePassword(
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentGeometry.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
context.push(Routes.verifyPhoneNumber, extra: false);
|
||||
},
|
||||
child: Text(
|
||||
context.loc.forgot_password,
|
||||
style: AppTextStyles.size14Medium.copyWith(
|
||||
color: AppColors.c34A853,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
40.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.continue_str,
|
||||
isLoading: state.status.isLoading(),
|
||||
trailing: SvgPicture.asset(
|
||||
AppIcons.icArrowRightLight,
|
||||
).paddingOnly(left: 10),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
context.read<LoginBloc>().add(
|
||||
LoginEvent.login(
|
||||
LoginParams(
|
||||
phoneNumber:
|
||||
"+998${_phoneController.text.trim().replaceAll(" ", "")}",
|
||||
password: _passwordController.text.trim(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
borderRadius: 15,
|
||||
backgroundColor: AppColors.c34A853,
|
||||
),
|
||||
20.verticalSpace,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.loc.dont_have_account,
|
||||
style: AppTextStyles.size14Medium,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.push(Routes.verifyPhoneNumber, extra: true);
|
||||
},
|
||||
child: Text(
|
||||
context.loc.sign_up,
|
||||
style: AppTextStyles.size15Bold.copyWith(
|
||||
color: AppColors.c34A853,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
20.verticalSpace,
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import 'package:food_delivery_client/feature/auth/presentation/pages/register_page/widgets/w_register_body.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
import '../../blocs/register_bloc/register_bloc.dart';
|
||||
|
||||
class RegisterPage extends StatelessWidget {
|
||||
const RegisterPage({super.key, required this.phoneNumber});
|
||||
|
||||
final String phoneNumber;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<RegisterBloc>(),
|
||||
child: BlocBuilder<RegisterBloc, RegisterState>(
|
||||
builder: (context, state) {
|
||||
return WLayout(
|
||||
top: false,
|
||||
child: Scaffold(body: WRegisterBody(phoneNumber: phoneNumber)),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
|
||||
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
import '../../../blocs/register_bloc/register_bloc.dart';
|
||||
|
||||
class WRegisterBody extends StatefulWidget {
|
||||
const WRegisterBody({super.key, required this.phoneNumber});
|
||||
|
||||
final String phoneNumber;
|
||||
|
||||
@override
|
||||
State<WRegisterBody> createState() => _WRegisterBodyState();
|
||||
}
|
||||
|
||||
class _WRegisterBodyState extends State<WRegisterBody> {
|
||||
late TextEditingController _firstNameController;
|
||||
late TextEditingController _lastNameController;
|
||||
late TextEditingController _phoneNumberController;
|
||||
late TextEditingController _passwordController;
|
||||
late TextEditingController _repeatPasswordController;
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_firstNameController = TextEditingController();
|
||||
_lastNameController = TextEditingController();
|
||||
_phoneNumberController = TextEditingController();
|
||||
_passwordController = TextEditingController();
|
||||
_repeatPasswordController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_firstNameController.dispose();
|
||||
_lastNameController.dispose();
|
||||
_phoneNumberController.dispose();
|
||||
_passwordController.dispose();
|
||||
_repeatPasswordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<RegisterBloc, RegisterState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.go(Routes.login);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: WAuthBackground(
|
||||
child: SizedBox(
|
||||
width: context.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
20.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: Text(
|
||||
context.loc.sign_up,
|
||||
style: AppTextStyles.size24Bold,
|
||||
),
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.first_name,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
hintText: context.loc.enter_first_name,
|
||||
controller: _firstNameController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
keyBoardType: TextInputType.name,
|
||||
validator: (value) {
|
||||
return Validators.validateFields(
|
||||
_firstNameController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
Text(
|
||||
'Last name',
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
hintText: "Enter LastName",
|
||||
controller: _lastNameController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
keyBoardType: TextInputType.text,
|
||||
validator: (value) {
|
||||
return Validators.validateFields(
|
||||
_lastNameController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
/* Text(
|
||||
context.loc.phone_number,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
hintText: context.loc.enter_phone_number,
|
||||
controller: _phoneNumberController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
keyBoardType: TextInputType.phone,
|
||||
prefixIcon: Text("+ 998", style: AppTextStyles.size16Regular),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
Formatters.phoneFormatter,
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
],
|
||||
validator: (value) {
|
||||
return Validators.validatePhoneNumber(
|
||||
_phoneNumberController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
*/
|
||||
10.verticalSpace,
|
||||
Text(
|
||||
context.loc.enter_password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
hintText: context.loc.password,
|
||||
controller: _passwordController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
keyBoardType: TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
return Validators.validatePassword(
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
|
||||
Text(
|
||||
context.loc.repeat_password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
hintText: context.loc.enter_repeat_password,
|
||||
controller: _repeatPasswordController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
keyBoardType: TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
return Validators.validateRepeatPassword(
|
||||
_repeatPasswordController.text.trim(),
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
20.verticalSpace,
|
||||
AppButton(
|
||||
isLoading: state.status.isLoading(),
|
||||
name: context.loc.continue_str,
|
||||
borderRadius: 15,
|
||||
backgroundColor: AppColors.c34A853,
|
||||
trailing: SvgPicture.asset(
|
||||
AppIcons.icArrowRightLight,
|
||||
).paddingOnly(left: 8),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
context.read<RegisterBloc>().add(
|
||||
RegisterEvent.loaded(
|
||||
RegisterParams(
|
||||
phoneNumber: widget.phoneNumber,
|
||||
password: _passwordController.text.trim(),
|
||||
firstName: _firstNameController.text.trim(),
|
||||
lastName: _lastNameController.text.trim(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
20.verticalSpace,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.loc.already_has_account,
|
||||
style: AppTextStyles.size14Medium,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pushReplacement(Routes.login);
|
||||
},
|
||||
child: Text(
|
||||
context.loc.login,
|
||||
style: AppTextStyles.size15Bold.copyWith(
|
||||
color: AppColors.c34A853,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
|
||||
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/blocs/reset_password_bloc/reset_password_bloc.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class ResetPasswordPage extends StatefulWidget {
|
||||
const ResetPasswordPage({super.key, required this.phoneNumber});
|
||||
|
||||
final String phoneNumber;
|
||||
|
||||
@override
|
||||
State<ResetPasswordPage> createState() => _ResetPasswordPageState();
|
||||
}
|
||||
|
||||
class _ResetPasswordPageState extends State<ResetPasswordPage> {
|
||||
late TextEditingController _passwordController;
|
||||
late TextEditingController _repeatPasswordController;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_passwordController = TextEditingController();
|
||||
_repeatPasswordController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordController.dispose();
|
||||
_repeatPasswordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<ResetPasswordBloc>(),
|
||||
child: BlocConsumer<ResetPasswordBloc, ResetPasswordState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.go(Routes.login);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: WLayout(
|
||||
top: false,
|
||||
child: Scaffold(
|
||||
body: WAuthBackground(
|
||||
child: SizedBox(
|
||||
width: context.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
25.verticalSpace,
|
||||
Text(
|
||||
context.loc.reset_password,
|
||||
style: AppTextStyles.size20Medium,
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.new_password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
controller: _passwordController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
hintText: context.loc.enter_password,
|
||||
keyBoardType: TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
return Validators.validatePassword(
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
context.loc.password,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
obscureText: true,
|
||||
controller: _repeatPasswordController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
hintText: context.loc.enter_password,
|
||||
keyBoardType: TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
return Validators.validateRepeatPassword(
|
||||
_repeatPasswordController.text.trim(),
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
25.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.continue_str,
|
||||
trailing: SvgPicture.asset(
|
||||
AppIcons.icArrowRightLight,
|
||||
).paddingOnly(left: 8),
|
||||
isLoading: state.status.isLoading(),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
context.read<ResetPasswordBloc>().add(
|
||||
ResetPasswordEvent.loaded(
|
||||
ResetPasswordParams(
|
||||
phoneNumber: widget.phoneNumber,
|
||||
newPassword: _passwordController.text
|
||||
.trim(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
backgroundColor: AppColors.c34A853,
|
||||
borderRadius: 15,
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:food_delivery_client/core/helpers/time_formatters.dart';
|
||||
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/blocs/verify_otp_bloc/verify_otp_bloc.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
|
||||
import 'package:pinput/pinput.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class VerifyOtpCodePage extends StatefulWidget {
|
||||
const VerifyOtpCodePage({super.key, required this.params});
|
||||
|
||||
final OtpCodePageParams params;
|
||||
|
||||
@override
|
||||
State<VerifyOtpCodePage> createState() => _VerifyOtpCodePageState();
|
||||
}
|
||||
|
||||
class _VerifyOtpCodePageState extends State<VerifyOtpCodePage> {
|
||||
late TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final defaultPinTheme = PinTheme(
|
||||
height: 56,
|
||||
width: 56,
|
||||
textStyle: AppTextStyles.size18Medium,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)),
|
||||
color: Color.fromRGBO(234, 234, 243, 1),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<VerifyOtpBloc>()..add(VerifyOtpEvent.started()),
|
||||
child: BlocConsumer<VerifyOtpBloc, VerifyOtpState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
if (widget.params.isRegister) {
|
||||
context.push(Routes.register, extra: widget.params.phoneNumber);
|
||||
} else {
|
||||
context.push(
|
||||
Routes.resetPassword,
|
||||
extra: widget.params.phoneNumber,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return WLayout(
|
||||
top: false,
|
||||
child: Scaffold(
|
||||
body: WAuthBackground(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
40.verticalSpace,
|
||||
Text(
|
||||
context.loc.enter_otp_code(widget.params.phoneNumber),
|
||||
style: AppTextStyles.size20Medium,
|
||||
),
|
||||
20.verticalSpace,
|
||||
Pinput(
|
||||
length: 5,
|
||||
enabled: true,
|
||||
controller: _controller,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
autofocus: true,
|
||||
showCursor: true,
|
||||
defaultPinTheme: defaultPinTheme,
|
||||
|
||||
focusedPinTheme: defaultPinTheme.copyWith(
|
||||
decoration: defaultPinTheme.decoration!.copyWith(
|
||||
color: Color.fromRGBO(234, 239, 243, 1),
|
||||
),
|
||||
),
|
||||
submittedPinTheme: defaultPinTheme.copyWith(
|
||||
decoration: defaultPinTheme.decoration!.copyWith(
|
||||
color: Color.fromRGBO(234, 239, 243, 1),
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
if (value.length == 5 && state.time > 0) {}
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
context.loc.resend_otp_after,
|
||||
style: AppTextStyles.size14Regular,
|
||||
),
|
||||
|
||||
if (state.time != 0)
|
||||
Text(
|
||||
TimeFormatters.formatMinutesToTime(state.time),
|
||||
),
|
||||
|
||||
if (state.time == 0)
|
||||
state.resendStatus.isLoading()
|
||||
? CircularProgressIndicator.adaptive()
|
||||
: IconButton(
|
||||
onPressed: () {
|
||||
if (widget.params.isRegister) {
|
||||
context.read<VerifyOtpBloc>().add(
|
||||
VerifyOtpEvent.resendRegister(
|
||||
widget.params.phoneNumber,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
context.read<VerifyOtpBloc>().add(
|
||||
VerifyOtpEvent.resendForgot(
|
||||
widget.params.phoneNumber,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: Icon(
|
||||
CupertinoIcons.restart,
|
||||
color: AppColors.c000000,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
20.verticalSpace,
|
||||
AppButton(
|
||||
name: context.loc.continue_str,
|
||||
onPressed: () {
|
||||
if (_controller.text.trim().length == 5 &&
|
||||
state.time > 0) {
|
||||
if (widget.params.isRegister) {
|
||||
context.read<VerifyOtpBloc>().add(
|
||||
VerifyOtpEvent.verifyOtpRegister(
|
||||
VerifyOtpCodeParams(
|
||||
phoneNumber: widget.params.phoneNumber,
|
||||
otpCode: _controller.text.trim().substring(
|
||||
0,
|
||||
4,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
context.read<VerifyOtpBloc>().add(
|
||||
VerifyOtpEvent.verifyOtpReset(
|
||||
VerifyOtpCodeParams(
|
||||
phoneNumber: widget.params.phoneNumber,
|
||||
otpCode: int.tryParse(
|
||||
_controller.text.trim().substring(0, 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
isLoading: state.status.isLoading(),
|
||||
backgroundColor: AppColors.c34A853,
|
||||
borderRadius: 15,
|
||||
trailing: SvgPicture.asset(
|
||||
AppIcons.icArrowRightLight,
|
||||
).paddingOnly(left: 8),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
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/domain/usecases/verify_otp_code_login_usecase.dart';
|
||||
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/blocs/verify_phone_bloc/verify_phone_bloc.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class VerifyPhoneNumberPage extends StatefulWidget {
|
||||
const VerifyPhoneNumberPage({super.key, required this.isRegister});
|
||||
|
||||
final bool isRegister;
|
||||
|
||||
@override
|
||||
State<VerifyPhoneNumberPage> createState() => _VerifyPhoneNumberPageState();
|
||||
}
|
||||
|
||||
class _VerifyPhoneNumberPageState extends State<VerifyPhoneNumberPage> {
|
||||
late TextEditingController _phoneNumberController;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_phoneNumberController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneNumberController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<VerifyPhoneBloc>(),
|
||||
child: BlocConsumer<VerifyPhoneBloc, VerifyPhoneState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.push(
|
||||
Routes.verifyOtpCode,
|
||||
extra: OtpCodePageParams(
|
||||
phoneNumber:
|
||||
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
|
||||
isRegister: widget.isRegister,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: WLayout(
|
||||
top: false,
|
||||
child: Scaffold(
|
||||
body: WAuthBackground(
|
||||
child: SizedBox(
|
||||
width: context.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
50.verticalSpace,
|
||||
Text(
|
||||
context.loc.enter_phone_number,
|
||||
style: AppTextStyles.size20Medium,
|
||||
),
|
||||
20.verticalSpace,
|
||||
AppTextFormField(
|
||||
controller: _phoneNumberController,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
hintText: context.loc.phone_number,
|
||||
keyBoardType: TextInputType.phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
Formatters.phoneFormatter,
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
],
|
||||
|
||||
prefixIcon: Text(
|
||||
"+ 998",
|
||||
style: AppTextStyles.size16Regular,
|
||||
),
|
||||
validator: (value) {
|
||||
return Validators.validatePhoneNumber(
|
||||
_phoneNumberController.text.trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
25.verticalSpace,
|
||||
AppButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
|
||||
|
||||
if (widget.isRegister) {
|
||||
context.read<VerifyPhoneBloc>().add(
|
||||
VerifyPhoneEvent.verifyPhoneRegister(
|
||||
VerifyPhoneNumberParams(
|
||||
phoneNumber:
|
||||
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
context.read<VerifyPhoneBloc>().add(
|
||||
VerifyPhoneEvent.verifyPhoneReset(
|
||||
VerifyPhoneNumberParams(
|
||||
phoneNumber:
|
||||
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
isLoading: state.status.isLoading(),
|
||||
name: context.loc.continue_str,
|
||||
borderRadius: 15,
|
||||
backgroundColor: AppColors.c34A853,
|
||||
),
|
||||
10.verticalSpace,
|
||||
Text(
|
||||
context.loc.consent_message("Felix Eats"),
|
||||
style: AppTextStyles.size12Medium.copyWith(
|
||||
color: AppColors.c888888,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user