From 55cafb5466022ebce6f0980e79feb51ede731b75 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 1 Sep 2022 16:39:43 +0300 Subject: [PATCH] improvement. --- lib/ui/my_team/profile_details.dart | 61 +++------ lib/ui/my_team/subordinate_leave.dart | 178 +++++++++++--------------- 2 files changed, 94 insertions(+), 145 deletions(-) diff --git a/lib/ui/my_team/profile_details.dart b/lib/ui/my_team/profile_details.dart index cfc1730..b1bf5df 100644 --- a/lib/ui/my_team/profile_details.dart +++ b/lib/ui/my_team/profile_details.dart @@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/my_team/get_employee_subordinates_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; - class ProfileDetails extends StatefulWidget { const ProfileDetails({Key? key}) : super(key: key); @@ -18,8 +18,6 @@ class ProfileDetails extends StatefulWidget { class _ProfileDetailsState extends State { GetEmployeeSubordinatesList? getEmployeeSubordinates; - - @override void initState() { super.initState(); @@ -33,47 +31,26 @@ class _ProfileDetailsState extends State { title: LocaleKeys.profileDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - body: Column( + body: ListView( + padding: EdgeInsets.all(21), children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 21, - right: 21, - ), - padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 20), - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 5, - blurRadius: 26, - offset: Offset(0, 3), - ), - ], - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), - ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - 23.height, - LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), - "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.darkTextColor), - ]), - ), + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + LocaleKeys.category.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYMENTCATEGORYMEANING}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.address.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.lOCATIONNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.phoneNumber.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.eMPLOYEEMOBILENUMBER}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.businessGroup.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.bUSINESSGROUPNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + 23.height, + LocaleKeys.Payroll.tr().toText13(color: MyColors.lightGrayColor), + "${getEmployeeSubordinates?.pAYROLLNAME}".toText16(isBold: true, color: MyColors.darkTextColor), + ]).objectContainerView(), ], )); } - } diff --git a/lib/ui/my_team/subordinate_leave.dart b/lib/ui/my_team/subordinate_leave.dart index 9e69fdc..d9ca110 100644 --- a/lib/ui/my_team/subordinate_leave.dart +++ b/lib/ui/my_team/subordinate_leave.dart @@ -1,4 +1,3 @@ - import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; @@ -9,7 +8,6 @@ import 'package:mohem_flutter_app/api/my_team/my_team_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; -import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; @@ -18,7 +16,7 @@ import 'package:mohem_flutter_app/models/my_team/get_subordinates_leaves_total_v import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; - +import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class SubordinateLeave extends StatefulWidget { const SubordinateLeave({Key? key}) : super(key: key); @@ -33,19 +31,16 @@ class _SubordinateLeaveState extends State { DateTime selectedDateTo = DateTime.now(); bool showList = false; - - - @override void initState() { super.initState(); } - void getSubordinatesLeaves()async { + void getSubordinatesLeaves() async { try { Utils.showLoading(context); getSubordinatesLeavesTotalList = await MyTeamApiClient().getSubordinatesLeavesList(DateUtil.convertDateToStringLocation(selectedDateFrom), DateUtil.convertDateToStringLocation(selectedDateTo)); - showList= true; + showList = true; Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -54,108 +49,85 @@ class _SubordinateLeaveState extends State { } } - @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBarWidget( - context, - title: LocaleKeys.subordinateLeave.tr(), - ), - backgroundColor: MyColors.backgroundColor, - body: Column( - children: [ - Expanded( - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - Column( - children: [ - DynamicTextFieldWidget( - LocaleKeys.dateFrom.tr(), - selectedDateFrom.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateFrom = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ), - 12.height, - DynamicTextFieldWidget( - LocaleKeys.dateTo.tr(), - selectedDateTo.toString().split(" ")[0], - suffixIconData: Icons.calendar_today, - isEnable: false, - onTap: () async { - selectedDateTo = await _selectDate(context, DateTime.now()); - setState(() {}); - }, - ) - ], - ).objectContainerView(), - Container( - margin: EdgeInsets.only(left: 21, right: 21), - width: MediaQuery.of(context).size.width, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - showList? ListView.separated( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - separatorBuilder: (BuildContext cxt,int index) => 12.height, - itemCount: getSubordinatesLeavesTotalList.length, - itemBuilder: (BuildContext context,int index) { - var diffDays = DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!).difference(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!)).inDays; - return getSubordinatesLeavesTotalList.isEmpty - ? Utils.getNoDataWidget(context) - : Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SvgPicture.asset("assets/images/user.svg"), - 14.width, - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "${getSubordinatesLeavesTotalList[index].eMPLOYEENAME}".toText16(isBold: true, color: MyColors.grey3AColor), - 10.height, - Row( - children: [ - (LocaleKeys.from.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), - 14.width, - (LocaleKeys.to.tr() + ': ${DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!), "MMM dd yyyy")}').toText10(isBold: true, color: MyColors.grey57Color), - ], - ), - (LocaleKeys.numberDays.tr()+ ": $diffDays").toText10(color: MyColors.grey3AColor), - ], - ).expanded - ], - ).objectContainerView(); - } - ) - :Container(), - ], - ), - ), - ), - ], - ), - ), + appBar: AppBarWidget( + context, + title: LocaleKeys.subordinateLeave.tr(), + ), + backgroundColor: MyColors.backgroundColor, + body: Column( + children: [ + Expanded( + child: Column( + children: [ + Column( + children: [ + DynamicTextFieldWidget( + LocaleKeys.dateFrom.tr(), + selectedDateFrom.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateFrom = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ), + 12.height, + DynamicTextFieldWidget( + LocaleKeys.dateTo.tr(), + selectedDateTo.toString().split(" ")[0], + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + selectedDateTo = await _selectDate(context, DateTime.now()); + setState(() {}); + }, + ) + ], + ).objectContainerView(), + if (showList) + ListView.separated( + scrollDirection: Axis.vertical, + physics: ScrollPhysics(), + padding: const EdgeInsets.all(21), + separatorBuilder: (BuildContext cxt, int index) => 12.height, + itemCount: getSubordinatesLeavesTotalList.length, + itemBuilder: (BuildContext context, int index) { + var diffDays = DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!) + .difference(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!)) + .inDays; + return getSubordinatesLeavesTotalList.isEmpty + ? Utils.getNoDataWidget(context) + : Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset("assets/images/user.svg", width: 34, height: 34).paddingOnly(top: 4), + 9.width, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getSubordinatesLeavesTotalList[index].eMPLOYEENAME!.toText16(), + ItemDetailView(LocaleKeys.from.tr(), DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATESTART!), "MMM dd yyyy")), + ItemDetailView(LocaleKeys.to.tr(), DateUtil.getFormattedDate(DateUtil.convertStringToDate(getSubordinatesLeavesTotalList[index].dATEEND!), "MMM dd yyyy")), + ItemDetailView(LocaleKeys.numberDays.tr(), diffDays.toString()), + ], + ).expanded + ], + ).objectContainerView(); + }).expanded + ], ), - DefaultButton( - LocaleKeys.submit.tr(), () async { - getSubordinatesLeaves(); - }).insideContainer - ], ), - ); + DefaultButton(LocaleKeys.submit.tr(), () async { + getSubordinatesLeaves(); + }).insideContainer + ], + ), + ); } - - Future _selectDate(BuildContext context, DateTime selectedDate) async { DateTime time = selectedDate; if (!Platform.isIOS) {