import 'package:cheminova/screens/Add_products_screen.dart'; import 'package:flutter/material.dart'; import 'package:cheminova/widgets/common_background.dart'; import 'package:cheminova/widgets/common_app_bar.dart'; import 'package:cheminova/widgets/common_drawer.dart'; import 'package:cheminova/widgets/common_elevated_button.dart'; class UpdateInventoryScreen extends StatefulWidget { const UpdateInventoryScreen({super.key}); @override State createState() => _UpdateInventoryScreenState(); } class _UpdateInventoryScreenState extends State { final List principalDistributors = ['vaibhav', 'sonu', 'monu']; final List retailerDistributors = ['shivam', 'vivek']; String? selectedDistributorType; String? selectedDistributor; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return CommonBackground( child: Scaffold( backgroundColor: Colors.transparent, appBar: CommonAppBar( actions: [ IconButton( onPressed: () { Navigator.pop(context); }, icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20), ), ], title: const Text('Update Inventory Data', style: TextStyle( fontSize: 20, color: Colors.black, fontWeight: FontWeight.w400, fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0, ), drawer: const CommonDrawer(), bottomNavigationBar: Padding( padding: const EdgeInsets.all(16.0), child: CommonElevatedButton( borderRadius: 30, width: double.infinity, height: kToolbarHeight - 10, text: 'SUBMIT', backgroundColor: const Color(0xff004791), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const AddProductsScreen(), ), ); }, ), ), body: Stack( children: [ Column( children: [ // Dropdown for selecting distributor type Padding( padding: const EdgeInsets.symmetric( horizontal: 15.0, vertical: 25), child: DropdownButtonFormField( decoration: const InputDecoration( labelText: 'Select Distributor Type', fillColor: Colors.white, filled: true, border: OutlineInputBorder(), ), value: selectedDistributorType, items: ['Principal Distributor', 'Retailer Distributor'] .map((String type) { return DropdownMenuItem( value: type, child: Text(type), ); }).toList(), onChanged: (value) { setState(() { selectedDistributorType = value; selectedDistributor = null; // Reset distributor selection when type changes }); }, ), ), // Dropdown for selecting distributor name based on type Padding( padding: const EdgeInsets.symmetric( horizontal: 15.0, vertical: 25), child: DropdownButtonFormField( decoration: const InputDecoration( labelText: 'Select Distributor Name', fillColor: Colors.white, filled: true, border: OutlineInputBorder(), ), value: selectedDistributor, items: (selectedDistributorType == 'Principal Distributor' ? principalDistributors : retailerDistributors) .map((String distributor) { return DropdownMenuItem( value: distributor, child: Text(distributor), ); }).toList(), onChanged: (value) { setState(() { selectedDistributor = value; }); }, // Disable the dropdown if no distributor type is selected isExpanded: true, isDense: true, iconSize: 24, hint: Text( 'Please select a ${selectedDistributorType ?? "Distributor Type"} first'), ), ), ], ), ], ), ), ); } }