You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			124 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			124 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			Dart
		
	
| import 'package:easy_localization/easy_localization.dart';
 | |
| import 'package:flutter/material.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/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/dashboard/menus.dart';
 | |
| import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart';
 | |
| import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart';
 | |
| import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart';
 | |
| import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
 | |
| 
 | |
| class CreateRequest extends StatefulWidget {
 | |
|   const CreateRequest({Key? key}) : super(key: key);
 | |
| 
 | |
|   @override
 | |
|   _CreateRequestState createState() => _CreateRequestState();
 | |
| }
 | |
| 
 | |
| class _CreateRequestState extends State<CreateRequest> {
 | |
|   String searchEmpEmail = "";
 | |
|   String searchEmpName = "";
 | |
|   String searchEmpNo = "";
 | |
|   String? empId;
 | |
|   List<GetEmployeeSubordinatesList> getEmployeeSubordinatesList = [];
 | |
| 
 | |
| //  late DashboardProviderModel data;
 | |
|   List<GetMenuEntriesList> getMenuEntriesList = [];
 | |
|   GetEmployeeSubordinatesList? getEmployeeSubordinates;
 | |
|   List<Menus>? homeMenus;
 | |
| 
 | |
|   @override
 | |
|   void initState() {
 | |
|     super.initState();
 | |
|     // employeeSubRequest();
 | |
|   }
 | |
| 
 | |
|   void employeeSubRequest() async {
 | |
|     try {
 | |
|       Utils.showLoading(context);
 | |
|       // getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString());
 | |
|       getMenuEntriesList = await MyTeamApiClient().employeeSubordinatesRequest(getEmployeeSubordinates?.eMPLOYEENUMBER);
 | |
|       homeMenus = parseMenus(getMenuEntriesList);
 | |
|       Utils.hideLoading(context);
 | |
|       setState(() {});
 | |
|     } catch (ex) {
 | |
|       Utils.hideLoading(context);
 | |
|       Utils.handleException(ex, context, null);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   List<Menus> parseMenus(List<GetMenuEntriesList> getMenuEntriesList) {
 | |
|     List<Menus> menus = [];
 | |
|     for (int i = 0; i < getMenuEntriesList.length; i++) {
 | |
|       if (getMenuEntriesList[i].parenTMenuName!.isEmpty) {
 | |
|         menus.add(Menus(getMenuEntriesList[i], getMenuEntriesList.where((element) => getMenuEntriesList[i].menUName == element.parenTMenuName).toList()));
 | |
|       }
 | |
|     }
 | |
|     return menus;
 | |
|   }
 | |
| 
 | |
|   void handleOnPress(context, Menus menu) {
 | |
|     if (menu.menuEntry.menUEntryType == "FUNCTION") {
 | |
|       if (menu.menuEntry.requesTType == "EIT") {
 | |
|         Navigator.pushNamed(context, AppRoutes.dynamicScreen,
 | |
|             arguments: DynamicListViewParams(menu.menuEntry.prompt!, menu.menuEntry.functioNName!, selectedEmp: getEmployeeSubordinates?.eMPLOYEENUMBER ?? ''));
 | |
|       } else {}
 | |
|     } else {
 | |
|       Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen,
 | |
|           arguments: ServicesMenuListScreenParams(menu.menuEntry.prompt!, menu.menuEntiesList, selectedEmp: getEmployeeSubordinates?.eMPLOYEENUMBER ?? ''));
 | |
|     }
 | |
|     return;
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     if (getEmployeeSubordinates == null) {
 | |
|       getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList;
 | |
|       employeeSubRequest();
 | |
|     }
 | |
|     return Scaffold(
 | |
|       backgroundColor: Colors.white,
 | |
|       appBar: AppBarWidget(
 | |
|         context,
 | |
|         title: LocaleKeys.createRequest.tr(),
 | |
|       ),
 | |
|       body: SizedBox(
 | |
|         width: double.infinity,
 | |
|         height: double.infinity,
 | |
|         child: homeMenus == null
 | |
|             ? const SizedBox()
 | |
|             : (homeMenus!.isEmpty
 | |
|                 ? Utils.getNoDataWidget(context)
 | |
|                 : ListView.separated(
 | |
|                     padding: const EdgeInsets.all(21),
 | |
|                     itemBuilder: (cxt, index) => itemView("assets/images/pdf.svg", homeMenus![index].menuEntry.prompt!, index).onPress(() {
 | |
|                           handleOnPress(context, homeMenus![index]);
 | |
|                         }),
 | |
|                     separatorBuilder: (cxt, index) => 12.height,
 | |
|                     itemCount: homeMenus!.length)),
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   Widget itemView(String icon, String title, index) {
 | |
|     return Row(
 | |
|       children: [
 | |
|         (title).toText16().expanded,
 | |
|         12.width,
 | |
|         SvgPicture.asset(
 | |
|           "assets/images/arrow_next.svg",
 | |
|           color: MyColors.darkIconColor,
 | |
|         )
 | |
|       ],
 | |
|     ).objectContainerView();
 | |
|   }
 | |
| }
 |