diff --git a/images/advance.png b/images/advance.png new file mode 100644 index 0000000..5d6e29a Binary files /dev/null and b/images/advance.png differ diff --git a/images/capacity.png b/images/capacity.png new file mode 100644 index 0000000..a4e1256 Binary files /dev/null and b/images/capacity.png differ diff --git a/images/cross.png b/images/cross.png new file mode 100644 index 0000000..7969155 Binary files /dev/null and b/images/cross.png differ diff --git a/images/edit.png b/images/edit.png new file mode 100644 index 0000000..7310594 Binary files /dev/null and b/images/edit.png differ diff --git a/images/plus.png b/images/plus.png new file mode 100644 index 0000000..c5f716c Binary files /dev/null and b/images/plus.png differ diff --git a/images/price.png b/images/price.png new file mode 100644 index 0000000..949b100 Binary files /dev/null and b/images/price.png differ diff --git a/images/quantity.png b/images/quantity.png new file mode 100644 index 0000000..01edaa6 Binary files /dev/null and b/images/quantity.png differ diff --git a/images/rite.png b/images/rite.png new file mode 100644 index 0000000..75221d7 Binary files /dev/null and b/images/rite.png differ diff --git a/images/send.png b/images/send.png new file mode 100644 index 0000000..e7379c1 Binary files /dev/null and b/images/send.png differ diff --git a/images/time.png b/images/time.png new file mode 100644 index 0000000..d28b5a6 Binary files /dev/null and b/images/time.png differ diff --git a/images/water.png b/images/water.png new file mode 100644 index 0000000..05cb909 Binary files /dev/null and b/images/water.png differ diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index 5d31887..da337d8 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -9,8 +9,10 @@ import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/financials/financial_main_screen.dart'; import 'package:supplier_new/orders/all_orders.dart'; import 'package:supplier_new/orders/order_requests.dart'; +import 'package:supplier_new/orders/search_order_appbar.dart'; import 'package:supplier_new/plans/all_plans.dart'; import 'package:supplier_new/plans/plan_requests.dart'; +import 'package:supplier_new/plans/search_plan_appbar.dart'; import 'package:supplier_new/resources/fleet.dart'; import 'package:supplier_new/set_rates/set_rates.dart'; @@ -33,12 +35,15 @@ class _DashboardScreenState extends State { ), ); final GlobalKey _scaffoldKey = GlobalKey(); + final TextEditingController orderSearchController = TextEditingController(); + final TextEditingController planSearchController = TextEditingController(); + // Define a list of widgets for each screen final List _screens = [ HomeScreen(), - AllOrders(), - AllPlans(), + AllOrders(navigationFrom: 'bottombar',), + AllPlans(navigationFrom: 'bottombar',), FleetStep1Page(), FinancialMainScreen(), ]; @@ -246,6 +251,126 @@ class _DashboardScreenState extends State { }); } + final List _screenTitles = [ + 'Aquick Supplier', // index 0 + 'Orders', // index 1 + 'Plans', // index 2 + 'Resources', // index 3 + 'Financials', // index 4 + ]; + + String getScreenTitle(int index) { + if (index < 0 || index >= _screenTitles.length) return ''; + return _screenTitles[index]; + } + + PreferredSizeWidget? _buildAppBar() { + // 👉 Orders tab (index 1): Custom Search AppBar + if (_currentIndex == 1) { + return SearchOrderAppBar( + controller: orderSearchController, + onBack: () { + setState(() { + _currentIndex = 0; // go back to Home + }); + }, + onHelp: () { + // handle help button action + debugPrint("Help tapped"); + }, + ); + } + + if (_currentIndex == 2) { + return SearchPlanAppBar( + controller: planSearchController, + onBack: () { + setState(() { + _currentIndex = 0; // go back to Home + }); + }, + onHelp: () { + // handle help button action + debugPrint("Help tapped"); + }, + ); + } + + // 👉 Home tab (index 0): Main AppBar + if (_currentIndex == 0) { + return AppBar( + backgroundColor: Colors.white, + elevation: 0, + scrolledUnderElevation: 0, + titleSpacing: 0, + title: Text( + 'Aquick Supplier', + style: fontTextStyle( + 16, const Color(0XFF515253), FontWeight.w600), + ), + iconTheme: const IconThemeData(color: Color(0XFF2A2A2A)), + actions: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(10, 10, 0, 10), + child: IconButton( + icon: Image.asset('images/calendar_appbar.png'), + onPressed: () {}, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 10, 10, 10), + child: IconButton( + icon: Image.asset('images/notification_appbar.png'), + onPressed: () {}, + ), + ), + ], + ) + ], + leading: IconButton( + icon: Image.asset( + 'images/profile_appbar.png', + height: 20, + width: 20, + ), + onPressed: () { + _scaffoldKey.currentState?.openDrawer(); + }, + ), + ); + } + + // 👉 Other tabs (index 2,3,4): Simple AppBar with Back to Home + return AppBar( + backgroundColor: Colors.white, + elevation: 0, + scrolledUnderElevation: 0, + titleSpacing: 0, + title: Text( + getScreenTitle(_currentIndex), + style: fontTextStyle( + 16, const Color(0XFF515253), FontWeight.w600), + ), + leading: GestureDetector( + onTap:(){ + setState(() { + _currentIndex = 0; // Back → Home + }); + }, // 👉 use callback from parent + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'images/backbutton_appbar.png', + height: 24, + width: 24, + fit: BoxFit.contain, + ), + ), + ), + ); + } @override Widget build(BuildContext context) { @@ -352,52 +477,8 @@ class _DashboardScreenState extends State { child: Scaffold( key: _scaffoldKey, backgroundColor: Colors.white, - appBar: _currentIndex==0?AppBar( - backgroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, - titleSpacing: 0, - title: Text('Aquick Supplier',style: fontTextStyle(16,Color(0XFF515253),FontWeight.w600),), - iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), - actions: [ - Row( - children: [ - Padding(padding: EdgeInsets.fromLTRB(10,10,0,10), - child: IconButton( - icon: Image( - image: AssetImage('images/calendar_appbar.png') + appBar: _buildAppBar(), - ), - onPressed: (){ - - }, - ), - ), - - Padding(padding: EdgeInsets.fromLTRB(0,10,10,10), - child: IconButton( - icon: Image.asset( - 'images/notification_appbar.png', // Example URL image - ), - onPressed: (){ - - }, - ), - ) - ], - ) - ], - leading: IconButton( - icon: Image( - image: AssetImage('images/profile_appbar.png'), - height: 20, - width: 20, - ), - onPressed: (){ - _scaffoldKey.currentState?.openDrawer(); - }, - ), - ):null, drawer: Drawer( width: MediaQuery.of(context).size.width, backgroundColor: Colors.white, @@ -730,7 +811,7 @@ class _HomeScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => AllOrders()), + builder: (context) => AllOrders(navigationFrom: 'dashboard',)), ); }, ), diff --git a/lib/common/settings.dart b/lib/common/settings.dart index e501051..b46aa58 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -574,6 +574,22 @@ class AppSettings{ style: fontTextStyle(16, Color(0XFF2A2A2A), FontWeight.w600), ), iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), + leading: GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Padding( + padding: + const EdgeInsets.fromLTRB(8, 8, 8, 8), // Add padding if needed + child: Image.asset( + 'images/backbutton_appbar.png', // Replace with your image path + fit: BoxFit.contain, + color: Color(0XFF2A2A2A), + height: 24, + width: 24, + ), + ), + ), actions: [ Row( children: [ @@ -591,6 +607,21 @@ class AppSettings{ ], ) ], + + ); + } + + static supplierAppBarWithActionsText(String title,context) { + title = title ?? ''; + return AppBar( + backgroundColor: Colors.white, + elevation: 0, + scrolledUnderElevation: 0, + title: Text( + title, + style: fontTextStyle(16, Color(0XFF2A2A2A), FontWeight.w600), + ), + iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), leading: GestureDetector( onTap: () { Navigator.pop(context); @@ -607,6 +638,15 @@ class AppSettings{ ), ), ), + actions: [ + Padding(padding: EdgeInsets.all(8), + child: TextButton( + onPressed: () async { + }, + child: Text('HELP', + style: fontTextStyle(14,primaryColor,FontWeight.w600),), + ),) + ], ); } diff --git a/lib/financials/add_transaction_for_credit_account.dart b/lib/financials/add_transaction_for_credit_account.dart new file mode 100644 index 0000000..50b6e6d --- /dev/null +++ b/lib/financials/add_transaction_for_credit_account.dart @@ -0,0 +1,216 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class AddCreditTransactionPage extends StatefulWidget { + const AddCreditTransactionPage({super.key}); + + @override + State createState() => + _AddCreditTransactionPageState(); +} + +class _AddCreditTransactionPageState extends State { + final _formKey = GlobalKey(); + + String? _transactionType; + String? _creditAccount; + String? _paymentMode; + String? _paymentStatus; + DateTime? _selectedDate; + + final TextEditingController _amountController = + TextEditingController(text: "₹500"); + final TextEditingController _transactionIdController = + TextEditingController(text: "₹500"); + final TextEditingController _detailsController = TextEditingController(); + + Future _pickDate() async { + DateTime now = DateTime.now(); + final picked = await showDatePicker( + context: context, + initialDate: now, + firstDate: DateTime(2020), + lastDate: DateTime(2100), + ); + if (picked != null) { + setState(() { + _selectedDate = picked; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + elevation: 0, + backgroundColor: Colors.white, + leading: IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.black), + onPressed: () => Navigator.pop(context), + ), + title: const Text( + "Add Credit Transaction", + style: TextStyle(color: Colors.black, fontWeight: FontWeight.w600), + ), + actions: [ + TextButton( + onPressed: () {}, + child: const Text( + "HELP", + style: TextStyle(color: Colors.blue), + ), + ), + ], + ), + body: SafeArea( + child: SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildDropdown( + label: "Transaction Type *", + value: _transactionType, + items: ["Credit", "Debit"], + onChanged: (val) => setState(() => _transactionType = val), + ), + const SizedBox(height: 12), + _buildDropdown( + label: "Credit Account Name *", + value: _creditAccount, + items: ["Credit Account", "Other Account"], + onChanged: (val) => setState(() => _creditAccount = val), + ), + const SizedBox(height: 12), + _buildTextField( + controller: _amountController, + label: "Amount (in ₹) *", + keyboardType: TextInputType.number, + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: _buildDropdown( + label: "Payment Mode *", + value: _paymentMode, + items: ["Cash", "UPI", "Bank Transfer"], + onChanged: (val) => setState(() => _paymentMode = val), + ), + ), + const SizedBox(width: 12), + Expanded( + child: GestureDetector( + onTap: _pickDate, + child: AbsorbPointer( + child: TextFormField( + decoration: InputDecoration( + labelText: "Date *", + hintText: "DD-MM-YYYY", + suffixIcon: const Icon(Icons.calendar_today), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + controller: TextEditingController( + text: _selectedDate == null + ? "" + : DateFormat("dd-MM-yyyy") + .format(_selectedDate!), + ), + ), + ), + ), + ), + ], + ), + const SizedBox(height: 12), + _buildTextField( + controller: _transactionIdController, + label: "Transaction ID *", + ), + const SizedBox(height: 12), + _buildDropdown( + label: "Payment Status *", + value: _paymentStatus, + items: ["Pending", "Completed", "Failed"], + onChanged: (val) => setState(() => _paymentStatus = val), + ), + const SizedBox(height: 12), + _buildTextField( + controller: _detailsController, + label: "Additional Details", + ), + const SizedBox(height: 24), + ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + // Handle save + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Transaction Saved")), + ); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + padding: const EdgeInsets.symmetric(vertical: 14), + minimumSize: const Size(double.infinity, 50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: const Text("Save Transaction"), + ), + ], + ), + ), + ), + ), + ); + } + + Widget _buildDropdown({ + required String label, + required String? value, + required List items, + required Function(String?) onChanged, + }) { + return DropdownButtonFormField( + value: value, + isExpanded: true, + decoration: InputDecoration( + labelText: label, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + items: items + .map((e) => DropdownMenuItem( + value: e, + child: Text(e), + )) + .toList(), + onChanged: onChanged, + ); + } + + Widget _buildTextField({ + required TextEditingController controller, + required String label, + TextInputType keyboardType = TextInputType.text, + }) { + return TextFormField( + controller: controller, + keyboardType: keyboardType, + decoration: InputDecoration( + labelText: label, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + ); + } +} diff --git a/lib/financials/add_transactions.dart b/lib/financials/add_transactions.dart new file mode 100644 index 0000000..d5ba924 --- /dev/null +++ b/lib/financials/add_transactions.dart @@ -0,0 +1,151 @@ +import 'package:flutter/material.dart'; + +class AddTransactionScreen extends StatefulWidget { + @override + _AddTransactionScreenState createState() => _AddTransactionScreenState(); +} + +class _AddTransactionScreenState extends State { + final _formKey = GlobalKey(); + + String? transactionType; + String? accountName; + String? paymentMode; + String? paymentStatus; + + TextEditingController amountController = TextEditingController(text: "₹500"); + TextEditingController transactionIdController = TextEditingController(text: "₹500"); + TextEditingController dateController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0, + leading: Icon(Icons.arrow_back, color: Colors.black), + title: Text( + "Add Transaction", + style: TextStyle(color: Colors.black, fontWeight: FontWeight.w600), + ), + actions: [ + TextButton( + onPressed: () {}, + child: Text("HELP", style: TextStyle(color: Colors.purple)), + ) + ], + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Form( + key: _formKey, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdown("Transaction Type *", ["Credit", "Debit"], transactionType, (val) { + setState(() => transactionType = val); + }), + SizedBox(height: 16), + buildDropdown("Account Name *", ["Name1", "Name2"], accountName, (val) { + setState(() => accountName = val); + }), + SizedBox(height: 16), + buildTextField("Amount (in ₹) *", amountController), + SizedBox(height: 16), + Row( + children: [ + Expanded( + child: buildDropdown("Payment Mode *", ["Cash", "Card", "UPI"], paymentMode, (val) { + setState(() => paymentMode = val); + }), + ), + SizedBox(width: 12), + Expanded( + child: buildDatePicker(), + ), + ], + ), + SizedBox(height: 16), + buildTextField("Transaction ID *", transactionIdController), + SizedBox(height: 16), + buildDropdown("Payment Status *", ["Pending", "Completed", "Failed"], paymentStatus, (val) { + setState(() => paymentStatus = val); + }), + SizedBox(height: 24), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF8270DB), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + padding: EdgeInsets.symmetric(vertical: 14), + ), + onPressed: () { + if (_formKey.currentState!.validate()) { + // Handle save + } + }, + child: Text("Save", style: TextStyle(color: Colors.white, fontSize: 16)), + ), + ) + ], + ), + ), + ), + ), + ); + } + + Widget buildDropdown(String label, List items, String? value, Function(String?) onChanged) { + return DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + value: value, + items: items.map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), + onChanged: onChanged, + ); + } + + Widget buildTextField(String label, TextEditingController controller) { + return TextFormField( + controller: controller, + decoration: InputDecoration( + labelText: label, + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + ); + } + + Widget buildDatePicker() { + return TextFormField( + controller: dateController, + readOnly: true, + decoration: InputDecoration( + labelText: "Date *", + suffixIcon: Icon(Icons.calendar_today), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12), + ), + onTap: () async { + DateTime? picked = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100), + ); + if (picked != null) { + setState(() { + dateController.text = "${picked.day}-${picked.month}-${picked.year}"; + }); + } + }, + ); + } +} diff --git a/lib/financials/building_transactions_details.dart b/lib/financials/building_transactions_details.dart new file mode 100644 index 0000000..3f82ec1 --- /dev/null +++ b/lib/financials/building_transactions_details.dart @@ -0,0 +1,296 @@ +import 'package:flutter/material.dart'; +import 'package:supplier_new/financials/add_transaction_for_credit_account.dart'; + +class BuildingTransactionsDetails extends StatefulWidget { + const BuildingTransactionsDetails({super.key}); + + @override + State createState() => _BuildingTransactionsDetailsState(); +} + +class _BuildingTransactionsDetailsState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: SizedBox( + width: 52, // default is 56 + height: 52, // make it bigger + child: FloatingActionButton( + shape: const CircleBorder(), // ensures perfect round shape + backgroundColor: Colors.black, + onPressed: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => AddCreditTransactionPage(), + ), + ); + + }, + child:Image.asset( + "images/plus.png", // your custom image + width: 20, + height: 20, + color: Colors.white, // optional: apply tint + ), + ), + ), + body: SafeArea( + child: Column( + children: [ + // Header + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Green Valley Apartments", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 4), + Text( + "Gachibowli", + style: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ), + ], + ), + TextButton( + onPressed: () {}, + child: const Text( + "HELP", + style: TextStyle(color: Colors.blue), + ), + ) + ], + ), + ), + + // Statement button + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + OutlinedButton.icon( + style: OutlinedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onPressed: () {}, + icon: const Icon(Icons.download), + label: const Text("Statement"), + ), + ], + ), + ), + + // Orders and balances + Padding( + padding: const EdgeInsets.all(16), + child: Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.grey.shade100, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + children: [ + // Total orders + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + "Total Orders", + style: TextStyle(fontSize: 16), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: const [ + Text( + "45", + style: TextStyle( + fontSize: 22, fontWeight: FontWeight.bold), + ), + Text( + "12 complete", + style: + TextStyle(fontSize: 13, color: Colors.grey), + ) + ], + ) + ], + ), + const SizedBox(height: 16), + // Balances + Row( + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + Text("Receivable Balance"), + SizedBox(height: 4), + Text( + "₹24,000", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.red), + ), + SizedBox(height: 2), + Text( + "40.61% of total credit", + style: TextStyle( + fontSize: 12, color: Colors.grey), + ) + ], + ), + ), + ), + const SizedBox(width: 12), + Expanded( + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + Text("Advance Balance"), + SizedBox(height: 4), + Text( + "₹24,000", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.green), + ), + SizedBox(height: 2), + Text( + "60.41% of total credit", + style: TextStyle( + fontSize: 12, color: Colors.grey), + ) + ], + ), + ), + ), + ], + ), + ], + ), + ), + ), + + // Buttons + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () {}, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + padding: const EdgeInsets.symmetric(vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: const Text("Add Transaction"), + ), + ), + const SizedBox(width: 12), + Expanded( + child: OutlinedButton( + onPressed: () {}, + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: const Text("Request Top up"), + ), + ), + ], + ), + ), + + const SizedBox(height: 12), + + // History label + const Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "HISTORY", + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 15), + ), + ), + ), + + const SizedBox(height: 8), + + // History list + Expanded( + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 16), + children: [ + _historyItem( + "Transaction Description", "21 August", "+ ₹2,580", true), + _historyItem( + "Transaction Description", "19 August", "- ₹748", false), + _historyItem( + "Transaction Description", "16 August", "- ₹10,000", false), + _historyItem( + "Transaction Description", "12 August", "- ₹500", false), + ], + ), + ), + ], + ), + ), + ); + } + + Widget _historyItem( + String title, String date, String amount, bool isCredit) { + return ListTile( + contentPadding: EdgeInsets.zero, + leading: CircleAvatar( + backgroundColor: Colors.blue.shade100, + child: const Icon(Icons.swap_horiz, color: Colors.blue), + ), + title: Text(title), + subtitle: Text(date), + trailing: Text( + amount, + style: TextStyle( + fontWeight: FontWeight.bold, + color: isCredit ? Colors.green : Colors.red, + ), + ), + ); + } +} diff --git a/lib/financials/create_credit_accounts.dart b/lib/financials/create_credit_accounts.dart new file mode 100644 index 0000000..2fe3148 --- /dev/null +++ b/lib/financials/create_credit_accounts.dart @@ -0,0 +1,143 @@ +import 'package:flutter/material.dart'; +import 'package:dropdown_button2/dropdown_button2.dart'; + +class CreateCreditAccountScreen extends StatefulWidget { + @override + _CreateCreditAccountScreenState createState() => _CreateCreditAccountScreenState(); +} +class _CreateCreditAccountScreenState extends State { + String? selectedCustomer; + String paymentTerm = 'Net 30'; + final creditLimitController = TextEditingController(text: '₹500'); + final openingBalanceController = TextEditingController(text: '₹500'); + final List> customers = [ + {'name': 'Ramakrishna', 'date': '20 August'}, + {'name': 'Mallesham Water Supplies', 'date': '21 August'}, + {'name': 'My Home Bhooja', 'date': '21 August'}, + ]; + final List paymentTerms = ['Net 15', 'Net 30', 'Net 45']; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Create Credit Account'), + actions: [ + TextButton( + onPressed: () {}, + child: Text('HELP', style: TextStyle(color: Colors.blue)), + ) + ], + backgroundColor: Colors.white, + foregroundColor: Colors.black, + elevation: 1, + ), + body: Padding( + padding: const EdgeInsets.all(16), + child: ListView( + children: [ + Text('SELECT CUSTOMER', style: TextStyle(fontWeight: FontWeight.bold)), + const SizedBox(height: 10), + ...customers.map((customer) { + return GestureDetector( + onTap: () { + setState(() { + selectedCustomer = customer['name']; + }); + }, + child: Container( + margin: const EdgeInsets.only(bottom: 10), + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + border: Border.all( + color: selectedCustomer == customer['name'] ? Colors.black : Colors.grey.shade300, + width: 1.5, + ), + borderRadius: BorderRadius.circular(8), + color: Colors.white, + ), + child: Row( + children: [ + CircleAvatar(child: Icon(Icons.person)), + const SizedBox(width: 10), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(customer['name']!, style: TextStyle(fontSize: 16)), + Text(customer['date']!, style: TextStyle(color: Colors.grey)), + ], + ) + ], + ), + ), + ); + }), + const SizedBox(height: 20), + Text('ENTER DETAILS', style: TextStyle(fontWeight: FontWeight.bold)), + const SizedBox(height: 10), + TextField( + controller: creditLimitController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: 'Credit Limit (in ₹) *', + border: OutlineInputBorder(), + ), + ), + const SizedBox(height: 15), + DropdownButtonFormField2( + decoration: InputDecoration( + labelText: 'Payment Terms *', + border: OutlineInputBorder(), + ), + value: paymentTerm, + items: paymentTerms.map((term) { + return DropdownMenuItem( + value: term, + child: Text(term), + ); + }).toList(), + onChanged: (value) { + setState(() { + paymentTerm = value!; + }); + }, + ), + const SizedBox(height: 15), + TextField( + controller: openingBalanceController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: 'Opening Balance (in ₹) *', + border: OutlineInputBorder(), + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Icon(Icons.info_outline, color: Colors.orange, size: 18), + const SizedBox(width: 8), + Expanded( + child: Text( + 'Creating an Account will send the customer a notification about the details and a request to add balance to start the water delivery plan.', + style: TextStyle(color: Colors.black87, fontSize: 13), + ), + ) + ], + ), + const SizedBox(height: 20), + ElevatedButton( + onPressed: () { + // Add your submission logic here + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF9375E8), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + minimumSize: Size(double.infinity, 50), + ), + child: Text('Create Account'), + ) + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/financials/financial_main_screen.dart b/lib/financials/financial_main_screen.dart index 6472bb2..b7ec9a1 100644 --- a/lib/financials/financial_main_screen.dart +++ b/lib/financials/financial_main_screen.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'package:supplier_new/common/settings.dart'; +import 'package:supplier_new/financials/add_transactions.dart'; +import 'package:supplier_new/financials/building_transactions_details.dart'; +import 'package:supplier_new/financials/create_credit_accounts.dart'; class FinancialMainScreen extends StatefulWidget { @@ -55,6 +58,9 @@ class _FinancialMainScreenState extends State void initState() { super.initState(); _tabController = TabController(length: 2, vsync: this); + _tabController.addListener(() { + setState(() {}); // rebuilds FAB visibility when tab changes + }); } @override @@ -63,6 +69,50 @@ class _FinancialMainScreenState extends State super.dispose(); } + Widget fab(){ + final index = _tabController.index; + + if (index == 0) { + return SizedBox( + width: 52, + height: 52, + child: FloatingActionButton( + shape: const CircleBorder(), + backgroundColor: Colors.black, + onPressed: _onFabPressed, + child: Image.asset( + "images/plus.png", + width: 20, + height: 20, + color: Colors.white, + ), + ), + ); + } else { + return Container(); + } + } + + void _onFabPressed() { + final index = _tabController.index; + + if (index == 0) { + // Tab 1 → Navigate to Create Account + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => AddTransactionScreen(), + ), + ); + } else if (index == 1) { + // Tab 2 → Navigate to Transactions + /*Navigator.push( + context, + MaterialPageRoute(builder: (_) => const TransactionsPage()), + );*/ + } + } + Widget Transactions(){ return Container( @@ -134,10 +184,345 @@ class _FinancialMainScreenState extends State } Widget CreditAccounts(){ - return Container( - color: Color(0XFFFFFFFF), - child:Center( - child: Text("Credit Accounts Coming Soon..."), + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + // Account Summary + + Align( + alignment: Alignment.centerRight, // aligns button to the right + child: OutlinedButton( + style: OutlinedButton.styleFrom( + foregroundColor: Color(0xFFFFFFFF), + backgroundColor: Color(0xFF000000), + side: BorderSide(color: Color(0xFF000000)), + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16), // padding around content + ), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => CreateCreditAccountScreen(), + ), + ); + }, + child: Row( + mainAxisSize: MainAxisSize.min, // shrink button to fit content + children: [ + Image.asset('images/plus.png', height: 20, width: 20), + SizedBox(width: 4), + Text( + "Create Account", + style: fontTextStyle(14, const Color(0xFFFFFFFF), FontWeight.w400), + ), + ], + ), + ), + ), + + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + const Expanded( + child: Text( + "Account Summary", + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.w600), + ), + ), + Column( + children: const [ + Text( + "05", + style: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + color: Colors.blue), + ), + SizedBox(height: 2), + Text( + "4 active, 1 overdue", + style: TextStyle( + fontSize: 12, + color: Colors.grey, + ), + ), + ], + ), + ], + ), + const SizedBox(height: 16), + Row( + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: const Color(0xfffafafa), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + Text( + "Receivable Balance", + style: TextStyle( + fontSize: 12, color: Colors.black54), + ), + SizedBox(height: 4), + Text( + "₹24,000", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.red), + ), + Text( + "40.6% of total credit", + style: TextStyle( + fontSize: 11, color: Colors.grey), + ), + ], + ), + ), + ), + const SizedBox(width: 12), + Expanded( + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: const Color(0xfffafafa), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + Text( + "Advance Balance", + style: TextStyle( + fontSize: 12, color: Colors.black54), + ), + SizedBox(height: 4), + Text( + "₹24,000", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.green), + ), + Text( + "60.4% of total credit", + style: TextStyle( + fontSize: 11, color: Colors.grey), + ), + ], + ), + ), + ), + ], + ), + ], + ), + ), + const SizedBox(height: 20), + + // Search Bar + Container( + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + const Icon(Icons.search, color: Colors.grey), + const SizedBox(width: 8), + const Expanded( + child: TextField( + decoration: InputDecoration( + hintText: "Search", + border: InputBorder.none, + ), + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon(Icons.sort, color: Colors.grey), + ), + ], + ), + ), + const SizedBox(height: 20), + + // Accounts List + _accountTile( + name: "SVG Towers", + status: "active", + orders: "48 orders", + balance: "₹10,000", + credit: "₹10,000", + lastPayment: "₹5,000 | 12 Aug", + balanceColor: Colors.red, + creditColor: Colors.green, + ), + _accountTile( + name: "Canvas Creations", + status: "active", + orders: "32 orders", + balance: "₹7,500", + credit: "₹7,500", + lastPayment: "₹3,000 | 5 Aug", + balanceColor: Colors.red, + creditColor: Colors.green, + ), + _accountTile( + name: "Digital Designs", + status: "inactive", + orders: "15 orders", + balance: "₹2,000", + credit: "₹2,000", + lastPayment: "₹1,000 | 1 Aug", + balanceColor: Colors.red, + creditColor: Colors.green, + ), + ], + ), + ), + ); + } + + Widget _accountTile({ + required String name, + required String status, + required String orders, + required String balance, + required String credit, + required String lastPayment, + required Color balanceColor, + required Color creditColor, + }) { + return GestureDetector( + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => BuildingTransactionsDetails(), + ), + ); + }, + child: Container( + margin: const EdgeInsets.only(bottom: 12), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Name + Status + Row( + children: [ + Expanded( + child: Text( + name, + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.bold), + ), + ), + Container( + padding: + const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: status == "active" + ? Colors.green.withOpacity(0.1) + : Colors.red.withOpacity(0.1), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + status, + style: TextStyle( + color: + status == "active" ? Colors.green : Colors.redAccent, + fontSize: 12, + fontWeight: FontWeight.w500, + ), + ), + ) + ], + ), + const SizedBox(height: 4), + Text( + orders, + style: const TextStyle(color: Colors.grey, fontSize: 12), + ), + const SizedBox(height: 12), + + // Balance - Credit - Last Payment + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("Available Balance", + style: TextStyle( + fontSize: 12, color: Colors.black54)), + const SizedBox(height: 4), + Text( + balance, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: balanceColor), + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("Available Credit", + style: TextStyle( + fontSize: 12, color: Colors.black54)), + const SizedBox(height: 4), + Text( + credit, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: creditColor), + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("Last Payment", + style: TextStyle( + fontSize: 12, color: Colors.black54)), + const SizedBox(height: 4), + Text( + lastPayment, + style: const TextStyle( + fontSize: 12, fontWeight: FontWeight.w500), + ), + ], + ), + ], + ) + ], + ), ), ); } @@ -148,28 +533,8 @@ class _FinancialMainScreenState extends State appBar:AppBar( elevation: 0, backgroundColor: Colors.white, - title: Text( - 'Financials', - style: fontTextStyle(14, Color(0XFF2A2A2A), FontWeight.w500), - ), - iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), - leading: GestureDetector( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 8, 8, 8), // Add padding if needed - child: Image.asset( - 'images/backbutton_appbar.png', - height: 24, - width: 24,// Replace with your image path - fit: BoxFit.contain, // Adjust the fit - ), - ), - ), bottom: PreferredSize( - preferredSize: const Size.fromHeight(50.0), + preferredSize: const Size.fromHeight(0.0), child: Container( height: 38, margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), @@ -218,10 +583,9 @@ class _FinancialMainScreenState extends State CreditAccounts() ], ), - floatingActionButton: FloatingActionButton( - onPressed: () {}, - child: const Icon(Icons.add), - ), + + + floatingActionButton:_tabController.index == 0 ? fab() : null, ); } diff --git a/lib/orders/accept_order_requests.dart b/lib/orders/accept_order_requests.dart index 038bdfe..9136896 100644 --- a/lib/orders/accept_order_requests.dart +++ b/lib/orders/accept_order_requests.dart @@ -1,32 +1,81 @@ import 'package:flutter/material.dart'; +import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/orders/edit_order_requests.dart'; class AcceptOrderRequests extends StatefulWidget { var order; - AcceptOrderRequests({this.order}); + var status; + AcceptOrderRequests({this.order,this.status}); @override State createState() => _AcceptOrderRequestsState(); } class _AcceptOrderRequestsState extends State { + double advancePayable=0.0; + double advance=0.0; + double amountToPayAfterDelivery=0.0; + double totalFare=0.0; + + @override + void initState() { + // TODO: implement initState + super.initState(); + advance=150; + advancePayable = advance; + totalFare=advance+double.parse(widget.order.quoted_amount); + amountToPayAfterDelivery = totalFare - advancePayable; + } + + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - + extendBodyBehindAppBar: true, appBar: AppBar( - backgroundColor: Colors.white, + backgroundColor: Colors.transparent, elevation: 0, - leading: IconButton( - icon: const Icon(Icons.arrow_back, color: Colors.black), - onPressed: () => Navigator.pop(context), + scrolledUnderElevation: 0, + title: Text( + '', + style: fontTextStyle(16, Color(0XFF2A2A2A), FontWeight.w600), ), + iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), actions: [ - IconButton( - icon: const Icon(Icons.help_outline, color: Colors.black), - onPressed: () {}, - ), + Row( + children: [ + Padding( + padding: EdgeInsets.fromLTRB(0, 10, 10, 10), + child: IconButton( + icon: Image.asset( + 'images/help_appbar.png', + height: 20, + width: 20, + color: Color(0XFFFFFFFF), + ), + onPressed: () {}, + ), + ) + ], + ) ], + leading: GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Padding( + padding: + const EdgeInsets.fromLTRB(8, 8, 8, 8), // Add padding if needed + child: Image.asset( + 'images/backbutton_appbar.png', // Replace with your image path + fit: BoxFit.contain, + color: Color(0XFFFFFFFF), + height: 24, + width: 24, + + ), + ), + ), ), body: SingleChildScrollView( @@ -35,125 +84,170 @@ class _AcceptOrderRequestsState extends State { children: [ /// 🔹 Top Card with Image Stack( + clipBehavior: Clip.none, children: [ + /// 🔹 Background Image ClipRRect( - borderRadius: BorderRadius.circular(12), + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(0), + ), child: Image.asset( - "images/building.png", // replace with network image - height: 180, + "images/building.png", + height: 220, width: double.infinity, fit: BoxFit.cover, ), ), - /// Status Chip + /// 🔹 Floating Info Card (half on image, half below) Positioned( - top: 12, + bottom: -40, // pulls the card out by 40px left: 12, + right: 12, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.blue.withOpacity(0.1), - borderRadius: BorderRadius.circular(8), + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black12, + blurRadius: 6, + offset: Offset(0, 3), + ), + ], ), - child: const Text( - "New", - style: TextStyle( - color: Colors.blue, - fontWeight: FontWeight.w600, - fontSize: 12, - ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Color(0XFFFFFFFF), + borderRadius: BorderRadius.circular(4), + border: Border.all( + color: widget.status.statusColor, + width: 0.5, + ), + ), + child: Text( + widget.status.status, + style: fontTextStyle(12, widget.status.statusColor, FontWeight.w500) + ), + ), + Text( + widget.order.building_name, + style: fontTextStyle(20, const Color(0XFF2D2E30), FontWeight.w600), + ), + SizedBox(height: 4), + Text( + widget.order.displayAddress, + style: fontTextStyle(12, const Color(0XFF939495), FontWeight.w400), + ), + ], + ), + const Spacer(), + Text( + widget.order.distanceInKm.toString()+'Km', + style: fontTextStyle(12, const Color(0XFF939495), FontWeight.w400), + ), + ], ), ), ), ], ), + SizedBox(height:MediaQuery.of(context).size.height * .08,), - /// Title + Location + Distance + /// 🔹 Order Details Padding( - padding: const EdgeInsets.all(12), + padding: EdgeInsets.fromLTRB(16,0,16,0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - Text( - "Club Kohinoor", - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), + children: [ + Text( + "ORDER DETAILS", + style: fontTextStyle(10, const Color(0XFF2D2E30), FontWeight.w600), ), - SizedBox(height: 4), - Text( - "Banjara Hills, Hyderabad • 5.5 Km", - style: TextStyle( - fontSize: 13, - color: Colors.grey, - ), + SizedBox(height:MediaQuery.of(context).size.height * .011,), + _detailTwoRow( + "Tanker Price", "₹${AppSettings.formDouble(widget.order.quoted_amount) ?? ''}","images/financialsBottomIcon.png", + "", "","" ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + _detailTwoRow( + "Water Type", "${widget.order.type_of_water}","images/water.png", + "Date of Delivery", "${widget.order.time}","images/calendar_appbar.png", + ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + _detailTwoRow( + "Capacity", "${widget.order.capacity}","images/capacity.png", + "Time of Delivery", "${widget.order.averageTime}","images/time.png", + ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + _detailTwoRow( + "Quantity", "${widget.order.quantity}","images/quantity.png", + "Booking Charges", advance.toString(),"images/advance.png", + ), + ], ), ), - - const Divider(), - - /// 🔹 Order Details + SizedBox(height:MediaQuery.of(context).size.height * .008,), + /// 🔹 Additional Details Padding( - padding: const EdgeInsets.all(12), + padding: EdgeInsets.fromLTRB(16,0,16,16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - "ORDER DETAILS", - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - ), + Text( + "ADDITIONAL DETAILS", + style: fontTextStyle(10, const Color(0XFF2D2E30), FontWeight.w600), + ), + SizedBox(height:MediaQuery.of(context).size.height * .011,), + Text( + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " + "aliquip ex ea commodo consequat.", + style: fontTextStyle(12, const Color(0XFF646566), FontWeight.w400), ), - const SizedBox(height: 12), - - _detailRow("Tanker Price", "₹ ${widget.order.quoted_amount}"), - _detailRow("Water Type", " ${widget.order.type_of_water}"), - _detailRow("Date of Delivery", "${widget.order.time}"), - _detailRow("Capacity", "${widget.order.capacity}"), - _detailRow("Time of Delivery", "${widget.order.averageTime}"), - _detailRow("Quantity", "${widget.order.quantity}"), - _detailRow("Advance", "10%"), ], - ), - ), + ) - const Divider(), - /// 🔹 Additional Details - const Padding( - padding: EdgeInsets.all(12), - child: Text( - "ADDITIONAL DETAILS\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, " - "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " - "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " - "aliquip ex ea commodo consequat.", - style: TextStyle(fontSize: 13, color: Colors.black87, height: 1.4), - ), ), - const Divider(), - /// 🔹 Payment Summary Padding( - padding: const EdgeInsets.all(12), + padding: EdgeInsets.fromLTRB(16,0,16,16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( + Text( "PAYMENT SUMMARY", - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - ), + style: fontTextStyle(10, const Color(0XFF2D2E30), FontWeight.w600), ), - const SizedBox(height: 12), - _detailRow("Tanker Price", "₹ 1,500"), - _detailRow("Advance", "10%"), + SizedBox(height:MediaQuery.of(context).size.height * .011,), + _detailRow("Tanker Price", "₹${AppSettings.formDouble(widget.order.quoted_amount) ?? ''}"), + SizedBox(height:MediaQuery.of(context).size.height * .004,), + _detailRow("Booking Charges", "₹ "+advance.toString()), + SizedBox(height:MediaQuery.of(context).size.height * .004,), + _detailRow("Total Amount", "₹ "+totalFare.toString()), + SizedBox(height:MediaQuery.of(context).size.height * .004,), + Divider(color: Color(0XFF646566), + thickness: 0.3,), + SizedBox(height:MediaQuery.of(context).size.height * .004,), + _detailRow("Booking Charges Payable",'₹${AppSettings.formDouble(advancePayable.toString()) ?? ''}' + + ), + SizedBox(height:MediaQuery.of(context).size.height * .004,), + _detailRow("Amount to Pay (After Delivery)", '₹${AppSettings.formDouble(amountToPayAfterDelivery.toString()) ?? ''}' + ), ], ), ), @@ -167,50 +261,101 @@ class _AcceptOrderRequestsState extends State { bottomNavigationBar: Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( - color: Colors.white, - border: Border(top: BorderSide(color: Colors.grey.shade300)), + color: Color(0XFFFFFFFF), + border: Border(top: BorderSide(color: Color(0XFFF5F6F6))), ), child: Row( children: [ Expanded( child: OutlinedButton( + style: OutlinedButton.styleFrom( + foregroundColor: Color(0XFF000000), + backgroundColor: Color(0xFFF1F1F1), + side: BorderSide(color: Color(0xFFF1F1F1)), + padding: EdgeInsets.symmetric(vertical: 10), // uniform height + ), onPressed: () { - Navigator.push( context, MaterialPageRoute( - builder: (_) => EditOrderRequests(order: widget.order,advance:"10%" ,), + builder: (_) => EditOrderRequests( + order: widget.order, + advance: advance.toString(), + status: widget.status, + ), ), ); - }, - child: const Text("Edit Order"), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('images/edit.png', height: 20, width: 20), + SizedBox(width: 4), + Text( + "Edit Order", + style: fontTextStyle(14, const Color(0XFF000000), FontWeight.w400), + ), + ], + ), ), ), - const SizedBox(width: 8), + + SizedBox(width: 8), + Expanded( child: OutlinedButton( style: OutlinedButton.styleFrom( - foregroundColor: Colors.red, - side: const BorderSide(color: Colors.red), + foregroundColor: Color(0XFFE2483D), + backgroundColor: Colors.white, + side: BorderSide(color: Color(0XFFE2483D)), + padding: EdgeInsets.symmetric(vertical: 10), ), onPressed: () {}, - child: const Text("Reject"), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('images/cross.png', height: 20, width: 20), + SizedBox(width: 4), + Text( + "Reject", + style: fontTextStyle(14, const Color(0XFF000000), FontWeight.w400), + ), + ], + ), ), ), - const SizedBox(width: 8), + + SizedBox(width: 8), + Expanded( child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Colors.green, - foregroundColor: Colors.white, + backgroundColor: Color(0XFF0A9E04), + foregroundColor: Color(0XFFFFFFFF), + padding: EdgeInsets.symmetric(vertical: 10), + ), + onPressed: () { + + + + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('images/rite.png', height: 20, width: 20), + SizedBox(width: 4), + Text( + "Accept", + style: fontTextStyle(14, const Color(0XFFFFFFFF), FontWeight.w400), + ), + ], ), - onPressed: () {}, - child: const Text("Accept"), ), ), ], - ), + ) + + ), ); } @@ -218,17 +363,74 @@ class _AcceptOrderRequestsState extends State { /// 🔹 Helper widget for rows Widget _detailRow(String title, String value) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 6), + padding: const EdgeInsets.symmetric(vertical: 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(title, - style: const TextStyle(fontSize: 13, color: Colors.grey)), + style: fontTextStyle(12, const Color(0XFF646566), FontWeight.w400),), Text(value, - style: const TextStyle( - fontSize: 13, fontWeight: FontWeight.w600)), + style: fontTextStyle(12, const Color(0XFF2D2E30), FontWeight.w500),), ], ), ); } + + Widget _detailTwoRow( + String title1, + String value1, + String path1, + String title2, + String value2, + String path2, { + EdgeInsetsGeometry padding = const EdgeInsets.symmetric(vertical: 6), + }) { + final titleStyle = fontTextStyle(12, Color(0XFF646566), FontWeight.w400); + final valueStyle = fontTextStyle(12, Color(0XFF343637), FontWeight.w500); + + Widget _col(String t, String v, String path) { + return Expanded( + child: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (path.isNotEmpty) + Image.asset( + path, + fit: BoxFit.contain, + height: 20, + width: 20, + color: const Color(0XFFC3C4C4), + ), + if (path.isNotEmpty) const SizedBox(width: 6), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(t, style: titleStyle, maxLines: 1, overflow: TextOverflow.ellipsis), + Text(v, style: valueStyle, maxLines: 1, overflow: TextOverflow.ellipsis), + ], + ), + ) + ], + ), + ), + ); + } + + return Padding( + padding: padding, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _col(title1, value1, path1), + _col(title2, value2, path2), + ], + ), + ); + } + + + } diff --git a/lib/orders/all_orders.dart b/lib/orders/all_orders.dart index 465a4f6..216152c 100644 --- a/lib/orders/all_orders.dart +++ b/lib/orders/all_orders.dart @@ -6,8 +6,11 @@ import 'package:supplier_new/orders/search_order_appbar.dart'; import 'package:intl/intl.dart'; class AllOrders extends StatefulWidget { - const AllOrders({super.key}); - + final String navigationFrom; + AllOrders({ + super.key, + required this.navigationFrom, + }); @override State createState() => _AllOrdersState(); } @@ -82,14 +85,15 @@ class _AllOrdersState extends State { } return Scaffold( backgroundColor: Color(0XFFF2F2F2), - appBar: SearchOrderAppBar( + appBar: widget.navigationFrom.toString().toLowerCase()=='dashboard'? + SearchOrderAppBar( controller: searchController, onBack: () => Navigator.pop(context), onHelp: () { // Show help dialog or navigate print("Help tapped"); }, - ), + ):null, body: SingleChildScrollView( child: Padding( diff --git a/lib/orders/edit_order_requests.dart b/lib/orders/edit_order_requests.dart index c5671f1..e8e2164 100644 --- a/lib/orders/edit_order_requests.dart +++ b/lib/orders/edit_order_requests.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:supplier_new/common/settings.dart'; class EditOrderRequests extends StatefulWidget { var order; String? advance; - EditOrderRequests({this.order,this.advance}); + var status; + EditOrderRequests({this.order,this.advance,this.status}); @override State createState() => _EditOrderRequestsState(); @@ -30,11 +32,11 @@ class _EditOrderRequestsState extends State { advanceController.text='${widget.advance}'; // Update summary in real-time as user types tankerPriceController.addListener(() => setState(() {})); - capacityController.addListener(() => setState(() {})); + /*capacityController.addListener(() => setState(() {})); quantityController.addListener(() => setState(() {})); dateController.addListener(() => setState(() {})); timeController.addListener(() => setState(() {})); - waterTypeController.addListener(() => setState(() {})); + waterTypeController.addListener(() => setState(() {}));*/ advanceController.addListener(() => setState(() {})); } @@ -43,25 +45,42 @@ class _EditOrderRequestsState extends State { int tankerPrice = int.tryParse(tankerPriceController.text) ?? 0; int updatedQuantity=int.tryParse(quantityController.text) ?? 0; String updatedCapacity=capacityController.text ?? ''; - int totalPrice = tankerPrice * updatedQuantity; - double advancePercent = - double.tryParse(advanceController.text.replaceAll('%', '')) ?? 0; - int advancePayable = (totalPrice * (advancePercent / 100)).round(); + // Parse booking/advance as a double to accept "150.0" then convert to int (round) + double bookingChargesDouble = double.tryParse(advanceController.text.trim()) ?? 0.0; + int bookingCharges = bookingChargesDouble.round(); // or .toInt() / .floor() as you prefer + + int totalPrice = (tankerPrice * updatedQuantity) + bookingCharges; + int advancePayable = bookingCharges; // + int amountToPayAfterDelivery=totalPrice-bookingCharges; return Scaffold( backgroundColor: Colors.white, appBar: AppBar( - backgroundColor: Colors.white, + backgroundColor: Colors.white, elevation: 0, - leading: IconButton( - icon: const Icon(Icons.close, color: Colors.black), - onPressed: () => Navigator.pop(context), + scrolledUnderElevation: 0, + title: Text( + 'Edit Order', + style: fontTextStyle(16, Color(0XFF2A2A2A), FontWeight.w600), ), - title: const Text( - "Edit Order", - style: TextStyle(color: Colors.black, fontWeight: FontWeight.w600), + leading: GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Padding( + padding: + const EdgeInsets.fromLTRB(16, 8, 8, 8), // Add padding if needed + child: Image.asset( + 'images/cross.png', // Replace with your image path + fit: BoxFit.contain, + color: Color(0XFF2A2A2A), + height: 24, + width: 24, + + ), + ), ), - centerTitle: true, + iconTheme: IconThemeData(color: Color(0XFF2A2A2A)), ), body: SingleChildScrollView( padding: const EdgeInsets.all(16), @@ -69,92 +88,146 @@ class _EditOrderRequestsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ // 🔹 Club Info Card - Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - border: Border.all(color: Colors.grey.shade300), - borderRadius: BorderRadius.circular(12), - ), - child: Row( - children: [ - Expanded( - child: Column( + Material( + elevation: 4, // shadow depth + borderRadius: BorderRadius.circular(12), + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, // Material needs a background color + border: Border.all(color: Color(0XFFC9C2F0),width: 0.5), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - Chip( - label: Text("New", - style: TextStyle( - color: Colors.blue, - fontSize: 12, - fontWeight: FontWeight.w600)), - backgroundColor: Color(0xFFEAF3FF), - padding: EdgeInsets.symmetric(horizontal: 4), + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Color(0XFFFFFFFF), + borderRadius: BorderRadius.circular(4), + border: Border.all( + color: widget.status.statusColor, + width: 0.5, + ), + ), + child: Text( + widget.status.status, + style: fontTextStyle(12, widget.status.statusColor, FontWeight.w500) + ), ), - Text("Club Kohinoor", - style: TextStyle( - fontSize: 18, fontWeight: FontWeight.w600)), SizedBox(height: 4), - Text("Banjara Hills, Hyderabad", - style: TextStyle(color: Colors.grey, fontSize: 13)), + Text( + widget.order.building_name, + style: fontTextStyle(20, const Color(0XFF2D2E30), FontWeight.w600), + ), + Text( + widget.order.displayAddress, + style: fontTextStyle(12, const Color(0XFF939495), FontWeight.w400), + ), ], ), - ), - const Text("5.5 Km", style: TextStyle(color: Colors.black54)), - ], + const Spacer(), + Text( + widget.order.distanceInKm.toString()+'Km', + style: fontTextStyle(12, const Color(0XFF939495), FontWeight.w400), + ), + ], + ), ), ), - const SizedBox(height: 20), - const Text("ORDER DETAILS", - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14)), + + SizedBox(height:MediaQuery.of(context).size.height * .06,), + Text("ORDER DETAILS", + style: fontTextStyle(12, const Color(0XFF2D2E30), FontWeight.w600),), const SizedBox(height: 12), // 🔹 Two in a row - _twoFields(tankerPriceController, "Tanker Price", null, null), - _twoFields(capacityController, "Capacity", quantityController, "Quantity"), - _twoFields(waterTypeController, "Water Type",advanceController, "Advance"), - _twoFields(dateController, "Date",timeController, "Time Of Delivery"), + _twoFields(tankerPriceController, "Tanker Price",'images/price.png',false, null, null,null,null), + _twoFields(capacityController, "Capacity",'images/capacity.png',true,quantityController, "Quantity",'images/quantity.png',true), + _twoFields(waterTypeController, "Water Type",'images/water.png',true,advanceController, "Booking Charges",'images/advance.png',false), + _twoFields(dateController, "Date",'images/calendar_appbar.png',true,timeController, "Time Of Delivery",'images/time.png',true), const SizedBox(height: 20), - const Text("UPDATED PAYMENT SUMMARY", - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14)), + Text("UPDATED PAYMENT SUMMARY", + style: fontTextStyle(12,Color(0XFF2D2E30),FontWeight.w600),), const SizedBox(height: 12), _summaryRow("Tanker Price", "₹ $tankerPrice"), _summaryRow("Quantity", " $updatedQuantity"), _summaryRow("Capacity", "$updatedCapacity"), + _summaryRow("Booking Charges", "₹ $bookingCharges"), _summaryRow("Total Price", "₹ $totalPrice"), const Divider(), - _summaryRow("Advance", advanceController.text), - _summaryRow("Advance Payable", "₹ $advancePayable"), + + _summaryRow("Booking Charges Payable", "₹ $advancePayable"), + _summaryRow("Amount to Pay (After Delivery)", "₹ $amountToPayAfterDelivery"), ], ), ), bottomNavigationBar: Container( - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( - color: Colors.white, - border: Border(top: BorderSide(color: Colors.grey.shade300)), + color: Color(0XFFFFFFFF), + border: Border(top: BorderSide(color: Color(0XFFF5F6F6))), ), child: Row( children: [ Expanded( child: OutlinedButton( - onPressed: () => Navigator.pop(context), - child: const Text("Cancel"), + style: OutlinedButton.styleFrom( + foregroundColor: Color(0XFF000000), + backgroundColor: Color(0xFFFFFFFF), + side: BorderSide(color: Color(0xFF939495)), + padding: EdgeInsets.symmetric(vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), // <-- radius here + ), + ), + onPressed: () { + Navigator.pop(context); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + + Text( + "Cancel", + style: fontTextStyle(14, const Color(0XFF000000), FontWeight.w400), + ), + ], + ), ), ), const SizedBox(width: 8), Expanded( - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.deepPurple, - foregroundColor: Colors.white, + child: OutlinedButton( + style: OutlinedButton.styleFrom( + foregroundColor: Color(0XFFFFFFFF), + backgroundColor: Color(0xFF8270DB), + side: BorderSide(color: Color(0xFF8270DB)), + padding: EdgeInsets.symmetric(vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), // <-- radius here + ), ), onPressed: () { - // 🔹 Collect updated values - print("Tanker Price: ${tankerPriceController.text}"); - print("Water Type: ${waterTypeController.text}"); - // Save logic here + }, - child: const Text("Send ➤"), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + + Text( + "Send", + style: fontTextStyle(14, const Color(0XFFFFFFFF), FontWeight.w400), + ), + SizedBox(width: 12), + Image.asset('images/send.png', height: 20, width: 20), + + ], + ), ), ), ], @@ -164,36 +237,72 @@ class _EditOrderRequestsState extends State { } /// 🔹 Two fields side by side - Widget _twoFields(TextEditingController? controller1, String? label1, - TextEditingController? controller2, String? label2) { + Widget _twoFields(TextEditingController? controller1, String? label1,String? path1, bool? readOnly1, + TextEditingController? controller2, String? label2,String? path2,bool? readOnly2) { return Row( children: [ Expanded( - child: _textField(controller1, label1), + child: _textField(controller1, label1,path1,readOnly1!), ), const SizedBox(width: 10), if (controller2 != null) Expanded( - child: _textField(controller2, label2), + child: _textField(controller2, label2,path2,readOnly2!), ), ], ); } /// 🔹 Custom text field - Widget _textField(TextEditingController? controller, String? label) { + Widget _textField(TextEditingController? controller, String? label,String? path,bool readOnly) { return Container( margin: const EdgeInsets.only(bottom: 12), child: TextField( controller: controller, + cursorColor: primaryColor, + readOnly: readOnly, decoration: InputDecoration( - labelText: label, + counterText: '', + filled: false, + fillColor: Colors.white, + prefixIcon: Padding( + padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 6.0), + child: SizedBox( + width: 18, + height: 18, + child: Image.asset( + path!, + fit: BoxFit.contain, + color: Color(0XFFC3C4C4), + ), + ), + ), + prefixIconConstraints: BoxConstraints( + minWidth: 24, + minHeight: 24, + ), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide(color: Color(0XFFC3C4C4), + width: 1,)), + focusedBorder: !readOnly?OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide(color: Color(0XFF8270DB),width: 1,), + ):OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide(color: Color(0XFFC3C4C4),width: 1,), ), - contentPadding: - const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide(color: Color(0XFFC3C4C4)), + ), + labelText: label, + labelStyle:fontTextStyle(12,Color(0XFF646566),FontWeight.w400), + /* TextStyle(color: greyColor, fontWeight: FontWeight.bold //<-- SEE HERE + ),*/ ), + style:fontTextStyle(12,Color(0XFF343637),FontWeight.w500), ), ); } @@ -205,12 +314,12 @@ class _EditOrderRequestsState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: const TextStyle(color: Colors.black54)), + Text(title, style: fontTextStyle(12,Color(0XFF646566),FontWeight.w400),), Text(value, - style: const TextStyle( - fontWeight: FontWeight.w600, color: Colors.black)), + style: fontTextStyle(12,Color(0XFF2D2E30),FontWeight.w500),), ], ), ); } + } diff --git a/lib/orders/order_requests.dart b/lib/orders/order_requests.dart index a40362d..bdb71cd 100644 --- a/lib/orders/order_requests.dart +++ b/lib/orders/order_requests.dart @@ -31,7 +31,7 @@ class _OrderRequestsPageState extends State { final data = (jsonDecode(response)['data'] as List) .map((e) => OrderRequestsModel.fromJson(e)) .toList(); - + if (!mounted) return; setState(() { orderRequestsList = data; isLoading = false; @@ -58,8 +58,8 @@ class _OrderRequestsPageState extends State { if (difference.inHours < 2) { status = "New"; color = const Color(0XFF1D7AFC); // Blue - } else if (difference.inHours < 48) { - int remaining = 48 - difference.inHours; + } else if (difference.inHours < 240) { + int remaining = 240 - difference.inHours; status = "Expires in ${remaining}h"; if (difference.inHours < 6) { color = const Color(0XFFE56910); // Less urgent @@ -124,7 +124,7 @@ class _OrderRequestsPageState extends State { Navigator.push( context, MaterialPageRoute( - builder: (_) => AcceptOrderRequests(order: order), + builder: (_) => AcceptOrderRequests(order: order,status:cardModel), ), ); }, diff --git a/lib/orders/order_requests_model.dart b/lib/orders/order_requests_model.dart index f43fd95..ec8f328 100644 --- a/lib/orders/order_requests_model.dart +++ b/lib/orders/order_requests_model.dart @@ -15,6 +15,7 @@ class OrderRequestsModel { double lat=0; double lng=0; double distanceInMeters=0; + double distanceInKm=0.0; OrderRequestsModel(); @@ -36,12 +37,13 @@ class OrderRequestsModel { if (parts.length >= 2) { rtvm.displayAddress = parts[parts.length -4]; // "Banjara Hills" } - /* rtvm.distanceInMeters = double.parse((Geolocator.distanceBetween( + rtvm.distanceInMeters = double.parse((Geolocator.distanceBetween( rtvm.lat, rtvm.lng, AppSettings.supplierLatitude, AppSettings.supplierLongitude - ) / 1000).toStringAsFixed(2));*/ + ) / 1000).toStringAsFixed(2)); + rtvm.distanceInKm = double.parse(( rtvm.distanceInMeters / 1000).toStringAsFixed(1)); return rtvm; } diff --git a/lib/orders/search_order_appbar.dart b/lib/orders/search_order_appbar.dart index c2eb385..fd13cdb 100644 --- a/lib/orders/search_order_appbar.dart +++ b/lib/orders/search_order_appbar.dart @@ -20,17 +20,14 @@ class SearchOrderAppBar extends StatelessWidget implements PreferredSizeWidget { scrolledUnderElevation: 0, elevation: 0, leading: GestureDetector( - onTap: () { - Navigator.pop(context); - }, + onTap: onBack, // 👉 Controlled by parent child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 8, 8, 8), // Add padding if needed + padding: const EdgeInsets.all(8.0), child: Image.asset( 'images/backbutton_appbar.png', height: 24, - width: 24,// Replace with your image path - fit: BoxFit.contain, // Adjust the fit + width: 24, + fit: BoxFit.contain, ), ), ), @@ -40,18 +37,22 @@ class SearchOrderAppBar extends StatelessWidget implements PreferredSizeWidget { decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(22), - border: Border.all(color: Color(0XFF939495)), + border: Border.all(color: const Color(0XFF939495)), ), child: TextField( controller: controller, decoration: InputDecoration( hintText: "Search order", - hintStyle: fontTextStyle(16, Color(0XFF646566), FontWeight.w400), + hintStyle: fontTextStyle( + 16, + const Color(0XFF646566), + FontWeight.w400, + ), prefixIcon: SizedBox( height: 20, width: 20, child: Padding( - padding: const EdgeInsets.all(8.0), // adjust spacing + padding: const EdgeInsets.all(8.0), child: Image.asset( 'images/search.png', fit: BoxFit.contain, @@ -60,29 +61,30 @@ class SearchOrderAppBar extends StatelessWidget implements PreferredSizeWidget { ), border: InputBorder.none, contentPadding: const EdgeInsets.symmetric(vertical: 0), - ), - style: fontTextStyle(16,Color(0XFF2A2A2A),FontWeight.w400), + style: fontTextStyle( + 16, + const Color(0XFF2A2A2A), + FontWeight.w400, + ), + onSubmitted: (value) { + debugPrint("Search Orders: $value"); + }, ), ), - - actions: [ - Padding(padding: EdgeInsets.all(8), - child: - GestureDetector( - onTap: () { - }, - child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 8, 8, 8), // Add padding if needed + actions: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: onHelp, // 👉 Controlled by parent child: Image.asset( 'images/help_appbar.png', height: 24, - width: 24,// Replace with your image path - fit: BoxFit.contain, // Adjust the fit + width: 24, + fit: BoxFit.contain, ), ), - ),) + ), ], ); } diff --git a/lib/plans/all_plans.dart b/lib/plans/all_plans.dart index 95cca86..185ccb0 100644 --- a/lib/plans/all_plans.dart +++ b/lib/plans/all_plans.dart @@ -5,7 +5,11 @@ import 'package:supplier_new/plans/plans_model.dart'; import 'package:supplier_new/plans/search_plan_appbar.dart'; class AllPlans extends StatefulWidget { - const AllPlans({super.key}); + final String navigationFrom; + AllPlans({ + super.key, + required this.navigationFrom, + }); @override State createState() => _AllPlansState(); @@ -57,13 +61,13 @@ class _AllPlansState extends State { return Scaffold( backgroundColor: const Color(0XFFFFFFFF), - appBar: SearchPlanAppBar( + appBar: widget.navigationFrom.toString().toLowerCase()=='dashboard'?SearchPlanAppBar( controller: searchController, onBack: () => Navigator.pop(context), onHelp: () { print("Help tapped"); }, - ), + ):null, body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/plans/search_plan_appbar.dart b/lib/plans/search_plan_appbar.dart index 6e7f823..d1ea464 100644 --- a/lib/plans/search_plan_appbar.dart +++ b/lib/plans/search_plan_appbar.dart @@ -20,17 +20,14 @@ class SearchPlanAppBar extends StatelessWidget implements PreferredSizeWidget { scrolledUnderElevation: 0, elevation: 0, leading: GestureDetector( - onTap: () { - Navigator.pop(context); - }, + onTap: onBack, // 👉 use callback from parent child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 8, 8, 8), // Add padding if needed + padding: const EdgeInsets.all(8.0), child: Image.asset( 'images/backbutton_appbar.png', height: 24, - width: 24,// Replace with your image path - fit: BoxFit.contain, // Adjust the fit + width: 24, + fit: BoxFit.contain, ), ), ), @@ -40,18 +37,18 @@ class SearchPlanAppBar extends StatelessWidget implements PreferredSizeWidget { decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(22), - border: Border.all(color: Color(0XFF939495)), + border: Border.all(color: const Color(0XFF939495)), ), child: TextField( controller: controller, decoration: InputDecoration( hintText: "Search Plan", - hintStyle: fontTextStyle(16, Color(0XFF646566), FontWeight.w400), + hintStyle: fontTextStyle(16, const Color(0XFF646566), FontWeight.w400), prefixIcon: SizedBox( height: 20, width: 20, child: Padding( - padding: const EdgeInsets.all(8.0), // adjust spacing + padding: const EdgeInsets.all(8.0), child: Image.asset( 'images/search.png', fit: BoxFit.contain, @@ -60,29 +57,26 @@ class SearchPlanAppBar extends StatelessWidget implements PreferredSizeWidget { ), border: InputBorder.none, contentPadding: const EdgeInsets.symmetric(vertical: 0), - ), - style: fontTextStyle(16,Color(0XFF2A2A2A),FontWeight.w400), + style: fontTextStyle(16, const Color(0XFF2A2A2A), FontWeight.w400), + onSubmitted: (value) { + debugPrint("Search Plan: $value"); + }, ), ), - - actions: [ - Padding(padding: EdgeInsets.all(8), - child: - GestureDetector( - onTap: () { - }, - child: Padding( - padding: const EdgeInsets.fromLTRB( - 8, 8, 8, 8), // Add padding if needed + actions: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: onHelp, // 👉 use callback from parent child: Image.asset( 'images/help_appbar.png', height: 24, - width: 24,// Replace with your image path - fit: BoxFit.contain, // Adjust the fit + width: 24, + fit: BoxFit.contain, ), ), - ),) + ), ], ); } diff --git a/lib/set_rates/set_rates.dart b/lib/set_rates/set_rates.dart index f74cf08..d5b4204 100644 --- a/lib/set_rates/set_rates.dart +++ b/lib/set_rates/set_rates.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:supplier_new/common/settings.dart'; class SetRatesScreen extends StatefulWidget { const SetRatesScreen({super.key}); @@ -11,158 +12,381 @@ class _SetRatesScreenState extends State with SingleTickerProviderStateMixin { late TabController _tabController; - final TextEditingController drinking5000 = TextEditingController(); - final TextEditingController drinking10000 = TextEditingController(); - final TextEditingController drinking15000 = TextEditingController(); - final TextEditingController bore5000 = TextEditingController(); - final TextEditingController bore10000 = TextEditingController(); - final TextEditingController bore15000 = TextEditingController(); + final Map controllers = {}; + // Define categories + tankers + final Map> tankerGroups = {}; + final Map deliveryControllers = {}; + + + /*delivery fee controllers*/ + final TextEditingController pumpFeeController = TextEditingController(); + + final List> data = [ + {"category": "DRINKING WATER", "size": "5,000L", "price": "12"}, + {"category": "DRINKING WATER", "size": "15,000L", "price": "18"}, + {"category": "DRINKING WATER", "size": "20,000L", "price": "20"}, + {"category": "BORE WATER", "size": "5,000L", "price": "10"}, + {"category": "BORE WATER", "size": "10,000L", "price": "14"}, + {"category": "BORE WATER", "size": "15,000L", "price": "16"}, + {"category": "BORE WATER", "size": "25,000L", "price": null}, + ]; @override void initState() { super.initState(); _tabController = TabController(length: 3, vsync: this); - // Prefill values - drinking5000.text = "₹500"; - drinking10000.text = "₹500"; - drinking15000.text = "₹500"; - bore5000.text = "₹500"; - bore10000.text = "₹500"; - bore15000.text = "₹500"; + + // Group data by category and initialize controllers for WaterCharges + for (final item in data) { + final category = item['category'] as String; + final size = item['size'] as String; + final price = item['price']?.toString() ?? ""; // default to empty if null + + if (!tankerGroups.containsKey(category)) { + tankerGroups[category] = []; + } + tankerGroups[category]!.add(size); + + // Pre-fill controller with price or empty + controllers.putIfAbsent("$category-$size", () => TextEditingController(text: price)); + } + + // Initialize controllers for unique capacities for DeliveryFee + final capacities = data.map((item) => item['size'] as String).toSet(); + for (final cap in capacities) { + // Take first price for this capacity, default to empty if null + final price = data.firstWhere( + (d) => d['size'] == cap, + orElse: () => {'price': ''}, + )['price']?.toString() ?? ""; + deliveryControllers.putIfAbsent(cap, () => TextEditingController(text: price)); + } + + } + + @override + void dispose() { + // Dispose all controllers + for (final controller in controllers.values) { + controller.dispose(); + } + for (final controller in deliveryControllers.values) { + controller.dispose(); + } + super.dispose(); } Widget buildTextField(String label, TextEditingController controller) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: TextField( - controller: controller, - decoration: InputDecoration( - labelText: label, - labelStyle: const TextStyle(fontSize: 14, color: Colors.black87), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), + padding: const EdgeInsets.symmetric(vertical: 8), + child: TextField( + controller: controller, + cursorColor: primaryColor, + readOnly: false, + keyboardType: TextInputType.number, + decoration: InputDecoration( + counterText: '', + filled: false, + fillColor: Colors.white, + prefixIconConstraints: BoxConstraints( + minWidth: 24, + minHeight: 24, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide( + color: Color(0XFFC3C4C4), + width: 1, + )), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide( + color: Color(0XFF8270DB), + width: 1, + ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(4.0), + borderSide: BorderSide(color: Color(0XFFC3C4C4)), + ), + hintText: label, + hintStyle: fontTextStyle(14, Color(0XFF939495), FontWeight.w400), + /* TextStyle(color: greyColor, fontWeight: FontWeight.bold //<-- SEE HERE + ),*/ ), - ), - keyboardType: TextInputType.number, + style: fontTextStyle(14, Color(0XFF515253), FontWeight.w500), + )); + } + + Widget labelText(String label) { + return Text( + label, + style: fontTextStyle(12, const Color(0XFF515253), FontWeight.w500), + ); + } + + Widget WaterCharges() { + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (final entry in tankerGroups.entries) ...[ + Text( + entry.key, + style: fontTextStyle(10, Color(0XFF2D2E30), FontWeight.w600), + ), + const SizedBox(height: 8), + for (final size in entry.value) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + labelText("$size (in ₹)*"), + const SizedBox(height: 4), + buildTextField("₹500", controllers["${entry.key}-$size"]!), + const SizedBox(height: 12), + ], + ), + const SizedBox(height: 10), + ], + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0XFF8270DB), + foregroundColor: Color(0XFFFFFFFF), + padding: EdgeInsets.symmetric(vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), // <-- set your radius here + ), + ), + onPressed: () { + final Map> grouped = {}; + tankerGroups.forEach((category, sizes) { + grouped[category] = {}; + for (final size in sizes) { + grouped[category]![size] = + controllers["$category-$size"]!.text; + } + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Rates saved successfully")), + ); + + print(grouped); // Debug: print entered rates + }, + child: Text( + "Save", + style: fontTextStyle(14, const Color(0XFFFFFFFF), FontWeight.w600), + ), + ), + ) + ], ), ); } - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - appBar: AppBar( - title: const Text( - "Set Rates", - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), + + Widget DeliveryFee() { + // Extract unique capacities + final capacities = data.map((item) => item['size'] as String).toSet().toList(); + + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "ADDITIONAL RATES", + style: fontTextStyle(10, const Color(0xFF2D2E30), FontWeight.w600), ), - centerTitle: true, - actions: [ - TextButton( - onPressed: () {}, - child: const Text( - "HELP", - style: TextStyle(color: Colors.blue, fontSize: 14), - ), - ) + SizedBox(height: MediaQuery.of(context).size.height * .004), + Text( + "Add your price per Kilometer for every tanker capacity", + style: fontTextStyle(12, const Color(0xFF939495), FontWeight.w400), + ), + SizedBox(height: MediaQuery.of(context).size.height * .020), + + // 🔹 Dynamic textfields + for (final cap in capacities) ...[ + labelText('$cap tanker (per KM)*'), + SizedBox(height: MediaQuery.of(context).size.height * .004), + buildTextField("+ ₹12", deliveryControllers[cap]!), + const SizedBox(height: 12), ], + + const SizedBox(height: 10), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0XFF8270DB), + foregroundColor: Color(0XFFFFFFFF), + padding: EdgeInsets.symmetric(vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), // <-- set your radius here + ), + ), + onPressed: () { + final Map fees = {}; + deliveryControllers.forEach((cap, controller) { + fees[cap] = controller.text; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Rates saved successfully")), + ); + + print(fees); + }, + child: Text( + "Save", + style: fontTextStyle(14, const Color(0XFFFFFFFF), FontWeight.w600), + ), + ), + ) + ], + ), + ); + } + + + Widget PumpFee() { + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + "TANKER TYPE", + style: fontTextStyle(10, Color(0XFF2D2E30), FontWeight.w600), + ), + SizedBox(height: MediaQuery.of(context).size.height * .004), + Text( + "Add your price addition for tankers with pump", + style: fontTextStyle(12, Color(0XFF939495), FontWeight.w400), ), - body: Column( - children: [ - const SizedBox(height: 16), - const CircleAvatar( - radius: 40, - backgroundColor: Color(0xFFE0E0E0), - child: Icon(Icons.water_drop_outlined, - size: 40, color: Colors.deepPurple), + SizedBox(height: MediaQuery.of(context).size.height * .024), + labelText('Tanker with pump*'), + SizedBox(height: MediaQuery.of(context).size.height * .004), + buildTextField("+ ₹50 ", pumpFeeController), + SizedBox(height: MediaQuery.of(context).size.height * .024), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0XFF8270DB), + foregroundColor: Color(0XFFFFFFFF), + padding: EdgeInsets.symmetric(vertical: 10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), // <-- set your radius here + ), ), - const SizedBox(height: 16), - const Text( - "What’s today’s water price?", - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), + onPressed: () { + // Handle save logic + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Rates saved successfully")), + ); + }, + child: Text( + "Save", + style: fontTextStyle(14, const Color(0XFFFFFFFF), FontWeight.w600), ), - const SizedBox(height: 4), - const Text( - "Set your daily rate so customers know what to expect", - style: TextStyle(fontSize: 13, color: Colors.black54), - textAlign: TextAlign.center, + ), + ) + ]), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0XFFFFFFFF), + appBar: AppSettings.supplierAppBarWithActionsText('Set Rates', context), + body: Column( + children: [ + Container( + width: double.infinity, + decoration: const BoxDecoration( + color: Color(0XFFF3F1FB), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), + bottomRight: Radius.circular(24), + ), ), - const SizedBox(height: 20), - TabBar( - controller: _tabController, - labelColor: Colors.black, - unselectedLabelColor: Colors.grey, - indicatorColor: Colors.deepPurple, - tabs: const [ - Tab(text: "Water Type"), - Tab(text: "Delivery Fee"), - Tab(text: "Pump"), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24), + child: Column( + children: [ + SizedBox(height: MediaQuery.of(context).size.height * .096), + const CircleAvatar(radius: 50, backgroundColor: Color(0XFFC9C2F0)), + SizedBox(height: MediaQuery.of(context).size.height * .016), + Text( + "What’s today’s water price?", + style: fontTextStyle(20, Color(0XFF343637), FontWeight.w600), + ), + SizedBox(height: MediaQuery.of(context).size.height * .008), + Text( + "Set your daily rate so customers know what to expect", + style: fontTextStyle(12, Color(0XFF343637), FontWeight.w400), + textAlign: TextAlign.center, + ), ], ), - Expanded( - child: TabBarView( - controller: _tabController, - children: [ - // Water Type Tab - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - "DRINKING WATER", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 14), - ), - buildTextField("5,000L (in ₹)", drinking5000), - buildTextField("10,000L (in ₹)", drinking10000), - buildTextField("15,000L (in ₹)", drinking15000), - const SizedBox(height: 20), - const Text( - "BORE WATER", - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 14), + ), + const SizedBox(height: 20), + Container( + height: 30, + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: AnimatedBuilder( + animation: _tabController, + builder: (context, _) { + return TabBar( + controller: _tabController, + indicatorColor: Colors.transparent, // remove underline + dividerColor: Colors.transparent, + isScrollable: false, + overlayColor: MaterialStateProperty.all(Colors.transparent),// equal width + tabs: List.generate(3, (index) { + final labels = ['Water Type', 'Delivery Fee','Pump']; + final isSelected = _tabController.index == index; + + return Container( + decoration: BoxDecoration( + color: isSelected ? const Color(0XFFF1F1F1) : Colors.transparent, + borderRadius: BorderRadius.circular(27), + ), + alignment: Alignment.center, + child: Text( + labels[index], + style: isSelected ?fontTextStyle( + 12, + const Color(0XFF101214), + FontWeight.w600, + ):fontTextStyle( + 12, + const Color(0XFF646464), + FontWeight.w600, ), - buildTextField("5,000L (in ₹)", bore5000), - buildTextField("10,000L (in ₹)", bore10000), - buildTextField("15,000L (in ₹)", bore15000), - const SizedBox(height: 30), - SizedBox( - width: double.infinity, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.deepPurple, - padding: const EdgeInsets.symmetric(vertical: 14), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10)), - ), - onPressed: () { - // Handle save logic - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Rates saved successfully")), - ); - }, - child: const Text( - "Save", - style: - TextStyle(fontSize: 16, color: Colors.white), - ), - ), - ) - ], - ), - ), - // Delivery Fee Tab - const Center(child: Text("Delivery Fee Settings")), - // Pump Tab - const Center(child: Text("Pump Settings")), - ], - ), + ), + ); + }), + ); + }, ), - ], - ), + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: [ + // Water Type Tab + WaterCharges(), + // Delivery Fee Tab + DeliveryFee(), + // Pump Tab + PumpFee() + ], + ), + ), + ], ), ); } diff --git a/pubspec.lock b/pubspec.lock index 6e8bfd5..f390594 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -113,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dropdown_button2: + dependency: "direct main" + description: + name: dropdown_button2 + sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1 + url: "https://pub.dev" + source: hosted + version: "2.3.9" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0f33060..ae70739 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: geocoding: ^3.0.0 provider: ^6.0.5 google_maps_place_picker_mb: ^3.0.2 + dropdown_button2: ^2.0.0 dev_dependencies: flutter_test: