click fixes 1.0
parent
472c62ca07
commit
7bbcaaf89f
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,45 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final employeeLeavesList = employeeLeavesListFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
EmployeeLeavesList employeeLeavesListFromJson(String str) => EmployeeLeavesList.fromJson(json.decode(str));
|
||||
|
||||
String employeeLeavesListToJson(EmployeeLeavesList data) => json.encode(data.toJson());
|
||||
|
||||
class EmployeeLeavesList {
|
||||
EmployeeLeavesList({
|
||||
this.absenceAttendanceTypeName,
|
||||
this.dateEnd,
|
||||
this.dateStart,
|
||||
this.eventDate,
|
||||
this.holidayType,
|
||||
this.leaveType,
|
||||
});
|
||||
|
||||
String? absenceAttendanceTypeName;
|
||||
String? dateEnd;
|
||||
String? dateStart;
|
||||
String? eventDate;
|
||||
String? holidayType;
|
||||
String? leaveType;
|
||||
|
||||
factory EmployeeLeavesList.fromJson(Map<String, dynamic> json) => EmployeeLeavesList(
|
||||
absenceAttendanceTypeName: json["ABSENCE_ATTENDANCE_TYPE_NAME"],
|
||||
dateEnd: json["DATE_END"],
|
||||
dateStart: json["DATE_START"],
|
||||
eventDate: json["EVENT_DATE"],
|
||||
holidayType: json["HOLIDAY_TYPE"],
|
||||
leaveType: json["LEAVE_TYPE"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"ABSENCE_ATTENDANCE_TYPE_NAME": absenceAttendanceTypeName,
|
||||
"DATE_END": dateEnd,
|
||||
"DATE_START": dateStart,
|
||||
"EVENT_DATE": eventDate,
|
||||
"HOLIDAY_TYPE": holidayType,
|
||||
"LEAVE_TYPE": leaveType,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
class SupervisorHierarchyLists {
|
||||
SupervisorHierarchyLists({
|
||||
this.subordinateHierarchyList,
|
||||
this.supervisorHierarchyList,
|
||||
});
|
||||
|
||||
List<HierarchyList>? subordinateHierarchyList;
|
||||
List<HierarchyList>? supervisorHierarchyList;
|
||||
|
||||
factory SupervisorHierarchyLists.fromJson(Map<String, dynamic> json) => SupervisorHierarchyLists(
|
||||
subordinateHierarchyList: json["SubordinateHierarchyList"] == null ? [] : List<HierarchyList>.from(json["SubordinateHierarchyList"]!.map((x) => HierarchyList.fromJson(x))),
|
||||
supervisorHierarchyList: json["SupervisorHierarchyList"] == null ? [] : List<HierarchyList>.from(json["SupervisorHierarchyList"]!.map((x) => HierarchyList.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"SubordinateHierarchyList": subordinateHierarchyList == null ? [] : List<dynamic>.from(subordinateHierarchyList!.map((x) => x.toJson())),
|
||||
"SupervisorHierarchyList": supervisorHierarchyList == null ? [] : List<dynamic>.from(supervisorHierarchyList!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class HierarchyList {
|
||||
HierarchyList({
|
||||
this.employeeEmailAddress,
|
||||
this.employeeImage,
|
||||
this.employeeMobileNumber,
|
||||
this.employeeName,
|
||||
this.employeeNumber,
|
||||
this.employeeWorkNumber,
|
||||
this.lvl,
|
||||
this.numOfSubordinates,
|
||||
this.organizationName,
|
||||
this.positionName,
|
||||
});
|
||||
|
||||
String? employeeEmailAddress;
|
||||
dynamic employeeImage;
|
||||
String? employeeMobileNumber;
|
||||
String? employeeName;
|
||||
String? employeeNumber;
|
||||
String? employeeWorkNumber;
|
||||
int? lvl;
|
||||
int? numOfSubordinates;
|
||||
String? organizationName;
|
||||
String? positionName;
|
||||
|
||||
factory HierarchyList.fromJson(Map<String, dynamic> json) => HierarchyList(
|
||||
employeeEmailAddress: json["EMPLOYEE_EMAIL_ADDRESS"],
|
||||
employeeImage: json["EMPLOYEE_IMAGE"],
|
||||
employeeMobileNumber: json["EMPLOYEE_MOBILE_NUMBER"],
|
||||
employeeName: json["EMPLOYEE_NAME"],
|
||||
employeeNumber: json["EMPLOYEE_NUMBER"],
|
||||
employeeWorkNumber: json["EMPLOYEE_WORK_NUMBER"],
|
||||
lvl: json["LVL"],
|
||||
numOfSubordinates: json["NUM_OF_SUBORDINATES"],
|
||||
organizationName: json["ORGANIZATION_NAME"],
|
||||
positionName: json["POSITION_NAME"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"EMPLOYEE_EMAIL_ADDRESS": employeeEmailAddress,
|
||||
"EMPLOYEE_IMAGE": employeeImage,
|
||||
"EMPLOYEE_MOBILE_NUMBER": employeeMobileNumber,
|
||||
"EMPLOYEE_NAME": employeeName,
|
||||
"EMPLOYEE_NUMBER": employeeNumber,
|
||||
"EMPLOYEE_WORK_NUMBER": employeeWorkNumber,
|
||||
"LVL": lvl,
|
||||
"NUM_OF_SUBORDINATES": numOfSubordinates,
|
||||
"ORGANIZATION_NAME": organizationName,
|
||||
"POSITION_NAME": positionName,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final employeeQualificationsList = employeeQualificationsListFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
EmployeeQualificationsList employeeQualificationsListFromJson(String str) => EmployeeQualificationsList.fromJson(json.decode(str));
|
||||
|
||||
String employeeQualificationsListToJson(EmployeeQualificationsList data) => json.encode(data.toJson());
|
||||
|
||||
class EmployeeQualificationsList {
|
||||
EmployeeQualificationsList({
|
||||
this.establishment,
|
||||
this.grade,
|
||||
this.gradeDescription,
|
||||
this.qualificationType,
|
||||
this.status,
|
||||
});
|
||||
|
||||
String? establishment;
|
||||
String? grade;
|
||||
String? gradeDescription;
|
||||
String? qualificationType;
|
||||
String? status;
|
||||
|
||||
factory EmployeeQualificationsList.fromJson(Map<String, dynamic> json) => EmployeeQualificationsList(
|
||||
establishment: json["ESTABLISHMENT"],
|
||||
grade: json["GRADE"],
|
||||
gradeDescription: json["GRADE_DESCRIPTION"],
|
||||
qualificationType: json["QUALIFICATION_TYPE"],
|
||||
status: json["STATUS"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"ESTABLISHMENT": establishment,
|
||||
"GRADE": grade,
|
||||
"GRADE_DESCRIPTION": gradeDescription,
|
||||
"QUALIFICATION_TYPE": qualificationType,
|
||||
"STATUS": status,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,331 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:easy_localization/src/public_ext.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mohem_flutter_app/api/monthly_attendance_api_client.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.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/employee_leaves_list.dart';
|
||||
import 'package:mohem_flutter_app/models/get_day_hours_type_details_list_model.dart';
|
||||
import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model.dart';
|
||||
import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart';
|
||||
import 'package:month_picker_dialog_2/month_picker_dialog_2.dart';
|
||||
import 'package:pie_chart/pie_chart.dart';
|
||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||
|
||||
enum LeaveType { ABSENCE, BUSINESS_TRIP, HOLIDAY, NORMAL }
|
||||
|
||||
class MoeMonthlyAttendanceScreen extends StatefulWidget {
|
||||
@override
|
||||
State<MoeMonthlyAttendanceScreen> createState() => _MoeMonthlyAttendanceScreenState();
|
||||
}
|
||||
|
||||
class _MoeMonthlyAttendanceScreenState extends State<MoeMonthlyAttendanceScreen> {
|
||||
DateTime currentDate = DateTime.now();
|
||||
int searchYear = DateTime.now().year;
|
||||
final CalendarController _calendarController = CalendarController();
|
||||
|
||||
List<EmployeeLeavesList> employeeLeavesList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getLeavesData(currentDate);
|
||||
// callTimeCardAndHourDetails(date.day, searchMonth, searchYear);
|
||||
}
|
||||
|
||||
void getLeavesData(DateTime date) async {
|
||||
try {
|
||||
Utils.showLoading(context);
|
||||
String startDate = '${date.year}-${date.month}-${date.day}';
|
||||
int lastday = DateTime(date.year, date.month + 1, 0).day;
|
||||
String endDate = '${date.year}-${date.month}-$lastday';
|
||||
employeeLeavesList = await MonthlyAttendanceApiClient().getEmployeeLeaves(startDate, endDate);
|
||||
Utils.hideLoading(context);
|
||||
_calendarController.displayDate = date;
|
||||
setState(() {});
|
||||
} catch (ex) {
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
// title: LocaleKeys.mowadhafhiRequest.tr(),
|
||||
title: "",
|
||||
// showHomeButton: true,
|
||||
),
|
||||
body: ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LocaleKeys.attendance.tr().toText24(isBold: true, color: MyColors.grey3AColor),
|
||||
Row(
|
||||
children: [
|
||||
"${DateFormat("MMMM-yyyy").format(currentDate)}".toText16(color: MyColors.greyACColor),
|
||||
const Icon(Icons.keyboard_arrow_down_rounded, color: MyColors.greyACColor),
|
||||
],
|
||||
).onPress(() async {
|
||||
showMonthPicker(
|
||||
context: context,
|
||||
//locale: EasyLocalization.of(context)?.locale,
|
||||
initialDate: currentDate,
|
||||
firstDate: DateTime(searchYear - 2),
|
||||
lastDate: DateTime.now(),
|
||||
confirmText: Text(LocaleKeys.confirm.tr()),
|
||||
cancelText: Text(LocaleKeys.cancel.tr()),
|
||||
).then((selectedDate) {
|
||||
if (selectedDate != null) {
|
||||
getLeavesData(selectedDate);
|
||||
setState(() {
|
||||
currentDate = selectedDate;
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
18.height,
|
||||
AspectRatio(aspectRatio: 304 / 244, child: calendarWidget()),
|
||||
],
|
||||
).paddingOnly(left: 21, right: 21, top: 21),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget calendarWidget() {
|
||||
return SfCalendar(
|
||||
view: CalendarView.month,
|
||||
showDatePickerButton: false,
|
||||
controller: _calendarController,
|
||||
backgroundColor: Colors.white,
|
||||
headerHeight: 0,
|
||||
viewNavigationMode: ViewNavigationMode.none,
|
||||
todayHighlightColor: MyColors.grey3AColor,
|
||||
showNavigationArrow: false,
|
||||
showCurrentTimeIndicator: false,
|
||||
showWeekNumber: false,
|
||||
cellBorderColor: Colors.white,
|
||||
onTap: (v) {
|
||||
dynamic index = v.date?.day;
|
||||
if (index != null) {
|
||||
index = index - 1;
|
||||
}
|
||||
EmployeeLeavesList leaves = employeeLeavesList[index];
|
||||
if (leaves.leaveType != LeaveType.NORMAL.name) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(25.0),
|
||||
topRight: Radius.circular(25.0),
|
||||
)),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: MyColors.white,
|
||||
builder: (_) {
|
||||
return DraggableScrollableSheet(
|
||||
maxChildSize: 0.75,
|
||||
expand: false,
|
||||
initialChildSize: 0.75,
|
||||
builder: (_, controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 49,
|
||||
height: 7,
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
color: MyColors.darkGreyColor,
|
||||
),
|
||||
),
|
||||
16.height,
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 40),
|
||||
margin: const EdgeInsets.only(left: 20, right: 20),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DateUtil.getWeekDay(DateUtil.convertStringToDateTime(leaves.eventDate ?? "").weekday).toString().toText14(),
|
||||
DateUtil.convertStringToDateTime(leaves.eventDate ?? "").day.toString().toText20(),
|
||||
DateUtil.getMonth(DateUtil.convertStringToDateTime(leaves.eventDate ?? "").month).toString().toText14(),
|
||||
DateUtil.convertStringToDateTime(leaves.eventDate ?? "").year.toString().toText14(),
|
||||
],
|
||||
),
|
||||
),
|
||||
6.height,
|
||||
showText(LocaleKeys.leaveType.tr(), leaves.leaveType.toString()),
|
||||
if (leaves.absenceAttendanceTypeName.toString().isNotEmpty)
|
||||
const Divider(
|
||||
color: MyColors.borderCEColor,
|
||||
),
|
||||
if (leaves.absenceAttendanceTypeName.toString().isNotEmpty) showText(LocaleKeys.attendanceType.tr(), leaves.absenceAttendanceTypeName.toString()),
|
||||
const Divider(
|
||||
color: MyColors.borderCEColor,
|
||||
),
|
||||
showText(LocaleKeys.startDateT.tr(), leaves.dateStart.toString()),
|
||||
const Divider(
|
||||
color: MyColors.borderCEColor,
|
||||
),
|
||||
showText(LocaleKeys.endDate.tr(), leaves.dateEnd.toString()),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
selectionDecoration: BoxDecoration(
|
||||
border: Border.all(color: MyColors.white, width: 1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
dataSource: MeetingDataSource(_getDataSource()),
|
||||
// onTap: calendarTapped,
|
||||
monthViewSettings: const MonthViewSettings(
|
||||
dayFormat: 'EEE',
|
||||
showTrailingAndLeadingDates: false,
|
||||
showAgenda: false,
|
||||
),
|
||||
viewHeaderStyle: const ViewHeaderStyle(
|
||||
dayTextStyle: TextStyle(color: MyColors.grey3AColor, fontSize: 13, fontWeight: FontWeight.w600),
|
||||
),
|
||||
monthCellBuilder: (build, details) {
|
||||
LeaveType leaveType = LeaveType.NORMAL;
|
||||
for (int i = 0; i < employeeLeavesList.length; i++) {
|
||||
if (details.date.day == DateUtil.convertSimpleStringDateToDateddMMyyyy(employeeLeavesList[i].eventDate ?? "").day) {
|
||||
if (employeeLeavesList[i].leaveType == LeaveType.ABSENCE.name) {
|
||||
leaveType = LeaveType.ABSENCE;
|
||||
} else if (employeeLeavesList[i].leaveType == LeaveType.BUSINESS_TRIP.name) {
|
||||
leaveType = LeaveType.BUSINESS_TRIP;
|
||||
} else if (employeeLeavesList[i].leaveType == LeaveType.HOLIDAY.name) {
|
||||
leaveType = LeaveType.HOLIDAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: leaveType == LeaveType.ABSENCE
|
||||
? MyColors.redColor
|
||||
: leaveType == LeaveType.BUSINESS_TRIP
|
||||
? MyColors.gradiantStartColor
|
||||
: leaveType == LeaveType.HOLIDAY
|
||||
? MyColors.gradiantEndColor
|
||||
: MyColors.white,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: leaveType == LeaveType.ABSENCE
|
||||
? MyColors.redColor
|
||||
: leaveType == LeaveType.BUSINESS_TRIP
|
||||
? MyColors.gradiantStartColor
|
||||
: leaveType == LeaveType.HOLIDAY
|
||||
? MyColors.gradiantEndColor
|
||||
: MyColors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
"${details.date.day}",
|
||||
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: leaveType == LeaveType.NORMAL ? MyColors.black : MyColors.white),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Meeting> _getDataSource() {
|
||||
List<Meeting> meetings = <Meeting>[];
|
||||
return meetings;
|
||||
}
|
||||
|
||||
Widget showText(String title, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
value.toText18(color: MyColors.gradiantEndColor, isBold: true),
|
||||
title.toText14(color: MyColors.greyACColor, isBold: false),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MeetingDataSource extends CalendarDataSource {
|
||||
MeetingDataSource(List<Meeting> source) {
|
||||
appointments = source;
|
||||
}
|
||||
|
||||
@override
|
||||
DateTime getStartTime(int index) {
|
||||
return _getMeetingData(index).from;
|
||||
}
|
||||
|
||||
@override
|
||||
DateTime getEndTime(int index) {
|
||||
return _getMeetingData(index).to;
|
||||
}
|
||||
|
||||
@override
|
||||
String getSubject(int index) {
|
||||
return _getMeetingData(index).eventName;
|
||||
}
|
||||
|
||||
@override
|
||||
Color getColor(int index) {
|
||||
return _getMeetingData(index).background;
|
||||
}
|
||||
|
||||
@override
|
||||
bool isAllDay(int index) {
|
||||
return _getMeetingData(index).isAllDay;
|
||||
}
|
||||
|
||||
Meeting _getMeetingData(int index) {
|
||||
dynamic meeting = appointments;
|
||||
Meeting meetingData;
|
||||
if (meeting is Meeting) {
|
||||
meetingData = meeting;
|
||||
}
|
||||
return meeting;
|
||||
}
|
||||
}
|
||||
|
||||
class Meeting {
|
||||
Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay);
|
||||
|
||||
String eventName;
|
||||
DateTime from;
|
||||
DateTime to;
|
||||
Color background;
|
||||
bool isAllDay;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
|
||||
class HelpScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.help.tr(),
|
||||
),
|
||||
backgroundColor: MyColors.backgroundColor,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
(LocaleKeys.dear.tr() + " " + AppState().memberInformationList!.eMPLOYEENAME!).toText18(isBold: true),
|
||||
12.height,
|
||||
LocaleKeys.assistant.tr().toText14(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,298 @@
|
||||
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/profile_api_client.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/hierarchy_lists.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class HierarchyScreen extends StatefulWidget {
|
||||
@override
|
||||
State<HierarchyScreen> createState() => _HierarchyScreenState();
|
||||
}
|
||||
|
||||
class _HierarchyScreenState extends State<HierarchyScreen> {
|
||||
SupervisorHierarchyLists? hierarchyList;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getData("221142");
|
||||
}
|
||||
|
||||
void getData(String selectedId) async {
|
||||
Utils.showLoading(context);
|
||||
try {
|
||||
hierarchyList = await ProfileApiClient().getHierarchy(selectedId);
|
||||
hierarchyList!.supervisorHierarchyList!.removeWhere((element) => element.lvl == 1);
|
||||
hierarchyList!.supervisorHierarchyList = hierarchyList!.supervisorHierarchyList!.reversed.toList();
|
||||
// hierarchyList!.subordinateHierarchyList!.clear();
|
||||
setState(() {});
|
||||
Utils.hideLoading(context);
|
||||
} catch (ex) {
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.profile_personalInformation.tr(),
|
||||
),
|
||||
backgroundColor: MyColors.backgroundColor,
|
||||
body: hierarchyList == null
|
||||
? const Center(child: SizedBox())
|
||||
: SizedBox(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 78 + 12,
|
||||
child: Stack(
|
||||
children: [
|
||||
Align(
|
||||
alignment: (index == 0) ? Alignment.bottomCenter : Alignment.topCenter,
|
||||
child: SizedBox(
|
||||
// height: index == 0
|
||||
// ? 40 + 6
|
||||
// : (index == hierarchyList!.supervisorHierarchyList!.length - 1)
|
||||
// ? 40 + 6
|
||||
// : 78 + 6,
|
||||
height: index == 0
|
||||
? 40 + 6
|
||||
: (index == hierarchyList!.supervisorHierarchyList!.length - 1)
|
||||
? 40 + 6
|
||||
: 78 + 6 + 6,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
child: Divider(
|
||||
color: Colors.black,
|
||||
thickness: 2,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(top: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
border: Border.all(color: MyColors.lightGreyEDColor, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
hierarchyList?.supervisorHierarchyList![index].employeeImage == null
|
||||
? SvgPicture.asset(
|
||||
"assets/images/user.svg",
|
||||
height: 52,
|
||||
width: 52,
|
||||
)
|
||||
: CircleAvatar(
|
||||
radius: 52 / 2,
|
||||
backgroundImage: MemoryImage(Utils.dataFromBase64String(hierarchyList?.supervisorHierarchyList![index].employeeImage)),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
12.width,
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
hierarchyList!.supervisorHierarchyList![index].employeeName.toString().toText14(isBold: true, maxlines: 1),
|
||||
hierarchyList!.supervisorHierarchyList![index].positionName.toString().toText12(isBold: false, maxLine: 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
launch("tel://${hierarchyList!.supervisorHierarchyList![index].employeeMobileNumber}");
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.phone,
|
||||
color: MyColors.gradiantEndColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
itemCount: hierarchyList?.supervisorHierarchyList?.length ?? 0,
|
||||
padding: const EdgeInsets.only(left: 12, right: 12, top: 12),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
),
|
||||
ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InkWell(
|
||||
onTap: (hierarchyList!.subordinateHierarchyList![index].numOfSubordinates == 0)
|
||||
? null
|
||||
: () {
|
||||
getData(hierarchyList!.subordinateHierarchyList![index].employeeNumber.toString());
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: AppState().isArabic(context)
|
||||
? 0
|
||||
: index == 0
|
||||
? 28
|
||||
: 58,
|
||||
right: !AppState().isArabic(context)
|
||||
? 0
|
||||
: index == 0
|
||||
? 28
|
||||
: 58),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 78 + 12,
|
||||
child: Stack(
|
||||
children: [
|
||||
Align(
|
||||
alignment: (index == 0) ? Alignment.topCenter : Alignment.topCenter,
|
||||
child: SizedBox(
|
||||
height: index == 0
|
||||
? 40 + 6
|
||||
: (index == hierarchyList!.subordinateHierarchyList!.length - 1)
|
||||
? 40 + 6
|
||||
: 78 + 6 + 6,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 18,
|
||||
child: Divider(
|
||||
color: Colors.black,
|
||||
thickness: 2,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(top: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
border: Border.all(color: MyColors.lightGreyEDColor, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
hierarchyList?.subordinateHierarchyList![index].employeeImage == null
|
||||
? SvgPicture.asset(
|
||||
"assets/images/user.svg",
|
||||
height: 52,
|
||||
width: 52,
|
||||
)
|
||||
: CircleAvatar(
|
||||
radius: 52 / 2,
|
||||
backgroundImage: MemoryImage(Utils.dataFromBase64String(hierarchyList?.subordinateHierarchyList![index].employeeImage)),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
12.width,
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
hierarchyList!.subordinateHierarchyList![index].employeeName.toString().toText14(isBold: true, maxlines: 1),
|
||||
hierarchyList!.subordinateHierarchyList![index].positionName.toString().toText12(isBold: false, maxLine: 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
8.width,
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
launch("tel://${hierarchyList!.subordinateHierarchyList![index].employeeMobileNumber}");
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(bottom: 10),
|
||||
child: Icon(
|
||||
Icons.phone,
|
||||
color: MyColors.gradiantEndColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hierarchyList!.subordinateHierarchyList![index].numOfSubordinates != 0)
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: MyColors.gradiantEndColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
width: 18,
|
||||
height: 18,
|
||||
alignment: Alignment.center,
|
||||
child: hierarchyList!.subordinateHierarchyList![index].numOfSubordinates.toString().toTextAuto(isBold: true, color: Colors.white, fontSize: 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: hierarchyList?.subordinateHierarchyList?.length ?? 0,
|
||||
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 12),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue