150 lines
5.0 KiB
Dart
150 lines
5.0 KiB
Dart
import 'package:citycards_customer/checkout/bloc/email_verify_bloc.dart';
|
|
import 'package:citycards_customer/checkout/repository/auth_local_repository.dart';
|
|
import 'package:citycards_customer/common_packages/custom_filled_button.dart';
|
|
import 'package:citycards_customer/common_packages/custom_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_otp_text_field/flutter_otp_text_field.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import '../../core/route_constants.dart';
|
|
|
|
class VerifyOtpBottomsheet extends StatelessWidget {
|
|
VerifyOtpBottomsheet({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AnimatedPadding(
|
|
duration: const Duration(milliseconds: 250),
|
|
curve: Curves.easeOut,
|
|
padding: EdgeInsets.only(
|
|
top: 24.h,
|
|
left: 20.h,
|
|
right: 20.h,
|
|
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min, // shrink to fit content
|
|
children: [
|
|
Image.asset("assets/logo/logo_city_cards_orange.png", scale: 4),
|
|
|
|
SizedBox(height: 8.h),
|
|
|
|
CustomText(
|
|
text: "Verify your phone",
|
|
size: 18.sp,
|
|
weight: FontWeight.w500,
|
|
),
|
|
|
|
SizedBox(height: 42.h),
|
|
|
|
BlocBuilder<EmailVerifyBloc, EmailVerifyState>(
|
|
builder: (context, state) {
|
|
return Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text:
|
|
"Enter the verification code sent to your email id: ",
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black.withOpacity(0.6),
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: " ${state.email}",
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
|
|
SizedBox(height: 15.h),
|
|
|
|
BlocBuilder<EmailVerifyBloc, EmailVerifyState>(
|
|
builder: (context, state) {
|
|
final bloc = (context).read<EmailVerifyBloc>();
|
|
return OtpTextField(
|
|
numberOfFields: 6,
|
|
borderWidth: 0.4.w,
|
|
fieldWidth: 48.w,
|
|
fieldHeight: 60.h,
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
filled: true,
|
|
fillColor: const Color(0xFFFFF5F5),
|
|
borderColor: const Color(0xFFBB474A),
|
|
cursorColor: const Color(0xFFF95F62),
|
|
showFieldAsBox: true,
|
|
textStyle: TextStyle(
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
onCodeChanged: (code) {},
|
|
onSubmit: (code) {
|
|
bloc.add(CheckOtpFilled(true));
|
|
debugPrint("OTP entered: $code");
|
|
},
|
|
);
|
|
},
|
|
),
|
|
|
|
SizedBox(height: 42.h),
|
|
BlocBuilder<EmailVerifyBloc, EmailVerifyState>(
|
|
builder: (context, state) {
|
|
return CustomFilledButton(
|
|
onTap: () async {
|
|
if (state.isOtpFilled) {
|
|
Navigator.pop(context);
|
|
await LocalAuth().setloggedIn(true);
|
|
context.read<EmailVerifyBloc>().add(CheckIsLoggedIn());
|
|
}
|
|
},
|
|
label: "Continue",
|
|
width: double.infinity,
|
|
);
|
|
},
|
|
),
|
|
|
|
SizedBox(height: 20.h),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).pushNamed(RouteConstants.createAcct);
|
|
},
|
|
child: Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: "Already have an account?",
|
|
style: TextStyle(
|
|
color: Colors.black.withOpacity(0.6),
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: " Sign in",
|
|
style: TextStyle(
|
|
color: const Color(0xFFF95F62),
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 15.h),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|