Skip to content

Commit

Permalink
Show backed amount total (#810)
Browse files Browse the repository at this point in the history
* Show total backed amount

* Fix tests
  • Loading branch information
justinswart authored Aug 21, 2019
1 parent 861ea22 commit 4554b82
Show file tree
Hide file tree
Showing 28 changed files with 5 additions and 19 deletions.
6 changes: 1 addition & 5 deletions Library/SharedFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,8 @@ public func formattedAmountForRewardOrBacking(
omitCurrencyCode: project.stats.omitUSCurrencyCode
)
case let .right(backing):
let amount = backing.amount
let backingAmount = floor(amount) == backing.amount
? String(Int(amount))
: String(format: "%.2f", backing.amount)
return Format.formattedCurrency(
backingAmount,
backing.amount,
country: project.country,
omitCurrencyCode: project.stats.omitUSCurrencyCode
)
Expand Down
16 changes: 3 additions & 13 deletions Library/ViewModels/PledgeCTAContainerViewViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ private func subtitle(project: Project, pledgeState: PledgeStateCTAType) -> Stri

if pledgeState == .fix { return pledgeState.subtitleLabel ?? "" }

let basicPledge = formattedAmount(for: backing)
let amount = Format.formattedCurrency(
basicPledge,
country: project.country,
omitCurrencyCode: project.stats.omitUSCurrencyCode
let amount = formattedAmountForRewardOrBacking(
project: project,
rewardOrBacking: .right(backing)
)

let reward = backing.reward
Expand All @@ -139,11 +137,3 @@ private func subtitle(project: Project, pledgeState: PledgeStateCTAType) -> Stri
guard let rewardTitle = reward.title else { return "\(amount)" }
return "\(amount)\(rewardTitle)"
}

private func formattedAmount(for backing: Backing) -> String {
let amount = backing.amount - Double(backing.shippingAmount ?? 0)
let backingAmount = floor(amount) == amount
? String(Int(amount))
: String(format: "%.2f", backing.amount)
return backingAmount
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal final class PledgeCTAContainerViewViewModelTests: TestCase {
self.buttonStyleType.assertValues([ButtonStyleType.blue])
self.buttonTitleText.assertValues([Strings.Manage()])
self.titleText.assertValues([Strings.Youre_a_backer()])
self.subtitleText.assertValues(["$8 • Magic Lamp"])
self.subtitleText.assertValues(["$10 • Magic Lamp"])
self.spacerIsHidden.assertValues([false])
self.stackViewIsHidden.assertValues([false])
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4554b82

Please sign in to comment.