fixed error pincode ui

This commit is contained in:
2025-02-06 00:36:50 +05:30
parent 96e4c10656
commit 1c9c112a2f
12 changed files with 883 additions and 785 deletions

View File

@@ -799,108 +799,104 @@ class _MycartState extends State<Mycart> {
context: context,
builder: (BuildContext context) {
return Consumer<AddtocartProvider>(
builder: (context, pinProvider, child) {
return Container(
padding: EdgeInsets.all(20.w),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Form(
child: Container(
width: 200.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
8), // Border radius for container
border: Border.all(color: Colors.grey, width: 1),
), // Border for the container
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
flex: 2,
child: Container(
height: 20.h,
child: TextFormField(
controller: pinProvider.checkPinCode,
maxLength: 6,
keyboardType: TextInputType.phone,
onChanged: (value) {},
decoration: InputDecoration(
hintText: 'Enter PIN',
counterText: "",
border: InputBorder
.none, // Remove the inner border
builder: (context, pinProvider, child) {
return Container(
padding: EdgeInsets.all(20.w),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Form(
child: Container(
width: 200.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey, width: 1),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
flex: 2,
child: Container(
height: 20.h,
child: TextFormField(
controller: pinProvider.checkPinCode,
maxLength: 6,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
hintText: 'Enter PIN',
counterText: "",
border: InputBorder.none,
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Cannot be empty';
} else if (!RegExp(r'^[0-9]{4,6}$')
.hasMatch(value)) {
return 'Enter a valid PIN (4-6 digits)';
}
return null;
},
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Cannot be empty';
} else if (!RegExp(r'^[0-9]{4,6}$')
.hasMatch(value)) {
return 'Enter a valid PIN (4-6 digits)';
}
return null;
},
),
),
),
InkWell(
onTap: () {
pinProvider.checkPin(
context, pinProvider.checkPinCode.text);
},
child: Expanded(
flex: 1,
child: pinProvider.ischeckpin
? Center(
child: CircularProgressIndicator(
color: APPCOLOR.lightGreen,
),
)
: Text(
"Check PIN",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black),
)),
),
],
const SizedBox(width: 8), // Add some spacing
InkWell(
onTap: () {
pinProvider.checkPin(
context, pinProvider.checkPinCode.text);
},
child: pinProvider.ischeckpin
? Center(
child: CircularProgressIndicator(
color: APPCOLOR.lightGreen,
),
)
: Text(
"Check PIN",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
],
),
),
),
),
),
if (!pinProvider.isDeliverable) ...{
Text(
'Delivery is not available for this pincode. Please try another pincode.',
style: TextStyle(color: Colors.red, fontSize: 10),
),
} else ...{
Text(
'Delivery available for this pincode. Submit now.',
style: TextStyle(color: Colors.lightGreen, fontSize: 10),
),
},
Gap(10.h),
Center(
child: SizedBox(
const SizedBox(
height: 10), // Add spacing before the next text
if (!pinProvider.isDeliverable)
Text(
'Delivery is not available for this pincode. Please try another pincode.',
style: TextStyle(color: Colors.red, fontSize: 12),
)
else
Text(
'Delivery available for this pincode. Submit now.',
style: TextStyle(color: Colors.lightGreen, fontSize: 12),
),
const SizedBox(height: 10), // Add spacing before the button
Center(
child: SizedBox(
width: double.infinity,
child: ButtonElevated(
text: 'Submit',
onPressed: () {
Navigator.pop(context);
},
backgroundColor: APPCOLOR.appGreen),
text: 'Submit',
onPressed: () {
Navigator.pop(context);
},
backgroundColor: APPCOLOR.appGreen,
),
),
),
),
],
),
);
});
],
),
);
},
);
},
);
}