mycart
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:grocery_app/src/logic/provider/auth_provider.dart';
|
||||
import 'package:grocery_app/src/ui/entername/enter_fullname_screen.dart';
|
||||
import 'package:grocery_app/utils/constants/assets_constant.dart';
|
||||
import 'package:grocery_app/utils/constants/color_constant.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:grocery_app/utils/extensions/color_ex.dart';
|
||||
import 'package:grocery_app/utils/extensions/uicontext.dart';
|
||||
import 'package:otp_text_field/otp_text_field.dart';
|
||||
import 'package:otp_text_field/style.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/routes/routes.dart';
|
||||
|
||||
@@ -20,8 +22,22 @@ class OtpScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _OtpScreenState extends State<OtpScreen> {
|
||||
String maskNumber(String number) {
|
||||
// Ensure the input has at least 4 digits to avoid errors
|
||||
if (number.length < 4) {
|
||||
throw Exception('Number is too short to mask');
|
||||
}
|
||||
|
||||
// Replace all characters except the last 4 with '*'
|
||||
String maskedPart = '*' * (number.length - 4);
|
||||
String visiblePart = number.substring(number.length - 4);
|
||||
return maskedPart + visiblePart;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pageNotifier = Provider.of<AuthProvider>(context, listen: false);
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
@@ -49,7 +65,7 @@ class _OtpScreenState extends State<OtpScreen> {
|
||||
SizedBox(
|
||||
width: 300,
|
||||
child: Text(
|
||||
APPSTRING.enterCode,
|
||||
"Enter the 6-digit code sent to you at ${maskNumber(pageNotifier.numberwithCode)}",
|
||||
style: context.customRegular(APPCOLOR.grey666666, 16),
|
||||
),
|
||||
),
|
||||
@@ -57,16 +73,12 @@ class _OtpScreenState extends State<OtpScreen> {
|
||||
OTPTextField(
|
||||
length: 6,
|
||||
onChanged: (c) {
|
||||
if (c.length == 6)
|
||||
{
|
||||
context.push(MyRoutes.FULLNAME);
|
||||
|
||||
// Navigator.push(context, MaterialPageRoute(
|
||||
// builder: (context)
|
||||
// {
|
||||
// return const EnterFullNameScreen();
|
||||
// },
|
||||
// ));
|
||||
if (c.length == 6) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const EnterFullNameScreen();
|
||||
},
|
||||
));
|
||||
}
|
||||
},
|
||||
width: MediaQuery.of(context).size.width,
|
||||
@@ -77,7 +89,20 @@ class _OtpScreenState extends State<OtpScreen> {
|
||||
style: const TextStyle(fontSize: 17),
|
||||
textFieldAlignment: MainAxisAlignment.spaceBetween,
|
||||
fieldStyle: FieldStyle.box,
|
||||
onCompleted: (pin) {},
|
||||
onCompleted: (pin) async {
|
||||
final success = await pageNotifier.verifiOtp(pin, context);
|
||||
|
||||
if (success) {
|
||||
context.push(MyRoutes.FULLNAME);
|
||||
} else {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// backgroundColor: Colors.grey,
|
||||
// content: Text("Failed to send OTP. Please try again."),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
|
||||
Reference in New Issue
Block a user