Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(confirmation-screen): show total qty in all units #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions lib/src/widgets/order_booking/summary/order_amount_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ class OrderAmountSummaryWidget extends StatelessWidget {
required this.totalQty,
required this.mainColor,
required this.currencyUtil,
required this.qty,
required this.stdQty,
required this.additionalQty,
this.customWidget,
this.currency = "₹",
this.unit = "SKUs",
this.stdUnitName = "Std. Unit",
this.additionalUnitName = "Add. Unit",
this.showMargin = true,
this.discountWidget,
this.isDistributorVisible = false,
Expand All @@ -67,6 +72,7 @@ class OrderAmountSummaryWidget extends StatelessWidget {
const EdgeInsets.only(bottom: 2, left: 2, right: 2),
this.compactNumber = false,
this.payableAmountInSecondCurrency,
this.showTotalQtyInAllUnits = false,
super.key,
});

Expand All @@ -75,6 +81,8 @@ class OrderAmountSummaryWidget extends StatelessWidget {
final String distributorAddress;
final String currency;
final String unit;
final String stdUnitName;
final String additionalUnitName;
final List<QuantityBreakdown> quantityBreakdownList;
final List<AmountBreakdown> amountBreakdownList;
final CurrencyUtil currencyUtil;
Expand All @@ -85,6 +93,9 @@ class OrderAmountSummaryWidget extends StatelessWidget {
final double marginAmount;
final String payableAmount;
final int totalQty;
final int qty;
final int stdQty;
final int additionalQty;
final Color mainColor;
final Widget? customWidget;
final bool showMargin;
Expand All @@ -95,6 +106,7 @@ class OrderAmountSummaryWidget extends StatelessWidget {
final EdgeInsets breakDownListPadding;
final bool compactNumber;
final String? payableAmountInSecondCurrency;
final bool showTotalQtyInAllUnits;

final titleTextStyle = TextStyle(
fontWeight: FontWeight.w500,
Expand All @@ -106,6 +118,20 @@ class OrderAmountSummaryWidget extends StatelessWidget {
fontSize: 12,
);

Text getDisplayQty(int additionalQty, int stdQty, int qty, String addName,
String stdName, String unitName) {
String additionalUnitDisplay = (additionalQty > 0)
? additionalQty.toString() + " " + additionalUnitName + " "
: "";
String stdUnitDisplay =
(stdQty > 0) ? stdQty.toString() + " " + stdUnitName + " " : "";
String unitDisplay =
(qty > 0) ? qty.toString() + " " + unitName : "0 $unitName";

return Text(additionalUnitDisplay + stdUnitDisplay + unitDisplay,
style: titleTextStyle);
}

@override
Widget build(BuildContext context) {
return Card(
Expand Down Expand Up @@ -165,10 +191,10 @@ class OrderAmountSummaryWidget extends StatelessWidget {
style: titleTextStyle,
),
Spacer(),
Text(
"$totalQty $unit",
style: titleTextStyle,
)
showTotalQtyInAllUnits
? getDisplayQty(additionalQty, stdQty, qty,
additionalUnitName, stdUnitName, unit)
: Text("$totalQty $unit"),
],
),
leading: SvgPicture.asset(
Expand Down