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 {
  //  String? name;
  // final String uniqueId;
  // final String email;
  // final String mobileNumber;
  // final String designation;

  const ProfileScreen({
    Key? key,

  }) : super(key: key);

  @override
  State<ProfileScreen> createState() => _ProfileScreenState();
}

class _ProfileScreenState extends State<ProfileScreen> {

  final homecontroller = Get.put(HomeController());
  @override
  Widget build(BuildContext context) {
    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: () {
                    Navigator.pop(context);
                  },
                  icon: SvgPicture.asset(
                    'assets/svg/back_arrow.svg',
                  ),
                  padding: const EdgeInsets.only(right: 20),
                ),
              ],
            ),
            body: 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),
                        _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),
        ],
      ),
    );
  }
}
