import 'package:flutter/material.dart';
import 'package:get/get.dart';


import '../../../core/constants/translation_keys.dart';
import '../../../core/utils/SessionCache.dart';
import '../../../custom_widgets/custom_app_bar.dart';
import '../../../res/app_colors.dart';
import '../../../routes/app_pages.dart';
import '../controllers/user_profile_controller.dart';

class ProfileDetailsView extends GetView<UserProfileController> {
  const ProfileDetailsView({super.key});

  @override
  Widget build(BuildContext context) {
    return responsiveWidget(
      Scaffold(
        appBar: DashBoardAppBar(
          title: TranslationKeys.makeTranslation("Profile"),
          onBackButtonPressed: () {
            Get.back();
          },
        ),
        body: Padding(
          padding: const EdgeInsets.only(left: 14, right: 21),
          child: GetBuilder<UserProfileController>(builder: (controller) {
            return Column(
              children: [
                const SizedBox(height: 5),
                // ProfileDetailsTile(
                //   title: 'Personal Details',
                //   subtitle: ''
                //   // SessionCache.instance.depositAccountList.first.mbmBkmstitle,
                // ),
                // ProfileDetailsTile(
                //   title: 'Login Name',
                //   subtitle: ''
                //   // SessionCache.instance.userInfo.name,
                // ),
                // ProfileDetailsTile(
                //   title: 'Mobile Number',
                //   subtitle: ''
                //   // SessionCache.instance.depositAccountList.first.padAdrsmobphone,
                // ),
                // ProfileDetailsTile(
                //   title: 'Email Address',
                //   subtitle: ''
                //   // SessionCache.instance.userInfo.cmpUserId,
                // ),
                ProfileDetailsTile(
                  title: 'Personal Details',
                  subtitle: SessionCache.instance.depositAccountList.first.mbmBkmstitle,
                ),

                ProfileDetailsTile(
                  title: 'Login Name',
                  subtitle: SessionCache.instance.userInfo.name ?? '',
                ),

                ProfileDetailsTile(
                  title: 'Mobile Number',
                  subtitle: SessionCache.instance.depositAccountList.first.padAdrsmobphone,
                ),

                ProfileDetailsTile(
                  title: 'Email Address',
                  subtitle: SessionCache.instance.userInfo.cmpUserId,
                ),
              ],
            );
          }),
        ),
      ),
    );
  }

  Widget editButton(BuildContext context, {void Function()? onTap}) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: 65,
        decoration: BoxDecoration(
          color: AppColors.f0f0f0,
          border: Border.all(
            color: AppColors.c0c0c0,
          ),
          borderRadius: BorderRadius.circular(12),
        ),
        padding: const EdgeInsets.all(4),
        child: Row(
          children: [
            const SizedBox(
              width: 10,
            ),
            Text(
              "Edit",
              style: context.textTheme.bodyMedium!.copyWith(fontSize: 11, fontWeight: FontWeight.w400),
            ),
            const SizedBox(
              width: 7,
            ),
            const Icon(
              Icons.edit,
              size: 12,
              color: AppColors.colorPrimary,
            ),
            const SizedBox(
              width: 2,
            ),
          ],
        ),
      ),
    );
  }
}

class ProfileDetailsTile extends StatelessWidget {
  const ProfileDetailsTile({
    super.key,
    required this.title,
    required this.subtitle,
    this.widget,
  });

  final String title;
  final String subtitle;
  final Widget? widget;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          border: Border.all(
            color: AppColors.colorGrey350,
          ),
          borderRadius: BorderRadius.circular(8)),
      height: widget == null ? 60 : 91,
      width: Get.width,
      padding: const EdgeInsets.only(left: 12, right: 14, top: 12),
      margin: const EdgeInsets.only(top: 14),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            style: context.textTheme.bodyMedium!.copyWith(fontSize: 10, fontWeight: FontWeight.w400),
          ),
          const SizedBox(height: 4),
          Text(
             subtitle,
            style: context.textTheme.bodyMedium!.copyWith(fontSize: 15, fontWeight: FontWeight.w400),
          ),
          const SizedBox(height: 8),
          widget ?? const SizedBox(),
          widget == null
              ? const SizedBox()
              : const SizedBox(
                  height: 8,
                ),
        ],
      ),
    );
  }
}
