import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:nearle/views/helpers/constants/Font_constant.dart'; import 'package:nearle/views/helpers/constants/Colorconstants.dart'; class SavedAddressPage extends StatefulWidget { const SavedAddressPage({super.key}); @override State createState() => _SavedAddressPageState(); } class _SavedAddressPageState extends State { final TextEditingController _addressController = TextEditingController(); @override void initState() { super.initState(); _loadAddress(); } Future _loadAddress() async { final prefs = await SharedPreferences.getInstance(); final address = (prefs.getString('user_address') ?? '').trim(); _addressController.text = address; setState(() {}); } @override void dispose() { _addressController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; final addressText = _addressController.text.trim(); return Scaffold( backgroundColor: const Color(0xFFF8F9FB), appBar: AppBar( backgroundColor: ColorConstants.primaryColor, centerTitle: true, toolbarHeight: 70, elevation: 3, leading: IconButton( icon: const Icon(Icons.arrow_back_ios_new_rounded, color: Colors.white), onPressed: () => Navigator.pop(context), ), title: const Text( 'Saved Address', style: TextStyle( fontSize: 24, color: Colors.white, fontWeight: FontWeight.bold, letterSpacing: 1.1, ), ), ), body: SafeArea( child: Padding( padding: EdgeInsets.symmetric(horizontal: size.width * 0.05, vertical: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // 🏠 Header Section Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.15), spreadRadius: 1, blurRadius: 8, offset: const Offset(0, 3), ), ], ), child: Padding( padding: const EdgeInsets.all(16), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( color: ColorConstants.primaryColor.withOpacity(0.1), shape: BoxShape.circle, ), padding: const EdgeInsets.all(10), child: Icon( Icons.location_on_rounded, color: ColorConstants.primaryColor, size: 26, ), ), const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Current Address', style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, fontFamily: FontConstants.fontFamily, color: Colors.black87, ), ), const SizedBox(height: 8), Text( addressText.isNotEmpty ? addressText : 'No address saved yet.', style: TextStyle( fontSize: 15, fontFamily: FontConstants.fontFamily, color: Colors.grey.shade700, height: 1.4, ), ), ], ), ), ], ), ), ), const SizedBox(height: 28), // ✨ Info Section Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: ColorConstants.primaryColor.withOpacity(0.05), borderRadius: BorderRadius.circular(12), ), child: Row( children: [ Icon(Icons.info_outline_rounded, color: ColorConstants.primaryColor, size: 24), const SizedBox(width: 12), Expanded( child: Text( 'Your saved address is used for deliveries, pickups, and nearby service accuracy.', style: TextStyle( fontSize: 14, color: Colors.grey.shade800, fontFamily: FontConstants.fontFamily, height: 1.4, ), ), ), ], ), ), const Spacer(), ], ), ), ), ); } }