From ea8912dc2b45e52850ba647fdf40c32c73434d4f Mon Sep 17 00:00:00 2001 From: Mirza Shafique Date: Wed, 15 Dec 2021 16:04:01 +0000 Subject: [PATCH 1/6] Initial commit --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4dadb64 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# mohem_flutter_app + + + +## Getting started + +To make it easy for you to get started with GitLab, here's a list of recommended next steps. + +Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! + +## Add your files + +- [ ] [Create](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files +- [ ] [Add files using the command line](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: + +``` +cd existing_repo +git remote add origin https://gitlab.com/mirza.shafique/mohem_flutter_app.git +git branch -M main +git push -uf origin main +``` + +## Integrate with your tools + +- [ ] [Set up project integrations](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://gitlab.com/mirza.shafique/mohem_flutter_app/-/settings/integrations) + +## Collaborate with your team + +- [ ] [Invite team members and collaborators](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/members/) +- [ ] [Create a new merge request](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) +- [ ] [Automatically close issues from merge requests](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) +- [ ] [Enable merge request approvals](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) +- [ ] [Automatically merge when pipeline succeeds](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) + +## Test and Deploy + +Use the built-in continuous integration in GitLab. + +- [ ] [Get started with GitLab CI/CD](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/ci/quick_start/index.html) +- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/application_security/sast/) +- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/topics/autodevops/requirements.html) +- [ ] [Use pull-based deployments for improved Kubernetes management](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/user/clusters/agent/) +- [ ] [Set up protected environments](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://docs.gitlab.com/ee/ci/environments/protected_environments.html) + +*** + +# Editing this README + +When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://gitlab.com/-/experiment/new_project_readme_content:9529efb8c774508b24431e4d43ca8b4e?https://www.makeareadme.com/) for this template. + +## Suggestions for a good README +Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. + +## Name +Choose a self-explaining name for your project. + +## Description +Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. + +## Badges +On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. + +## Visuals +Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. + +## Installation +Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. + +## Usage +Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. + +## Support +Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. + +## Roadmap +If you have ideas for releases in the future, it is a good idea to list them in the README. + +## Contributing +State if you are open to contributions and what your requirements are for accepting them. + +For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. + +You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. + +## Authors and acknowledgment +Show your appreciation to those who have contributed to the project. + +## License +For open source projects, say how it is licensed. + +## Project status +If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. + From c2ced77bca8ab1ada2e12b2fe7df7b3c1501eceb Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Mon, 24 Jan 2022 14:57:08 +0300 Subject: [PATCH 2/6] shimmer --- lib/ui/landing/dashboard.dart | 193 +++++++++------------------------- pubspec.lock | 17 ++- pubspec.yaml | 1 + 3 files changed, 64 insertions(+), 147 deletions(-) diff --git a/lib/ui/landing/dashboard.dart b/lib/ui/landing/dashboard.dart index 2c8367a..ac427d1 100644 --- a/lib/ui/landing/dashboard.dart +++ b/lib/ui/landing/dashboard.dart @@ -8,7 +8,9 @@ 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/theme/colors.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; +import 'package:shimmer/shimmer.dart'; class Dashboard extends StatefulWidget { Dashboard({Key? key}) : super(key: key); @@ -32,34 +34,14 @@ class _DashboardState extends State { @override Widget build(BuildContext context) { - List names = [ - LocaleKeys.workList.tr(), - LocaleKeys.missingSwipes.tr(), - LocaleKeys.leaveBalance.tr(), - LocaleKeys.ticketBalance.tr() - ]; + List names = [LocaleKeys.workList.tr(), LocaleKeys.missingSwipes.tr(), LocaleKeys.leaveBalance.tr(), LocaleKeys.ticketBalance.tr()]; List namesInt = [118, 02, 18.5, 03]; List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; - List namesT = [ - LocaleKeys.monthlyAttendance.tr(), - LocaleKeys.workFromHome.tr(), - LocaleKeys.ticketRequest.tr(), - LocaleKeys.monthlyAttendance.tr() - ]; - List iconT = [ - "assets/images/monthly_attendance.svg", - "assets/images/work_from_home.svg", - "assets/images/ticket_request.svg", - "assets/images/work_from_home.svg" - ]; + List namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()]; + List iconT = ["assets/images/monthly_attendance.svg", "assets/images/work_from_home.svg", "assets/images/ticket_request.svg", "assets/images/work_from_home.svg"]; - List namesD = [ - "Nostalgia Perfume Perfume", - "Al Nafoura", - "AlJadi", - "Nostalgia Perfume" - ]; + List namesD = ["Nostalgia Perfume Perfume", "Al Nafoura", "AlJadi", "Nostalgia Perfume"]; return Scaffold( body: Column( @@ -72,8 +54,7 @@ class _DashboardState extends State { CircularAvatar( width: 34, height: 34, - url: - "https://cdn4.iconfinder.com/data/icons/professions-2-2/151/89-512.png", + url: "https://cdn4.iconfinder.com/data/icons/professions-2-2/151/89-512.png", ), 8.width, SvgPicture.asset("assets/images/side_nav.svg"), @@ -103,9 +84,7 @@ class _DashboardState extends State { top: 0, child: Container( padding: const EdgeInsets.only(left: 5, right: 5), - decoration: BoxDecoration( - color: MyColors.redColor, - borderRadius: BorderRadius.circular(17)), + decoration: BoxDecoration(color: MyColors.redColor, borderRadius: BorderRadius.circular(17)), child: "3".toText12(color: Colors.white), ), ) @@ -121,9 +100,7 @@ class _DashboardState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.goodMorning - .tr() - .toText14(color: MyColors.grey77Color), + LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color), "Mahmoud Shrouf".toText24(isBold: true), 16.height, Row( @@ -134,41 +111,27 @@ class _DashboardState extends State { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient( - transform: GradientRotation(.46), - begin: Alignment.topRight, - end: Alignment.bottomRight, - colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), + gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), ), child: Stack( alignment: Alignment.center, children: [ - SvgPicture.asset("assets/images/"), + // SvgPicture.asset("assets/images/"), Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.markAttendance - .tr() - .toText14( - color: Colors.white, - isBold: true), + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), 9.height, - "07:55:12".toText14( - color: Colors.white, - isBold: true), - LocaleKeys.timeLeftToday - .tr() - .toText12(color: Colors.white), + "07:55:12".toText14(color: Colors.white, isBold: true), + LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), 9.height, const ClipRRect( borderRadius: BorderRadius.all( @@ -177,50 +140,33 @@ class _DashboardState extends State { child: LinearProgressIndicator( value: 0.7, minHeight: 8, - valueColor: - const AlwaysStoppedAnimation< - Color>(Colors.white), - backgroundColor: - const Color(0xff196D73), + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), ), ), ], - ).paddingOnly( - top: 12, right: 15, left: 12), + ).paddingOnly(top: 12, right: 15, left: 12), ), Row( children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - LocaleKeys.checkIn - .tr() - .toText12( - color: Colors.white), - "09:00".toText14( - color: Colors.white, - isBold: true), - 4.height - ], + crossAxisAlignment: CrossAxisAlignment.start, + children: [LocaleKeys.checkIn.tr().toText12(color: Colors.white), "09:00".toText14(color: Colors.white, isBold: true), 4.height], ).paddingOnly(left: 12), ), Container( width: 45, height: 45, - padding: const EdgeInsets.only( - left: 14, right: 14), + padding: const EdgeInsets.only(left: 14, right: 14), decoration: const BoxDecoration( color: Color(0xff259EA4), borderRadius: BorderRadius.only( - bottomRight: - Radius.circular(15), + bottomRight: Radius.circular(15), ), ), - child: SvgPicture.asset( - "assets/images/stop.svg"), + child: SvgPicture.asset("assets/images/stop.svg"), ), ], ), @@ -229,8 +175,7 @@ class _DashboardState extends State { ], ), ).onPress(() { - Navigator.pushNamed( - context, AppRoutes.todayAttendance); + Navigator.pushNamed(context, AppRoutes.todayAttendance); }), ), ), @@ -240,12 +185,7 @@ class _DashboardState extends State { shrinkWrap: true, primary: false, physics: const NeverScrollableScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - childAspectRatio: 2 / 2, - crossAxisSpacing: 9, - mainAxisSpacing: 9), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), padding: EdgeInsets.zero, itemCount: 4, itemBuilder: (BuildContext context, int index) { @@ -255,31 +195,22 @@ class _DashboardState extends State { borderRadius: BorderRadius.circular(10), ), child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ names[index].toText12(color: Colors.white), Row( children: [ Expanded( - child: namesInt[index] - .toStringAsFixed(1) - .toText16( - color: Colors.white, - isBold: true), + child: namesInt[index].toStringAsFixed(1).toText16(color: Colors.white, isBold: true), ), - SvgPicture.asset( - "assets/images/arrow_next.svg", - color: Colors.white) + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) ], ) ], - ).paddingOnly( - left: 10, right: 10, bottom: 6, top: 6), + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), ).onPress(() { - Navigator.pushNamed( - context, AppRoutes.workList); + Navigator.pushNamed(context, AppRoutes.workList); }); }, ), @@ -300,9 +231,7 @@ class _DashboardState extends State { ], ), ), - LocaleKeys.viewAllServices - .tr() - .toText12(isUnderLine: true), + LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), ], ), ], @@ -312,8 +241,7 @@ class _DashboardState extends State { child: ListView.separated( shrinkWrap: true, physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only( - left: 21, right: 21, top: 13, bottom: 13), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { return AspectRatio( @@ -324,8 +252,7 @@ class _DashboardState extends State { borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( - color: - const Color(0xff000000).withOpacity(.05), + color: const Color(0xff000000).withOpacity(.05), blurRadius: 26, offset: const Offset(0, -3), ), @@ -340,17 +267,13 @@ class _DashboardState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( - child: - namesT[index].toText11(isBold: true), + child: namesT[index].toText11(isBold: true), ), - SvgPicture.asset( - "assets/images/arrow_next.svg") - .paddingOnly(bottom: 4) + SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) ], ) ], - ).paddingOnly( - left: 10, right: 10, bottom: 10, top: 12), + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), ), ); }, @@ -363,11 +286,8 @@ class _DashboardState extends State { padding: EdgeInsets.only(top: 31), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.only( - topRight: Radius.circular(50), - topLeft: Radius.circular(50)), - border: - Border.all(color: MyColors.lightGreyEDColor, width: 1), + borderRadius: BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: Column( mainAxisSize: MainAxisSize.min, @@ -383,29 +303,21 @@ class _DashboardState extends State { LocaleKeys.offers.tr().toText12(), Row( children: [ - LocaleKeys.discounts - .tr() - .toText24(isBold: true), + LocaleKeys.discounts.tr().toText24(isBold: true), 6.width, Container( - padding: const EdgeInsets.only( - left: 8, right: 8), + padding: const EdgeInsets.only(left: 8, right: 8), decoration: BoxDecoration( color: MyColors.yellowColor, - borderRadius: - BorderRadius.circular(10), + borderRadius: BorderRadius.circular(10), ), - child: LocaleKeys.newString - .tr() - .toText10(isBold: true)), + child: LocaleKeys.newString.tr().toText10(isBold: true)), ], ), ], ), ), - LocaleKeys.viewAllOffers - .tr() - .toText12(isUnderLine: true), + LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true), ], ).paddingOnly(left: 21, right: 21), SizedBox( @@ -413,8 +325,7 @@ class _DashboardState extends State { child: ListView.separated( shrinkWrap: true, physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only( - left: 21, right: 21, top: 13), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { return SizedBox( @@ -429,9 +340,7 @@ class _DashboardState extends State { borderRadius: const BorderRadius.all( Radius.circular(100), ), - border: Border.all( - color: MyColors.lightGreyEDColor, - width: 1), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: ClipRRect( borderRadius: const BorderRadius.all( @@ -445,8 +354,8 @@ class _DashboardState extends State { ), 4.height, Expanded( - child: namesD[6 % (index + 1)].toText12( - isCenter: true, maxLine: 2)), + child: namesD[6 % (index + 1)].toText12(isCenter: true, maxLine: 2), + ), ], ), ); diff --git a/pubspec.lock b/pubspec.lock index 56d2f3f..1ae9d08 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,7 +14,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -202,7 +202,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: @@ -392,6 +392,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.3" + shimmer: + dependency: "direct main" + description: + name: shimmer + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" sizer: dependency: "direct main" description: @@ -445,7 +452,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" typed_data: dependency: transitive description: @@ -466,7 +473,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dfbb0eb..868012d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,7 @@ dependencies: sizer: ^2.0.15 local_auth: ^1.1.9 fluttertoast: ^8.0.8 + shimmer: ^2.0.0 dev_dependencies: From ab25a98a9efa88da930c61ad170e81b8a2668797 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Sun, 30 Jan 2022 10:29:07 +0300 Subject: [PATCH 3/6] 1.1 --- lib/generated/locale_keys.g.dart | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/generated/locale_keys.g.dart diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart new file mode 100644 index 0000000..24d7171 --- /dev/null +++ b/lib/generated/locale_keys.g.dart @@ -0,0 +1,69 @@ +// DO NOT EDIT. This is code generated via package:easy_localization/generate.dart + +abstract class LocaleKeys { + static const mohemm = 'mohemm'; + static const english = 'english'; + static const arabic = 'arabic'; + static const login = 'login'; + static const pleaseEnterLoginDetails = 'pleaseEnterLoginDetails'; + static const username = 'username'; + static const password = 'password'; + static const welcomeBack = 'welcomeBack'; + static const wouldYouLikeToLoginWithCurrentUsername = 'wouldYouLikeToLoginWithCurrentUsername'; + static const lastLoginDetails = 'lastLoginDetails'; + static const verificationType = 'verificationType'; + static const pleaseVerify = 'pleaseVerify'; + static const verifyThroughFace = 'verifyThroughFace'; + static const verifyThroughFingerprint = 'verifyThroughFingerprint'; + static const verifyThroughSMS = 'verifyThroughSMS'; + static const verifyThroughWhatsapp = 'verifyThroughWhatsapp'; + static const useAnotherAccount = 'useAnotherAccount'; + static const pleaseEnterTheVerificationCodeSentTo = 'pleaseEnterTheVerificationCodeSentTo'; + static const theVerificationCodeWillExpireIn = 'theVerificationCodeWillExpireIn'; + static const goodMorning = 'goodMorning'; + static const markAttendance = 'markAttendance'; + static const timeLeftToday = 'timeLeftToday'; + static const checkIn = 'checkIn'; + static const workList = 'workList'; + static const leaveBalance = 'leaveBalance'; + static const missingSwipes = 'missingSwipes'; + static const ticketBalance = 'ticketBalance'; + static const services = 'services'; + static const viewAllServices = 'viewAllServices'; + static const monthlyAttendance = 'monthlyAttendance'; + static const workFromHome = 'workFromHome'; + static const ticketRequest = 'ticketRequest'; + static const viewAllOffers = 'viewAllOffers'; + static const offers = 'offers'; + static const discounts = 'discounts'; + static const newString = 'newString'; + static const setTheNewPassword = 'setTheNewPassword'; + static const typeYourNewPasswordBelow = 'typeYourNewPasswordBelow'; + static const confirmPassword = 'confirmPassword'; + static const update = 'update'; + static const title = 'title'; + static const home = 'home'; + static const mySalary = 'mySalary'; + static const createRequest = 'createRequest'; + static const forgotPassword = 'forgotPassword'; + static const employeeId = 'employeeId'; + static const loginCodeWillSentToMobileNumber = 'loginCodeWillSentToMobileNumber'; + static const changePassword = 'changePassword'; + static const itemsForSale = 'itemsForSale'; + static const msg = 'msg'; + static const msg_named = 'msg_named'; + static const clickMe = 'clickMe'; + static const human = 'human'; + static const resources = 'resources'; + 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'; + static const profile_reset_password = 'profile.reset_password'; + static const profile = 'profile'; + static const clicked = 'clicked'; + static const amount = 'amount'; + static const gender_with_arg = 'gender.with_arg'; + static const gender = 'gender'; + static const reset_locale = 'reset_locale'; + +} From baa7182655cccdeddec21f6ff55307b5c19fe29c Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Mon, 31 Jan 2022 10:11:26 +0300 Subject: [PATCH 4/6] Dashboard API's 1.0 --- lib/api/api_client.dart | 3 + lib/api/dashboard_api_client.dart | 69 +++++++ lib/api/login_api_client.dart | 7 + lib/app_state/app_state.dart | 14 +- lib/classes/consts.dart | 3 + .../get_accrual_balances_list_model.dart | 39 ++++ .../get_attendance_tracking_list_model.dart | 55 +++++ .../get_open_missing_swipes_list_model.dart | 24 +++ .../get_open_notifications_list.dart | 23 +++ lib/models/dashboard/itg_forms_model.dart | 189 ++++++++++++++++++ lib/models/generic_response_model.dart | 23 ++- lib/models/post_params_model.dart | 51 ++++- lib/ui/landing/dashboard.dart | 5 +- lib/ui/login/login_screen.dart | 4 +- lib/ui/login/verify_login_screen.dart | 4 +- 15 files changed, 497 insertions(+), 16 deletions(-) create mode 100644 lib/api/dashboard_api_client.dart create mode 100644 lib/models/dashboard/get_accrual_balances_list_model.dart create mode 100644 lib/models/dashboard/get_attendance_tracking_list_model.dart create mode 100644 lib/models/dashboard/get_open_missing_swipes_list_model.dart create mode 100644 lib/models/dashboard/get_open_notifications_list.dart create mode 100644 lib/models/dashboard/itg_forms_model.dart diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index dcd184e..a08ed01 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -75,6 +75,9 @@ class ApiClient { } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); try { + if (!kReleaseMode) { + print("res: " + response.body); + } var jsonData = jsonDecode(response.body); if (jsonData["ErrorMessage"] == null) { return factoryConstructor(jsonData); diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart new file mode 100644 index 0000000..5b6f961 --- /dev/null +++ b/lib/api/dashboard_api_client.dart @@ -0,0 +1,69 @@ +import 'dart:async'; + +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; +import 'package:mohem_flutter_app/models/check_mobile_app_version_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/member_login_list_model.dart'; + +import 'api_client.dart'; + +class DashbaordApiClient { + static final DashbaordApiClient _instance = DashbaordApiClient._internal(); + + DashbaordApiClient._internal(); + + factory DashbaordApiClient() => _instance; + + Future getAttendanceTracking() async { + String url = "${ApiConsts.erpRest}GET_Attendance_Tracking"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + + Future getOpenNotifications() async { + String url = "${ApiConsts.erpRest}GET_OPEN_NOTIFICATIONS"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + + Future getItgFormsPendingTask() async { + String url = "${ApiConsts.cocRest}ITGFormsPendingTasks"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + ItgFormsModel responseData = ItgFormsModel.fromJson(json); + return responseData; + }, url, postParams); + } + + Future getAccrualBalances() async { + String url = "${ApiConsts.erpRest}GET_ACCRUAL_BALANCES"; + Map postParams = {"P_EFFECTIVE_DATE": "1/30/2022"}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + + Future getOpenMissingSwipes() async { + String url = "${ApiConsts.erpRest}GET_OPEN_MISSING_SWIPES"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } +} diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index 1811414..fb6bb80 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -47,7 +47,14 @@ class LoginApiClient { postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); + AppState().setLogged = true; AppState().postParamsObject?.setTokenID = responseData.tokenID; + AppState().postParamsObject?.mobileNumber = responseData.basicMemberInformation!.pMOBILENUMBER; + AppState().postParamsObject?.userName = AppState().getUserName; + AppState().postParamsObject?.pEmailAddress = responseData.basicMemberInformation!.pEMAILADDRESS; + AppState().postParamsObject?.pSessionId = responseData.pSESSIONID; + AppState().postParamsObject?.pUserName = AppState().getUserName; + AppState().postParamsObject?.pSelectedEmployeeNumber = AppState().getUserName; return responseData; }, url, postParams); } diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 2af87d8..65d5184 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -8,6 +8,12 @@ class AppState { factory AppState() => _instance; + bool isLogged = false; + + set setLogged(v) => isLogged = v; + + bool? get getIsLogged => isLogged; + String? forgetPasswordTokenID; set setForgetPasswordTokenID(token) => forgetPasswordTokenID = token; @@ -18,15 +24,17 @@ class AppState { PostParamsModel? get postParamsObject => _postParams; - Map get postParamsJson => _postParams?.toJson() ?? {}; + Map get postParamsJson => isLogged ? (_postParams?.toJsonAfterLogin() ?? {}) : (_postParams?.toJson() ?? {}); void setPostParamsModel(PostParamsModel _postParams) { this._postParams = _postParams; } - String? username; + String? _username; + + set setUserName(v) => _username = v; - set setUserName(_username) => username = _username; + String? get getUserName => _username; MemberLoginListModel? _memberLoginList; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index b0453c0..4bad83c 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -6,8 +6,11 @@ class ApiConsts { static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; static String erpRest = baseUrlServices + "ERP.svc/REST/"; static String user = baseUrlServices + "api/User/"; + static String cocRest = baseUrlServices + "COCWS.svc/REST/"; } + + class GlobalConsts { static String isRememberMe = "remember_me"; static String email = "email"; diff --git a/lib/models/dashboard/get_accrual_balances_list_model.dart b/lib/models/dashboard/get_accrual_balances_list_model.dart new file mode 100644 index 0000000..a53133e --- /dev/null +++ b/lib/models/dashboard/get_accrual_balances_list_model.dart @@ -0,0 +1,39 @@ +class GetAccrualBalancesList { + GetAccrualBalancesList({ + this.accrualNetEntitlement, + this.accrualUsedEntitlement, + this.accrualYearlyEntitlement, + this.accuralPlanName, + this.endDate, + this.lastAccrualDate, + this.startDate, + }); + + double? accrualNetEntitlement; + int? accrualUsedEntitlement; + dynamic accrualYearlyEntitlement; + String? accuralPlanName; + String? endDate; + String? lastAccrualDate; + String? startDate; + + factory GetAccrualBalancesList.fromJson(Map json) => GetAccrualBalancesList( + accrualNetEntitlement: json["ACCRUAL_NET_ENTITLEMENT"] == null ? null : json["ACCRUAL_NET_ENTITLEMENT"].toDouble(), + accrualUsedEntitlement: json["ACCRUAL_USED_ENTITLEMENT"] == null ? null : json["ACCRUAL_USED_ENTITLEMENT"], + accrualYearlyEntitlement: json["ACCRUAL_YEARLY_ENTITLEMENT"], + accuralPlanName: json["ACCURAL_PLAN_NAME"] == null ? null : json["ACCURAL_PLAN_NAME"], + endDate: json["END_DATE"] == null ? null : json["END_DATE"], + lastAccrualDate: json["LAST_ACCRUAL_DATE"] == null ? null : json["LAST_ACCRUAL_DATE"], + startDate: json["START_DATE"] == null ? null : json["START_DATE"], + ); + + Map toJson() => { + "ACCRUAL_NET_ENTITLEMENT": accrualNetEntitlement == null ? null : accrualNetEntitlement, + "ACCRUAL_USED_ENTITLEMENT": accrualUsedEntitlement == null ? null : accrualUsedEntitlement, + "ACCRUAL_YEARLY_ENTITLEMENT": accrualYearlyEntitlement, + "ACCURAL_PLAN_NAME": accuralPlanName == null ? null : accuralPlanName, + "END_DATE": endDate == null ? null : endDate, + "LAST_ACCRUAL_DATE": lastAccrualDate == null ? null : lastAccrualDate, + "START_DATE": startDate == null ? null : startDate, + }; +} diff --git a/lib/models/dashboard/get_attendance_tracking_list_model.dart b/lib/models/dashboard/get_attendance_tracking_list_model.dart new file mode 100644 index 0000000..66b9ed8 --- /dev/null +++ b/lib/models/dashboard/get_attendance_tracking_list_model.dart @@ -0,0 +1,55 @@ +class GetAttendanceTrackingList { + GetAttendanceTrackingList({ + this.pBreakHours, + this.pLateInHours, + this.pRemainingHours, + this.pReturnMsg, + this.pReturnStatus, + this.pScheduledHours, + this.pShtName, + this.pSpentHours, + this.pSwipesExemptedFlag, + this.pSwipeIn, + this.pSwipeOut, + }); + + String? pBreakHours; + String? pLateInHours; + String? pRemainingHours; + String? pReturnMsg; + String? pReturnStatus; + String? pScheduledHours; + String? pShtName; + String? pSpentHours; + String? pSwipesExemptedFlag; + dynamic pSwipeIn; + dynamic pSwipeOut; + + factory GetAttendanceTrackingList.fromMap(Map json) => GetAttendanceTrackingList( + pBreakHours: json["P_BREAK_HOURS"] == null ? null : json["P_BREAK_HOURS"], + pLateInHours: json["P_LATE_IN_HOURS"] == null ? null : json["P_LATE_IN_HOURS"], + pRemainingHours: json["P_REMAINING_HOURS"] == null ? null : json["P_REMAINING_HOURS"], + pReturnMsg: json["P_RETURN_MSG"] == null ? null : json["P_RETURN_MSG"], + pReturnStatus: json["P_RETURN_STATUS"] == null ? null : json["P_RETURN_STATUS"], + pScheduledHours: json["P_SCHEDULED_HOURS"] == null ? null : json["P_SCHEDULED_HOURS"], + pShtName: json["P_SHT_NAME"] == null ? null : json["P_SHT_NAME"], + pSpentHours: json["P_SPENT_HOURS"] == null ? null : json["P_SPENT_HOURS"], + pSwipesExemptedFlag: json["P_SWIPES_EXEMPTED_FLAG"] == null ? null : json["P_SWIPES_EXEMPTED_FLAG"], + pSwipeIn: json["P_SWIPE_IN"], + pSwipeOut: json["P_SWIPE_OUT"], + ); + + Map toMap() => { + "P_BREAK_HOURS": pBreakHours == null ? null : pBreakHours, + "P_LATE_IN_HOURS": pLateInHours == null ? null : pLateInHours, + "P_REMAINING_HOURS": pRemainingHours == null ? null : pRemainingHours, + "P_RETURN_MSG": pReturnMsg == null ? null : pReturnMsg, + "P_RETURN_STATUS": pReturnStatus == null ? null : pReturnStatus, + "P_SCHEDULED_HOURS": pScheduledHours == null ? null : pScheduledHours, + "P_SHT_NAME": pShtName == null ? null : pShtName, + "P_SPENT_HOURS": pSpentHours == null ? null : pSpentHours, + "P_SWIPES_EXEMPTED_FLAG": pSwipesExemptedFlag == null ? null : pSwipesExemptedFlag, + "P_SWIPE_IN": pSwipeIn, + "P_SWIPE_OUT": pSwipeOut, + }; +} diff --git a/lib/models/dashboard/get_open_missing_swipes_list_model.dart b/lib/models/dashboard/get_open_missing_swipes_list_model.dart new file mode 100644 index 0000000..86ac6a9 --- /dev/null +++ b/lib/models/dashboard/get_open_missing_swipes_list_model.dart @@ -0,0 +1,24 @@ + +class GetOpenMissingSwipesList { + GetOpenMissingSwipesList({ + this.pOpenMissingSwipes, + this.pReturnMsg, + this.pReturnStatus, + }); + + int? pOpenMissingSwipes; + String? pReturnMsg; + String? pReturnStatus; + + factory GetOpenMissingSwipesList.fromJson(Map json) => GetOpenMissingSwipesList( + pOpenMissingSwipes: json["P_OPEN_MISSING_SWIPES"] == null ? null : json["P_OPEN_MISSING_SWIPES"], + pReturnMsg: json["P_RETURN_MSG"] == null ? null : json["P_RETURN_MSG"], + pReturnStatus: json["P_RETURN_STATUS"] == null ? null : json["P_RETURN_STATUS"], + ); + + Map toJson() => { + "P_OPEN_MISSING_SWIPES": pOpenMissingSwipes == null ? null : pOpenMissingSwipes, + "P_RETURN_MSG": pReturnMsg == null ? null : pReturnMsg, + "P_RETURN_STATUS": pReturnStatus == null ? null : pReturnStatus, + }; +} diff --git a/lib/models/dashboard/get_open_notifications_list.dart b/lib/models/dashboard/get_open_notifications_list.dart new file mode 100644 index 0000000..854b62a --- /dev/null +++ b/lib/models/dashboard/get_open_notifications_list.dart @@ -0,0 +1,23 @@ +class GetOpenNotificationsList { + GetOpenNotificationsList({ + this.itemType, + this.itemTypeDisplayName, + this.openNtfNumber, + }); + + String? itemType; + String? itemTypeDisplayName; + int? openNtfNumber; + + factory GetOpenNotificationsList.fromMap(Map json) => GetOpenNotificationsList( + itemType: json["ITEM_TYPE"] == null ? null : json["ITEM_TYPE"], + itemTypeDisplayName: json["ITEM_TYPE_DISPLAY_NAME"] == null ? null : json["ITEM_TYPE_DISPLAY_NAME"], + openNtfNumber: json["OPEN_NTF_NUMBER"] == null ? null : json["OPEN_NTF_NUMBER"], + ); + + Map toMap() => { + "ITEM_TYPE": itemType == null ? null : itemType, + "ITEM_TYPE_DISPLAY_NAME": itemTypeDisplayName == null ? null : itemTypeDisplayName, + "OPEN_NTF_NUMBER": openNtfNumber == null ? null : openNtfNumber, + }; +} diff --git a/lib/models/dashboard/itg_forms_model.dart b/lib/models/dashboard/itg_forms_model.dart new file mode 100644 index 0000000..c5a0145 --- /dev/null +++ b/lib/models/dashboard/itg_forms_model.dart @@ -0,0 +1,189 @@ +// To parse this JSON data, do +// +// final itgFormsModel = itgFormsModelFromMap(jsonString); + +import 'dart:convert'; + +ItgFormsModel itgFormsModelFromMap(String str) => ItgFormsModel.fromJson(json.decode(str)); + +String itgFormsModelToMap(ItgFormsModel data) => json.encode(data.toMap()); + +class ItgFormsModel { + ItgFormsModel({ + this.date, + this.languageId, + this.serviceName, + this.time, + this.androidLink, + this.authenticationTokenId, + this.data, + this.dataw, + this.dietType, + this.dietTypeId, + this.errorCode, + this.errorEndUserMessage, + this.errorEndUserMessageN, + this.errorMessage, + this.errorType, + this.foodCategory, + this.iosLink, + this.isAuthenticated, + this.mealOrderStatus, + this.mealType, + this.messageStatus, + this.numberOfResultRecords, + this.patientBlodType, + this.successMsg, + this.successMsgN, + this.vidaUpdatedResponse, + this.itgRequest, + this.itgFormAttachmentsList, + this.message, + this.mohemmItgDepartmentSectionsList, + this.mohemmItgProjectDepartmentsList, + this.mohemmItgResponseItem, + this.mohemmItgSectionTopicsList, + this.mohemmItgTicketDetailsList, + this.mohemmItgTicketTransactionsList, + this.mohemmItgTicketsByEmployeeList, + this.mohemmItgProjectsList, + this.mohemmItgTicketTypesList, + this.referenceNumber, + this.requestType, + this.totalCount, + this.statuseCode, + }); + + dynamic date; + int? languageId; + int? serviceName; + dynamic time; + dynamic androidLink; + dynamic authenticationTokenId; + dynamic data; + bool? dataw; + int? dietType; + int? dietTypeId; + dynamic errorCode; + dynamic errorEndUserMessage; + dynamic errorEndUserMessageN; + dynamic errorMessage; + int? errorType; + int? foodCategory; + dynamic iosLink; + bool? isAuthenticated; + int? mealOrderStatus; + int? mealType; + int? messageStatus; + int? numberOfResultRecords; + dynamic patientBlodType; + String? successMsg; + dynamic successMsgN; + dynamic vidaUpdatedResponse; + dynamic itgRequest; + dynamic itgFormAttachmentsList; + String? message; + dynamic mohemmItgDepartmentSectionsList; + dynamic mohemmItgProjectDepartmentsList; + dynamic mohemmItgResponseItem; + dynamic mohemmItgSectionTopicsList; + dynamic mohemmItgTicketDetailsList; + dynamic mohemmItgTicketTransactionsList; + dynamic mohemmItgTicketsByEmployeeList; + dynamic mohemmItgProjectsList; + dynamic mohemmItgTicketTypesList; + DateTime? referenceNumber; + dynamic requestType; + int? totalCount; + int? statuseCode; + + factory ItgFormsModel.fromJson(Map json) => ItgFormsModel( + date: json["Date"], + languageId: json["LanguageID"] == null ? null : json["LanguageID"], + serviceName: json["ServiceName"] == null ? null : json["ServiceName"], + time: json["Time"], + androidLink: json["AndroidLink"], + authenticationTokenId: json["AuthenticationTokenID"], + data: json["Data"], + dataw: json["Dataw"] == null ? null : json["Dataw"], + dietType: json["DietType"] == null ? null : json["DietType"], + dietTypeId: json["DietTypeID"] == null ? null : json["DietTypeID"], + errorCode: json["ErrorCode"], + errorEndUserMessage: json["ErrorEndUserMessage"], + errorEndUserMessageN: json["ErrorEndUserMessageN"], + errorMessage: json["ErrorMessage"], + errorType: json["ErrorType"] == null ? null : json["ErrorType"], + foodCategory: json["FoodCategory"] == null ? null : json["FoodCategory"], + iosLink: json["IOSLink"], + isAuthenticated: json["IsAuthenticated"] == null ? null : json["IsAuthenticated"], + mealOrderStatus: json["MealOrderStatus"] == null ? null : json["MealOrderStatus"], + mealType: json["MealType"] == null ? null : json["MealType"], + messageStatus: json["MessageStatus"] == null ? null : json["MessageStatus"], + numberOfResultRecords: json["NumberOfResultRecords"] == null ? null : json["NumberOfResultRecords"], + patientBlodType: json["PatientBlodType"], + successMsg: json["SuccessMsg"] == null ? null : json["SuccessMsg"], + successMsgN: json["SuccessMsgN"], + vidaUpdatedResponse: json["VidaUpdatedResponse"], + itgRequest: json["ITGRequest"], + itgFormAttachmentsList: json["Itg_FormAttachmentsList"], + message: json["Message"] == null ? null : json["Message"], + mohemmItgDepartmentSectionsList: json["Mohemm_ITG_DepartmentSectionsList"], + mohemmItgProjectDepartmentsList: json["Mohemm_ITG_ProjectDepartmentsList"], + mohemmItgResponseItem: json["Mohemm_ITG_ResponseItem"], + mohemmItgSectionTopicsList: json["Mohemm_ITG_SectionTopicsList"], + mohemmItgTicketDetailsList: json["Mohemm_ITG_TicketDetailsList"], + mohemmItgTicketTransactionsList: json["Mohemm_ITG_TicketTransactionsList"], + mohemmItgTicketsByEmployeeList: json["Mohemm_ITG_TicketsByEmployeeList"], + mohemmItgProjectsList: json["Mohemm_Itg_ProjectsList"], + mohemmItgTicketTypesList: json["Mohemm_Itg_TicketTypesList"], + referenceNumber: json["ReferenceNumber"] == null ? null : DateTime.parse(json["ReferenceNumber"]), + requestType: json["RequestType"], + totalCount: json["TotalCount"] == null ? null : json["TotalCount"], + statuseCode: json["statuseCode"] == null ? null : json["statuseCode"], + ); + + Map toMap() => { + "Date": date, + "LanguageID": languageId == null ? null : languageId, + "ServiceName": serviceName == null ? null : serviceName, + "Time": time, + "AndroidLink": androidLink, + "AuthenticationTokenID": authenticationTokenId, + "Data": data, + "Dataw": dataw == null ? null : dataw, + "DietType": dietType == null ? null : dietType, + "DietTypeID": dietTypeId == null ? null : dietTypeId, + "ErrorCode": errorCode, + "ErrorEndUserMessage": errorEndUserMessage, + "ErrorEndUserMessageN": errorEndUserMessageN, + "ErrorMessage": errorMessage, + "ErrorType": errorType == null ? null : errorType, + "FoodCategory": foodCategory == null ? null : foodCategory, + "IOSLink": iosLink, + "IsAuthenticated": isAuthenticated == null ? null : isAuthenticated, + "MealOrderStatus": mealOrderStatus == null ? null : mealOrderStatus, + "MealType": mealType == null ? null : mealType, + "MessageStatus": messageStatus == null ? null : messageStatus, + "NumberOfResultRecords": numberOfResultRecords == null ? null : numberOfResultRecords, + "PatientBlodType": patientBlodType, + "SuccessMsg": successMsg == null ? null : successMsg, + "SuccessMsgN": successMsgN, + "VidaUpdatedResponse": vidaUpdatedResponse, + "ITGRequest": itgRequest, + "Itg_FormAttachmentsList": itgFormAttachmentsList, + "Message": message == null ? null : message, + "Mohemm_ITG_DepartmentSectionsList": mohemmItgDepartmentSectionsList, + "Mohemm_ITG_ProjectDepartmentsList": mohemmItgProjectDepartmentsList, + "Mohemm_ITG_ResponseItem": mohemmItgResponseItem, + "Mohemm_ITG_SectionTopicsList": mohemmItgSectionTopicsList, + "Mohemm_ITG_TicketDetailsList": mohemmItgTicketDetailsList, + "Mohemm_ITG_TicketTransactionsList": mohemmItgTicketTransactionsList, + "Mohemm_ITG_TicketsByEmployeeList": mohemmItgTicketsByEmployeeList, + "Mohemm_Itg_ProjectsList": mohemmItgProjectsList, + "Mohemm_Itg_TicketTypesList": mohemmItgTicketTypesList, + "ReferenceNumber": referenceNumber == null ? null : referenceNumber!.toIso8601String(), + "RequestType": requestType, + "TotalCount": totalCount == null ? null : totalCount, + "statuseCode": statuseCode == null ? null : statuseCode, + }; +} diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index b993db8..fad6e51 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -1,6 +1,10 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'basic_member_information_model.dart'; +import 'dashboard/get_accrual_balances_list_model.dart'; +import 'dashboard/get_attendance_tracking_list_model.dart'; +import 'dashboard/get_open_missing_swipes_list_model.dart'; +import 'dashboard/get_open_notifications_list.dart'; import 'member_information_list_model.dart'; import 'privilege_list_model.dart'; @@ -57,13 +61,13 @@ class GenericResponseModel { List? getAbsenceCollectionNotificationBodyList; List? getAbsenceDffStructureList; List? getAbsenceTransactionList; - List? getAccrualBalancesList; + List? getAccrualBalancesList; List? getActionHistoryList; List? getAddressDffStructureList; List? getAddressNotificationBodyList; List? getApprovesList; List? getAttachementList; - List? getAttendanceTrackingList; + GetAttendanceTrackingList? getAttendanceTrackingList; List? getBasicDetColsStructureList; List? getBasicDetDffStructureList; List? getBasicDetNtfBodyList; @@ -105,8 +109,8 @@ class GenericResponseModel { List? getNotificationButtonsList; List? getNotificationReassignModeList; List? getObjectValuesList; - List? getOpenMissingSwipesList; - List? getOpenNotificationsList; + GetOpenMissingSwipesList? getOpenMissingSwipesList; + List? getOpenNotificationsList; List? getOpenNotificationsNumList; List? getOpenPeriodDatesList; List? getOrganizationsSalariesList; @@ -563,13 +567,15 @@ class GenericResponseModel { getAbsenceCollectionNotificationBodyList = json['GetAbsenceCollectionNotificationBodyList']; getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; getAbsenceTransactionList = json['GetAbsenceTransactionList']; - getAccrualBalancesList = json['GetAccrualBalancesList']; + getAccrualBalancesList: + json["GetAccrualBalancesList"] == null ? null : List.from(json["GetAccrualBalancesList"].map((x) => GetAccrualBalancesList.fromJson(x))); getActionHistoryList = json['GetActionHistoryList']; getAddressDffStructureList = json['GetAddressDffStructureList']; getAddressNotificationBodyList = json['GetAddressNotificationBodyList']; getApprovesList = json['GetApprovesList']; getAttachementList = json['GetAttachementList']; - getAttendanceTrackingList = json['GetAttendanceTrackingList']; + getAttendanceTrackingList: + json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTrackingList.fromMap(json["GetAttendanceTrackingList"]); getBasicDetColsStructureList = json['GetBasicDetColsStructureList']; getBasicDetDffStructureList = json['GetBasicDetDffStructureList']; getBasicDetNtfBodyList = json['GetBasicDetNtfBodyList']; @@ -611,8 +617,9 @@ class GenericResponseModel { getNotificationButtonsList = json['GetNotificationButtonsList']; getNotificationReassignModeList = json['GetNotificationReassignModeList']; getObjectValuesList = json['GetObjectValuesList']; - getOpenMissingSwipesList = json['GetOpenMissingSwipesList']; - getOpenNotificationsList = json['GetOpenNotificationsList']; + getOpenMissingSwipesList: json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); + getOpenNotificationsList: + json["GetOpenNotificationsList"] == null ? null : List.from(json["GetOpenNotificationsList"].map((x) => GetOpenNotificationsList.fromMap(x))); getOpenNotificationsNumList = json['GetOpenNotificationsNumList']; getOpenPeriodDatesList = json['GetOpenPeriodDatesList']; getOrganizationsSalariesList = json['GetOrganizationsSalariesList']; diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index cd6dd72..1ab86f7 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -5,8 +5,27 @@ class PostParamsModel { String? mobileType; String? logInTokenID; String? tokenID; + String? mobileNumber; + String? pEmailAddress; + String? pUserName; + String? pSelectedEmployeeNumber; + int? pSessionId; + String? userName; - PostParamsModel({this.versionID, this.channel, this.languageID, this.mobileType, this.logInTokenID, this.tokenID}); + PostParamsModel({ + this.versionID, + this.channel, + this.languageID, + this.mobileType, + this.logInTokenID, + this.tokenID, + this.mobileNumber, + this.userName, + this.pEmailAddress, + this.pSessionId, + this.pUserName, + this.pSelectedEmployeeNumber, + }); PostParamsModel.fromJson(Map json) { versionID = json['VersionID']; @@ -28,7 +47,37 @@ class PostParamsModel { return data; } + Map toJsonAfterLogin() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['MobileType'] = this.mobileType; + data['LogInTokenID'] = this.logInTokenID; + data['TokenID'] = this.tokenID; + data['MobileNumber'] = this.mobileNumber; + data['UserName'] = this.userName; + data['P_EMAIL_ADDRESS'] = this.pEmailAddress; + data['P_SESSION_ID'] = this.pSessionId; + data['P_SELECTED_EMPLOYEE_NUMBER'] = this.pSelectedEmployeeNumber; + data['P_USER_NAME'] = this.pUserName; + + return data; + } + set setLogInTokenID(String? token) => logInTokenID = token; set setTokenID(String? token) => tokenID = token; + + set setMobileNumer(String? v) => mobileNumber = v; + + set setUserName(String? v) => userName = v; + + set setPEmailAddress(String? v) => pEmailAddress = v; + + set setPSessionId(int? v) => pSessionId = v; + + set setPUserName(String? v) => pUserName = v; + + set setPSelectedEmployeeNumber(String? v) => pSelectedEmployeeNumber = v; } diff --git a/lib/ui/landing/dashboard.dart b/lib/ui/landing/dashboard.dart index ac427d1..e8c2157 100644 --- a/lib/ui/landing/dashboard.dart +++ b/lib/ui/landing/dashboard.dart @@ -2,6 +2,7 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/api/dashboard_api_client.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'; @@ -25,6 +26,7 @@ class _DashboardState extends State { @override void initState() { super.initState(); + DashbaordApiClient().getAttendanceTracking(); } @override @@ -42,7 +44,8 @@ class _DashboardState extends State { List iconT = ["assets/images/monthly_attendance.svg", "assets/images/work_from_home.svg", "assets/images/ticket_request.svg", "assets/images/work_from_home.svg"]; List namesD = ["Nostalgia Perfume Perfume", "Al Nafoura", "AlJadi", "Nostalgia Perfume"]; - + // DashbaordApiClient().getOpenNotifications(); + DashbaordApiClient().getOpenMissingSwipes(); return Scaffold( body: Column( children: [ diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 5f0f266..2353f99 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -49,7 +49,7 @@ class _LoginScreenState extends State { _checkMobileAppVersion = await LoginApiClient().checkMobileAppVersion(); _memberLoginList = await LoginApiClient().memberLogin(username.text, password.text); AppState().setMemberLoginListModel = _memberLoginList; - AppState().username = username.text; + AppState().setUserName = username.text; print(_memberLoginList?.toJson()); Utils.hideLoading(context); Navigator.pushNamed(context, AppRoutes.verifyLogin); @@ -62,6 +62,8 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { + username.text="15153"; + password.text="e123e123e123"; return Scaffold( body: Column( children: [ diff --git a/lib/ui/login/verify_login_screen.dart b/lib/ui/login/verify_login_screen.dart index b28ad4d..ba0eb98 100644 --- a/lib/ui/login/verify_login_screen.dart +++ b/lib/ui/login/verify_login_screen.dart @@ -626,7 +626,7 @@ class _VerifyLoginScreenState extends State { } else { Utils.showLoading(context); BasicMemberInformationModel? memberInformationModel = await LoginApiClient() - .mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().username); + .mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName); Utils.hideLoading(context); OtpDialog( context, @@ -635,7 +635,7 @@ class _VerifyLoginScreenState extends State { (value) async { Utils.showLoading(context); try { - GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().username); + GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName); if (genericResponseModel?.errorMessage != null) { Utils.showToast(genericResponseModel?.errorMessage ?? ""); // Navigator.pop(context); From fb8d6c7b20d3c074d6f269c2636bd67a28e9d556 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Mon, 31 Jan 2022 17:46:43 +0300 Subject: [PATCH 5/6] Dashboard API's 1.1 --- assets/images/play.svg | 3 + assets/images/thumb.svg | 8 + lib/api/api_client.dart | 4 +- lib/api/dashboard_api_client.dart | 5 +- lib/config/routes.dart | 4 +- lib/extensions/widget_extensions.dart | 19 ++ lib/main.dart | 18 +- .../get_attendance_tracking_list_model.dart | 6 +- lib/models/generic_response_model.dart | 12 +- lib/provider/dashboard_provider_model.dart | 39 ++++ .../{dashboard.dart => dashboard_screen.dart} | 182 ++++++++++-------- .../shimmer/dashboard_shimmer_widget.dart | 82 ++++++++ pubspec.lock | 14 ++ pubspec.yaml | 2 + 14 files changed, 308 insertions(+), 90 deletions(-) create mode 100644 assets/images/play.svg create mode 100644 assets/images/thumb.svg create mode 100644 lib/provider/dashboard_provider_model.dart rename lib/ui/landing/{dashboard.dart => dashboard_screen.dart} (64%) create mode 100644 lib/widgets/shimmer/dashboard_shimmer_widget.dart diff --git a/assets/images/play.svg b/assets/images/play.svg new file mode 100644 index 0000000..1608b2e --- /dev/null +++ b/assets/images/play.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/thumb.svg b/assets/images/thumb.svg new file mode 100644 index 0000000..855ba71 --- /dev/null +++ b/assets/images/thumb.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index a08ed01..609aca9 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -7,6 +7,8 @@ import 'package:http/http.dart'; import 'package:http/io_client.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; +import '../main.dart'; + typedef FactoryConstructor = U Function(dynamic); class APIError { @@ -76,7 +78,7 @@ class ApiClient { var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); try { if (!kReleaseMode) { - print("res: " + response.body); + logger.i("res: " + response.body); } var jsonData = jsonDecode(response.body); if (jsonData["ErrorMessage"] == null) { diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 5b6f961..ad513e9 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -4,6 +4,7 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; import 'package:mohem_flutter_app/models/check_mobile_app_version_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; @@ -17,13 +18,13 @@ class DashbaordApiClient { factory DashbaordApiClient() => _instance; - Future getAttendanceTracking() async { + Future getAttendanceTracking() async { String url = "${ApiConsts.erpRest}GET_Attendance_Tracking"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); - return responseData; + return responseData.getAttendanceTrackingList; }, url, postParams); } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 39a4ebc..8e5a64e 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/ui/landing/dashboard.dart'; +import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart'; import 'package:mohem_flutter_app/ui/login/forgot_password_screen.dart'; import 'package:mohem_flutter_app/ui/login/login_screen.dart'; @@ -28,7 +28,7 @@ class AppRoutes { static final Map routes = { login: (context) => LoginScreen(), verifyLogin: (context) => VerifyLoginScreen(), - dashboard: (context) => Dashboard(), + dashboard: (context) => DashboardScreen(), newPassword: (context) => NewPasswordScreen(), forgotPassword: (context) => ForgotPasswordScreen(), todayAttendance: (context) => TodayAttendanceScreen(), diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 787894d..dc083ce 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:shimmer/shimmer.dart'; extension WidgetExtensions on Widget { Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this); @@ -8,4 +9,22 @@ extension WidgetExtensions on Widget { Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) => Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this); + + Widget toShimmer() => Shimmer.fromColors( + baseColor: Color(0xffe8eff0), + highlightColor: Colors.white, + child: Container( + child: this, + color: Colors.white, + )); + + Widget animatedSwither() => AnimatedSwitcher( + duration: const Duration(milliseconds: 500), + // transitionBuilder: (Widget child, Animation animation) { + // return ScaleTransition(scale: animation, child: child); + // }, + switchInCurve: Curves.linearToEaseOut, + switchOutCurve: Curves.linearToEaseOut, + child: this, + ); } diff --git a/lib/main.dart b/lib/main.dart index 99cff95..0b05d10 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,11 +6,22 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/config/app_provider.dart'; import 'package:mohem_flutter_app/generated/codegen_loader.g.dart'; import 'package:mohem_flutter_app/models/post_params_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/theme/app_theme.dart'; +import 'package:provider/provider.dart'; import 'package:sizer/sizer.dart'; +import 'package:logger/logger.dart'; import 'config/routes.dart'; + +var logger = Logger( + filter: null, // Use the default LogFilter (-> only log in debug mode) + printer: PrettyPrinter(), // Use the PrettyPrinter to format and print log + output: null, // U +); + + Future main() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); @@ -22,7 +33,12 @@ Future main() async { ], path: 'assets/langs', assetLoader: CodegenLoader(), - child: MyApp(), + child: MultiProvider( + providers: [ + ChangeNotifierProvider(create: (_) => DashboardProviderModel()), + ], + child: MyApp(), + ), ), ); } diff --git a/lib/models/dashboard/get_attendance_tracking_list_model.dart b/lib/models/dashboard/get_attendance_tracking_list_model.dart index 66b9ed8..fb415b0 100644 --- a/lib/models/dashboard/get_attendance_tracking_list_model.dart +++ b/lib/models/dashboard/get_attendance_tracking_list_model.dart @@ -1,5 +1,5 @@ -class GetAttendanceTrackingList { - GetAttendanceTrackingList({ +class GetAttendanceTracking { + GetAttendanceTracking({ this.pBreakHours, this.pLateInHours, this.pRemainingHours, @@ -25,7 +25,7 @@ class GetAttendanceTrackingList { dynamic pSwipeIn; dynamic pSwipeOut; - factory GetAttendanceTrackingList.fromMap(Map json) => GetAttendanceTrackingList( + factory GetAttendanceTracking.fromMap(Map json) => GetAttendanceTracking( pBreakHours: json["P_BREAK_HOURS"] == null ? null : json["P_BREAK_HOURS"], pLateInHours: json["P_LATE_IN_HOURS"] == null ? null : json["P_LATE_IN_HOURS"], pRemainingHours: json["P_REMAINING_HOURS"] == null ? null : json["P_REMAINING_HOURS"], diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index fad6e51..86552a0 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -67,7 +67,7 @@ class GenericResponseModel { List? getAddressNotificationBodyList; List? getApprovesList; List? getAttachementList; - GetAttendanceTrackingList? getAttendanceTrackingList; + GetAttendanceTracking? getAttendanceTrackingList; List? getBasicDetColsStructureList; List? getBasicDetDffStructureList; List? getBasicDetNtfBodyList; @@ -567,15 +567,15 @@ class GenericResponseModel { getAbsenceCollectionNotificationBodyList = json['GetAbsenceCollectionNotificationBodyList']; getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; getAbsenceTransactionList = json['GetAbsenceTransactionList']; - getAccrualBalancesList: + getAccrualBalancesList= json["GetAccrualBalancesList"] == null ? null : List.from(json["GetAccrualBalancesList"].map((x) => GetAccrualBalancesList.fromJson(x))); getActionHistoryList = json['GetActionHistoryList']; getAddressDffStructureList = json['GetAddressDffStructureList']; getAddressNotificationBodyList = json['GetAddressNotificationBodyList']; getApprovesList = json['GetApprovesList']; getAttachementList = json['GetAttachementList']; - getAttendanceTrackingList: - json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTrackingList.fromMap(json["GetAttendanceTrackingList"]); + getAttendanceTrackingList= + json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTracking.fromMap(json["GetAttendanceTrackingList"]); getBasicDetColsStructureList = json['GetBasicDetColsStructureList']; getBasicDetDffStructureList = json['GetBasicDetDffStructureList']; getBasicDetNtfBodyList = json['GetBasicDetNtfBodyList']; @@ -617,8 +617,8 @@ class GenericResponseModel { getNotificationButtonsList = json['GetNotificationButtonsList']; getNotificationReassignModeList = json['GetNotificationReassignModeList']; getObjectValuesList = json['GetObjectValuesList']; - getOpenMissingSwipesList: json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); - getOpenNotificationsList: + getOpenMissingSwipesList= json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); + getOpenNotificationsList= json["GetOpenNotificationsList"] == null ? null : List.from(json["GetOpenNotificationsList"].map((x) => GetOpenNotificationsList.fromMap(x))); getOpenNotificationsNumList = json['GetOpenNotificationsNumList']; getOpenPeriodDatesList = json['GetOpenPeriodDatesList']; diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart new file mode 100644 index 0000000..6ccbfc1 --- /dev/null +++ b/lib/provider/dashboard_provider_model.dart @@ -0,0 +1,39 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/main.dart'; +import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; + +/// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool +// ignore: prefer_mixin +class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { + bool isAttendanceTrackingLoading = true; + int isTimeRemainingInSeconds = 0; + GetAttendanceTracking? attendanceTracking; + + fetchAttendanceTracking() async { + try { + attendanceTracking = await DashbaordApiClient().getAttendanceTracking(); + isAttendanceTrackingLoading = false; + isTimeRemainingInSeconds = calculateSeconds("00:00:30"); + notifyListeners(); + } catch (ex) { + Utils.handleException(ex, null); + } + } + + int calculateSeconds(String time) { + int hour = int.parse(time.split(":")[0]); + int mints = int.parse(time.split(":")[1]); + int seconds = int.parse(time.split(":")[2]); + return ((hour * 60 * 60) + (mints * 60) + seconds); + } + + update() { + isAttendanceTrackingLoading = !isAttendanceTrackingLoading; + attendanceTracking?.pSwipeIn = "a"; + isTimeRemainingInSeconds = calculateSeconds("00:00:30"); + notifyListeners(); + } +} diff --git a/lib/ui/landing/dashboard.dart b/lib/ui/landing/dashboard_screen.dart similarity index 64% rename from lib/ui/landing/dashboard.dart rename to lib/ui/landing/dashboard_screen.dart index e8c2157..4a4ad94 100644 --- a/lib/ui/landing/dashboard.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -9,26 +10,33 @@ import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/theme/colors.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; +import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; +import 'package:provider/provider.dart'; import 'package:shimmer/shimmer.dart'; -class Dashboard extends StatefulWidget { - Dashboard({Key? key}) : super(key: key); +class DashboardScreen extends StatefulWidget { + DashboardScreen({Key? key}) : super(key: key); @override - _DashboardState createState() { - return _DashboardState(); + _DashboardScreenState createState() { + return _DashboardScreenState(); } } -class _DashboardState extends State { +class _DashboardScreenState extends State { @override void initState() { super.initState(); - DashbaordApiClient().getAttendanceTracking(); + final data = Provider.of(context, listen: false); + data.fetchAttendanceTracking(); } + int endTime = 0; + @override void dispose() { super.dispose(); @@ -44,8 +52,9 @@ class _DashboardState extends State { List iconT = ["assets/images/monthly_attendance.svg", "assets/images/work_from_home.svg", "assets/images/ticket_request.svg", "assets/images/work_from_home.svg"]; List namesD = ["Nostalgia Perfume Perfume", "Al Nafoura", "AlJadi", "Nostalgia Perfume"]; - // DashbaordApiClient().getOpenNotifications(); - DashbaordApiClient().getOpenMissingSwipes(); + final data = Provider.of(context); + + endTime=DateTime.now().millisecondsSinceEpoch + Duration(seconds: data.isTimeRemainingInSeconds).inMilliseconds; return Scaffold( body: Column( children: [ @@ -93,7 +102,9 @@ class _DashboardState extends State { ) ], ), - ) + ).onPress(() { + data.update(); + }) ], ).paddingOnly(left: 21, right: 21, top: 48, bottom: 7), Expanded( @@ -111,75 +122,96 @@ class _DashboardState extends State { Expanded( child: AspectRatio( aspectRatio: 159 / 159, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - child: Stack( - alignment: Alignment.center, - children: [ - // SvgPicture.asset("assets/images/"), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, + child: (data.isAttendanceTrackingLoading + ? GetAttendanceTrackingShimmer() + : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Stack( + alignment: Alignment.center, children: [ - LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), - 9.height, - "07:55:12".toText14(color: Colors.white, isBold: true), - LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), - 9.height, - const ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(20), - ), - child: LinearProgressIndicator( - value: 0.7, - minHeight: 8, - valueColor: const AlwaysStoppedAnimation(Colors.white), - backgroundColor: const Color(0xff196D73), - ), - ), - ], - ).paddingOnly(top: 12, right: 15, left: 12), - ), - Row( - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, + if (data.attendanceTracking?.pSwipeIn == null) SvgPicture.asset("assets/images/thumb.svg"), + Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [LocaleKeys.checkIn.tr().toText12(color: Colors.white), "09:00".toText14(color: Colors.white, isBold: true), 4.height], - ).paddingOnly(left: 12), - ), - Container( - width: 45, - height: 45, - padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( - color: Color(0xff259EA4), - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), - ), + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CountdownTimer( + endTime: endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), + if (data.attendanceTracking?.pSwipeIn == null) "01-02-2022".toText12(color: Colors.white), + if (data.attendanceTracking?.pSwipeIn != null) + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 9.height, + "07:55:12".toText14(color: Colors.white, isBold: true), + LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), + 9.height, + const ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + child: LinearProgressIndicator( + value: 0.7, + minHeight: 8, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), + ), + ), + ], + ), + ], + ).paddingOnly(top: 12, right: 15, left: 12), + ), + Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.checkIn.tr().toText12(color: Colors.white), + (data.attendanceTracking?.pSwipeIn == null ? "--:--" : "09:00").toText14(color: Colors.white, isBold: true), + 4.height + ], + ).paddingOnly(left: 12), + ), + Container( + width: 45, + height: 45, + padding: const EdgeInsets.only(left: 14, right: 14), + decoration: const BoxDecoration( + color: Color(0xff259EA4), + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(15), + ), + ), + child: SvgPicture.asset(data.attendanceTracking?.pSwipeIn == null ? "assets/images/play.svg" : "assets/images/stop.svg"), + ), + ], + ), + ], ), - child: SvgPicture.asset("assets/images/stop.svg"), - ), - ], - ), - ], - ), - ], - ), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.todayAttendance); - }), + ], + ), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.todayAttendance); + })) + .animatedSwither(), ), ), 9.width, diff --git a/lib/widgets/shimmer/dashboard_shimmer_widget.dart b/lib/widgets/shimmer/dashboard_shimmer_widget.dart new file mode 100644 index 0000000..1c63d71 --- /dev/null +++ b/lib/widgets/shimmer/dashboard_shimmer_widget.dart @@ -0,0 +1,82 @@ +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.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:shimmer/shimmer.dart'; + +class GetAttendanceTrackingShimmer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: double.infinity, + clipBehavior: Clip.antiAlias, + 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: Stack( + alignment: Alignment.center, + children: [ + // SvgPicture.asset("assets/images/"), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true).toShimmer(), + 16.height, + "07:55:12".toText10(color: Colors.white, isBold: true).toShimmer(), + 3.height, + LocaleKeys.timeLeftToday.tr().toText10(color: Colors.white).toShimmer(), + 9.height, + const ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + child: LinearProgressIndicator( + value: 0.7, + minHeight: 8, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), + ), + ).toShimmer(), + ], + ).paddingOnly(top: 12, right: 15, left: 12), + ), + Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [LocaleKeys.checkIn.tr().toText12(color: Colors.white).toShimmer(),], + ).paddingOnly(left: 12), + ), + Container( + width: 45, + height: 45, + // color: Colors.blue, + padding: const EdgeInsets.only(left: 14, right: 14), + ).toShimmer(), + ], + ), + ], + ), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 1ae9d08..58ce64a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -104,6 +104,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_countdown_timer: + dependency: "direct main" + description: + name: flutter_countdown_timer + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" flutter_lints: dependency: "direct dev" description: @@ -196,6 +203,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.9" + logger: + dependency: "direct main" + description: + name: logger + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 868012d..e7d1182 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,6 +45,8 @@ dependencies: local_auth: ^1.1.9 fluttertoast: ^8.0.8 shimmer: ^2.0.0 + logger: ^1.1.0 + flutter_countdown_timer: ^4.1.0 dev_dependencies: From b6670289b12de5707e8f4a642835047c7318493c Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Mon, 7 Feb 2022 11:09:15 +0300 Subject: [PATCH 6/6] Dashboard API's 1.2 --- lib/api/dashboard_api_client.dart | 22 ++ lib/api/login_api_client.dart | 1 + lib/extensions/string_extensions.dart | 8 + lib/extensions/widget_extensions.dart | 15 +- lib/main.dart | 6 +- lib/models/dashboard/list_menu.dart | 39 ++ lib/models/dashboard/menu_entries.dart | 60 +++ lib/models/dashboard/menus.dart | 10 + lib/models/generic_response_model.dart | 23 +- lib/provider/dashboard_provider_model.dart | 142 +++++++- lib/ui/landing/dashboard_screen.dart | 341 +++++++----------- lib/ui/landing/widget/menus_widget.dart | 138 +++++++ lib/ui/landing/widget/services_widget.dart | 147 ++++++++ lib/widgets/Updater.dart | 39 ++ .../shimmer/dashboard_shimmer_widget.dart | 109 +++++- 15 files changed, 864 insertions(+), 236 deletions(-) create mode 100644 lib/models/dashboard/list_menu.dart create mode 100644 lib/models/dashboard/menu_entries.dart create mode 100644 lib/models/dashboard/menus.dart create mode 100644 lib/ui/landing/widget/menus_widget.dart create mode 100644 lib/ui/landing/widget/services_widget.dart create mode 100644 lib/widgets/Updater.dart diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index ad513e9..b98a777 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -67,4 +67,26 @@ class DashbaordApiClient { return responseData; }, url, postParams); } + + //Menus List + Future getListMenu() async { + String url = "${ApiConsts.erpRest}GET_MENU"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + + //GET_MENU_ENTRIES + Future getGetMenuEntries() async { + String url = "${ApiConsts.erpRest}GET_MENU_ENTRIES"; + Map postParams = {"P_SELECTED_RESP_ID": -999,"P_MENU_TYPE":"E"}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } } diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index fb6bb80..86b7ace 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -55,6 +55,7 @@ class LoginApiClient { AppState().postParamsObject?.pSessionId = responseData.pSESSIONID; AppState().postParamsObject?.pUserName = AppState().getUserName; AppState().postParamsObject?.pSelectedEmployeeNumber = AppState().getUserName; + return responseData; }, url, postParams); } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 9db4829..5d4f8cd 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -2,6 +2,14 @@ import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +extension CapExtension on String { + String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}"; + String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; + String get allInCaps => this.toUpperCase(); + String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; +} + + extension EmailValidator on String { Widget get toWidget => Text(this); diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index dc083ce..130c867 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -10,13 +10,14 @@ extension WidgetExtensions on Widget { Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) => Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this); - Widget toShimmer() => Shimmer.fromColors( - baseColor: Color(0xffe8eff0), - highlightColor: Colors.white, - child: Container( - child: this, - color: Colors.white, - )); + Widget toShimmer({bool isShow=true}) =>isShow? Shimmer.fromColors( + baseColor: Color(0xffe8eff0), + highlightColor: Colors.white, + child: Container( + child: this, + color: Colors.white, + ), + ):Container(child: this,); Widget animatedSwither() => AnimatedSwitcher( duration: const Duration(milliseconds: 500), diff --git a/lib/main.dart b/lib/main.dart index 0b05d10..1146ff0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,9 +16,9 @@ import 'config/routes.dart'; var logger = Logger( - filter: null, // Use the default LogFilter (-> only log in debug mode) - printer: PrettyPrinter(), // Use the PrettyPrinter to format and print log - output: null, // U + // filter: null, // Use the default LogFilter (-> only log in debug mode) + printer: PrettyPrinter(lineLength: 0), // Use the PrettyPrinter to format and print log + // output: null, // U ); diff --git a/lib/models/dashboard/list_menu.dart b/lib/models/dashboard/list_menu.dart new file mode 100644 index 0000000..ba327c2 --- /dev/null +++ b/lib/models/dashboard/list_menu.dart @@ -0,0 +1,39 @@ +class ListMenu { + ListMenu({ + this.menuId, + this.menuName, + this.menuType, + this.requestGroupId, + this.requestGroupName, + this.respId, + this.subMenuName, + }); + + int? menuId; + String? menuName; + String? menuType; + int? requestGroupId; + String? requestGroupName; + dynamic? respId; + String? subMenuName; + + factory ListMenu.fromJson(Map json) => ListMenu( + menuId: json["MENU_ID"] == null ? null : json["MENU_ID"], + menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"], + menuType: json["MENU_TYPE"] == null ? null : json["MENU_TYPE"], + requestGroupId: json["REQUEST_GROUP_ID"] == null ? null : json["REQUEST_GROUP_ID"], + requestGroupName: json["REQUEST_GROUP_NAME"] == null ? null : json["REQUEST_GROUP_NAME"], + respId: json["RESP_ID"], + subMenuName: json["SUB_MENU_NAME"] == null ? null : json["SUB_MENU_NAME"], + ); + + Map toJson() => { + "MENU_ID": menuId == null ? null : menuId, + "MENU_NAME": menuName == null ? null : menuName, + "MENU_TYPE": menuType == null ? null : menuType, + "REQUEST_GROUP_ID": requestGroupId == null ? null : requestGroupId, + "REQUEST_GROUP_NAME": requestGroupName == null ? null : requestGroupName, + "RESP_ID": respId, + "SUB_MENU_NAME": subMenuName == null ? null : subMenuName, + }; +} diff --git a/lib/models/dashboard/menu_entries.dart b/lib/models/dashboard/menu_entries.dart new file mode 100644 index 0000000..7678ad8 --- /dev/null +++ b/lib/models/dashboard/menu_entries.dart @@ -0,0 +1,60 @@ +class GetMenuEntriesList { + GetMenuEntriesList({ + this.addButton, + this.deleteButton, + this.entrySequence, + this.functionName, + this.icon, + this.lvl, + this.menuEntryType, + this.menuName, + this.parentMenuName, + this.prompt, + this.requestType, + this.updateButton, + }); + + String? addButton; + String? deleteButton; + int? entrySequence; + String? functionName; + String? icon; + int? lvl; + String? menuEntryType; + String? menuName; + String? parentMenuName; + String? prompt; + String? requestType; + String? updateButton; + + factory GetMenuEntriesList.fromJson(Map json) => GetMenuEntriesList( + addButton: json["ADD_BUTTON"] == null ? null : json["ADD_BUTTON"], + deleteButton: json["DELETE_BUTTON"] == null ? null : json["DELETE_BUTTON"], + entrySequence: json["ENTRY_SEQUENCE"] == null ? null : json["ENTRY_SEQUENCE"], + functionName: json["FUNCTION_NAME"] == null ? null : json["FUNCTION_NAME"], + icon: json["ICON"] == null ? null : json["ICON"], + lvl: json["LVL"] == null ? null : json["LVL"], + menuEntryType: json["MENU_ENTRY_TYPE"] == null ? null : json["MENU_ENTRY_TYPE"], + menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"], + parentMenuName: json["PARENT_MENU_NAME"] == null ? null : json["PARENT_MENU_NAME"], + prompt: json["PROMPT"] == null ? null : json["PROMPT"], + requestType: json["REQUEST_TYPE"] == null ? null : json["REQUEST_TYPE"], + updateButton: json["UPDATE_BUTTON"] == null ? null :json["UPDATE_BUTTON"], + ); + + Map toJson() => { + "ADD_BUTTON": addButton == null ? null :addButton, + "DELETE_BUTTON": deleteButton == null ? null : deleteButton, + "ENTRY_SEQUENCE": entrySequence == null ? null : entrySequence, + "FUNCTION_NAME": functionName == null ? null : functionName, + "ICON": icon == null ? null : icon, + "LVL": lvl == null ? null : lvl, + "MENU_ENTRY_TYPE": menuEntryType == null ? null : menuEntryType, + "MENU_NAME": menuName == null ? null : menuName, + "PARENT_MENU_NAME": parentMenuName == null ? null : parentMenuName, + "PROMPT": prompt == null ? null : prompt, + "REQUEST_TYPE": requestType == null ? null : requestType, + "UPDATE_BUTTON": updateButton == null ? null : updateButton, + }; +} + diff --git a/lib/models/dashboard/menus.dart b/lib/models/dashboard/menus.dart new file mode 100644 index 0000000..7b88a33 --- /dev/null +++ b/lib/models/dashboard/menus.dart @@ -0,0 +1,10 @@ +import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; + +class Menus { + GetMenuEntriesList menuEntry; + List menuEntiesList; + + Menus(this.menuEntry, this.menuEntiesList); + + +} diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 86552a0..8ac68bb 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -5,6 +5,8 @@ import 'dashboard/get_accrual_balances_list_model.dart'; import 'dashboard/get_attendance_tracking_list_model.dart'; import 'dashboard/get_open_missing_swipes_list_model.dart'; import 'dashboard/get_open_notifications_list.dart'; +import 'dashboard/list_menu.dart'; +import 'dashboard/menu_entries.dart'; import 'member_information_list_model.dart'; import 'privilege_list_model.dart'; @@ -103,7 +105,7 @@ class GenericResponseModel { List? getItemTypeNotificationsList; List? getItemTypesList; List? getLookupValuesList; - List? getMenuEntriesList; + List? getMenuEntriesList; List? getMoItemHistoryList; List? getMoNotificationBodyList; List? getNotificationButtonsList; @@ -169,7 +171,7 @@ class GenericResponseModel { String? listItemImagesDetails; String? listItemMaster; String? listMedicineDetails; - String? listMenu; + List? listMenu; String? listNewEmployees; String? listRadScreen; String? logInTokenID; @@ -198,7 +200,7 @@ class GenericResponseModel { String? pINFORMATION; int? pMBLID; String? pNUMOFSUBORDINATES; - String? pOPENNTFNUMBER; + int? pOPENNTFNUMBER; String? pQUESTION; int? pSESSIONID; String? pSchema; @@ -567,15 +569,13 @@ class GenericResponseModel { getAbsenceCollectionNotificationBodyList = json['GetAbsenceCollectionNotificationBodyList']; getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; getAbsenceTransactionList = json['GetAbsenceTransactionList']; - getAccrualBalancesList= - json["GetAccrualBalancesList"] == null ? null : List.from(json["GetAccrualBalancesList"].map((x) => GetAccrualBalancesList.fromJson(x))); + getAccrualBalancesList = json["GetAccrualBalancesList"] == null ? null : List.from(json["GetAccrualBalancesList"].map((x) => GetAccrualBalancesList.fromJson(x))); getActionHistoryList = json['GetActionHistoryList']; getAddressDffStructureList = json['GetAddressDffStructureList']; getAddressNotificationBodyList = json['GetAddressNotificationBodyList']; getApprovesList = json['GetApprovesList']; getAttachementList = json['GetAttachementList']; - getAttendanceTrackingList= - json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTracking.fromMap(json["GetAttendanceTrackingList"]); + getAttendanceTrackingList = json["GetAttendanceTrackingList"] == null ? null : GetAttendanceTracking.fromMap(json["GetAttendanceTrackingList"]); getBasicDetColsStructureList = json['GetBasicDetColsStructureList']; getBasicDetDffStructureList = json['GetBasicDetDffStructureList']; getBasicDetNtfBodyList = json['GetBasicDetNtfBodyList']; @@ -611,15 +611,14 @@ class GenericResponseModel { getItemTypeNotificationsList = json['GetItemTypeNotificationsList']; getItemTypesList = json['GetItemTypesList']; getLookupValuesList = json['GetLookupValuesList']; - getMenuEntriesList = json['GetMenuEntriesList']; + getMenuEntriesList= json["GetMenuEntriesList"] == null ? null : List.from(json["GetMenuEntriesList"].map((x) => GetMenuEntriesList.fromJson(x))); getMoItemHistoryList = json['GetMoItemHistoryList']; getMoNotificationBodyList = json['GetMoNotificationBodyList']; getNotificationButtonsList = json['GetNotificationButtonsList']; getNotificationReassignModeList = json['GetNotificationReassignModeList']; getObjectValuesList = json['GetObjectValuesList']; - getOpenMissingSwipesList= json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); - getOpenNotificationsList= - json["GetOpenNotificationsList"] == null ? null : List.from(json["GetOpenNotificationsList"].map((x) => GetOpenNotificationsList.fromMap(x))); + getOpenMissingSwipesList = json["GetOpenMissingSwipesList"] == null ? null : GetOpenMissingSwipesList.fromJson(json["GetOpenMissingSwipesList"]); + getOpenNotificationsList = json["GetOpenNotificationsList"] == null ? null : List.from(json["GetOpenNotificationsList"].map((x) => GetOpenNotificationsList.fromMap(x))); getOpenNotificationsNumList = json['GetOpenNotificationsNumList']; getOpenPeriodDatesList = json['GetOpenPeriodDatesList']; getOrganizationsSalariesList = json['GetOrganizationsSalariesList']; @@ -678,7 +677,7 @@ class GenericResponseModel { listItemImagesDetails = json['List_ItemImagesDetails']; listItemMaster = json['List_ItemMaster']; listMedicineDetails = json['List_MedicineDetails']; - listMenu = json['List_Menu']; + listMenu = json["List_Menu"] == null ? null : List.from(json["List_Menu"].map((x) => ListMenu.fromJson(x))); listNewEmployees = json['List_NewEmployees']; listRadScreen = json['List_RadScreen']; logInTokenID = json['LogInTokenID']; diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 6ccbfc1..b52448e 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -1,23 +1,54 @@ +import 'dart:convert'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; +import 'package:mohem_flutter_app/models/dashboard/menus.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/widgets/Updater.dart'; /// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool // ignore: prefer_mixin class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { + //Attendance Tracking bool isAttendanceTrackingLoading = true; - int isTimeRemainingInSeconds = 0; + int endTime = 0, isTimeRemainingInSeconds = 0; GetAttendanceTracking? attendanceTracking; + //Work List + bool isWorkListLoading = true; + int workListCounter = 0; + + //Misssing Swipe + bool isMissingSwipeLoading = true; + int missingSwipeCounter = 0; + + //Leave and Ticket Balance + bool isLeaveTicketBalanceLoading = true; + double leaveBalance = 0; + double ticketBalance = 0; + + //Menu Entries + bool isServicesMenusLoading = true; + List? homeMenus; + List? getMenuEntriesList; + + //Attendance Tracking API's & Methods fetchAttendanceTracking() async { try { attendanceTracking = await DashbaordApiClient().getAttendanceTracking(); isAttendanceTrackingLoading = false; - isTimeRemainingInSeconds = calculateSeconds("00:00:30"); - notifyListeners(); + isTimeRemainingInSeconds = calculateSeconds("00:00:00"); + endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds; + print("isTimeRemainingInSeconds " + isTimeRemainingInSeconds.toString()); + print("endTime " + endTime.toString()); + + // notifyListeners(); } catch (ex) { Utils.handleException(ex, null); } @@ -32,8 +63,111 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { update() { isAttendanceTrackingLoading = !isAttendanceTrackingLoading; + isWorkListLoading = !isWorkListLoading; attendanceTracking?.pSwipeIn = "a"; - isTimeRemainingInSeconds = calculateSeconds("00:00:30"); + isTimeRemainingInSeconds = calculateSeconds("00:10:30"); + endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds; + notifyListeners(); } + + //Work List API's & Methods + fetchWorkListCounter() async { + try { + GenericResponseModel? genericResponseModel = await DashbaordApiClient().getOpenNotifications(); + isWorkListLoading = false; + workListCounter = genericResponseModel?.pOPENNTFNUMBER ?? 0; + ItgFormsModel? itgFormsModel = await DashbaordApiClient().getItgFormsPendingTask(); + workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0); + notifyListeners(); + } catch (ex) { + isWorkListLoading = false; + logger.wtf(ex); + notifyListeners(); + Utils.handleException(ex, null); + } + } + + //Missing Siwpe API's & Methods + fetchMissingSwipe() async { + try { + GenericResponseModel? genericResponseModel = await DashbaordApiClient().getOpenMissingSwipes(); + isMissingSwipeLoading = false; + missingSwipeCounter = genericResponseModel!.getOpenMissingSwipesList!.pOpenMissingSwipes ?? 0; + notifyListeners(); + } catch (ex) { + isMissingSwipeLoading = false; + logger.wtf(ex); + notifyListeners(); + Utils.handleException(ex, null); + } + } + + //Leave and Ticket Balance API's & Methods + fetchLeaveTicketBalance() async { + try { + GenericResponseModel? genericResponseModel = await DashbaordApiClient().getAccrualBalances(); + isLeaveTicketBalanceLoading = false; + leaveBalance = genericResponseModel?.getAccrualBalancesList![0].accrualNetEntitlement ?? 0.0; + ticketBalance = (genericResponseModel?.getAccrualBalancesList![1].accrualNetEntitlement ?? 0.0) + (genericResponseModel?.getAccrualBalancesList![2].accrualNetEntitlement ?? 0.0); + notifyListeners(); + } catch (ex) { + isLeaveTicketBalanceLoading = false; + logger.wtf(ex); + notifyListeners(); + Utils.handleException(ex, null); + } + } + + //List Menu API's & Methods + fetchListMenu() async { + try { + GenericResponseModel? genericResponseModel = await DashbaordApiClient().getListMenu(); + Map map = {}; + print(jsonEncode(genericResponseModel!.listMenu)); + for (int i = 0; i < genericResponseModel!.listMenu!.length; i++) { + print(genericResponseModel!.listMenu![i]!.menuName ?? ""); + map[genericResponseModel!.listMenu![i]!.menuName ?? ""] = i.toString(); + } + logger.i(map); + notifyListeners(); + } catch (ex) { + logger.wtf(ex); + notifyListeners(); + Utils.handleException(ex, null); + } + } + + //Menu Entries API's & Methods + fetchMenuEntries() async { + try { + GenericResponseModel? genericResponseModel = await DashbaordApiClient().getGetMenuEntries(); + getMenuEntriesList = genericResponseModel!.getMenuEntriesList; + homeMenus = parseMenues(getMenuEntriesList ?? []); + isServicesMenusLoading = false; + notifyListeners(); + } catch (ex) { + logger.wtf(ex); + notifyListeners(); + Utils.handleException(ex, null); + } + } + + List parseMenues(List getMenuEntriesList) { + List menus = []; + for (int i = 0; i < getMenuEntriesList.length; i++) { + if (getMenuEntriesList[i].parentMenuName!.isEmpty) { + menus.add(Menus(getMenuEntriesList[i], getMenuEntriesList.where((element) => getMenuEntriesList[i].menuName == element.parentMenuName).toList())); + } + } + + //Verify Menus by printing in log + // for(int i=0;i { + late var data; + @override void initState() { super.initState(); - final data = Provider.of(context, listen: false); + data = Provider.of(context, listen: false); data.fetchAttendanceTracking(); + data.fetchWorkListCounter(); + data.fetchMissingSwipe(); + data.fetchLeaveTicketBalance(); + // data.fetchMenuEntries(); } - int endTime = 0; - @override void dispose() { super.dispose(); @@ -44,17 +56,8 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { - List names = [LocaleKeys.workList.tr(), LocaleKeys.missingSwipes.tr(), LocaleKeys.leaveBalance.tr(), LocaleKeys.ticketBalance.tr()]; - List namesInt = [118, 02, 18.5, 03]; - List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; - - List namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()]; - List iconT = ["assets/images/monthly_attendance.svg", "assets/images/work_from_home.svg", "assets/images/ticket_request.svg", "assets/images/work_from_home.svg"]; - List namesD = ["Nostalgia Perfume Perfume", "Al Nafoura", "AlJadi", "Nostalgia Perfume"]; - final data = Provider.of(context); - - endTime=DateTime.now().millisecondsSinceEpoch + Duration(seconds: data.isTimeRemainingInSeconds).inMilliseconds; + return Scaffold( body: Column( children: [ @@ -108,214 +111,134 @@ class _DashboardScreenState extends State { ], ).paddingOnly(left: 21, right: 21, top: 48, bottom: 7), Expanded( - child: ListView( - padding: EdgeInsets.zero, + child: Column( + // padding: EdgeInsets.zero, + // physics: NeverScrollableScrollPhysics(), children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color), - "Mahmoud Shrouf".toText24(isBold: true), - 16.height, - Row( + Expanded( + child: SingleChildScrollView( + child: Column( children: [ - Expanded( - child: AspectRatio( - aspectRatio: 159 / 159, - child: (data.isAttendanceTrackingLoading - ? GetAttendanceTrackingShimmer() - : Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - child: Stack( - alignment: Alignment.center, - children: [ - if (data.attendanceTracking?.pSwipeIn == null) SvgPicture.asset("assets/images/thumb.svg"), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CountdownTimer( - endTime: endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color), + "Mahmoud Shrouf".toText24(isBold: true), + 16.height, + Row( + children: [ + Expanded( + child: AspectRatio( + aspectRatio: 159 / 159, + child: Consumer( + builder: (context, model, child) { + return (model.isAttendanceTrackingLoading + ? GetAttendanceTrackingShimmer() + : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), ), - LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), - if (data.attendanceTracking?.pSwipeIn == null) "01-02-2022".toText12(color: Colors.white), - if (data.attendanceTracking?.pSwipeIn != null) - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 9.height, - "07:55:12".toText14(color: Colors.white, isBold: true), - LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), - 9.height, - const ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(20), + child: Stack( + alignment: Alignment.center, + children: [ + if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), + if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white), + if (model.isTimeRemainingInSeconds != 0) + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 9.height, + CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), + LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), + 9.height, + const ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + child: LinearProgressIndicator( + value: 0.7, + minHeight: 8, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), + ), + ), + ], + ), + ], + ).paddingOnly(top: 12, right: 15, left: 12), ), - child: LinearProgressIndicator( - value: 0.7, - minHeight: 8, - valueColor: const AlwaysStoppedAnimation(Colors.white), - backgroundColor: const Color(0xff196D73), + Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.checkIn.tr().toText12(color: Colors.white), + (model.isTimeRemainingInSeconds == 0 ? "--:--" : "09:00").toText14(color: Colors.white, isBold: true), + 4.height + ], + ).paddingOnly(left: 12), + ), + Container( + width: 45, + height: 45, + padding: const EdgeInsets.only(left: 14, right: 14), + decoration: const BoxDecoration( + color: Color(0xff259EA4), + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(15), + ), + ), + child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), + ), + ], ), - ), - ], - ), - ], - ).paddingOnly(top: 12, right: 15, left: 12), - ), - Row( - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.checkIn.tr().toText12(color: Colors.white), - (data.attendanceTracking?.pSwipeIn == null ? "--:--" : "09:00").toText14(color: Colors.white, isBold: true), - 4.height + ], + ), ], - ).paddingOnly(left: 12), - ), - Container( - width: 45, - height: 45, - padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( - color: Color(0xff259EA4), - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), - ), ), - child: SvgPicture.asset(data.attendanceTracking?.pSwipeIn == null ? "assets/images/play.svg" : "assets/images/stop.svg"), - ), - ], - ), - ], - ), - ], - ), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.todayAttendance); - })) - .animatedSwither(), - ), - ), - 9.width, - Expanded( - child: GridView.builder( - shrinkWrap: true, - primary: false, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), - padding: EdgeInsets.zero, - itemCount: 4, - itemBuilder: (BuildContext context, int index) { - return Container( - decoration: BoxDecoration( - color: Color(namesColor[index]), - borderRadius: BorderRadius.circular(10), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.todayAttendance); + })) + .animatedSwither(); + }, + )), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - names[index].toText12(color: Colors.white), - Row( - children: [ - Expanded( - child: namesInt[index].toStringAsFixed(1).toText16(color: Colors.white, isBold: true), - ), - SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.workList); - }); - }, - ), - ), - ], - ), - 20.height, - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - "Other".tr().toText12(), - LocaleKeys.services.tr().toText24(isBold: true), - ], - ), - ), - LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), - ], - ), - ], - ).paddingOnly(left: 21, right: 21, top: 7), - 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: 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), + 9.width, + Expanded( + child: MenusWidget(), ), ], ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset(iconT[index]), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: namesT[index].toText11(isBold: true), - ), - SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ), - ); - }, - separatorBuilder: (cxt, index) => 9.width, - itemCount: 4), + 20.height, + ], + ).paddingOnly(left: 21, right: 21, top: 7), + ServicesWidget(), + 8.height, + ], + ), + ), ), - 8.height, Container( width: double.infinity, padding: EdgeInsets.only(top: 31), diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart new file mode 100644 index 0000000..4d13775 --- /dev/null +++ b/lib/ui/landing/widget/menus_widget.dart @@ -0,0 +1,138 @@ +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:mohem_flutter_app/config/routes.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/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; +import 'package:provider/provider.dart'; + +class MenusWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; + + return Consumer(builder: (context, data, child) { + return GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), + padding: EdgeInsets.zero, + shrinkWrap: true, + primary: false, + physics: const NeverScrollableScrollPhysics(), + children: [ + data.isWorkListLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[0]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.workList.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + // Navigator.pushNamed(context, AppRoutes.workList); + data.fetchWorkListCounter(); + }), + data.isMissingSwipeLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[1]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.workList); + }), + data.isLeaveTicketBalanceLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[2]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.leaveBalance.toString().toText16(color: Colors.white, isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.workList); + }), + data.isLeaveTicketBalanceLoading + ? MenuShimmer().onPress(() { + data.fetchWorkListCounter(); + }) + : Container( + decoration: BoxDecoration( + color: Color(namesColor[3]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.ticketBalance.toString().toText16(color: Colors.white, isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.workList); + }) + ], + ); + }); + } +} diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart new file mode 100644 index 0000000..f397a4c --- /dev/null +++ b/lib/ui/landing/widget/services_widget.dart @@ -0,0 +1,147 @@ +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.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/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; +import 'package:provider/provider.dart'; + +class ServicesWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + List namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()]; + List iconT = [ + "assets/images/monthly_attendance.svg", + "assets/images/work_from_home.svg", + "assets/images/ticket_request.svg", + "assets/images/work_from_home.svg", + "assets/images/work_from_home.svg", + "assets/images/work_from_home.svg", + "assets/images/work_from_home.svg", + "assets/images/work_from_home.svg" + ]; + + return Consumer( + builder: (context, data, child) { + return data.isServicesMenusLoading + ? whileLoading() + : ListView.separated( + itemBuilder: (context, parentIndex) { + return Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + firstWord(data.homeMenus![parentIndex].menuEntry.prompt!).toText12(), + lastWord(data.homeMenus![parentIndex].menuEntry.prompt!).toText24(isBold: true), + ], + ), + ), + 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), + ), + ); + }, + separatorBuilder: (cxt, index) => 9.width, + itemCount: data.homeMenus![parentIndex].menuEntiesList.length), + ), + ], + ); + }, + separatorBuilder: (context, index) { + return 12.height; + }, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: data.homeMenus!.length); + }, + ); + } + + String firstWord(String value) { + return value.split(" ").length > 1 ? value.split(" ")[0] : ""; + } + + String lastWord(String value) { + var parts = value.split(" "); + if (parts.length == 1) { + return value; + } else { + int i = value.indexOf(" "); + return value.substring(i + 1).toCamelCase; + } + } + + Widget whileLoading() { + return Column( + children: [ + ServicesHeaderShimmer().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: ServicesMenuShimmer(), + ); + }, + separatorBuilder: (cxt, index) => 9.width, + itemCount: 4), + ), + ], + ); + } +} diff --git a/lib/widgets/Updater.dart b/lib/widgets/Updater.dart new file mode 100644 index 0000000..154173d --- /dev/null +++ b/lib/widgets/Updater.dart @@ -0,0 +1,39 @@ +/* ZiK */ + +import 'dart:async'; +import 'package:flutter/cupertino.dart'; + +typedef ChildProvider = Widget Function(BuildContext context, E? data); + +class Updater extends StatelessWidget{ + final ChildProvider childProvider; + StreamController? sink; + T? initialData; + List _history = []; + + Stream? _stream; + Updater({T? initialData, required this.childProvider}){ + this.sink = StreamController(); + this.initialData = initialData; + _stream = this.sink?.stream; + } + + @override + Widget build(BuildContext context) { + return StreamBuilder( + initialData: this.initialData, + stream: _stream, + builder: (ctx, snapshot){ + return childProvider(context, snapshot.data); + }); + } + + pushData(T? data) { + _history.add(data); + sink?.sink.add(data); + } + + List getDataHistory() => _history; + T? getLatestData() => _history.last; + +} \ No newline at end of file diff --git a/lib/widgets/shimmer/dashboard_shimmer_widget.dart b/lib/widgets/shimmer/dashboard_shimmer_widget.dart index 1c63d71..5b5bd60 100644 --- a/lib/widgets/shimmer/dashboard_shimmer_widget.dart +++ b/lib/widgets/shimmer/dashboard_shimmer_widget.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.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'; @@ -62,7 +63,9 @@ class GetAttendanceTrackingShimmer extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, - children: [LocaleKeys.checkIn.tr().toText12(color: Colors.white).toShimmer(),], + children: [ + LocaleKeys.checkIn.tr().toText12(color: Colors.white).toShimmer(), + ], ).paddingOnly(left: 12), ), Container( @@ -80,3 +83,107 @@ class GetAttendanceTrackingShimmer extends StatelessWidget { ); } } + +class MenuShimmer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + clipBehavior: Clip.antiAlias, + 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: [ + LocaleKeys.workList.tr().toText12(color: Colors.white).toShimmer(), + Row( + children: [ + Expanded( + flex: 3, + child: 123.toString().toText10(color: Colors.white, isBold: true).toShimmer(), + ), + 12.width, + SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white).toShimmer() + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ); + } +} + +class ServicesHeaderShimmer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + "Other".tr().toText10().toShimmer(), + 6.height, + LocaleKeys.services.tr().toText12(isBold: true).toShimmer(), + ], + ), + ), + LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true).toShimmer(), + ], + ); + } +} + +class ServicesMenuShimmer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return 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("assets/images/monthly_attendance.svg").toShimmer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + "Attendan".toText11(isBold: false).toShimmer(), + 5.height, + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: "Attendance".toText11(isBold: false).toShimmer(), + ), + 6.width, + SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4).toShimmer() + ], + ), + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ); + } +}