orderlistcomplete
This commit is contained in:
@@ -80,20 +80,33 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
print("kjdhfkhjghjkdf");
|
||||
if (paymentProvider.selectedPaymentMethod == "Online") {
|
||||
paymentProvider.orderPaymnet(
|
||||
context,
|
||||
widget.amount,
|
||||
widget.currency,
|
||||
widget.originalAmount,
|
||||
widget.name,
|
||||
widget.phone,
|
||||
widget.email,
|
||||
widget.userId,
|
||||
widget.cartId,
|
||||
widget.addressId,
|
||||
widget.remarks);
|
||||
} else {
|
||||
// paymentProvider.paymentCODOrder(
|
||||
// context,
|
||||
// subtotal,
|
||||
// deliverCharge,
|
||||
// discountPrice,
|
||||
// grandTotal,
|
||||
// couponId,
|
||||
|
||||
// widget.addressId,
|
||||
// );
|
||||
}
|
||||
|
||||
paymentProvider.orderPaymnet(
|
||||
context,
|
||||
widget.amount,
|
||||
widget.currency,
|
||||
widget.originalAmount,
|
||||
widget.name,
|
||||
widget.phone,
|
||||
widget.email,
|
||||
widget.userId,
|
||||
widget.cartId,
|
||||
widget.addressId,
|
||||
widget.remarks);
|
||||
|
||||
},
|
||||
child: Container(
|
||||
height: 50,
|
||||
|
||||
@@ -713,7 +713,7 @@ class _MycartState extends State<Mycart> {
|
||||
);
|
||||
} else if (provider.allitem == null) {
|
||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
||||
} else if (provider.allitem.items == null) {
|
||||
} else if (provider.allitem.items!.isEmpty) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
|
||||
@@ -729,6 +729,7 @@ class _MycartState extends State<Mycart> {
|
||||
),
|
||||
));
|
||||
} else {
|
||||
print("kldjhgjkhfgjkh ${provider.allitem.items}");
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -976,7 +977,8 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
builder: (context)
|
||||
{
|
||||
return CardCheckoutScreen(
|
||||
amount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
@@ -992,9 +994,6 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
|
||||
remarks: paymentProvider.selecteUserName);
|
||||
},
|
||||
));
|
||||
|
||||
// showPaymentMethodBottomSheet(context);
|
||||
// context.push(MyRoutes.SELECTPAYMENTSCREEN);
|
||||
},
|
||||
label: Text(
|
||||
"Continue",
|
||||
|
||||
205
lib/src/ui/myOrder/OrderDetailsScreen.dart
Normal file
205
lib/src/ui/myOrder/OrderDetailsScreen.dart
Normal file
@@ -0,0 +1,205 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:grocery_app/src/common_widget/network_image.dart';
|
||||
import 'package:grocery_app/src/data/myOrder.dart';
|
||||
|
||||
class OrderDetailsScreen extends StatefulWidget {
|
||||
final Datum order;
|
||||
|
||||
const OrderDetailsScreen({Key? key, required this.order}) : super(key: key);
|
||||
|
||||
@override
|
||||
_OrderDetailsScreenState createState() => _OrderDetailsScreenState();
|
||||
}
|
||||
|
||||
class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
||||
int currentStep = 1;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Order Details')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_orderInfo(),
|
||||
SizedBox(height: 20),
|
||||
_animatedShippingTimeline(),
|
||||
SizedBox(height: 20),
|
||||
_itemsList(),
|
||||
SizedBox(height: 20),
|
||||
_cancelButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Order Information
|
||||
Widget _orderInfo() {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.order.orderNumber,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 5),
|
||||
Text(widget.order.createdAt.toString()),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
"Status: ${_getStatusText(widget.order.orderStatus)}",
|
||||
style:
|
||||
TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Animated Shipping Timeline
|
||||
Widget _animatedShippingTimeline() {
|
||||
return Column(
|
||||
children: [
|
||||
for (int i = 0; i < 3; i++) _timelineStep(i),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Each Step in the Timeline
|
||||
Widget _timelineStep(int step) {
|
||||
bool isCompleted = step <= currentStep;
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 500),
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: isCompleted ? Colors.green : Colors.grey,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(Icons.check, size: 14, color: Colors.white),
|
||||
),
|
||||
if (step < 2)
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 500),
|
||||
width: 5,
|
||||
height: 50,
|
||||
color: isCompleted ? Colors.green : Colors.grey,
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
_getStatusTextForStep(widget.order.orderStatus),
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Status Texts
|
||||
String _getStatusTextForStep(orderStatus) {
|
||||
switch (orderStatus) {
|
||||
case 'PENDING':
|
||||
return "PENDING";
|
||||
case 'SHIPPED':
|
||||
return "SHIPPED";
|
||||
case 'DELIVERD':
|
||||
return "DELIVERD";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatusText(orderStatus) {
|
||||
switch (orderStatus) {
|
||||
case 'PENDING':
|
||||
return "PENDING";
|
||||
case 'SHIPPED':
|
||||
return "SHIPPED";
|
||||
case 'DELIVERD':
|
||||
return "DELIVERD";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// List of Ordered Items
|
||||
Widget _itemsList() {
|
||||
// final List<Map<String, dynamic>> items = [
|
||||
// {
|
||||
// "name": "Coffee",
|
||||
// "quantity": 2,
|
||||
// "price": 10.00,
|
||||
// "image": "https://via.placeholder.com/50"
|
||||
// },
|
||||
// {
|
||||
// "name": "Rice",
|
||||
// "quantity": 1,
|
||||
// "price": 10.50,
|
||||
// "image": "https://via.placeholder.com/50"
|
||||
// }
|
||||
// ];
|
||||
|
||||
return Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: widget.order.orderItems!.length,
|
||||
itemBuilder: (context, index) {
|
||||
// final item = items[index];
|
||||
var orderitem = widget.order.orderItems![index];
|
||||
return Card(
|
||||
margin: EdgeInsets.symmetric(vertical: 8),
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: AppNetworkImage(
|
||||
height: MediaQuery.of(context).size.height * 0.08,
|
||||
width: 48,
|
||||
imageUrl: orderitem.productImage ?? "",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
title: Text(orderitem.productName ?? ""),
|
||||
subtitle: Text("Qty: ${orderitem.quantity.toString()}"),
|
||||
trailing: Text("\$${orderitem.price ?? ""}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Cancel Order Button (Only if not delivered)
|
||||
Widget _cancelButton() {
|
||||
return ElevatedButton(
|
||||
onPressed: currentStep < 2
|
||||
? () {
|
||||
setState(() {
|
||||
currentStep = 2; // Simulate cancellation
|
||||
});
|
||||
}
|
||||
: null, // Disable if already delivered
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
disabledBackgroundColor: Colors.grey,
|
||||
),
|
||||
child: Text("Cancel Order", style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
}
|
||||
235
lib/src/ui/myOrder/my_order.dart
Normal file
235
lib/src/ui/myOrder/my_order.dart
Normal file
@@ -0,0 +1,235 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:grocery_app/src/common_widget/network_image.dart';
|
||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||
import 'package:grocery_app/src/logic/provider/order_provider.dart';
|
||||
import 'package:grocery_app/utils/constants/assets_constant.dart';
|
||||
import 'package:grocery_app/utils/constants/color_constant.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class MyOrderScreen extends StatefulWidget {
|
||||
@override
|
||||
State<MyOrderScreen> createState() => _MyOrderScreenState();
|
||||
}
|
||||
|
||||
class _MyOrderScreenState extends State<MyOrderScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
Provider.of<OrderProvider>(context, listen: false).getMyOrder(context);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
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(
|
||||
"My Order",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Consumer<OrderProvider>(builder: (context, orderProvider, child) {
|
||||
if (orderProvider.isloading) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (orderProvider.orderList.isEmpty) {
|
||||
return Center(child: Text('No orders found!'));
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: orderProvider.orderList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final order = orderProvider.orderList[index];
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.pushNamed(MyRoutes.ORDERDETAILS, extra: order);
|
||||
//context.push(MyRoutes.ORDERDETAILS);
|
||||
},
|
||||
child: Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AppNetworkImage(
|
||||
height: MediaQuery.of(context)
|
||||
.size
|
||||
.height *
|
||||
0.08,
|
||||
width: 48,
|
||||
imageUrl: order
|
||||
.orderItems!.first.productImage,
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(order.orderNumber,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
Text(order.paymentMethod,
|
||||
style: TextStyle(color: Colors.grey)),
|
||||
Text(order.totalItems.toString() + " items",
|
||||
style: TextStyle(color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
if (order.totalItems == 1) ...{
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.shade100,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(order.orderStatus,
|
||||
style: TextStyle(color: Colors.green)),
|
||||
),
|
||||
} else ...{
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.shade100,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text("View All",
|
||||
style: TextStyle(color: Colors.green)),
|
||||
),
|
||||
}
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(order.createdAt.toString(),
|
||||
style: TextStyle(color: Colors.grey)),
|
||||
SizedBox(height: 5),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("\$" + order.grandTotal,
|
||||
style:
|
||||
TextStyle(fontWeight: FontWeight.bold)),
|
||||
Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(color: Colors.green),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.message,
|
||||
color: Colors.green),
|
||||
SizedBox(width: 5),
|
||||
Text('Message',
|
||||
style: TextStyle(
|
||||
color: Colors.green)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
print("lkdhgkjdfgj");
|
||||
_makePhoneCall(
|
||||
order.stores!.first.vendor!.phone);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.call, color: Colors.white),
|
||||
SizedBox(width: 5),
|
||||
Text('Call',
|
||||
style: TextStyle(
|
||||
color: Colors.white)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _makePhoneCall(String number) async {
|
||||
try {
|
||||
final Uri phoneUri = Uri(scheme: 'tel', path: number);
|
||||
if (await canLaunchUrl(phoneUri)) {
|
||||
await launchUrl(phoneUri);
|
||||
} else {
|
||||
throw 'Could not launch $phoneUri';
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error launching phone call: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:grocery_app/src/common_widget/network_image.dart';
|
||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
|
||||
import 'package:grocery_app/src/ui/edit_profile/edit_profile_screen.dart';
|
||||
@@ -28,8 +30,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
var top = 0.0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context)
|
||||
{
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
@@ -171,8 +172,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
trailing: Icon(MdiIcons.chevronRight),
|
||||
),
|
||||
ListTile(
|
||||
onTap: ()
|
||||
{
|
||||
onTap: () {
|
||||
// Navigator.of(context).push(MaterialPageRoute(
|
||||
// builder: (context) {
|
||||
// return const CardCheckoutScreen();
|
||||
@@ -184,7 +184,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
trailing: Icon(MdiIcons.chevronRight),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
context.push(MyRoutes.MYORDER);
|
||||
},
|
||||
leading: Icon(MdiIcons.cubeOutline),
|
||||
title: const Text('My Order'),
|
||||
trailing: Icon(MdiIcons.chevronRight),
|
||||
|
||||
Reference in New Issue
Block a user