second commit
This commit is contained in:
612
lib/View/Orders/Tabs/Today.dart
Normal file
612
lib/View/Orders/Tabs/Today.dart
Normal file
@@ -0,0 +1,612 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import '../../../Controller/Orders/Tabs/Todaycontroller.dart';
|
||||
import '../../../Helper/Constants/Assetconstants.dart';
|
||||
import '../../../Helper/Constants/Colorconstants.dart';
|
||||
import '../../../Helper/toast.dart';
|
||||
|
||||
class TodayOrderView extends StatefulWidget {
|
||||
const TodayOrderView({super.key});
|
||||
|
||||
@override
|
||||
State<TodayOrderView> createState() => _TodayOrderViewState();
|
||||
}
|
||||
|
||||
class _TodayOrderViewState extends State<TodayOrderView> {
|
||||
late TodayOrderController todayOrderController;
|
||||
Timer? _refreshTimer;
|
||||
final TodayOrderController controller = Get.put(TodayOrderController());
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
todayOrderController.shimmer.value = true;
|
||||
|
||||
// Fetch once
|
||||
todayOrderController.getOrders();
|
||||
|
||||
// Then refresh every 3 seconds
|
||||
_refreshTimer = Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
print('hi');
|
||||
todayOrderController.getOrders();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_refreshTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<TodayOrderController>(
|
||||
builder: (controller) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10, top: 5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 5, right: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
height: Get.height * 0.06,
|
||||
width: Get.width * 0.94,
|
||||
child: TextField(
|
||||
controller: controller.searchController,
|
||||
onChanged: (data) {
|
||||
controller.search(data);
|
||||
controller.update();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 10,
|
||||
right: 45,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderSide: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderSide: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderSide: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
hintText: 'Name',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: controller.orderAllList.isEmpty && !controller.shimmer.value
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 92),
|
||||
Image(
|
||||
height: 160,
|
||||
width: 160,
|
||||
image: AssetImage(AssetConstants.NoRecords),
|
||||
),
|
||||
Text(
|
||||
"No orders at this moment",
|
||||
style: TextStyle(color: Colors.grey[600], fontSize: 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: controller.shimmer.value
|
||||
? orderShimmerCard(context)
|
||||
: ListView.builder(
|
||||
itemCount: controller.orderAllList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: 10, right: 10, top: 5),
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Get.to(() => DeliveryDetailsView(data: controller.orderAllList[index]));
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
height: Get.height * 0.06,
|
||||
width: Get.width * 0.13,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: ColorConstants.primaryColor),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
controller.orderAllList[index].deliverydate == ""
|
||||
? Text('')
|
||||
: Text(
|
||||
'${DateFormat("dd").format(DateFormat("yyyy-MM-dd'T'HH:mm:ss", "en_US").parse(controller.orderAllList[index].deliverydate!))}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
controller.orderAllList[index].deliverydate == ""
|
||||
? Text('')
|
||||
: Text(
|
||||
'${DateFormat("MMM").format(DateFormat("yyyy-MM-dd'T'HH:mm:ss", "en_US").parse(controller.orderAllList[index].deliverydate!))}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Container(
|
||||
height: Get.height * 0.06,
|
||||
width: Get.width * 0.13,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: ColorConstants.primaryColor),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delivery_dining,
|
||||
size: 25,
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
controller.orderAllList[index].kms == null
|
||||
? Text(
|
||||
'0.0',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'${controller.orderAllList[index].kms?.toString()}Km',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
height: Get.height * 0.05,
|
||||
width: Get.width * 0.28,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: Colors.grey[400]!),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 10),
|
||||
CircleAvatar(
|
||||
radius: 10,
|
||||
backgroundColor: ColorConstants.primaryColor1,
|
||||
child: controller.orderAllList[index].paymenttype == 42
|
||||
? Icon(Icons.mobile_friendly, color: ColorConstants.primaryColor, size: 12)
|
||||
: controller.orderAllList[index].paymenttype == 43
|
||||
? Icon(Icons.money, color: ColorConstants.primaryColor, size: 12)
|
||||
: Icon(Icons.wallet, color: ColorConstants.primaryColor, size: 12),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Text(
|
||||
"₹ ${controller.orderAllList[index].deliverycharges}",
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 9),
|
||||
controller.orderAllList[index].orderstatus == 'cancelled'
|
||||
? Container(
|
||||
height: Get.height * 0.04,
|
||||
width: Get.width * 0.3,
|
||||
decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(10)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 5),
|
||||
Icon(Icons.cancel, color: ColorConstants.secondaryColor, size: 18),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'${controller.orderAllList[index].orderstatus}',
|
||||
style: TextStyle(
|
||||
color: ColorConstants.secondaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: Get.height * 0.04,
|
||||
width: Get.width * 0.3,
|
||||
decoration: BoxDecoration(
|
||||
color: controller.orderAllList[index].orderstatus == 'completed' ? Colors.green : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 5),
|
||||
CircleAvatar(
|
||||
backgroundColor: controller.orderAllList[index].orderstatus == 'completed'
|
||||
? ColorConstants.secondaryColor
|
||||
: ColorConstants.primaryColor1,
|
||||
radius: 10,
|
||||
child: Icon(Icons.check, color: Colors.grey, size: 15),
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'${controller.orderAllList[index].orderstatus}',
|
||||
style: TextStyle(
|
||||
color: controller.orderAllList[index].orderstatus == 'completed'
|
||||
? ColorConstants.secondaryColor
|
||||
: ColorConstants.primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 7),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.person, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Container(
|
||||
width: Get.width * 0.35,
|
||||
child: Text(
|
||||
'${controller.orderAllList[index].pickupcustomer}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.phone, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'${controller.orderAllList[index].pickupcontactno}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.confirmation_num, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'${controller.orderAllList[index].orderid}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.business_rounded, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'${controller.orderAllList[index].tenantname}',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.primaryColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 5),
|
||||
child: Text(
|
||||
'${DateFormat("hh.mm a").format(DateFormat("yyyy-MM-dd'T'HH:mm:ss", "en_US").parse(controller.orderAllList[index].deliverydate!))}',
|
||||
style: TextStyle(fontSize: 10.5, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget orderShimmerCard(BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemCount: 6,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
height: Get.height * 0.21,
|
||||
width: Get.width * 0.9,
|
||||
margin: EdgeInsets.only(left: 10, right: 10, top: 5),
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Shimmer.fromColors(
|
||||
enabled: true,
|
||||
highlightColor: ColorConstants.lightGreyBg!,
|
||||
baseColor: Colors.grey[300]!,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
height: Get.height * 0.06,
|
||||
width: Get.width * 0.13,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: ColorConstants.primaryColor!),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold, fontSize: 15)),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold, fontSize: 15)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Container(
|
||||
height: Get.height * 0.06,
|
||||
width: Get.width * 0.13,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: ColorConstants.primaryColor!),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.delivery_dining, size: 25, color: ColorConstants.primaryColor),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
height: Get.height * 0.05,
|
||||
width: Get.width * 0.28,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: Colors.grey[400]!),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text("", style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold, fontSize: 15)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
Container(
|
||||
height: Get.height * 0.04,
|
||||
width: Get.width * 0.3,
|
||||
decoration: BoxDecoration(color: Colors.grey[100], borderRadius: BorderRadius.circular(10)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 5),
|
||||
CircleAvatar(backgroundColor: Colors.grey[100], radius: 10, child: Icon(Icons.check, color: Colors.grey, size: 15)),
|
||||
SizedBox(width: 6),
|
||||
Text('', style: TextStyle(color: Colors.grey[100], fontWeight: FontWeight.bold, fontSize: 15)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 7),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.person, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.phone, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.confirmation_num, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.business, color: Colors.grey[500], size: 22),
|
||||
SizedBox(width: 4),
|
||||
Text('', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.normal, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
height: Get.height * 0.02,
|
||||
width: Get.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 5),
|
||||
child: Text('', style: TextStyle(fontSize: 10.5, color: Colors.white)),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 80),
|
||||
Icon(Icons.cancel, size: 30, color: Colors.grey[100]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user