import 'dart:collection'; import 'dart:ui'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/html_parser.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/models/profile_menu.model.dart'; import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; import 'package:url_launcher/url_launcher.dart'; class EmployeeDetails extends StatefulWidget { EmployeeDetails(); @override _EmployeeDetailsState createState() => _EmployeeDetailsState(); } class _EmployeeDetailsState extends State { GetEmployeeSubordinatesList? getEmployeeSubordinates; static List menuData = []; List menu =[]; String? selectedFavLetter; List? favLetters; List? favUsersList; List? replacementList; @override void initState() { super.initState(); // setState(() {}); } //favorite void fetchChangeFav({required String email, required String employeName, required String image, required String userName, bool isFav = false, bool isNeedToRefresh = false}) async { Utils.showLoading(context); getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; GenericResponseModel model = await MyTeamApiClient().changeFavoriteReplacements( email: email, employeName: employeName, image: image, userName: userName, isFav: isFav, ); getEmployeeSubordinates!.isFavorite = isFav; Utils.hideLoading(context); setState(() {}); } @override Widget build(BuildContext context) { if(getEmployeeSubordinates == null) { getEmployeeSubordinates = ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; setMenu(); } return Scaffold( extendBody: true, backgroundColor: MyColors.lightGreyEFColor, body: Stack(children: [ Container( height: 200, margin: EdgeInsets.only(top: 30), decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates!.eMPLOYEEIMAGE)), fit: BoxFit.cover)), child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: new Container( decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), ), ), ), SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ 80.height, Container( padding: EdgeInsets.only(left: 15, right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( onPressed: () { Navigator.pop(context); }, icon: Icon( Icons.arrow_back_ios, color: Colors.white, ), ), ], ), ), myTeamInfo() ], ), ) ])); } Widget myTeamInfo() { Uri phoneNumber = Uri.parse('tel:${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}'); double _width = MediaQuery .of(context) .size .width; return Column( children: [ Container( margin: EdgeInsets.fromLTRB(21, 0, 21, 10), child: Stack(children: [ Container( width: _width, margin: EdgeInsets.only(top: 50), //padding: EdgeInsets.only(right: 17, left: 17), decoration: BoxDecoration( color: MyColors.whiteColor, borderRadius: const BorderRadius.all(Radius.circular(15)), boxShadow: [BoxShadow(color: MyColors.lightGreyColor, blurRadius: 15, spreadRadius: 3)], ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( onPressed: (){ if(getEmployeeSubordinates!.isFavorite != true){ showFavoriteAlertDialog(context); setState(() {}); }else{ fetchChangeFav( email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", isFav: false,); setState(() {}); } }, icon: getEmployeeSubordinates!.isFavorite != true ? Icon( Icons.star_outline, size: 35, color: MyColors.green9CColor, ) : Icon( Icons.star_outlined, size: 35, color: MyColors.green9CColor, ), ), InkWell( onTap:() { launchUrl(phoneNumber); }, child: SvgPicture.asset("assets/images/call.svg"), ), ], ).paddingOnly(left:6, right: 17, top: 16), Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ /// card header customLabel(getEmployeeSubordinates!.eMPLOYEENAME.toString(), 21, MyColors.grey3AColor, true), customLabel(getEmployeeSubordinates!.eMPLOYEENUMBER.toString() + ' | ' + getEmployeeSubordinates!.jOBNAME.toString(), 13, MyColors.grey80Color, true), customLabel(getEmployeeSubordinates!.eMPLOYEEEMAILADDRESS.toString(), 13, MyColors.grey3AColor, true), ], ).paddingOnly(bottom: 10, left: 35,right: 31), ], ), ), Container(height: 100, alignment: Alignment.center, child: ProfileImage()), ]) ), Container( margin: EdgeInsets.fromLTRB(21, 8, 21, 10), height: 260, padding: EdgeInsets.only(top: 15, bottom: 15), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(15)), boxShadow: [BoxShadow(color: MyColors.lightGreyColor, blurRadius: 15, spreadRadius: 3)], ), child: Column( children: menu.map((ProfileMenu i) => rowItem(i, context)).toList(), ), ), ], ); } Widget ProfileImage() => CircleAvatar( radius: 70, backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates?.eMPLOYEEIMAGE)), backgroundColor: Colors.black, ); Widget customLabel(String label, double size, Color color, bool isBold, {double padding = 0.0}) => Container( padding: EdgeInsets.all(padding), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [Text(label, style: TextStyle(color: color, fontSize: size, fontWeight: isBold ? FontWeight.bold : FontWeight.normal))])); Widget rowItem(obj, context) { return InkWell( onTap: () { Navigator.pushNamed(context, obj.route, arguments:obj.arguments); }, child: ListTile( leading: SvgPicture.asset('assets/images/' + obj.icon), title: Text(obj.name, style: TextStyle(color: MyColors.grey3AColor, fontWeight: FontWeight.w600, fontSize: 16)), trailing: Icon(Icons.arrow_forward, color: MyColors.grey3AColor,), ), ); } void setMenu(){ menu = [ ProfileMenu(name: "Profile Details", icon: "profile_details.svg", route: AppRoutes.profileDetails, arguments:getEmployeeSubordinates), ProfileMenu(name: "Create Request", icon: "create_request.svg", route: AppRoutes.createRequest,arguments: getEmployeeSubordinates), ProfileMenu(name: "View Attendance", icon: "view_attendance.svg", route: AppRoutes.viewAttendance, arguments: getEmployeeSubordinates), ProfileMenu(name: "Team Members", icon: "team.svg", route: AppRoutes.teamMembers, arguments: getEmployeeSubordinates), ]; } void showFavoriteAlertDialog(BuildContext context) { Widget cancelButton = TextButton( child: Text( LocaleKeys.cancel.tr(), ), onPressed: () { Navigator.pop(context); }, ); Widget continueButton = TextButton( child: Text( LocaleKeys.ok.tr(), ), onPressed: () { fetchChangeFav( email: getEmployeeSubordinates?.eMPLOYEEEMAILADDRESS ?? "", employeName: getEmployeeSubordinates!.eMPLOYEENAME ?? "", image: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", userName: getEmployeeSubordinates!.eMPLOYEENUMBER ?? "", isFav: true, ); setState(() {}); Navigator.pop(context); }, ); AlertDialog alert = AlertDialog( title: Text( LocaleKeys.confirm.tr(), ), content: Container( height: 150, child: Column( children: [ Text("Do you want to add" + "${getEmployeeSubordinates!.eMPLOYEENAME.toString()}" + "in your favorite list "), CircularAvatar( url: getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", height: 50, width: 50, isImageBase64: true, ).paddingOnly(top: 21), // 16.width, ], ), ), actions: [ cancelButton, continueButton, ], ); showDialog( context: context, builder: (BuildContext context) { return alert; }, ); } } GetMenuEntriesList getMenuEntries(String type) { List data = _EmployeeDetailsState.menuData.where((GetMenuEntriesList test) => test.functionName == type).toList(); if (data.isNotEmpty) { return data[0]; } else { return GetMenuEntriesList(); } }