Your changes
This commit is contained in:
@@ -20,8 +20,8 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final profile = Provider.of<UserProfileProvider>(
|
||||
context, listen: false).profile;
|
||||
final profile =
|
||||
Provider.of<UserProfileProvider>(context, listen: false).profile;
|
||||
|
||||
nameCtrl.text = profile?.customerName ?? '';
|
||||
companyCtrl.text = profile?.companyName ?? '';
|
||||
@@ -32,8 +32,7 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
final provider =
|
||||
Provider.of<UserProfileProvider>(context, listen: false);
|
||||
final provider = Provider.of<UserProfileProvider>(context, listen: false);
|
||||
|
||||
final data = {
|
||||
"customer_name": nameCtrl.text,
|
||||
@@ -44,14 +43,16 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
|
||||
"pincode": pincodeCtrl.text,
|
||||
};
|
||||
|
||||
final success =
|
||||
await provider.sendProfileUpdateRequest(context, data);
|
||||
final success = await provider.sendProfileUpdateRequest(context, data);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(success
|
||||
content: Text(
|
||||
success
|
||||
? "Request submitted. Wait for admin approval."
|
||||
: "Failed to submit request")),
|
||||
: "Failed to submit request",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (success) Navigator.pop(context);
|
||||
@@ -59,38 +60,179 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Edit Profile")),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(18),
|
||||
child: Column(
|
||||
children: [
|
||||
_field("Name", nameCtrl),
|
||||
_field("Company", companyCtrl),
|
||||
_field("Email", emailCtrl),
|
||||
_field("Mobile", mobileCtrl),
|
||||
_field("Address", addressCtrl),
|
||||
_field("Pincode", pincodeCtrl),
|
||||
final darkBlue = const Color(0xFF003B73);
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: _submit,
|
||||
child: const Text("Submit Update Request"),
|
||||
)
|
||||
],
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xFFB3E5FC), Color(0xFFE1F5FE)],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SafeArea(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
double scale = (screenWidth / 390).clamp(0.75, 1.3);
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 18 * scale),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 8 * scale),
|
||||
|
||||
/// BACK BUTTON
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios_new, size: 22 * scale),
|
||||
color: Colors.red,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
|
||||
SizedBox(height: 10 * scale),
|
||||
|
||||
/// TITLE
|
||||
Center(
|
||||
child: Text(
|
||||
"Edit Profile",
|
||||
style: TextStyle(
|
||||
color: darkBlue,
|
||||
fontSize: 26 * scale,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 20 * scale),
|
||||
|
||||
/// RESPONSIVE CENTERED FORM CARD
|
||||
Center(
|
||||
child: Container(
|
||||
width: screenWidth > 650 ? 550 : double.infinity,
|
||||
padding: EdgeInsets.all(24 * scale),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
borderRadius: BorderRadius.circular(20 * scale),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black12.withOpacity(0.15),
|
||||
blurRadius: 18 * scale,
|
||||
offset: Offset(0, 6 * scale),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildField("Full Name", nameCtrl, scale),
|
||||
_buildField("Company Name", companyCtrl, scale),
|
||||
_buildField("Email Address", emailCtrl, scale),
|
||||
_buildField("Mobile Number", mobileCtrl, scale),
|
||||
_buildField("Address", addressCtrl, scale),
|
||||
_buildField("Pincode", pincodeCtrl, scale),
|
||||
|
||||
SizedBox(height: 25 * scale),
|
||||
|
||||
/// RESPONSIVE GRADIENT SUBMIT BUTTON
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50 * scale,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14 * scale),
|
||||
gradient: const LinearGradient(
|
||||
colors: [
|
||||
Color(0xFF0052D4),
|
||||
Color(0xFF4364F7),
|
||||
Color(0xFF6FB1FC),
|
||||
],
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blueAccent.withOpacity(0.4),
|
||||
blurRadius: 10 * scale,
|
||||
offset: Offset(0, 4 * scale),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ElevatedButton(
|
||||
onPressed: _submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(14 * scale),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Submit Update Request",
|
||||
style: TextStyle(
|
||||
fontSize: 17 * scale,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30 * scale),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _field(String title, TextEditingController ctrl) {
|
||||
/// Reusable Responsive TextField Builder
|
||||
Widget _buildField(
|
||||
String label, TextEditingController ctrl, double scale) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: TextField(
|
||||
controller: ctrl,
|
||||
decoration: InputDecoration(
|
||||
labelText: title,
|
||||
border: OutlineInputBorder(),
|
||||
padding: EdgeInsets.only(bottom: 18 * scale),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16 * scale),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black12.withOpacity(0.06),
|
||||
blurRadius: 10 * scale,
|
||||
offset: Offset(0, 3 * scale),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextField(
|
||||
controller: ctrl,
|
||||
style: TextStyle(fontSize: 15 * scale),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
labelText: label,
|
||||
labelStyle: TextStyle(
|
||||
color: const Color(0xFF003B73),
|
||||
fontSize: 14 * scale,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(16 * scale),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(16 * scale),
|
||||
borderSide: BorderSide(
|
||||
color: const Color(0xFF003B73),
|
||||
width: 2 * scale,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user