import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/member_information_list_model.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:mohem_flutter_app/models/profile_menu.model.dart';
import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart';
import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart';

class ProfileInFo extends StatelessWidget {
  ProfileInFo(this.memberInfo);
  MemberInformationListModel memberInfo;
  String data = '.';
  double sliderValue = 75;
  List<ProfileMenu> menu = [
    ProfileMenu(name: LocaleKeys.profile_personalInformation.tr(), icon: 'personal-info.svg', route: AppRoutes.personalInfo, dynamicUrl: ''),
    ProfileMenu(
      name: LocaleKeys.profile_basicDetails.tr(),
      icon: 'basic-details.svg',
      route: AppRoutes.basicDetails,
    ),
    ProfileMenu(name: LocaleKeys.profile_contactDetails.tr(), icon: 'contact-details.svg', route: AppRoutes.contactDetails, dynamicUrl: ''),
    ProfileMenu(name: LocaleKeys.profile_familyDetails.tr(), icon: 'family-members.svg', route: AppRoutes.familyMembers, dynamicUrl: ''),
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
        child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
      /// card header
      customLabel(memberInfo.eMPLOYEENAME.toString(), 22, Colors.black, true),

      customLabel(memberInfo.eMPLOYEENUMBER.toString() + ' | ' + memberInfo.jOBNAME.toString(), 14, Colors.grey, false),

      customLabel(memberInfo.eMPLOYEEEMAILADDRESS.toString(), 13, Colors.black, true),

      Divider(height: 40, thickness: 8, color: const Color(0xffefefef)),

      customLabel(LocaleKeys.completingYear.tr(), 10, Colors.black, true),

      SizedBox(height: 10),
      Container(
          child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [
        Column(
          children: [customLabel(LocaleKeys.year.tr(), 14, const Color(0xff808080), true), customLabel(memberInfo.sERVICEYEARS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)],
        ),
        Column(
          children: [customLabel(LocaleKeys.month.tr(), 14, const Color(0xff808080), true), customLabel(memberInfo.sERVICEMONTHS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)],
        ),
        Column(
          children: [customLabel(LocaleKeys.day.tr(), 14, const Color(0xff808080), true), customLabel(memberInfo.sERVICEDAYS.toString().padLeft(2, '0'), 22, Color(0xff2BB8A6), true)],
        )
      ])),

      Divider(height: 40, thickness: 8, color: const Color(0xffefefef)),
      Container(
          padding: EdgeInsets.only(
            left: 20,
            right: 20,
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              customLabel(LocaleKeys.profile_profileCompletionPer.tr() + ' 75%', 18, Colors.black, true),
              const SizedBox(height: 10),
              Row(
                children: [
                  for (var i = 0; i < 4; i++)
                    if (i < 3) Expanded(child: drawSlider(Color(0xff2BB8A6))) else Expanded(child: drawSlider(const Color(0xffefefef)))
                ],
              ),
              const SizedBox(height: 10),
              Text(
                LocaleKeys.profile_completeProfile.tr(),
                style: TextStyle(color: Color(0xff2BB8A6), fontWeight: FontWeight.bold, decoration: TextDecoration.underline),
              ),
            ],
          )),

      /// description
      Divider(height: 50, thickness: 8, color: const Color(0xffefefef)),

      Column(
        children: menu.map((i) => rowItem(i, context)).toList(),
      )
    ]));
  }

  Widget drawSlider(color) {
    return Row(children: [
      Expanded(
          flex: 1,
          child: ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Container(
              height: 6,
              width: 20,
              color: color,
            ),
          )),
      Container(height: 6, width: 3, color: Colors.white),
    ]);
  }

  Widget rowItem(obj, context) {
    return InkWell(
      onTap: () {
        //if (obj.dynamicUrl == '') {
        Navigator.pushNamed(context, obj.route);
        // } else {
        //  Navigator.pushNamed(context, AppRoutes.addDynamicInputProfile, arguments: DynamicListViewParams(obj.name, obj.functionName, uRL: obj.dynamicUrl, requestID: obj.requestID));
        //}
      },
      child: ListTile(
        leading: SvgPicture.asset('assets/images/' + obj.icon),
        title: Text(obj.name),
        trailing: Icon(Icons.arrow_forward),
      ),
    );
  }

  Widget customLabel(String label, double size, Color color, bool isBold, {double padding = 0.0}) => Container(
      padding: EdgeInsets.all(padding),
      // height: 50,
      child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [Text(label, style: TextStyle(color: color, fontSize: size, fontWeight: isBold ? FontWeight.bold : FontWeight.normal))]));
}
