update bottomsheet
This commit is contained in:
@@ -895,106 +895,115 @@ class _MycartState extends State<Mycart> {
|
||||
void _showBottomSheet(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
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: 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;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context)
|
||||
.viewInsets
|
||||
.bottom, // Adjusts for keyboard
|
||||
),
|
||||
child: SingleChildScrollView(child: 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: 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;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
);
|
||||
},
|
||||
)));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user