diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 2427f5c..5fe5472 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -271,6 +271,7 @@ "performance": "تقييم الاداء", "performanceEvaluation": "تقييم الأداء في", "performanceEvaluationIn": "تقييم أدائك في", + "valuationIn": "تقييم الأداء في", "amount": "مقدار", "correctCurrentDatails": "تعديل او اكمال التفاصيل الحالية", "selectType": " حدد نوع التغيير الذي تريد القيام به", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 01e878f..5635c59 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -316,7 +316,8 @@ "regular": "Regular", "mark": "Mark", "performance": "Performance Evaluation", - "performanceEvaluationIn": "Your performance Evaluation in ", + "performanceEvaluationIn": "Your performance Evaluation in", + "valuationIn": "Performance Evaluation in", "viewBusinessCard": "View Business Card", "performanceEvaluation": "Performance Evaluation", "logout": "Logout", diff --git a/lib/api/profile_api_client.dart b/lib/api/profile_api_client.dart index 7b4acd8..2d8b71e 100644 --- a/lib/api/profile_api_client.dart +++ b/lib/api/profile_api_client.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; @@ -11,21 +12,17 @@ import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; import 'package:mohem_flutter_app/models/performance.dart'; +import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/get_countries_list_model.dart'; import 'package:mohem_flutter_app/models/profile/phone_number_types_model.dart'; import 'package:mohem_flutter_app/models/profile/start_address_approval_process_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_address_transaction.dart'; -import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/submit_basic_details_transaction_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_contact_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_phone_transactions.dart'; import 'package:mohem_flutter_app/models/start_phone_approval_process_model.dart'; -import 'package:mohem_flutter_app/models/profile/submit_contact_transaction_list_model.dart'; -import 'package:mohem_flutter_app/models/profile/submit_phone_transactions.dart'; -import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; -import 'package:mohem_flutter_app/api/api_client.dart'; class ProfileApiClient { static final ProfileApiClient _instance = ProfileApiClient._internal(); @@ -397,14 +394,14 @@ class ProfileApiClient { }, url, postParams); } - Future?> getPerformanceAppraisal() async { + Future> getPerformanceAppraisal() async { String url = "${ApiConsts.erpRest}GET_Performance_Appraisal"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.getPerformanceAppraisalList; + return responseData.getPerformanceAppraisalList ?? []; }, url, postParams); } } diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index e1448ef..4386960 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -18,6 +18,7 @@ class MyColors { static const Color grey98Color = Color(0xff989898); static const Color lightGreyEFColor = Color(0xffEFEFEF); static const Color lightGreyEDColor = Color(0xffEDEDED); + static const Color lightGreyDeColor = Color(0xffDEDEDE); static const Color lightGreyE3Color = Color(0xffE3E3E3); static const Color lightGreyE6Color = Color(0xffE6E6E6); static const Color lightGreyEAColor = Color(0xffEAEAEA); @@ -29,7 +30,6 @@ class MyColors { static const Color backgroundBlackColor = Color(0xff202529); static const Color black = Color(0xff000000); static const Color white = Color(0xffffffff); - static const Color green = Color(0xffffffff); static const Color borderColor = Color(0xffE8E8E8); static const Color borderE3Color = Color(0xffE3E3E3); static const Color borderCEColor = Color(0xffCECECE); diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 587b43f..5f78298 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -25,7 +25,7 @@ import 'package:mohem_flutter_app/ui/my_team/subordinate_leave.dart'; import 'package:mohem_flutter_app/ui/my_team/team_members.dart'; import 'package:mohem_flutter_app/ui/my_team/view_attendance.dart'; import 'package:mohem_flutter_app/ui/payslip/monthly_pay_slip_screen.dart'; -import 'package:mohem_flutter_app/ui/performance/performance.dart'; +import 'package:mohem_flutter_app/ui/performance/performance_appraisal_screen.dart'; import 'package:mohem_flutter_app/ui/profile/add_update_family_member.dart'; import 'package:mohem_flutter_app/ui/profile/basic_details.dart'; import 'package:mohem_flutter_app/ui/profile/contact_details.dart'; diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 82dc4df..fc4d8f4 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -42,12 +42,12 @@ extension WidgetExtensions on Widget { child: this, ); - Widget objectContainerView({String title = "", String note = "", bool disablePadding = false}) { + Widget objectContainerView({String title = "", String note = "", bool disablePadding = false,double radius =15}) { return Container( padding: disablePadding ? EdgeInsets.zero : const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.circular(15), + borderRadius: BorderRadius.circular(radius), boxShadow: [ BoxShadow( color: const Color(0xff000000).withOpacity(.05), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index c9e2ec5..96e1e09 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -287,6 +287,7 @@ class CodegenLoader extends AssetLoader{ "performance": "تقييم الاداء", "performanceEvaluation": "تقييم الأداء في", "performanceEvaluationIn": "تقييم أدائك في", + "valuationIn": "تقييم الأداء في", "amount": "مقدار", "correctCurrentDatails": "تعديل او اكمال التفاصيل الحالية", "selectType": " حدد نوع التغيير الذي تريد القيام به", @@ -754,7 +755,8 @@ static const Map en_US = { "regular": "Regular", "mark": "Mark", "performance": "Performance Evaluation", - "performanceEvaluationIn": "Your performance Evaluation in ", + "performanceEvaluationIn": "Your performance Evaluation in", + "valuationIn": "Performance Evaluation in", "viewBusinessCard": "View Business Card", "performanceEvaluation": "Performance Evaluation", "logout": "Logout", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index eb3fca2..b111cd2 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -272,6 +272,7 @@ abstract class LocaleKeys { static const performance = 'performance'; static const performanceEvaluation = 'performanceEvaluation'; static const performanceEvaluationIn = 'performanceEvaluationIn'; + static const valuationIn = 'valuationIn'; static const amount = 'amount'; static const correctCurrentDatails = 'correctCurrentDatails'; static const selectType = 'selectType'; diff --git a/lib/ui/performance/performance.dart b/lib/ui/performance/performance.dart deleted file mode 100644 index 1d5e19c..0000000 --- a/lib/ui/performance/performance.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'dart:io'; - -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/api/profile_api_client.dart'; -import 'package:mohem_flutter_app/classes/colors.dart'; -import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; -import 'package:mohem_flutter_app/models/performance.dart'; -import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; - -class PerformanceAppraisal extends StatefulWidget { - const PerformanceAppraisal({Key? key}) : super(key: key); - - @override - _PerformanceAppraisalState createState() => _PerformanceAppraisalState(); -} - -class _PerformanceAppraisalState extends State { - List performance = []; - @override - void initState() { - getPerformanceAppraisal(); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: MyColors.backgroundColor, - appBar: AppBarWidget( - context, - title: LocaleKeys.performance.tr(), - ), - body: performance.isNotEmpty - ? SingleChildScrollView( - child: Container( - width: double.infinity, - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), - child: Column(children: [ - Row(children: [Expanded(flex: 1, child: getPerformanceCard(performance.first))]), - GridView.count( - crossAxisCount: 2, - shrinkWrap: true, - childAspectRatio:1.3, - children: performance - .where((GetPerformanceAppraisalList el) => performance.indexOf(el) != 0) - .map( - (GetPerformanceAppraisalList item) => getPerformanceCard(item), - ) - .toList(), - ) - ]))) - : Utils.getNoDataWidget(context), - ); - } - - Widget getPerformanceCard(GetPerformanceAppraisalList performance) { - return Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - ), - child: Padding( - padding: const EdgeInsets.all(15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - LocaleKeys.performanceEvaluationIn.tr() + performance.aPPRAISALYEAR.toString(), - style: const TextStyle(fontWeight: FontWeight.bold), - ), - const SizedBox( - height: 10, - ), - SliderTheme( - data: SliderThemeData(trackHeight: 3, thumbShape: SliderComponentShape.noThumb, overlayShape: SliderComponentShape.noOverlay), - child: Slider( - max: 100, - min: 0, - inactiveColor: Colors.grey.withOpacity(.4), - activeColor: Colors.green, - value: double.parse(performance.aPPRAISALSCORE!), - onChanged: (value) {}, - semanticFormatterCallback: (double newValue) { - return '${newValue.round()}'; - })), - const SizedBox( - height: 10, - ), - Text( - performance.aPPRAISALSCORE.toString() + '%', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - color: Colors.green, - ), - ), - ], - ))); - } - - void getPerformanceAppraisal() async { - try { - Utils.showLoading(context); - performance = (await ProfileApiClient().getPerformanceAppraisal())!; - setState(() {}); - Utils.hideLoading(context); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - } - } -} diff --git a/lib/ui/performance/performance_appraisal_screen.dart b/lib/ui/performance/performance_appraisal_screen.dart new file mode 100644 index 0000000..9a684f9 --- /dev/null +++ b/lib/ui/performance/performance_appraisal_screen.dart @@ -0,0 +1,97 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/profile_api_client.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/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/performance.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; + +class PerformanceAppraisal extends StatelessWidget { + PerformanceAppraisal({Key? key}) : super(key: key); + + Future> getPerformanceAppraisal(context) async { + List performance = []; + try { + Utils.showLoading(context); + performance = await ProfileApiClient().getPerformanceAppraisal(); + Utils.hideLoading(context); + } catch (ex) { + performance = []; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + return performance; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: MyColors.backgroundColor, + appBar: AppBarWidget(context, title: LocaleKeys.performance.tr()), + body: FutureBuilder( + future: getPerformanceAppraisal(context), + builder: (cxt, snapShot) { + if (snapShot.connectionState == ConnectionState.done) { + if (snapShot.hasData) { + List performance = snapShot.data as List; + if (performance.isNotEmpty) { + return ListView( + padding: const EdgeInsets.all(0), + children: [ + getPerformanceCard(performance.first).paddingOnly(left: 21, right: 21, top: 21), + GridView.count( + physics: const NeverScrollableScrollPhysics(), + crossAxisCount: 2, + mainAxisSpacing: 13, + crossAxisSpacing: 13, + shrinkWrap: true, + childAspectRatio: 160 / 125, + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 14), + children: performance + .where((GetPerformanceAppraisalList el) => performance.indexOf(el) != 0) + .map( + (GetPerformanceAppraisalList item) => getPerformanceCard(item, isGrid: true), + ) + .toList(), + ), + ], + ); + } + } + return Utils.getNoDataWidget(context); + } + return const SizedBox(); + }, + ), + ); + } + + Widget getPerformanceCard(GetPerformanceAppraisalList performance, {bool isGrid = false}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 2, bottom: 2), + decoration: Utils.containerRadius(MyColors.greenColor, 5), + child: "Excellent".toText10(color: Colors.white), + ), + (isGrid ? 8 : 4).height, + isGrid ? "${LocaleKeys.performanceEvaluationIn.tr()} ${performance.aPPRAISALYEAR}".toText13() : "${LocaleKeys.performanceEvaluationIn.tr()} ${performance.aPPRAISALYEAR}".toText18(), + 4.height, + LinearProgressIndicator( + minHeight: 4, + backgroundColor: MyColors.lightGreyDeColor, + valueColor: const AlwaysStoppedAnimation(MyColors.greenColor), + value: double.parse(performance.aPPRAISALSCORE!) / 100, + ), + 4.height, + isGrid ? "${performance.aPPRAISALSCORE}%".toText13(color: MyColors.greenColor) : "${performance.aPPRAISALSCORE}%".toText20(color: MyColors.greenColor), + ], + ).objectContainerView(radius: 10); + } +}