import 'package:cheminova/controller/home_controller.dart'; import 'package:cheminova/widgets/my_drawer.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; import '../../widgets/comman_background.dart'; import '../../widgets/common_appbar.dart'; class ProfileScreen extends StatefulWidget { const ProfileScreen({ Key? key, }) : super(key: key); @override State createState() => _ProfileScreenState(); } class _ProfileScreenState extends State { // Initialize the HomeController using GetX final homecontroller = Get.put(HomeController()); @override void initState() { // TODO: implement initState super.initState(); homecontroller.getUser(); } @override Widget build(BuildContext context) { // Accessing the user details from the HomeController final user = homecontroller.user; return Stack( children: [ CommonBackground( isFullWidth: true, child: Scaffold( drawer: MyDrawer(), backgroundColor: Colors.transparent, appBar: CommonAppBar( title: const Text('Profile'), backgroundColor: Colors.transparent, elevation: 0, actions: [ IconButton( onPressed: () { // Navigates back to the previous screen Navigator.pop(context); }, icon: SvgPicture.asset( 'assets/svg/back_arrow.svg', ), padding: const EdgeInsets.only(right: 20), ), ], ), // Main content of the profile screen body: user == null ? const Center(child: CircularProgressIndicator()) : SingleChildScrollView( child: Column( children: [ Container( padding: const EdgeInsets.all(20.0) .copyWith(top: 15, bottom: 30), margin: const EdgeInsets.symmetric( horizontal: 30.0, vertical: 20.0), decoration: BoxDecoration( border: Border.all(color: Colors.white), color: const Color(0xffB4D1E5).withOpacity(0.9), borderRadius: BorderRadius.circular(26.0), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 20), // Displaying individual profile items _buildProfileItem('Name', user.name), _buildProfileItem('ID', user.uniqueId), _buildProfileItem('Email ID', user.email), _buildProfileItem('Mobile Number', user.phone), _buildProfileItem('Designation', user.role), ], ), ), ], ), ), ), ), ], ); } Widget _buildProfileItem(String label, String value) { return Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xff004791), ), ), const SizedBox(height: 5), Text( value, style: const TextStyle( fontSize: 18, color: Colors.black, ), ), const Divider(color: Colors.grey), ], ), ); } }