import 'package:flutter/material.dart'; class SetRatesScreen extends StatefulWidget { const SetRatesScreen({super.key}); @override State createState() => _SetRatesScreenState(); } 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(); @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"; } 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), ), ), keyboardType: TextInputType.number, ), ); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: const Text( "Set Rates", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), ), centerTitle: true, actions: [ TextButton( onPressed: () {}, child: const Text( "HELP", style: TextStyle(color: Colors.blue, fontSize: 14), ), ) ], ), 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), ), const SizedBox(height: 16), const Text( "What’s today’s water price?", style: TextStyle(fontSize: 16, fontWeight: 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, ), 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"), ], ), 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), ), 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")), ], ), ), ], ), ), ); } }