|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:supplier_new/common/settings.dart';
|
|
|
|
import 'package:supplier_new/orders/order_requests.dart';
|
|
|
|
import 'package:supplier_new/orders/orders_model.dart';
|
|
|
|
import 'package:supplier_new/orders/search_order_appbar.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
class AllOrders extends StatefulWidget {
|
|
|
|
const AllOrders({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AllOrders> createState() => _AllOrdersState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AllOrdersState extends State<AllOrders> {
|
|
|
|
final TextEditingController searchController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final List<OrdersModel> orders = [
|
|
|
|
OrdersModel(
|
|
|
|
date: DateTime(2025, 8, 24),
|
|
|
|
imageAsset: "images/building.png",// sample image
|
|
|
|
status: "completed",
|
|
|
|
title: "Rajpushpa Atria",
|
|
|
|
location: "Kokapet",
|
|
|
|
quantity: "15,000L - Bore Water",
|
|
|
|
time: "01:00 AM, Today",
|
|
|
|
extraInfo: "Delivered by Suresh",
|
|
|
|
),
|
|
|
|
OrdersModel(
|
|
|
|
date: DateTime(2025, 8, 24),
|
|
|
|
imageAsset: "images/building.png",// sample image
|
|
|
|
status: "in-progress",
|
|
|
|
title: "Rajpushpa Atria",
|
|
|
|
location: "Kokapet",
|
|
|
|
quantity: "15,000L - Bore Water",
|
|
|
|
time: "01:00 AM, 21/07/2025",
|
|
|
|
extraInfo: "Track Delivery",
|
|
|
|
),
|
|
|
|
OrdersModel(
|
|
|
|
date: DateTime(2025, 8, 23),
|
|
|
|
imageAsset: "images/building.png",// sample image
|
|
|
|
status: "cancelled",
|
|
|
|
title: "Lakeview Towers",
|
|
|
|
location: "Madhapur",
|
|
|
|
quantity: "8,000L - Tanker Water",
|
|
|
|
time: "09:30 PM, Yesterday",
|
|
|
|
extraInfo: "Cancelled by user",
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
// ✅ Group orders by date
|
|
|
|
final Map<String, List<OrdersModel>> groupedOrders = {};
|
|
|
|
for (var order in orders) {
|
|
|
|
final formattedDate = DateFormat("dd MMM yyyy").format(order.date);
|
|
|
|
groupedOrders.putIfAbsent(formattedDate, () => []).add(order);
|
|
|
|
}
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Color(0XFFF2F2F2),
|
|
|
|
appBar: SearchOrderAppBar(
|
|
|
|
controller: searchController,
|
|
|
|
onBack: () => Navigator.pop(context),
|
|
|
|
onHelp: () {
|
|
|
|
// Show help dialog or navigate
|
|
|
|
print("Help tapped");
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child:
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(16),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * .042),
|
|
|
|
/// Total Orders
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"12",
|
|
|
|
style:fontTextStyle(64, Color(0XFFFF2D2E30), FontWeight.w700),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Today's Total Orders",
|
|
|
|
style: fontTextStyle(24, Color(0XFFFF2D2E30), FontWeight.w600),
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * .042),
|
|
|
|
/// Bore Water + Drinking Water
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
OrderCategoryCard(
|
|
|
|
image: Image.asset(
|
|
|
|
'images/bore-water.png',
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
height: 40,
|
|
|
|
width: 40,
|
|
|
|
),
|
|
|
|
value: "16",
|
|
|
|
label: "Bore Water",
|
|
|
|
),
|
|
|
|
OrderCategoryCard(
|
|
|
|
image: Image.asset(
|
|
|
|
'images/drinking-water.png',
|
|
|
|
height: 40,
|
|
|
|
width: 40,
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
),
|
|
|
|
value: "08",
|
|
|
|
label: "Drinking Water",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * .024),
|
|
|
|
/// Button
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
backgroundColor:Color(0XFF8270DB),
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(32),
|
|
|
|
),
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16, vertical: 16),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => OrderRequestsPage()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
"View Order Requests",
|
|
|
|
style: fontTextStyle(16, Color(0XFFFFFFFFFF), FontWeight.w500),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
|
|
|
/// Filters Row
|
|
|
|
SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
FilterChipWidget(label: "Building"),
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
FilterChipWidget(label: "Status"),
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
FilterChipWidget(label: "Date"),
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
FilterChipWidget(label: "Amount"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
|
|
|
/// Order Card Example
|
|
|
|
/// Order List
|
|
|
|
ListView(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
shrinkWrap: true, // ✅ Important
|
|
|
|
physics: NeverScrollableScrollPhysics(), // ✅ Prevent nested scrolling
|
|
|
|
children: groupedOrders.entries.map((entry) {
|
|
|
|
final date = entry.key;
|
|
|
|
final ordersForDate = entry.value;
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// Date heading
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
child: Text(
|
|
|
|
date,
|
|
|
|
style:fontTextStyle(14, Color(0XFF343637), FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
// Orders list for this date
|
|
|
|
...ordersForDate.map((order) => OrderCard(order: order)),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Category Card (Bore Water, Drinking Water)
|
|
|
|
class OrderCategoryCard extends StatelessWidget {
|
|
|
|
final Image image;
|
|
|
|
final String value;
|
|
|
|
final String label;
|
|
|
|
|
|
|
|
const OrderCategoryCard({
|
|
|
|
super.key,
|
|
|
|
required this.image,
|
|
|
|
required this.value,
|
|
|
|
required this.label,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
width: 40,
|
|
|
|
height: 40,
|
|
|
|
child: image, // ✅ Replaced Icon with Image
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * .008),
|
|
|
|
Text(
|
|
|
|
value,
|
|
|
|
style: fontTextStyle(20, Color(0XFFFF515253), FontWeight.w700),
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * .008),
|
|
|
|
Text(label, style: fontTextStyle(16, Color(0XFFFF515253), FontWeight.w400),),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Filter Chip
|
|
|
|
class FilterChipWidget extends StatelessWidget {
|
|
|
|
final String label;
|
|
|
|
const FilterChipWidget({super.key, required this.label});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ChoiceChip(
|
|
|
|
label: Text(label),
|
|
|
|
selected: false,
|
|
|
|
onSelected: (_) {},
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
),
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
side: BorderSide(color: Colors.grey.shade300),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OrderCard extends StatelessWidget {
|
|
|
|
final OrdersModel order;
|
|
|
|
|
|
|
|
const OrderCard({super.key, required this.order});
|
|
|
|
|
|
|
|
Color _getStatusColor() {
|
|
|
|
switch (order.status.toLowerCase()) {
|
|
|
|
case "completed":
|
|
|
|
return Colors.green;
|
|
|
|
case "in-progress":
|
|
|
|
return Colors.blue;
|
|
|
|
case "cancelled":
|
|
|
|
return Colors.red;
|
|
|
|
default:
|
|
|
|
return Colors.grey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final statusColor = _getStatusColor();
|
|
|
|
|
|
|
|
return Padding(padding: EdgeInsets.fromLTRB(0, 8, 0, 0),
|
|
|
|
child: Container(
|
|
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withOpacity(0.05),
|
|
|
|
blurRadius: 5,
|
|
|
|
offset: const Offset(0, 3),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// Image
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(12),
|
|
|
|
bottomLeft: Radius.circular(12),
|
|
|
|
),
|
|
|
|
child: order.imageAsset != null
|
|
|
|
? Image.asset(
|
|
|
|
order.imageAsset!,
|
|
|
|
height: 100,
|
|
|
|
width: 100,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
)
|
|
|
|
: Image.network(
|
|
|
|
order.imageUrl!,
|
|
|
|
height: 100,
|
|
|
|
width: 100,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
// Right side content
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// Status chip
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 8,
|
|
|
|
vertical: 2,
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: statusColor.withOpacity(0.1),
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
order.status,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 11,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: statusColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
order.title,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 15,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
order.location,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey.shade600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
order.quantity,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 13,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
order.time,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey.shade600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
order.extraInfo,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: order.status == "in-progress"
|
|
|
|
? Colors.blue
|
|
|
|
: Colors.grey.shade600,
|
|
|
|
fontWeight: order.status == "in-progress"
|
|
|
|
? FontWeight.w600
|
|
|
|
: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),);
|
|
|
|
}
|
|
|
|
}
|