hubbleDiscountDetails function

List<Widget> hubbleDiscountDetails(
  1. BuildContext context
)

Implementation

List<Widget> hubbleDiscountDetails(BuildContext context) {
  final theme = hubbleThemeData(context);
  final response = context.getViewState().data.response;
  final transactionDetails = response.amountBreakup.discountDetails;
  final coinAmount = transactionDetails.coinDiscount.amount;
  final hubbleBaseDiscount = (transactionDetails.hubbleDiscount.percentage)
      .toPrecision(2)
      .toDisplayNumber();
  return [
    summaryItem(
      title: 'Instant rewards discount ($hubbleBaseDiscount%)',
      subtitle:
          '-${(transactionDetails.hubbleDiscount.amount).toIndianRupee()}',
      style: theme.subHeadingStyle.copyWith(
        color: theme.colors.system.success.dark,
      ),
    ),
    if (transactionDetails.coinDiscount.amount.isGreaterThan(0)) ...[
      theme.height12,
      summaryItem(
        title:
            'Earned rewards discount (${transactionDetails.coinDiscount.percentage}%)',
        subtitle:
            '-${(transactionDetails.coinDiscount.amount).toIndianRupee()}',
        style: theme.subHeadingStyle.copyWith(
          color: theme.colors.system.success.dark,
        ),
      ),
      theme.height2,
      Row(
        children: [
          Container(
            width: 2,
            height: 14,
            color: theme.baseSecondaryLight,
          ),
          theme.width4,
          HubbleText.rich(
            [
              const TextSpan(text: 'Using '),
              const WidgetSpan(
                  child: CoinIcon(
                size: 16,
              )),
              TextSpan(
                  text: ' ${coinAmount.toDisplayNumber()}',
                  style: TextStyle(
                    color: theme.colors.textColorDark,
                    fontWeight: FontWeight.w600,
                  ))
            ],
            style: theme.typography.s13.copyWith(
                color: theme.colors.textColorNormal,
                fontWeight: FontWeight.w400),
          )
        ],
      ),
    ],
  ];
}