import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '../common/settings.dart'; class SourceDetailsScreen extends StatefulWidget { var sourceDetails; var status; SourceDetailsScreen({this.sourceDetails, this.status}); @override State createState() => _SourceDetailsScreenState(); } class _SourceDetailsScreenState extends State { final List> recentTrips = [ {"type": "Drinking Water", "liters": "10,000 L", "time": "7:02 PM", "date": "28 Jun 2025"}, {"type": "Drinking Water", "liters": "10,000 L", "time": "7:02 PM", "date": "28 Jun 2025"}, {"type": "Drinking Water", "liters": "10,000 L", "time": "7:02 PM", "date": "28 Jun 2025"}, ]; double _avSize = 80; // avatar diameter double _cardHPad = 16; // horizontal padding double _cardTPad = 16; // top inner padding double _avatarOverlap = 28; // how much avatar rises above the card void _showMenu() { showModalBottomSheet( context: context, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(16)), ), builder: (context) { return Padding( padding: const EdgeInsets.symmetric(vertical: 16.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ ListTile( leading: const Icon(Icons.edit, color: Colors.black), title: const Text('Edit'), onTap: () => Navigator.pop(context), ), ListTile( leading: const Icon(Icons.block, color: Colors.black), title: const Text('Disable'), onTap: () => Navigator.pop(context), ), ListTile( leading: const Icon(Icons.delete_outline, color: Colors.red), title: const Text('Delete', style: TextStyle(color: Colors.red)), onTap: () => Navigator.pop(context), ), ], ), ); }, ); } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { // βœ… Return true to indicate successful tanker update refresh Navigator.pop(context, true); return false; // prevent default pop since we manually handled it }, child:Scaffold( backgroundColor: Colors.white, appBar:AppSettings.supplierAppBarWithActionsText( widget.sourceDetails.source_name.isNotEmpty ? widget.sourceDetails.source_name[0].toUpperCase() + widget.sourceDetails.source_name.substring(1) : '', context), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height:MediaQuery.of(context).size.height * .1,), // πŸ‘€ Driver Profile Card Stack( clipBehavior: Clip.none, children: [ // Main card (give extra top padding so text starts below the avatar) Container( padding: EdgeInsets.fromLTRB( _cardHPad, _cardTPad + _avSize - _avatarOverlap, // space for avatar _cardHPad, 16, ), decoration: const BoxDecoration( color: Color(0xFFF3F1FB), borderRadius: BorderRadius.only( topLeft: Radius.circular(24), topRight: Radius.circular(24), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // status chip (just under avatar, aligned left) Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded(child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 6), Text( widget.sourceDetails.source_name, style: fontTextStyle( 20, Color(0XFF2D2E30), FontWeight.w500), ), const SizedBox(height: 2), Text( "+91 "+widget.sourceDetails.phone, style: fontTextStyle( 12, Color(0XFF646566), FontWeight.w400), ), const SizedBox(height: 2), Text( "+91 "+widget.sourceDetails.phone, style: fontTextStyle( 12, Color(0XFF646566), FontWeight.w400), ), ], ),), PopupMenuButton( // πŸ” Use `child:` so you can place any widget (your 3-dots image) child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), child: Image.asset( 'images/popup_menu.png', // your 3-dots image width: 22, height: 22, // If you want to tint it like an icon: color: Color(0XFF939495), // remove if you want original colors colorBlendMode: BlendMode.srcIn, ), ), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), offset: const Offset(0, 40), color: Colors.white, elevation: 4, onSelected: (value) { if (value == 'edit') { //_openDriverFormSheet(context); } else if (value == 'disable') { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Disable selected')), ); } else if (value == 'delete') { //showDeleteDriverDialog(context); } }, itemBuilder: (context) => [ PopupMenuItem( value: 'edit', child: Row( children: [ Image.asset( 'images/edit.png', width: 20, height: 20, color: Color(0XFF646566), // tint (optional) colorBlendMode: BlendMode.srcIn, ), const SizedBox(width: 12), Text( 'Edit', style: fontTextStyle(14, const Color(0XFF646566), FontWeight.w400), ), ], ), ), PopupMenuItem( value: 'disable', child: Row( children: [ Image.asset( 'images/disable.png', width: 20, height: 20, color: Color(0XFF646566), // tint (optional) colorBlendMode: BlendMode.srcIn, ), const SizedBox(width: 12), Text( 'Disable', style: fontTextStyle(14, const Color(0XFF646566), FontWeight.w400), ), ], ), ), PopupMenuItem( value: 'delete', child: Row( children: [ Image.asset( 'images/delete.png', width: 20, height: 20, color: Color(0XFFE2483D), // red like your example colorBlendMode: BlendMode.srcIn, ), const SizedBox(width: 12), Text( 'Delete', style: fontTextStyle(14, const Color(0xFFE2483D), FontWeight.w400), ), ], ), ), ], ) ], ), const SizedBox(height: 8), ], ), ), // Floating avatar (top-left, overlapping the card) Positioned( top: -_avatarOverlap, left: _cardHPad, child: ClipRRect( borderRadius: BorderRadius.circular(_avSize / 2), child: Image.asset( 'images/avatar.png', width: _avSize, height: _avSize, fit: BoxFit.cover, ), ), ), // Call icon aligned with the card’s top-right /*Positioned( top: _cardTPad - _avatarOverlap + 4, // aligns near chip row right: _cardHPad - 4, child: IconButton( onPressed: () { // πŸ“ž Call action }, icon: const Icon(Icons.call, color: Color(0xFF4F46E5)), ), ),*/ ], ), const SizedBox(height: 12), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.sourceDetails.source_name, style: fontTextStyle(18, Colors.black, FontWeight.w600)), const SizedBox(height: 4), Text("Drinking Water", style: fontTextStyle(14, const Color(0xFF8270DB), FontWeight.w500)), const SizedBox(height: 4), Text("+91 789456212", style: fontTextStyle(14, Colors.black, FontWeight.w400)), const SizedBox(height: 4), Text( "Road No. 12, Krishnadwar Layout,\nGandipet, Hyderabad, 500065", style: fontTextStyle(13, const Color(0xFF656565), FontWeight.w400), ), ], ), ), const SizedBox(height: 20), // Filling & Wait time cards Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( children: [ Expanded( child: Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: const Color(0xFFF7F7F7), borderRadius: BorderRadius.circular(12), ), child: Column( children: [ Text("12", style: fontTextStyle(20, Colors.black, FontWeight.w600)), Text("sec/L", style: fontTextStyle(14, Colors.black, FontWeight.w400)), const SizedBox(height: 4), Text("Filling Time", style: fontTextStyle(12, Colors.grey, FontWeight.w400)), ], ), ), ), const SizedBox(width: 12), Expanded( child: Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: const Color(0xFFF7F7F7), borderRadius: BorderRadius.circular(12), ), child: Column( children: [ Text("24", style: fontTextStyle(20, Colors.black, FontWeight.w600)), Text("min", style: fontTextStyle(14, Colors.black, FontWeight.w400)), const SizedBox(height: 4), Text("Wait Time", style: fontTextStyle(12, Colors.grey, FontWeight.w400)), ], ), ), ), ], ), ), const SizedBox(height: 20), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text("Recent Trips", style: fontTextStyle(16, Colors.black, FontWeight.w600)), ), const SizedBox(height: 8), ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: recentTrips.length, itemBuilder: (context, index) { final trip = recentTrips[index]; return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), child: Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: const Color(0xFFF7F7F7), borderRadius: BorderRadius.circular(12), ), child: Row( children: [ const Icon(Icons.water_drop, color: Color(0xFF8270DB)), const SizedBox(width: 12), Expanded( child: Text( "${trip['type']} - ${trip['liters']}", style: fontTextStyle( 14, const Color(0xFF2D2E30), FontWeight.w500), ), ), Text( "${trip['time']}, ${trip['date']}", style: fontTextStyle( 12, const Color(0xFF656565), FontWeight.w400), ), ], ), ), ); }, ), const SizedBox(height: 20), ],)))); } }