import 'package:flutter/material.dart'; class OrderRequestsPage extends StatefulWidget { const OrderRequestsPage({super.key}); @override State createState() => _OrderRequestsPageState(); } class _OrderRequestsPageState extends State { final TextEditingController searchController = TextEditingController(); // ✅ Sample orders list final List allOrders = [ OrderModel( status: "New", title: "Green Valley Apartments", location: "Gachibowli", description: "10,000 L - Drinking water", price: "₹3,400", ), OrderModel( status: "Expires in 15m", title: "Lakeview Towers", location: "Madhapur", description: "8,000 L - Borewell water", price: "₹2,700", ), OrderModel( status: "Expired", title: "Sunrise Residency", location: "Kukatpally", description: "12,000 L - Tanker water", price: "₹4,000", ), OrderModel( status: "Rejected", title: "Skyline Apartments", location: "Kompally", description: "5,000 L - Drinking water", price: "₹1,600", ), OrderModel( status: "Pending", title: "Skyline Apartments", location: "Kompally", description: "5,000 L - Drinking water", price: "₹1,600", ), OrderModel( status: "Rejected", title: "Elite Towers", location: "Hitech City", description: "20,000 L - Borewell water", price: "₹6,000", ), ]; @override Widget build(BuildContext context) { // ✅ Split orders into rejected and others final rejectedOrders = allOrders.where((o) => o.status.toLowerCase() == "rejected").toList(); final otherOrders = allOrders.where((o) => o.status.toLowerCase() != "rejected").toList(); return Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Colors.white, elevation: 0, leading: IconButton( icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () => Navigator.pop(context), ), title: const Text( "Order Requests", style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600, ), ), centerTitle: false, actions: [ IconButton( icon: const Icon(Icons.help_outline, color: Colors.black), onPressed: () {}, ), const SizedBox(width: 8), ], ), body: Padding( padding: const EdgeInsets.all(12.0), child: Column( children: [ /// Search bar Row( children: [ Expanded( child: Container( height: 42, decoration: BoxDecoration( borderRadius: BorderRadius.circular(24), border: Border.all(color: Colors.grey.shade300), color: Colors.white, ), child: TextField( controller: searchController, decoration: const InputDecoration( hintText: "Search", prefixIcon: Icon(Icons.search, color: Colors.grey), border: InputBorder.none, contentPadding: EdgeInsets.symmetric(vertical: 10), ), ), ), ), const SizedBox(width: 10), Container( height: 42, width: 42, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.grey.shade300), color: Colors.white, ), child: IconButton( icon: const Icon(Icons.sort, size: 20, color: Colors.black), onPressed: () {}, ), ), ], ), const SizedBox(height: 16), /// Orders List Expanded( child: ListView( children: [ // Active / Other Orders ...otherOrders.map((o) => OrderCard(order: o)), // Rejected Orders Section if (rejectedOrders.isNotEmpty) ...[ const SizedBox(height: 12), const Text( "Rejected Requests", style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black, ), ), const SizedBox(height: 8), ...rejectedOrders.map((o) => OrderCard(order: o)), ], ], ), ), ], ), ), ); } } /// Order Model class OrderModel { final String status; final String title; final String location; final String description; final String price; OrderModel({ required this.status, required this.title, required this.location, required this.description, required this.price, }); } /// Order Card widget class OrderCard extends StatelessWidget { final OrderModel order; const OrderCard({super.key, required this.order}); Color _getStatusColor() { switch (order.status.toLowerCase()) { case "new": return Colors.blue; case "expires in 15m": case "expires in 5m": return Colors.orange; case "expired": return Colors.grey; case "rejected": return Colors.red; default: return Colors.black; } } @override Widget build(BuildContext context) { final statusColor = _getStatusColor(); return Container( margin: const EdgeInsets.only(bottom: 12), padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.grey.shade300), ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// Left content Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Status chip Container( padding: const EdgeInsets.symmetric( horizontal: 8, vertical: 4, ), 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), // Title Text( order.title, style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w600, ), ), // Location Text( order.location, style: TextStyle( fontSize: 12, color: Colors.grey.shade600, ), ), const SizedBox(height: 4), // Description Text( order.description, style: const TextStyle( fontSize: 12, color: Colors.blue, fontWeight: FontWeight.w500, ), ), ], ), ), /// Price Text( order.price, style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w600, ), ), ], ), ); } }