fixed error pincode ui
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||
import 'package:grocery_app/utils/constants/assets_constant.dart';
|
||||
import 'package:grocery_app/utils/extensions/extensions.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
class PaymentWebView extends StatefulWidget {
|
||||
final String paymentUrl;
|
||||
@@ -15,34 +18,72 @@ class PaymentWebView extends StatefulWidget {
|
||||
|
||||
class _PaymentWebViewState extends State<PaymentWebView> {
|
||||
InAppWebViewController? webViewController;
|
||||
|
||||
bool _isLoading = true;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
||||
title: Text("Complete Your Payment")),
|
||||
body: InAppWebView(
|
||||
initialUrlRequest:
|
||||
URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
|
||||
onWebViewCreated: (controller) {
|
||||
webViewController = controller;
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
|
||||
if (url.toString().contains("success"))
|
||||
{
|
||||
context.push(MyRoutes.SUCCESSPAYMENT);
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Center(
|
||||
child: SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
APPASSETS.back,
|
||||
height: 20,
|
||||
width: 20,
|
||||
)),
|
||||
),
|
||||
),
|
||||
title: const Text(
|
||||
"Complete Your Payment",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
InAppWebView(
|
||||
initialUrlRequest:
|
||||
URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
|
||||
onWebViewCreated: (controller) {
|
||||
webViewController = controller;
|
||||
},
|
||||
onLoadStart: (controller, url) {
|
||||
setState(() {
|
||||
_isLoading = true; // Show loader when page starts loading
|
||||
});
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
setState(() {
|
||||
_isLoading = false; // Hide loader when page finishes loading
|
||||
});
|
||||
if (url.toString().contains("success")) {
|
||||
context.clearAndPush(routePath: MyRoutes.SUCCESSPAYMENT);
|
||||
|
||||
print("kjdsfkjghdfhgkjdfhgkjdf");
|
||||
|
||||
} else if (url.toString().contains("failure")) {
|
||||
context.push(MyRoutes.PAYMENTFAILD);
|
||||
print("kjdsfkjghdfhgkjdfhgkjdf");
|
||||
} else if (url.toString().contains("failure")) {
|
||||
context.push(MyRoutes.PAYMENTFAILD);
|
||||
|
||||
print("faild");
|
||||
|
||||
}
|
||||
},
|
||||
print("faild");
|
||||
}
|
||||
},
|
||||
),
|
||||
// Loader Overlay
|
||||
if (_isLoading)
|
||||
Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user