From 2966ca129c090665112912e4f660bcc0c28c837d Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 27 Jun 2022 15:54:58 +0300 Subject: [PATCH] monthly pay slip improvement --- lib/classes/utils.dart | 17 ++++------ lib/ui/payslip/monthly_pay_slip_screen.dart | 37 +++++++++++---------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 114f32c..74ab127 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -161,14 +161,14 @@ class Utils { return base64Decode(base64String); } - static Widget tableColumnTitle(String? text, {bool showDivider = true}) { + static Widget tableColumnTitle(String? text, {bool showDivider = true, bool alignCenter = false}) { text ??= ""; return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ 6.height, - text.toText12(), + alignCenter ? text.toText12().center : text.toText12(), 5.height, if (showDivider) const Divider( @@ -180,20 +180,17 @@ class Utils { ); } - static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true}) { + static Widget tableColumnValue(String text, { bool isCapitable = true, bool alignCenter = false}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ 12.height, - (isCapitable ? text.toLowerCase().capitalizeFirstofEach : text).toText12(color: MyColors.normalTextColor), + if (alignCenter) + (isCapitable ? text.toLowerCase().capitalizeFirstofEach : text).toText12(color: MyColors.normalTextColor).center + else + (isCapitable ? text.toLowerCase().capitalizeFirstofEach : text).toText12(color: MyColors.normalTextColor), 12.height, - if (!isLast) - const Divider( - height: 1, - color: Color(0xffEFEFEF), - thickness: 1, - ) ], ); } diff --git a/lib/ui/payslip/monthly_pay_slip_screen.dart b/lib/ui/payslip/monthly_pay_slip_screen.dart index 13a7ee0..85ccf8d 100644 --- a/lib/ui/payslip/monthly_pay_slip_screen.dart +++ b/lib/ui/payslip/monthly_pay_slip_screen.dart @@ -99,8 +99,9 @@ class _MonthlyPaySlipScreenState extends State { children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - LocaleKeys.month.tr().toText17(isBold: true, color: MyColors.darkIconColor), + Container(alignment: Alignment.centerLeft, child: LocaleKeys.month.tr().toText17(isBold: true, color: MyColors.darkIconColor)), if (selectedMonthIndex != null) Row( children: [ @@ -158,15 +159,15 @@ class _MonthlyPaySlipScreenState extends State { TableRow( children: [ Utils.tableColumnTitle(LocaleKeys.particular.tr()), - Utils.tableColumnTitle(LocaleKeys.amount.tr()), + Utils.tableColumnTitle(LocaleKeys.amount.tr(), alignCenter: true), ], ), ); for (int i = 0; i < earningList.length; i++) { tableRow.add( TableRow(children: [ - Utils.tableColumnValue('${earningList[i].eLEMENTNAME}', isLast: i == earningList.length - 1), - Utils.tableColumnValue('${earningList[i].aMOUNT}', isLast: i == earningList.length - 1), + Utils.tableColumnValue('${earningList[i].eLEMENTNAME}'), + Utils.tableColumnValue('${earningList[i].aMOUNT}', alignCenter: true), ]), ); } @@ -190,15 +191,15 @@ class _MonthlyPaySlipScreenState extends State { TableRow( children: [ Utils.tableColumnTitle(LocaleKeys.particular.tr()), - Utils.tableColumnTitle(LocaleKeys.amount.tr()), + Utils.tableColumnTitle(LocaleKeys.amount.tr(), alignCenter: true), ], ), ); for (int i = 0; i < deductionList.length; i++) { tableRow.add( TableRow(children: [ - Utils.tableColumnValue('${deductionList[i].eLEMENTNAME}', isLast: i == deductionList.length - 1), - Utils.tableColumnValue('${deductionList[i].aMOUNT}', isLast: i == deductionList.length - 1), + Utils.tableColumnValue('${deductionList[i].eLEMENTNAME}'), + Utils.tableColumnValue('${deductionList[i].aMOUNT}', alignCenter: true), ]), ); } @@ -223,31 +224,31 @@ class _MonthlyPaySlipScreenState extends State { TableRow( children: [ Utils.tableColumnTitle(LocaleKeys.particular.tr()), - Utils.tableColumnTitle("%"), - Utils.tableColumnTitle(LocaleKeys.amount.tr()), + Utils.tableColumnTitle("%", alignCenter: true), + Utils.tableColumnTitle(LocaleKeys.amount.tr(), alignCenter: true), ], ), ); tableRow.add( TableRow(children: [ - Utils.tableColumnValue(LocaleKeys.deductions.tr(), isLast: false), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALDEDUCTIONSPERCENTAGE}', isLast: false), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALDEDUCTIONSAMOUNT}', isLast: false), + Utils.tableColumnValue(LocaleKeys.deductions.tr()), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALDEDUCTIONSPERCENTAGE}', alignCenter: true), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALDEDUCTIONSAMOUNT}', alignCenter: true), ]), ); tableRow.add( TableRow(children: [ - Utils.tableColumnValue(LocaleKeys.earnings.tr(), isLast: false), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALEARNINGSPERCENTAGE}', isLast: false), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALEARNINGSAMOUNT}', isLast: false), + Utils.tableColumnValue(LocaleKeys.earnings.tr()), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALEARNINGSPERCENTAGE}', alignCenter: true), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALEARNINGSAMOUNT}', alignCenter: true), ]), ); tableRow.add( TableRow(children: [ - Utils.tableColumnValue(LocaleKeys.totalPayAmount.tr(), isLast: true), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALPAYPERCENTAGE}', isLast: true), - Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALPAYAMOUNT}', isLast: true), + Utils.tableColumnValue(LocaleKeys.totalPayAmount.tr()), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALPAYPERCENTAGE}', alignCenter: true), + Utils.tableColumnValue('${summaryOfPaymentList[0].tOTALPAYAMOUNT}', alignCenter: true), ]), );