From 39b916bcc80d103d65fd3b5dc468266934c8e4b9 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 10 Aug 2022 11:45:31 +0300 Subject: [PATCH 1/6] performance page added --- assets/langs/ar-SA.json | 9 +- assets/langs/en-US.json | 9 +- lib/api/profile_api_client.dart | 14 ++- lib/config/routes.dart | 6 + lib/generated/locale_keys.g.dart | 8 +- lib/models/generic_response_model.dart | 6 +- lib/models/performance.dart | 18 +++ lib/ui/landing/widget/app_drawer.dart | 14 ++- lib/ui/landing/widget/services_widget.dart | 3 + lib/ui/performance/performance.dart | 117 +++++++++++++++++++ lib/ui/profile/add_update_family_member.dart | 4 +- 11 files changed, 190 insertions(+), 18 deletions(-) create mode 100644 lib/models/performance.dart create mode 100644 lib/ui/performance/performance.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index ecedbdf..44cbea9 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -266,6 +266,7 @@ "summaryOfInformation": "ملخص المعلومات", "totalPayAmount": "المبلغ الإجمالي للدفع", "paymentInformation": "معلومات الدفع", + "performance": "تقييم الاداء", "amount": "مقدار", "correctCurrentDatails": "تعديل او اكمال التفاصيل الحالية", "selectType": " حدد نوع التغيير الذي تريد القيام به", @@ -310,10 +311,10 @@ "requestType": "نوع الطلب", "employeeDigitalID": "هويةالموظف الرقمية", "businessCard": "بطاقة العمل", - "checkOut":"وقت الخروج", - "regular":"منتظم", - "mark" : "علامة", - "selectMethodOfAttendance":"اختر طريقة تسجيل الحضور", + "checkOut": "وقت الخروج", + "regular": "منتظم", + "mark": "علامة", + "selectMethodOfAttendance": "اختر طريقة تسجيل الحضور", "comeNearHMGWifi": "HMG wifi من فضلك اقترب من", "profile": { "reset_password": { diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 32a5e43..15087ff 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -310,10 +310,11 @@ "wantToReject": "Are you sure want to reject?", "employeeDigitalID": "Employee Digital ID", "businessCard": "Business Card", - "checkOut":"Check Out", - "regular":"Regular", - "mark" : "Mark", - "selectMethodOfAttendance":"Select the method to mark the attendance", + "checkOut": "Check Out", + "regular": "Regular", + "mark": "Mark", + "performance": "Performance Evaluation", + "selectMethodOfAttendance": "Select the method to mark the attendance", "comeNearHMGWifi": "Please come near to HMG wifi", "profile": { "reset_password": { diff --git a/lib/api/profile_api_client.dart b/lib/api/profile_api_client.dart index b332499..7b4acd8 100644 --- a/lib/api/profile_api_client.dart +++ b/lib/api/profile_api_client.dart @@ -10,6 +10,7 @@ import 'package:mohem_flutter_app/models/get_employee_address_model.dart'; 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/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'; @@ -379,7 +380,7 @@ class ProfileApiClient { }, url, postParams); } - Future submetConatctTransactionAddAndUpdate(String actionType, int relationId, List> list) async { + Future submitContactTransactionAddAndUpdate(String actionType, int relationId, List> list) async { String url = "${ApiConsts.erpRest}SUBMIT_CONTACT_TRANSACTION"; Map postParams = { "P_MENU_TYPE": "E", @@ -395,4 +396,15 @@ class ProfileApiClient { return responseData.submitContactTransactionList; }, url, postParams); } + + 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; + }, url, postParams); + } } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 9285671..733b603 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -15,6 +15,7 @@ import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.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/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'; @@ -104,6 +105,10 @@ class AppRoutes { //Pay slip static const String monthlyPaySlip = "/monthlyPaySlip"; + //performance evaluation + + static const String performanceEvaluation = "/performanceEvaluation"; + static final Map routes = { login: (context) => LoginScreen(), verifyLogin: (context) => VerifyLoginScreen(), @@ -165,5 +170,6 @@ class AppRoutes { //pay slip monthlyPaySlip: (context) => MonthlyPaySlipScreen(), + performanceEvaluation: (context) => PerformanceAppraisal(), }; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index eac063d..c0742da 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1,6 +1,6 @@ // DO NOT EDIT. This is code generated via package:easy_localization/generate.dart -abstract class LocaleKeys { +abstract class LocaleKeys { static const mohemm = 'mohemm'; static const english = 'english'; static const arabic = 'arabic'; @@ -247,7 +247,7 @@ abstract class LocaleKeys { static const Payroll = 'Payroll'; static const civilIdentityNumber = 'civilIdentityNumber'; static const dateOfBirth = 'dateOfBirth'; - static const maritalStatus = 'maritalStatus '; + static const maritalStatus = 'maritalStatus '; static const fullName = 'fullName'; static const remove = 'remove'; static const submit = 'submit'; @@ -273,7 +273,7 @@ abstract class LocaleKeys { static const enterNewInfo = 'enterNewInfo'; static const endDate = 'endDate'; static const removeThisMember = 'removeThisMember'; - static const updateThisMember = 'updateThisMember '; + static const updateThisMember = 'updateThisMember '; static const addNewFamilyMember = 'addNewFamilyMember'; static const addRow = 'addRow'; static const pleaseSelect = 'pleaseSelect'; @@ -282,6 +282,7 @@ abstract class LocaleKeys { static const add = 'add'; static const myProfile = 'myProfile'; static const mowadhafhi = 'mowadhafhi'; + static const performance = 'performance'; static const searchAnnouncements = 'searchAnnouncements'; static const announcements = 'announcements'; static const swipeRequest = 'swipeRequest'; @@ -334,5 +335,4 @@ abstract class LocaleKeys { static const gender_with_arg = 'gender.with_arg'; static const gender = 'gender'; static const reset_locale = 'reset_locale'; - } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 782fb7c..856e97b 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -51,6 +51,7 @@ import 'package:mohem_flutter_app/models/notification_action_model.dart'; import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/pending_transactions/get_pending_transactions_details.dart'; import 'package:mohem_flutter_app/models/pending_transactions/get_req_functions.dart'; +import 'package:mohem_flutter_app/models/performance.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_cols_structions.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; @@ -193,7 +194,7 @@ class GenericResponseModel { // List? getPendingReqDetailsList; // List? getPendingReqFunctionsList; - List? getPerformanceAppraisalList; + List? getPerformanceAppraisalList; List? getPhonesNotificationBodyList; List? getPoItemHistoryList; GetPoNotificationBodyList? getPoNotificationBodyList; @@ -900,7 +901,8 @@ class GenericResponseModel { } // getPendingReqDetailsList = json['GetPendingReqDetailsList']; // getPendingReqFunctionsList = json['GetPendingReqFunctionsList']; - getPerformanceAppraisalList = json['GetPerformanceAppraisalList']; + getPerformanceAppraisalList = + json['GetPerformanceAppraisalList'] == null ? null : List.from(json["GetPerformanceAppraisalList"].map((x) => GetPerformanceAppraisalList.fromJson(x))); getPhonesNotificationBodyList = json["GetPhonesNotificationBodyList"] == null ? null : List.from(json["GetPhonesNotificationBodyList"].map((x) => GetPhonesNotificationBodyList.fromJson(x))); if (json['GetPoItemHistoryList'] != null) { diff --git a/lib/models/performance.dart b/lib/models/performance.dart new file mode 100644 index 0000000..53058ed --- /dev/null +++ b/lib/models/performance.dart @@ -0,0 +1,18 @@ +class GetPerformanceAppraisalList { + String? aPPRAISALSCORE; + int? aPPRAISALYEAR; + + GetPerformanceAppraisalList({this.aPPRAISALSCORE, this.aPPRAISALYEAR}); + + GetPerformanceAppraisalList.fromJson(Map json) { + aPPRAISALSCORE = json['APPRAISAL_SCORE']; + aPPRAISALYEAR = json['APPRAISAL_YEAR']; + } + + Map toJson() { + final Map data = new Map(); + data['APPRAISAL_SCORE'] = this.aPPRAISALSCORE; + data['APPRAISAL_YEAR'] = this.aPPRAISALYEAR; + return data; + } +} diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index 9bc9985..09e57ca 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -44,7 +44,7 @@ class _AppDrawerState extends State { const Divider(), InkWell( child: DrawerItem( - // 'Mowadhafhi', + // 'Mowadhafhi', LocaleKeys.mowadhafhi.tr(), icon: Icons.person, color: Colors.grey, @@ -54,6 +54,18 @@ class _AppDrawerState extends State { }, ), const Divider(), + InkWell( + child: DrawerItem( + // 'Mowadhafhi', + LocaleKeys.performance.tr(), + icon: Icons.person, + color: Colors.grey, + ), + onTap: () { + drawerNavigator(context, AppRoutes.performanceEvaluation); + }, + ), + const Divider(), InkWell( child: DrawerItem( LocaleKeys.pendingTransactions.tr(), diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index e99205b..cf466be 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -115,6 +115,9 @@ class ServicesWidget extends StatelessWidget { } else if (menuEntry.requestType == "VACATION_RULE") { Navigator.pushNamed(context, AppRoutes.vacationRule); return; + } else if (menuEntry.menuName == "MBL_PERINFO_SS") { + Navigator.of(context).pushNamed(AppRoutes.profile); + return; } List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && element.menuEntryType == "FUNCTION").toList() ?? []; menuEntry.icon = ""; diff --git a/lib/ui/performance/performance.dart b/lib/ui/performance/performance.dart new file mode 100644 index 0000000..27ddcb2 --- /dev/null +++ b/lib/ui/performance/performance.dart @@ -0,0 +1,117 @@ +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), + // margin: 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, + // padding: EdgeInsets.all(4.0), + // //childAspectRatio: 8.0 / 9.0, + children: performance + .where((el) => performance.indexOf(el) != 0) + .map( + (item) => getPerformanceCard(item), + ) + .toList(), + ) + ]))) + : Utils.getNoDataWidget(context), + ); + } + + Widget getPerformanceCard(GetPerformanceAppraisalList performance) { + return Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + child: Padding( + padding: EdgeInsets.all(15), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Text( + "Performance evaluation in " + performance.aPPRAISALYEAR.toString(), + style: const TextStyle(fontWeight: FontWeight.bold), + )), + 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()}'; + })), + 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/profile/add_update_family_member.dart b/lib/ui/profile/add_update_family_member.dart index 9a0bd66..3d606cb 100644 --- a/lib/ui/profile/add_update_family_member.dart +++ b/lib/ui/profile/add_update_family_member.dart @@ -448,9 +448,9 @@ class _AddUpdateFamilyMemberState extends State { Utils.showLoading(context); if (args['actionType'] == "ADD") { var relationID = null; - submitContactTransactionList = await ProfileApiClient().submetConatctTransactionAddAndUpdate(args['actionType'], relationID, valuesFinal); + submitContactTransactionList = await ProfileApiClient().submitContactTransactionAddAndUpdate(args['actionType'], relationID, valuesFinal); } else if (args['actionType'] == "UPDATE") { - submitContactTransactionList = await ProfileApiClient().submetConatctTransactionAddAndUpdate(args['actionType'], args['relationID'], valuesFinal); + submitContactTransactionList = await ProfileApiClient().submitContactTransactionAddAndUpdate(args['actionType'], args['relationID'], valuesFinal); } var transactionId = submitContactTransactionList!.pTRANSACTIONID; var itemKey = submitContactTransactionList!.pITEMKEY; From b79edd701cfa9294e2a7317294056fbd31b21ab8 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 4 Sep 2022 12:44:38 +0300 Subject: [PATCH 2/6] code improvement & translation added. --- assets/langs/ar-SA.json | 7 + assets/langs/en-US.json | 7 + lib/classes/colors.dart | 1 + lib/extensions/int_extensions.dart | 4 + lib/extensions/string_extensions.dart | 2 +- lib/generated/codegen_loader.g.dart | 18 +- lib/generated/locale_keys.g.dart | 11 +- lib/provider/dashboard_provider_model.dart | 2 +- lib/ui/landing/dashboard_screen.dart | 10 +- lib/ui/profile/profile_screen.dart | 1 - .../fragments/items_for_sale.dart | 190 +++++++++--------- .../items_for_sale/item_for_sale_detail.dart | 7 +- .../items_for_sale/items_for_sale_home.dart | 23 +-- lib/ui/screens/my_requests/my_requests.dart | 91 ++++----- lib/ui/screens/my_requests/new_request.dart | 80 ++++---- .../offers_and_discounts_details.dart | 135 ++++++------- .../offers_and_discounts_home.dart | 39 ++-- 17 files changed, 307 insertions(+), 321 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 5353a84..082270f 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -363,6 +363,13 @@ "numberDays": "عدد الأيام", "poweredBy": "مشغل بواسطة", "cloudSolutions": "حلول السحابة", + "selectTemplate": "حدد قالب", + "myPostedAds": "إعلاناتي المنشورة", + "browseCategories": "تصفح الفئات", + "searchItems": "عناصر البحث", + "offerAndDiscounts": "العروض والخصومات", + "offerValid": "العرض صالح", + "offerExpired": "انتهى العرض", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 18bf326..1bf8cc7 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -363,6 +363,13 @@ "cloudSolutions": "Cloud Solutions", "subordinateLeave": "Subordinate Leave", "numberDays": "Number of days", + "selectTemplate": "Select Template", + "myPostedAds": "My posted ads", + "browseCategories": "Browse Categories", + "searchItems": "Search Items", + "offerAndDiscounts": "Offer & Discounts", + "offerValid": "Offer Valid", + "offerExpired": "Offer Expired", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 3469681..e1448ef 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 lightGreyE3Color = Color(0xffE3E3E3); static const Color lightGreyE6Color = Color(0xffE6E6E6); static const Color lightGreyEAColor = Color(0xffEAEAEA); static const Color darkWhiteColor = Color(0xffE0E0E0); diff --git a/lib/extensions/int_extensions.dart b/lib/extensions/int_extensions.dart index 215f8d9..f46d5bb 100644 --- a/lib/extensions/int_extensions.dart +++ b/lib/extensions/int_extensions.dart @@ -1,9 +1,13 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; extension IntExtensions on int { Widget get height => SizedBox(height: toDouble()); Widget get width => SizedBox(width: toDouble()); + Widget get divider => Divider(height: toDouble(), thickness: toDouble(), color: MyColors.lightGreyEFColor); + Widget get makeItSquare => SizedBox(width: toDouble(), height: toDouble()); } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 30c7e2e..5627f4c 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -15,7 +15,7 @@ extension CapExtension on String { extension EmailValidator on String { Widget get toWidget => Text(this); - Widget toText10({Color? color, bool isBold = false, int? maxLine}) => Text( + Widget toText10({Color? color, bool isBold = false, int? maxlines}) => Text( this, maxLines: maxlines, style: TextStyle(fontSize: 10, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 255e04e..0dfa765 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -379,6 +379,13 @@ class CodegenLoader extends AssetLoader{ "numberDays": "عدد الأيام", "poweredBy": "مشغل بواسطة", "cloudSolutions": "حلول السحابة", + "selectTemplate": "حدد قالب", + "myPostedAds": "إعلاناتي المنشورة", + "browseCategories": "تصفح الفئات", + "searchItems": "عناصر البحث", + "offerAndDiscounts": "العروض والخصومات", + "offerValid": "العرض صالح", + "offerExpired": "انتهى العرض", "profile": { "reset_password": { "label": "Reset Password", @@ -774,10 +781,17 @@ static const Map en_US = { "hours": "Hours", "approvalStatus": "Approval Status", "absenceStatus": "Absence Status", - "subordinateLeave": "Subordinate Leave", - "numberDays": "Number of days", "poweredBy": "Powered By", "cloudSolutions": "Cloud Solutions", + "subordinateLeave": "Subordinate Leave", + "numberDays": "Number of days", + "selectTemplate": "Select Template", + "myPostedAds": "My posted ads", + "browseCategories": "Browse Categories", + "searchItems": "Search Items", + "offerAndDiscounts": "Offer & Discounts", + "offerValid": "Offer Valid", + "offerExpired": "Offer Expired", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 8c6247b..7214616 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -360,10 +360,17 @@ abstract class LocaleKeys { static const hours = 'hours'; static const approvalStatus = 'approvalStatus'; static const absenceStatus = 'absenceStatus'; - static const poweredBy = 'poweredBy'; - static const cloudSolutions = 'cloudSolutions'; static const subordinateLeave = 'subordinateLeave'; static const numberDays = 'numberDays'; + static const poweredBy = 'poweredBy'; + static const cloudSolutions = 'cloudSolutions'; + static const selectTemplate = 'selectTemplate'; + static const myPostedAds = 'myPostedAds'; + static const browseCategories = 'browseCategories'; + static const searchItems = 'searchItems'; + static const offerAndDiscounts = 'offerAndDiscounts'; + static const offerValid = 'offerValid'; + static const offerExpired = 'offerExpired'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 5c4b20f..dca964d 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -159,7 +159,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List menuList = await DashboardApiClient().getListMenu(); List findMyRequest = menuList.where((element) => element.menuName == "My Requests").toList(); if (findMyRequest.isNotEmpty) { - drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myTeam)); + drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myRequests)); } List findMyTeam = menuList.where((element) => element.menuName == "My Team").toList(); if (findMyTeam.isNotEmpty) { diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index ad5ba1d..907072e 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -277,11 +277,9 @@ class _DashboardScreenState extends State { ], ), ), - InkWell( - onTap: () { - Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); - }, - child: LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true)), + LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); + }) ], ).paddingOnly(left: 21, right: 21), Consumer( @@ -312,7 +310,7 @@ class _DashboardScreenState extends State { borderRadius: const BorderRadius.all( Radius.circular(100), ), - border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + border: Border.all(color: MyColors.lightGreyE3Color, width: 1), ), child: ClipRRect( borderRadius: const BorderRadius.all( diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index 8caf637..e72d3a9 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -17,7 +17,6 @@ import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/ui/profile/widgets/profile_panel.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; -// todo '@sultan' kindly follow structure of code written. use extension methods for widgets and dont hard code strings, use localizations class ProfileScreen extends StatefulWidget { const ProfileScreen({Key? key}) : super(key: key); diff --git a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart index 93ea8e9..0e9f4db 100644 --- a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart +++ b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +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/items_for_sale/items_for_sale_api_client.dart'; @@ -9,9 +10,9 @@ 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/items_for_sale/get_items_for_sale_list.dart'; import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; -import 'package:mohem_flutter_app/ui/screens/items_for_sale/items_for_sale_home.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; class ItemsForSaleFragment extends StatefulWidget { @@ -35,7 +36,7 @@ class _ItemsForSaleFragmentState extends State { gridScrollController.addListener(() { if (gridScrollController.position.atEdge) { bool isTop = gridScrollController.position.pixels == 0; - if (!isTop) { + if (!isTop && getItemsForSaleList.length == currentPageNo * 10) { print('At the bottom'); currentPageNo++; getItemsForSale(currentPageNo, currentCategoryID); @@ -47,103 +48,100 @@ class _ItemsForSaleFragmentState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( + return ListView( controller: gridScrollController, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - DynamicTextFieldWidget( - "Search", - "Search Items", - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - // _runFilter(value); - }, - ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - "Browse Categories".toText17(), - IconButton( - icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), - onPressed: () => Navigator.pop(context), - ), - ], - ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 105.0, - child: getSaleCategoriesList.isNotEmpty - ? ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return AspectRatio( - aspectRatio: 1 / 1, - child: InkWell( - onTap: () { - setState(() { - currentCategoryID = getSaleCategoriesList[index].categoryID!; - getItemsForSaleList.clear(); - currentPageNo = 1; - getItemsForSale(currentPageNo, currentCategoryID); - }); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), - currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), - ], - ).expanded, - getSaleCategoriesList[index].title!.toText10() - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + children: [ + DynamicTextFieldWidget( + LocaleKeys.search.tr(), + LocaleKeys.searchItems.tr(), + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + // _runFilter(value); + }, + ).paddingOnly(left: 21, right: 21, top: 21), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + LocaleKeys.browseCategories.tr().toText17(), + // todo @haroon define the purpose of this icon button + IconButton( + icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), + onPressed: () => Navigator.pop(context), + ), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 105.0, + child: getSaleCategoriesList.isNotEmpty + ? ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 1 / 1, + child: InkWell( + onTap: () { + setState(() { + currentCategoryID = getSaleCategoriesList[index].categoryID!; + getItemsForSaleList.clear(); + currentPageNo = 1; + getItemsForSale(currentPageNo, currentCategoryID); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), + currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), + ], + ).expanded, + getSaleCategoriesList[index].title!.toText10() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), ), - ); - }, - separatorBuilder: (cxt, index) => 12.width, - itemCount: getSaleCategoriesList.length) - : Container(), - ), - getItemsForSaleList.isNotEmpty - ? GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), - shrinkWrap: true, - primary: false, - physics: const ScrollPhysics(), - children: getItemsForSaleWidgets(), - ) - : Utils.getNoDataWidget(context).paddingOnly(top: 50), - // 32.height, - ], - ), + ), + ); + }, + separatorBuilder: (cxt, index) => 12.width, + itemCount: getSaleCategoriesList.length) + : Container(), + ), + getItemsForSaleList.isNotEmpty + ? GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ) + : Utils.getNoDataWidget(context).paddingOnly(top: 50), + // 32.height, + ], ); } diff --git a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart index c85f4e0..8129b8a 100644 --- a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart +++ b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart @@ -1,10 +1,12 @@ import 'dart:convert'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.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/items_for_sale/get_items_for_sale_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -26,10 +28,7 @@ class _ItemForSaleDetailPageState extends State { getItemsForSaleList = ModalRoute.of(context)?.settings.arguments as GetItemsForSaleList; return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget(context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true,), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/ui/screens/items_for_sale/items_for_sale_home.dart b/lib/ui/screens/items_for_sale/items_for_sale_home.dart index 360c0ae..9f3151d 100644 --- a/lib/ui/screens/items_for_sale/items_for_sale_home.dart +++ b/lib/ui/screens/items_for_sale/items_for_sale_home.dart @@ -1,10 +1,11 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.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/models/items_for_sale/get_sale_categories_list.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/items_for_sale.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -24,10 +25,7 @@ class _ItemsForSaleState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget(context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: Column( children: [ Container( @@ -48,7 +46,7 @@ class _ItemsForSaleState extends State { ), ), child: Row( - children: [myTab("Items for sale", 0), myTab("My posted ads", 1)], + children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab("My posted ads", 1)], ), ), PageView( @@ -59,10 +57,7 @@ class _ItemsForSaleState extends State { tabIndex = pageIndex; }); }, - children: [ - ItemsForSaleFragment(), - MyPostedAdsFragment() - ], + children: [ItemsForSaleFragment(), MyPostedAdsFragment()], ).expanded, ], ), @@ -77,9 +72,11 @@ class _ItemsForSaleState extends State { ]), ), child: const Icon(Icons.add, color: Colors.white, size: 30), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.addNewItemForSale); - }) + ).onPress( + () { + Navigator.pushNamed(context, AppRoutes.addNewItemForSale); + }, + ), ); } diff --git a/lib/ui/screens/my_requests/my_requests.dart b/lib/ui/screens/my_requests/my_requests.dart index ebeff43..65aa534 100644 --- a/lib/ui/screens/my_requests/my_requests.dart +++ b/lib/ui/screens/my_requests/my_requests.dart @@ -49,45 +49,36 @@ class _MyRequestsState extends State { context, title: "Concurrent Reports", ), - body: Container( - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - children: [ - 12.height, - Container( - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), - child: PopupMenuButton( - child: DynamicTextFieldWidget( - "Template Name", - selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", - isEnable: false, - isPopup: true, - isInputTypeNum: true, - isReadOnly: false, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), - ], - onSelected: (int popupIndex) { - selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; - getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); - setState(() {}); - }), - ), - 12.height, - Expanded( + body: Column( + children: [ + ListView( + physics: const BouncingScrollPhysics(), + children: [ + Container( + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), + margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), + child: PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.templateName.tr(), + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? LocaleKeys.selectTemplate.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getConcurrentProgramsList!.length; i++) PopupMenuItem(child: Text(getConcurrentProgramsList![i].uSERCONCURRENTPROGRAMNAME!), value: i), + ], + onSelected: (int popupIndex) { + selectedConcurrentProgramList = getConcurrentProgramsList![popupIndex]; + getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); + setState(() {}); + }), + ), + 12.height, + Expanded( + // todo list don't have data, need to confirm later , because have issues, need fixes + child: ListView.separated( physics: const BouncingScrollPhysics(), shrinkWrap: true, @@ -149,21 +140,15 @@ class _MyRequestsState extends State { ); }, separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getCCPTransactionsList.length ?? 0)), - 80.height, - Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], + itemCount: getCCPTransactionsList.length), ), - child: DefaultButton(LocaleKeys.createRequest.tr(), () async { - openNewRequest(); - }).insideContainer, - ) - ], - ), + ], + ).expanded, + 1.divider, + DefaultButton(LocaleKeys.createRequest.tr(), () async { + openNewRequest(); + }).insideContainer, + ], ), ); } diff --git a/lib/ui/screens/my_requests/new_request.dart b/lib/ui/screens/my_requests/new_request.dart index 4cc2b20..b476ecc 100644 --- a/lib/ui/screens/my_requests/new_request.dart +++ b/lib/ui/screens/my_requests/new_request.dart @@ -4,7 +4,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/my_requests_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'; @@ -27,7 +26,7 @@ class _NewRequestState extends State { List getConcurrentProgramsList = []; GetConcurrentProgramsModel? selectedConcurrentProgramList; - List getCCPDFFStructureModelList = []; + List? getCCPDFFStructureModelList; DateTime selectedDate = DateTime.now(); @@ -45,17 +44,16 @@ class _NewRequestState extends State { context, title: "Concurrent Reports", ), - body: Container( - child: Column( - children: [ - 12.height, - Container( - padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), - margin: const EdgeInsets.only(left: 12, right: 12, top: 0, bottom: 0), - child: PopupMenuButton( + body: Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), + physics: const BouncingScrollPhysics(), + children: [ + PopupMenuButton( child: DynamicTextFieldWidget( - "Template Name", - selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? "", + LocaleKeys.templateName.tr(), + selectedConcurrentProgramList?.uSERCONCURRENTPROGRAMNAME ?? LocaleKeys.selectTemplate.tr(), isEnable: false, isPopup: true, isInputTypeNum: true, @@ -69,32 +67,28 @@ class _NewRequestState extends State { getCCPDFFStructure(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME); setState(() {}); }), - ), - (getCCPDFFStructureModelList.isEmpty - ? LocaleKeys.noDataAvailable.tr().toText16().center - : ListView.separated( - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.all(21), - itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList[parentIndex], parentIndex), - separatorBuilder: (cxt, index) => 0.height, - itemCount: getCCPDFFStructureModelList.length)) - .expanded, - Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), - ], - ), - child: DefaultButton(LocaleKeys.submit.tr(), () async { - // openNewRequest(); - }) - .insideContainer, - ) - ], - ), + getCCPDFFStructureModelList == null + ? const SizedBox() + : (getCCPDFFStructureModelList!.isEmpty + ? LocaleKeys.noDataAvailable.tr().toText16().center + : ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.all(0), + itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getCCPDFFStructureModelList![parentIndex], parentIndex), + separatorBuilder: (cxt, index) => 0.height, + itemCount: getCCPDFFStructureModelList!.length, + )), + ], + ).expanded, + 1.divider, + DefaultButton(LocaleKeys.submit.tr(), () { + // todo need to add submit method + // openNewRequest(); + }) + .insideContainer, + ], ), - // bottomSheet: ); } @@ -132,9 +126,7 @@ class _NewRequestState extends State { isReadOnly: model.rEADONLY == "Y", onChange: (text) { model.fieldAnswer = text; - if (model.eSERVICESDV == null) { - model.eSERVICESDV = ESERVICESDV(); - } + model.eSERVICESDV ??= ESERVICESDV(); model.eSERVICESDV!.pIDCOLUMNNAME = text; }, ).paddingOnly(bottom: 12); @@ -146,9 +138,7 @@ class _NewRequestState extends State { isInputTypeNum: true, onChange: (text) { model.fieldAnswer = text; - if (model.eSERVICESDV == null) { - model.eSERVICESDV = ESERVICESDV(); - } + model.eSERVICESDV ??= ESERVICESDV(); model.eSERVICESDV!.pIDCOLUMNNAME = text; }, ).paddingOnly(bottom: 12); @@ -164,7 +154,7 @@ class _NewRequestState extends State { } return DynamicTextFieldWidget( (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - displayText, + displayText.isEmpty ? LocaleKeys.pleaseSelectDate.tr() : displayText, suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { @@ -331,7 +321,7 @@ class _NewRequestState extends State { } return DynamicTextFieldWidget( (model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""), - displayText, + displayText.isEmpty ? LocaleKeys.pleaseSelectDate.tr() : displayText, suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart index e1e216d..9a308ba 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_details.dart @@ -50,86 +50,69 @@ class _OffersAndDiscountsDetailsState extends State { title: "Offers & Discounts", showHomeButton: true, ), - body: SingleChildScrollView( + body: ListView( controller: _scrollController, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Hero( + tag: "ItemImage" + getOffersList[0].rowID!, + // transitionOnUserGestures: true, + child: RepaintBoundary( + key: _globalKey, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.network( + getOffersList[0].bannerImage!, + fit: BoxFit.contain, + ), + ).paddingAll(12), + ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + 8.height, + AppState().isArabic(context) + ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center + : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, + Html( + data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", + onLinkTap: (String? url, RenderContext context, Map attributes, _) { + launchUrl(Uri.parse(url!)); + }, + ), + checkDate(getOffersList[0].endDate!).paddingOnly(left: 8), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Hero( - tag: "ItemImage" + getOffersList[0].rowID!, - // transitionOnUserGestures: true, - child: RepaintBoundary( - key: _globalKey, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.network( - getOffersList[0].bannerImage!, - fit: BoxFit.contain, - ), - ).paddingAll(12), - ), - ), - 8.height, - AppState().isArabic(context) - ? getOffersList[0].titleAR!.toText22(isBold: true, color: const Color(0xff2B353E)).center - : getOffersList[0].title!.toText22(isBold: true, color: const Color(0xff2B353E)).center, - Html( - data: AppState().isArabic(context) ? getOffersList[0].descriptionAR! : getOffersList[0].description ?? "", - onLinkTap: (String? url, RenderContext context, Map attributes, _) { - launchUrl(Uri.parse(url!)); - }, - ), - checkDate(getOffersList[0].endDate!).paddingOnly(left: 8), - 10.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getOffersList[0].discount!.toText16(isBold: true), - InkWell( - onTap: () { - _shareOfferAsImage(); - }, - child: const Icon(Icons.share, color: MyColors.darkIconColor).paddingOnly(bottom: 4)) - ], - ).paddingOnly(left: 8, right: 8), - getOffersList[0].isHasLocation == "true" - ? InkWell( - onTap: () {}, - child: Row( - children: [const Icon(Icons.map_sharp, color: MyColors.darkIconColor).paddingOnly(bottom: 4), "Offer Location".toText16(isUnderLine: true).paddingOnly(left: 8)], - ).paddingOnly(left: 8, right: 8, top: 8), - ) - : 12.height, + getOffersList[0].discount!.toText16(isBold: true), + InkWell( + onTap: () { + _shareOfferAsImage(); + }, + child: const Icon(Icons.share, color: MyColors.darkIconColor).paddingOnly(bottom: 4)) ], - ), - ).paddingOnly(left: 21, right: 21, top: 21), - "Related Offers".toText22(isBold: true, color: const Color(0xff2B353E)).paddingAll(21.0), - GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), - shrinkWrap: true, - primary: false, - physics: const ScrollPhysics(), - children: getItemsForSaleWidgets(), - ), - 50.height, - ], - ), + ).paddingOnly(left: 8, right: 8), + getOffersList[0].isHasLocation == "true" + ? InkWell( + onTap: () {}, + child: Row( + children: [const Icon(Icons.map_sharp, color: MyColors.darkIconColor).paddingOnly(bottom: 4), "Offer Location".toText16(isUnderLine: true).paddingOnly(left: 8)], + ).paddingOnly(left: 8, right: 8, top: 8), + ) + : 12.height, + ], + ).objectContainerView().paddingOnly(left: 21, right: 21, top: 21), + "Related Offers".toText22(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21, top: 21), + GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: const EdgeInsets.all(21), + shrinkWrap: true, + primary: false, + physics: const ScrollPhysics(), + children: getItemsForSaleWidgets(), + ), + ], ), ); } diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart index bdf6ed5..fed4583 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart @@ -9,6 +9,7 @@ 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/offers_and_discounts/get_categories_list.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; @@ -37,20 +38,15 @@ class _OffersAndDiscountsHomeState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Offers & Discounts", - showHomeButton: true, - ), + appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ DynamicTextFieldWidget( - "Search", - "Search Items", + LocaleKeys.search.tr(), + LocaleKeys.searchItems.tr(), isEnable: true, suffixIconData: Icons.search, isPopup: false, @@ -60,17 +56,16 @@ class _OffersAndDiscountsHomeState extends State { onChange: (String value) { // _runFilter(value); }, - ).paddingOnly(left: 21, right: 21, top: 21, bottom: 18), + ).paddingOnly(left: 21, right: 21, top: 21), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - "Browse Categories".toText17(), - IconButton( - icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0), - onPressed: () => Navigator.pop(context), - ), + LocaleKeys.browseCategories.tr().toText17(), + const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0).onPress(() { + Navigator.pop(context); + }), ], - ).paddingOnly(left: 21, right: 21), + ).paddingOnly(left: 21, right: 21, top: 21), SizedBox( height: 110.0, child: getCategoriesList.isNotEmpty @@ -120,7 +115,7 @@ class _OffersAndDiscountsHomeState extends State { currentCategoryID == getCategoriesList[index].id ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), ], ).expanded, - AppState().isArabic(context) ? getCategoriesList[index].categoryNameAr!.toText10(maxLine: 1) : getCategoriesList[index].categoryNameEn!.toText10(maxLine: 1) + AppState().isArabic(context) ? getCategoriesList[index].categoryNameAr!.toText10(maxlines: 1) : getCategoriesList[index].categoryNameEn!.toText10(maxlines: 1) ], ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), ), @@ -195,7 +190,9 @@ class _OffersAndDiscountsHomeState extends State { ), ), 10.height, - AppState().isArabic(context) ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), + AppState().isArabic(context) + ? getOffersList.titleAR!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1) + : getOffersList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), // Html( // data: AppState().isArabic(context) ? getOffersList.descriptionAR! : getOffersList.description ?? "", // // onLinkTap: (String? url, RenderContext context, Map attributes, _) { @@ -224,8 +221,8 @@ class _OffersAndDiscountsHomeState extends State { getOffersDetailList.add(offersListModelObj); getOffersList.forEach((element) { - if(counter <= 4) { - if(element.rowID != offersListModelObj.rowID) { + if (counter <= 4) { + if (element.rowID != offersListModelObj.rowID) { getOffersDetailList.add(element); counter++; } @@ -238,9 +235,9 @@ class _OffersAndDiscountsHomeState extends State { Widget checkDate(String endDate) { DateTime endDateObj = DateFormat("yyyy-MM-dd").parse(endDate); if (endDateObj.isAfter(DateTime.now())) { - return "Offer Valid".toText14(isBold: true, color: MyColors.greenColor); + return LocaleKeys.offerValid.tr().toText14(isBold: true, color: MyColors.greenColor); } else { - return "Offer Expired".toText14(isBold: true, color: MyColors.redColor); + return LocaleKeys.offerExpired.tr().toText14(isBold: true, color: MyColors.redColor); } } From f647b32c65d150d9c84637950aef84872967cbf9 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 4 Sep 2022 16:04:13 +0300 Subject: [PATCH 3/6] item for sale improvement. --- lib/extensions/widget_extensions.dart | 4 +- .../fragments/items_for_sale.dart | 112 +++++------- .../items_for_sale/item_for_sale_detail.dart | 173 ++++++++---------- 3 files changed, 119 insertions(+), 170 deletions(-) diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index c9a4b49..82dc4df 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -42,9 +42,9 @@ extension WidgetExtensions on Widget { child: this, ); - Widget objectContainerView({String title = "", String note = ""}) { + Widget objectContainerView({String title = "", String note = "", bool disablePadding = false}) { return Container( - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), + padding: disablePadding ? EdgeInsets.zero : const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15), diff --git a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart index 0e9f4db..89bf7ce 100644 --- a/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart +++ b/lib/ui/screens/items_for_sale/fragments/items_for_sale.dart @@ -95,34 +95,21 @@ class _ItemsForSaleFragmentState extends State { getItemsForSale(currentPageNo, currentCategoryID); }); }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), - currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), - ], - ).expanded, - getSaleCategoriesList[index].title!.toText10() - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(getSaleCategoriesList[index].content!, fit: BoxFit.contain), + currentCategoryID == getSaleCategoriesList[index].categoryID ? const Icon(Icons.check_circle_rounded, color: MyColors.greenColor, size: 16.0) : Container(), + ], + ).expanded, + getSaleCategoriesList[index].title!.toText10() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12).expanded.objectContainerView(disablePadding: true), ), ); }, @@ -133,7 +120,7 @@ class _ItemsForSaleFragmentState extends State { getItemsForSaleList.isNotEmpty ? GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 162 / 266, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 21), + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 12), shrinkWrap: true, primary: false, physics: const ScrollPhysics(), @@ -160,49 +147,36 @@ class _ItemsForSaleFragmentState extends State { onTap: () { Navigator.pushNamed(context, AppRoutes.itemsForSaleDetail, arguments: getItemsForSaleList); }, - child: Container( - padding: const EdgeInsets.all(10.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Hero( - tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), - transitionOnUserGestures: true, - child: AspectRatio( - aspectRatio: 148 / 127, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.memory( - base64Decode(getItemsForSaleList.itemAttachments![0].content!), - fit: BoxFit.cover, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 148 / 127, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(getItemsForSaleList.itemAttachments![0].content!), + fit: BoxFit.cover, ), ), ), - 10.height, - getItemsForSaleList.title!.toText16(isBold: true, color: const Color(0xff2B353E), maxlines: 1), - getItemsForSaleList.description!.toText12(maxLine: 2, color: const Color(0xff535353)), - 16.height, - getItemsForSaleList.status!.toText14(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: ["${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText14(isBold: true), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], - ), - ], - ), - ), + ), + 10.height, + getItemsForSaleList.title!.toText16(maxlines: 1), + getItemsForSaleList.description!.toText12(maxLine: 3, color: MyColors.grey57Color).expanded, + // 8.height, + getItemsForSaleList.status!.toText14(color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: ["${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText16(isBold: true), SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)], + ), + 6.height + ], + ).paddingAll(8).expanded.objectContainerView(disablePadding: true), ); } diff --git a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart index 8129b8a..ee76943 100644 --- a/lib/ui/screens/items_for_sale/item_for_sale_detail.dart +++ b/lib/ui/screens/items_for_sale/item_for_sale_detail.dart @@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.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'; @@ -11,6 +12,7 @@ import 'package:mohem_flutter_app/models/items_for_sale/get_items_for_sale_list. import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; import 'package:url_launcher/url_launcher.dart'; class ItemForSaleDetailPage extends StatefulWidget { @@ -26,113 +28,86 @@ class _ItemForSaleDetailPageState extends State { @override Widget build(BuildContext context) { getItemsForSaleList = ModalRoute.of(context)?.settings.arguments as GetItemsForSaleList; + return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), - body: SingleChildScrollView( - child: Column( - children: [ - AspectRatio( - aspectRatio: 336 / 554, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), + body: Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), + transitionOnUserGestures: true, + child: AspectRatio( + aspectRatio: 322 / 261, + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: Image.memory( + base64Decode(getItemsForSaleList.itemAttachments![0].content!), + fit: BoxFit.cover, + ), + ), ), - ], - ), - // color: Colors.red, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: const Color(0xffEBEBEB).withOpacity(1.0), - blurRadius: 26, - offset: const Offset(0, -3), + ).paddingAll(8), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getItemsForSaleList.title!.toText20(), + getItemsForSaleList.description!.toText12(maxLine: 5, color: MyColors.grey57Color), + 21.height, + getItemsForSaleList.status!.toText16(color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor), + "${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText20(isBold: true), + 1.divider.paddingOnly(top: 16, bottom: 16), + Row( + children: [ + CircularAvatar( + url: getItemsForSaleList.profilePicture, + height: 34, + width: 34, ), + 7.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [getItemsForSaleList.fullName!.toText14(), ItemDetailView("Posted on", DateUtil.formatDateToDate(DateTime.parse(getItemsForSaleList.created!), false))], + ).expanded, ], ), - child: Hero( - tag: "ItemImage" + getItemsForSaleList.itemSaleID.toString(), - transitionOnUserGestures: true, - child: AspectRatio( - aspectRatio: 148 / 127, - child: ClipRRect( - borderRadius: BorderRadius.circular(6), - child: Image.memory( - base64Decode(getItemsForSaleList.itemAttachments![0].content!), - fit: BoxFit.cover, - ), - ), - ).paddingAll(8), - ), - ), - getItemsForSaleList.title!.toText20(isBold: true, color: const Color(0xff2B353E)).paddingOnly(left: 21, right: 21), - getItemsForSaleList.description!.toText12(maxLine: 5, color: const Color(0xff535353)).paddingOnly(left: 21, right: 21, bottom: 21), - getItemsForSaleList.status!.toText16(isBold: true, color: getItemsForSaleList.status == 'Approved' ? MyColors.greenColor : MyColors.yellowColor).paddingOnly(left: 21, right: 21), - "${getItemsForSaleList.quotePrice} ${getItemsForSaleList.currencyCode!}".toText20(isBold: true).paddingOnly(left: 21, right: 21, bottom: 15), - const Divider().paddingOnly(left: 21, right: 21), - Row( - children: [ - CircularAvatar( - height: 40, - width: 40, - ).paddingOnly(left: 21, top: 21), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - getItemsForSaleList.fullName!.toText14(isBold: true).paddingOnly(left: 7, right: 7), - "Posted on: ${DateUtil.formatDateToDate(DateTime.parse(getItemsForSaleList.created!), false)}".toText12().paddingOnly(left: 7, right: 7), - ], - ).paddingOnly(top: 18), - ], - ), - ], - ), - ).paddingAll(21), - ), - Container( - decoration: const BoxDecoration( - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 1), - ], - ), - child: Row( - children: [ - DefaultButton("Email", () async { - Uri emailLaunchUri = Uri( - scheme: 'mailto', - path: getItemsForSaleList.emailAddress, - ); - launchUrl(emailLaunchUri); - }, iconData: Icons.email_sharp, isTextExpanded: false) - .insideContainer - .expanded, - DefaultButton("Call", () async { - Uri callLaunchUri = Uri( - scheme: 'tel', - path: getItemsForSaleList.mobileNumber, - ); - launchUrl(callLaunchUri); - }, iconData: Icons.call_sharp, isTextExpanded: false) - .insideContainer - .expanded, + ], + ).paddingOnly(right: 16, left: 16, top: 6, bottom: 16) ], - ), - ), - ], - ), + ).objectContainerView(disablePadding: true), + ], + ).expanded, + Row( + children: [ + DefaultButton("Email", () async { + Uri emailLaunchUri = Uri( + scheme: 'mailto', + path: getItemsForSaleList.emailAddress, + ); + launchUrl(emailLaunchUri); + }, iconData: Icons.email_sharp, isTextExpanded: false) + .expanded, + 8.width, + DefaultButton("Call", () async { + Uri callLaunchUri = Uri( + scheme: 'tel', + path: getItemsForSaleList.mobileNumber, + ); + launchUrl(callLaunchUri); + }, iconData: Icons.call_sharp, isTextExpanded: false) + .expanded, + ], + ).insideContainer, + ], ), ); } From f3477fb5f33f2a8ac8d6c7ea26c3cefd93cd70b9 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Sun, 4 Sep 2022 16:40:06 +0300 Subject: [PATCH 4/6] perforamce page updates --- assets/langs/ar-SA.json | 1 + assets/langs/en-US.json | 1 + lib/generated/locale_keys.g.dart | 1 + lib/ui/performance/performance.dart | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 44cbea9..036dde0 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -267,6 +267,7 @@ "totalPayAmount": "المبلغ الإجمالي للدفع", "paymentInformation": "معلومات الدفع", "performance": "تقييم الاداء", + "performanceEvaluation": "تقييم الأداء في", "amount": "مقدار", "correctCurrentDatails": "تعديل او اكمال التفاصيل الحالية", "selectType": " حدد نوع التغيير الذي تريد القيام به", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 15087ff..8f93658 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -314,6 +314,7 @@ "regular": "Regular", "mark": "Mark", "performance": "Performance Evaluation", + "performanceEvaluation": "Performance evaluation in", "selectMethodOfAttendance": "Select the method to mark the attendance", "comeNearHMGWifi": "Please come near to HMG wifi", "profile": { diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index c0742da..6ae78e0 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -335,4 +335,5 @@ abstract class LocaleKeys { static const gender_with_arg = 'gender.with_arg'; static const gender = 'gender'; static const reset_locale = 'reset_locale'; + static const performanceEvaluation = 'performanceEvaluation'; } diff --git a/lib/ui/performance/performance.dart b/lib/ui/performance/performance.dart index 27ddcb2..510db0b 100644 --- a/lib/ui/performance/performance.dart +++ b/lib/ui/performance/performance.dart @@ -70,7 +70,7 @@ class _PerformanceAppraisalState extends State { children: [ Container( child: Text( - "Performance evaluation in " + performance.aPPRAISALYEAR.toString(), + LocaleKeys.performanceEvaluation.tr() + performance.aPPRAISALYEAR.toString(), style: const TextStyle(fontWeight: FontWeight.bold), )), SizedBox( From 7eadd97869b2d74d9ff009a10492e28790a15e03 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 5 Sep 2022 11:49:20 +0300 Subject: [PATCH 5/6] item for sale ui improvements & translation added. --- assets/langs/ar-SA.json | 14 + assets/langs/en-US.json | 14 + lib/generated/codegen_loader.g.dart | 28 ++ lib/generated/locale_keys.g.dart | 14 + lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/landing/widget/services_widget.dart | 125 ++++--- .../items_for_sale/add_new_item_for_sale.dart | 199 ++++------ .../fragments/add_details_fragment.dart | 344 +++++++++--------- .../fragments/select_category_fragment.dart | 65 ++-- .../items_for_sale/items_for_sale_home.dart | 2 +- lib/widgets/radio/show_radio.dart | 3 +- 11 files changed, 407 insertions(+), 403 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 082270f..3f122fd 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -370,6 +370,20 @@ "offerAndDiscounts": "العروض والخصومات", "offerValid": "العرض صالح", "offerExpired": "انتهى العرض", + "whatAreYouOffering": "ما الذي تعرضه؟", + "selectCategory": "اختر الفئة", + "inProgress": "في تَقَدم", + "locked": "مقفل", + "addDetails": "أضف التفاصيل", + "reviewAndSell": "مراجعة وبيع", + "itemTitle": "عنوان البند", + "itemCondition": "حالة السلعة", + "used": "تستخدم", + "region": "منطقة", + "selectRegion": "اختر المنطقة", + "itemPrice": "سعر السلعة", + "itemPhotos": "صور البند", + "itemInfo": "معلومات العنصر", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 1bf8cc7..faccbe7 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -370,6 +370,20 @@ "offerAndDiscounts": "Offer & Discounts", "offerValid": "Offer Valid", "offerExpired": "Offer Expired", + "whatAreYouOffering": "What are you offering?", + "selectCategory": "Select Category", + "inProgress": "InProgress", + "locked": "Locked", + "addDetails": "Add Details", + "reviewAndSell": "Review & Sell", + "itemTitle": "Item Title", + "itemCondition": "Item Condition", + "used": "Used", + "region": "Region", + "selectRegion": "Select Region", + "itemPrice": "Item Price", + "itemPhotos": "Item Photos", + "itemInfo": "Item Info", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 0dfa765..c4a10d4 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -386,6 +386,20 @@ class CodegenLoader extends AssetLoader{ "offerAndDiscounts": "العروض والخصومات", "offerValid": "العرض صالح", "offerExpired": "انتهى العرض", + "whatAreYouOffering": "ما الذي تعرضه؟", + "selectCategory": "اختر الفئة", + "inProgress": "في تَقَدم", + "locked": "مقفل", + "addDetails": "أضف التفاصيل", + "reviewAndSell": "مراجعة وبيع", + "itemTitle": "عنوان البند", + "itemCondition": "حالة السلعة", + "used": "تستخدم", + "region": "منطقة", + "selectRegion": "اختر المنطقة", + "itemPrice": "سعر السلعة", + "itemPhotos": "صور البند", + "itemInfo": "معلومات العنصر", "profile": { "reset_password": { "label": "Reset Password", @@ -792,6 +806,20 @@ static const Map en_US = { "offerAndDiscounts": "Offer & Discounts", "offerValid": "Offer Valid", "offerExpired": "Offer Expired", + "whatAreYouOffering": "What are you offering?", + "selectCategory": "Select Category", + "inProgress": "InProgress", + "locked": "Locked", + "addDetails": "Add Details", + "reviewAndSell": "Review & Sell", + "itemTitle": "Item Title", + "itemCondition": "Item Condition", + "used": "Used", + "region": "Region", + "selectRegion": "Select Region", + "itemPrice": "Item Price", + "itemPhotos": "Item Photos", + "itemInfo": "Item Info", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 7214616..5cf6ba7 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -371,6 +371,20 @@ abstract class LocaleKeys { static const offerAndDiscounts = 'offerAndDiscounts'; static const offerValid = 'offerValid'; static const offerExpired = 'offerExpired'; + static const whatAreYouOffering = 'whatAreYouOffering'; + static const selectCategory = 'selectCategory'; + static const inProgress = 'inProgress'; + static const locked = 'locked'; + static const addDetails = 'addDetails'; + static const reviewAndSell = 'reviewAndSell'; + static const itemTitle = 'itemTitle'; + static const itemCondition = 'itemCondition'; + static const used = 'used'; + static const region = 'region'; + static const selectRegion = 'selectRegion'; + static const itemPrice = 'itemPrice'; + static const itemPhotos = 'itemPhotos'; + static const itemInfo = 'itemInfo'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 907072e..3f4e5f2 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -240,7 +240,7 @@ class _DashboardScreenState extends State { ], ).paddingOnly(left: 21, right: 21, top: 7), ServicesWidget(), - 8.height, + // 8.height, Container( width: double.infinity, padding: const EdgeInsets.only(top: 31), diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index 868ca5e..719155c 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -33,69 +33,68 @@ class ServicesWidget extends StatelessWidget { return data.isServicesMenusLoading ? whileLoading() : ListView.separated( + padding: const EdgeInsets.only(top: 21), itemBuilder: (context, parentIndex) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().expanded, - LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), - ], - ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 105 + 26, - child: ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return AspectRatio( - aspectRatio: 105 / 105, - child: data.isServicesMenusLoading - ? ServicesMenuShimmer() - : Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset(iconT[index]), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), - ), - SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ).onPress(() { - handleOnPress(context, data.homeMenus![parentIndex].menuEntiesList[index]); - }), - ); - }, - separatorBuilder: (cxt, index) => 9.width, - itemCount: data.homeMenus![parentIndex].menuEntiesList.length), - ), - ], - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().expanded, + LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 105 + 26, + child: ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 105 / 105, + child: data.isServicesMenusLoading + ? ServicesMenuShimmer() + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset(iconT[index]), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ).onPress(() { + handleOnPress(context, data.homeMenus![parentIndex].menuEntiesList[index]); + }), + ); + }, + separatorBuilder: (cxt, index) => 9.width, + itemCount: data.homeMenus![parentIndex].menuEntiesList.length), + ), + ], ); }, separatorBuilder: (context, index) { @@ -149,7 +148,7 @@ class ServicesWidget extends StatelessWidget { Widget whileLoading() { return Column( children: [ - ServicesHeaderShimmer().paddingOnly(left: 21, right: 21), + ServicesHeaderShimmer().paddingOnly(left: 21, right: 21, top: 21), SizedBox( height: 105 + 26, child: ListView.separated( diff --git a/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart index 307a834..aac9d13 100644 --- a/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart +++ b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart @@ -1,8 +1,11 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_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/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/items_for_sale/get_sale_categories_list.dart'; import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/add_details_fragment.dart'; @@ -43,91 +46,52 @@ class _AddNewItemForSaleState extends State { getRequestID(); return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true, - ), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AspectRatio( - aspectRatio: 335 / 118, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + Row( + children: [ + showProgress( + title: LocaleKeys.selectCategory.tr(), + status: _currentIndex == 0 ? LocaleKeys.inProgress.tr() : (_currentIndex > 0 ? LocaleKeys.completed.tr() : LocaleKeys.locked.tr()), + color: _currentIndex == 0 ? MyColors.orange : MyColors.greenColor, + pageIndex: 0, + ).expanded, + showProgress( + title: LocaleKeys.addDetails.tr(), + status: _currentIndex == 1 ? LocaleKeys.inProgress.tr() : (_currentIndex > 1 ? LocaleKeys.completed.tr() : LocaleKeys.locked.tr()), + color: _currentIndex == 1 ? MyColors.orange : (_currentIndex > 1 ? MyColors.greenColor : MyColors.lightGrayColor), + pageIndex: 1, + ).expanded, + showProgress( + title: LocaleKeys.reviewAndSell.tr(), + status: _currentIndex == 2 ? LocaleKeys.inProgress.tr() : LocaleKeys.locked.tr(), + color: _currentIndex == 2 + ? MyColors.orange + : _currentIndex > 3 + ? MyColors.greenColor + : MyColors.lightGrayColor, + isNeedBorder: false, + pageIndex: 2, ), - child: Row( - children: [ - Expanded( - child: showProgress( - title: "Select Category", - status: _currentIndex == 0 - ? "InProgress" - : _currentIndex > 0 - ? "Completed" - : "Locked", - color: _currentIndex == 0 ? MyColors.orange : MyColors.greenColor, - pageIndex: 0, - ), - ), - Expanded( - child: showProgress( - title: "Add Details", - status: _currentIndex == 1 - ? "InProgress" - : _currentIndex > 1 - ? "Completed" - : "Locked", - color: _currentIndex == 1 - ? MyColors.orange - : _currentIndex > 1 - ? MyColors.greenColor - : MyColors.lightGrayColor, - pageIndex: 1, - ), - ), - showProgress( - title: "Review & Sell", - status: _currentIndex == 2 ? "InProgress" : "Locked", - color: _currentIndex == 2 - ? MyColors.orange - : _currentIndex > 3 - ? MyColors.greenColor - : MyColors.lightGrayColor, - isNeedBorder: false, - pageIndex: 2, - ), - ], - ).paddingAll(21), - ).paddingOnly(left: 21, right: 21, top: 21), - ), - Expanded( - child: PageView( - physics: NeverScrollableScrollPhysics(), - controller: _controller, - onPageChanged: (index) { - setState(() { - _currentIndex = index; - }); - }, - scrollDirection: Axis.horizontal, - children: [ - getSaleCategoriesList.isNotEmpty ? SelectCategoryFragment(changePageViewIndex: changePageViewIndex, getSaleCategoriesList: getSaleCategoriesList) : Container(), - getSaleCategoriesList.isNotEmpty ? AddItemDetailsFragment(changePageViewIndex: changePageViewIndex, selectedSaleCategory: getSaleCategoriesList[0]) : Container(), - ItemReviewFragment(changePageViewIndex: changePageViewIndex), - ], - ), - ), + ], + ).paddingAll(21).objectContainerView(disablePadding: true).paddingAll(21), + PageView( + physics: const NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + getSaleCategoriesList.isNotEmpty ? SelectCategoryFragment(changePageViewIndex: changePageViewIndex, getSaleCategoriesList: getSaleCategoriesList) : Container(), + getSaleCategoriesList.isNotEmpty ? AddItemDetailsFragment(changePageViewIndex: changePageViewIndex, selectedSaleCategory: getSaleCategoriesList[0]) : Container(), + ItemReviewFragment(changePageViewIndex: changePageViewIndex), + ], + ).expanded, ], ), ); @@ -141,54 +105,43 @@ class _AddNewItemForSaleState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, + Row( children: [ - Row( - children: [ - Container( - width: 26, - height: 26, - decoration: Utils.containerRadius(color!, 200), - child: const Icon( - Icons.done, - color: Colors.white, - size: 16, - ), - ), - if (isNeedBorder) - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Utils.mDivider(Colors.grey), - )), - ], - ), - Utils.mHeight(8), - Text( - title!, - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - letterSpacing: -0.44, + Container( + width: 26, + height: 26, + decoration: Utils.containerRadius(color!, 200), + child: const Icon( + Icons.done, + color: Colors.white, + size: 16, ), ), - Utils.mHeight(2), - Container( - padding: EdgeInsets.all(5), - decoration: Utils.containerRadius(color.withOpacity(0.2), 4), - child: Text( - status!, - style: TextStyle( - fontSize: 8, - fontWeight: FontWeight.w600, - letterSpacing: -0.32, - color: color, + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Utils.mDivider(Colors.grey), ), ), - ), ], - ) + ), + Utils.mHeight(8), + title!.toText11(), + Utils.mHeight(2), + Container( + padding: const EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), + decoration: Utils.containerRadius(color.withOpacity(0.2), 4), + child: Text( + status!, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, + ), + ), + ), ], ), ); diff --git a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart index 7919c0d..bfb5a5e 100644 --- a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -51,112 +51,116 @@ class _AddItemDetailsFragmentState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "Add details".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DynamicTextFieldWidget( - "Title", - itemTitle.isEmpty ? "Item title" : itemTitle, - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - itemTitle = value; - }, - ).paddingOnly(), - DynamicTextFieldWidget( - "Description", - itemDescription.isEmpty ? "Item description" : itemDescription, - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 4, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - itemDescription = value; - }, - ).paddingOnly(top: 12), - "Item Condition".toText14(isBold: true).paddingOnly(top: 21), - Row( - children: [ - ShowRadio(title: "New", value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "new"; - setState(() {}); - }), - 12.width, - ShowRadio(title: "Used", value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "used"; + return Column( + children: [ + ListView( + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21), + children: [ + LocaleKeys.addDetails.tr().toText20(), + 12.height, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DynamicTextFieldWidget( + LocaleKeys.title.tr(), + itemTitle.isEmpty ? LocaleKeys.itemTitle.tr() : itemTitle, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemTitle = value; + }, + ), + DynamicTextFieldWidget( + LocaleKeys.description.tr(), + itemDescription.isEmpty ? LocaleKeys.itemDescription.tr() : itemDescription, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 4, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemDescription = value; + }, + ).paddingOnly(top: 12), + LocaleKeys.itemCondition.tr().toText14().paddingOnly(top: 21), + Row( + children: [ + ShowRadio(title: LocaleKeys.newString.tr(), value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "new"; + setState(() {}); + }), + 12.width, + ShowRadio(title: LocaleKeys.used.tr(), value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "used"; + setState(() {}); + }), + ], + ).paddingOnly(top: 12), + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.region.tr(), + selectedRegion.regionName ?? LocaleKeys.selectRegion.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem(child: Text(getRegionsList[i].regionName!), value: i), + ], + onSelected: (int popupIndex) { + selectedRegion = getRegionsList![popupIndex]; setState(() {}); - }), - ], - ).paddingOnly(top: 12), - PopupMenuButton( - child: DynamicTextFieldWidget( - "Region", - selectedRegion.regionName ?? "Select Region", - isEnable: false, - isPopup: true, + }, + ).paddingOnly(top: 21), + DynamicTextFieldWidget( + LocaleKeys.itemPrice.tr(), + itemPrice == 0 ? LocaleKeys.price.tr() : itemPrice.toString(), + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, isInputTypeNum: true, isReadOnly: false, - ), - itemBuilder: (_) => >[ - for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem(child: Text(getRegionsList[i].regionName!), value: i), - ], - onSelected: (int popupIndex) { - selectedRegion = getRegionsList![popupIndex]; - setState(() {}); - }, - ).paddingOnly(top: 21), - DynamicTextFieldWidget( - "Item Price", - itemPrice == 0 ? "Price" : itemPrice.toString(), - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: true, - isReadOnly: false, - onChange: (String value) { - itemPrice = num.parse(value); - }, - ).paddingOnly(top: 12), - "Item Photos".toText14(isBold: true).paddingOnly(top: 16), - attachmentView("Attachments").paddingOnly(top: 12), - Row( - children: [ - DefaultButton( - LocaleKeys.cancel.tr(), - () async { - Navigator.of(context).pop(); + onChange: (String value) { + itemPrice = num.parse(value); + }, + ).paddingOnly(top: 12), + LocaleKeys.itemPhotos.tr().toText14().paddingOnly(top: 21), + attachmentView(LocaleKeys.attachments.tr()).paddingOnly(top: 12), + ], + ).objectContainerView(title: LocaleKeys.itemInfo.tr()), + ], + ).expanded, + 1.divider, + Row( + children: [ + DefaultButton( + LocaleKeys.cancel.tr(), + () async { + Navigator.of(context).pop(); + }, + colors: const [Color(0xffD02127), Color(0xffD02127)], + ).expanded, + 8.width, + DefaultButton( + LocaleKeys.next.tr(), + isButtonDisabled() + ? null + : () async { + AddItemDetailsFragment.itemReviewModel = getItemReviewObject(); + widget.changePageViewIndex(2); }, - colors: const [Color(0xffD02127), Color(0xffD02127)], - ).expanded, - 12.width, - DefaultButton( - LocaleKeys.next.tr(), - isButtonDisabled() - ? null - : () async { - AddItemDetailsFragment.itemReviewModel = getItemReviewObject(); - widget.changePageViewIndex(2); - }, - disabledColor: MyColors.lightGrayColor, - ).expanded - ], - ).paddingOnly(top: 21), - ], - ).objectContainerView(title: "Item Info").paddingAll(21), - ], - ), + disabledColor: MyColors.lightGrayColor, + ).expanded + ], + ).insideContainer + ], ); } @@ -174,82 +178,70 @@ class _AddItemDetailsFragmentState extends State { } Widget attachmentView(String title) { - return Container( - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - title.toText16().expanded, - 6.width, - SimpleButton(LocaleKeys.add.tr(), () async { - ImageOptions.showImageOptions(context, (String image, File file) { - setState(() { - images.add(image); - }); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText16().expanded, + 6.width, + SimpleButton(LocaleKeys.add.tr(), () async { + ImageOptions.showImageOptions(context, (String image, File file) { + setState(() { + images.add(image); }); - }, fontSize: 14), - ], - ), - if (images.isNotEmpty) 12.height, - if (images.isNotEmpty) - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (cxt, index) { - return Container( - margin: const EdgeInsets.all(10), - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon(Icons.attach_file_sharp), - const SizedBox( - width: 8, - ), - 'image ${index + 1}.png'.toText16(), - ], + }); + }, fontSize: 14), + ], + ), + if (images.isNotEmpty) 12.height, + if (images.isNotEmpty) + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) { + return Container( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon(Icons.attach_file_sharp), + const SizedBox( + width: 8, + ), + 'image ${index + 1}.png'.toText16(), + ], + ), + InkWell( + onTap: () { + setState(() { + images.remove(images[index]); + }); + }, + child: Icon( + Icons.delete_sharp, + color: Colors.red[300], ), - InkWell( - onTap: () { - setState(() { - images.remove(images[index]); - }); - }, - child: Icon( - Icons.delete_sharp, - color: Colors.red[300], - )) - ], - ), - ); - }, - separatorBuilder: (cxt, index) => 6.height, - itemCount: images.length), - ], - ), - ); + ) + ], + ), + ); + }, + separatorBuilder: (cxt, index) => 6.height, + itemCount: images.length), + ], + ).objectContainerView(); } - void getAdDetails() async { + Future getAdDetails() async { + // todo need to change this method later , its not a good approach to do it like this. String details = await Utils.getStringFromPrefs(SharedPrefsConsts.editItemForSale); var body = json.decode(details); @@ -274,17 +266,15 @@ class _AddItemDetailsFragmentState extends State { AddItemDetailsFragment.itemReviewModel = itemReviewModel; SelectCategoryFragment.selectedSaleCategory = selectedSaleCategoryAd; - - setState(() {}); } void getRegions() async { try { Utils.showLoading(context); getRegionsList = await ItemsForSaleApiClient().getRegions(); + await getAdDetails(); Utils.hideLoading(context); setState(() {}); - getAdDetails(); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart index 6255302..04d6b2d 100644 --- a/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart @@ -1,7 +1,9 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.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/items_for_sale/get_sale_categories_list.dart'; class SelectCategoryFragment extends StatelessWidget { @@ -18,11 +20,11 @@ class SelectCategoryFragment extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - "What are you offering".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), + LocaleKeys.whatAreYouOffering.tr().toText20().paddingOnly(top: 0, left: 21, right: 21), getSaleCategoriesList.isNotEmpty ? GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 105 / 105, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 21, right: 21), + padding: const EdgeInsets.only(top: 15, bottom: 21, left: 21, right: 21), shrinkWrap: true, primary: false, physics: const ScrollPhysics(), @@ -37,41 +39,32 @@ class SelectCategoryFragment extends StatelessWidget { List getItemsForSaleWidgets() { List itemsList = []; - getSaleCategoriesList.forEach((element) { - itemsList.add(InkWell( - onTap: () { - selectedSaleCategory = element; - changePageViewIndex(1); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + getSaleCategoriesList.forEach( + (element) { + itemsList.add( + InkWell( + onTap: () { + selectedSaleCategory = element; + changePageViewIndex(1); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(element.content!, fit: BoxFit.contain, width: 32, height: 32), + ], + ).expanded, + element.title!.toText12() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 16).expanded.objectContainerView(disablePadding: true), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.string(element.content!, fit: BoxFit.contain, width: 32, height: 32), - ], - ).expanded, - element.title!.toText12() - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ), - )); - }); + ); + }, + ); return itemsList; } diff --git a/lib/ui/screens/items_for_sale/items_for_sale_home.dart b/lib/ui/screens/items_for_sale/items_for_sale_home.dart index 9f3151d..437b400 100644 --- a/lib/ui/screens/items_for_sale/items_for_sale_home.dart +++ b/lib/ui/screens/items_for_sale/items_for_sale_home.dart @@ -46,7 +46,7 @@ class _ItemsForSaleState extends State { ), ), child: Row( - children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab("My posted ads", 1)], + children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab(LocaleKeys.myPostedAds.tr(), 1)], ), ), PageView( diff --git a/lib/widgets/radio/show_radio.dart b/lib/widgets/radio/show_radio.dart index 6138fa3..9a5a4b8 100644 --- a/lib/widgets/radio/show_radio.dart +++ b/lib/widgets/radio/show_radio.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.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/extensions/int_extensions.dart'; class ShowRadio extends StatelessWidget { String title, value, groupValue; @@ -39,7 +38,7 @@ class ShowRadio extends StatelessWidget { ), ), 12.width, - title.toText12(isBold: true, maxLine: 2) + title.toText12(maxLine: 2) ], ); } From 8e94d57dae9a6d34b7d3aa4607adc5dd5928d6d9 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 5 Sep 2022 16:04:18 +0300 Subject: [PATCH 6/6] performance evaluation improvements. --- assets/langs/ar-SA.json | 1 + assets/langs/en-US.json | 3 +- lib/api/profile_api_client.dart | 15 +-- lib/classes/colors.dart | 2 +- lib/config/routes.dart | 2 +- lib/extensions/widget_extensions.dart | 4 +- lib/generated/codegen_loader.g.dart | 4 +- lib/generated/locale_keys.g.dart | 1 + lib/ui/performance/performance.dart | 114 ------------------ .../performance_appraisal_screen.dart | 97 +++++++++++++++ 10 files changed, 114 insertions(+), 129 deletions(-) delete mode 100644 lib/ui/performance/performance.dart create mode 100644 lib/ui/performance/performance_appraisal_screen.dart 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); + } +}