-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-203] (1/2) Pledge summary section #845
Conversation
Generated by 🚫 Danger |
let _ = backing.rewardId else { | ||
return true | ||
} | ||
if let reward = backing.reward { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes a backing can have rewardId
but the reward
can still be nil
Library/Format.swift
Outdated
@@ -144,6 +144,12 @@ public enum Format { | |||
return NSAttributedString(string: Strings.plus_shipping_cost(shipping_cost: ""), attributes: attributes) | |||
} | |||
|
|||
public static func attributedAmount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this function to return the attributed amount without the +
sign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a reason that we'd want to do this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably remove this function now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Couple of small things.
|> \.textColor .~ UIColor.black | ||
|> \.font .~ UIFont.ksr_subhead().bolded | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.text %~ { _ in "Total amount" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to use localizedString
directly until we have the string added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually after merging master I noticed that most of the strings were already there!
var outputs: ManagePledgeSummaryViewViewModelOutputs { get } | ||
} | ||
|
||
public class ManagePledgeSummaryViewViewModel: ManagePledgeSummaryViewViewModelType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure when we started calling VM's VVM's 😅. I don't think we should be naming them ViewViewModel
, the fact that this VM is used for a View and not a ViewController doesn't matter, we should just call it ManagePledgeSummaryViewModel
, I think we should also add an investment day task to fix these names in the codebase for other VVMs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol it makes sense. I will rename it
.zip(with: backing) | ||
|
||
self.backerNumberText = backing | ||
.map { "Backer #\($0.sequence)" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use localizedString
until this is translated.
|
||
private func formattedPledgeDate(_ backing: Backing) -> String { | ||
let formattedDate = Format.date(secondsInUTC: backing.pledgedAt, dateStyle: .long, timeStyle: .none) | ||
return "As of \(formattedDate)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localizedString
Library/Format.swift
Outdated
@@ -144,6 +144,12 @@ public enum Format { | |||
return NSAttributedString(string: Strings.plus_shipping_cost(shipping_cost: ""), attributes: attributes) | |||
} | |||
|
|||
public static func attributedAmount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a reason that we'd want to do this 🤔
let combinedAttributes = defaultAttributes | ||
.withAllValuesFrom(superscriptAttributes) | ||
|
||
return Format.attributedAmount(attributes: combinedAttributes) + attributedCurrency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as we don't need the +
sign, we can just do:
private func attributedCurrency(with project: Project, amount: Double) -> NSAttributedString? {
let defaultAttributes = checkoutCurrencyDefaultAttributes()
.withAllValuesFrom([.foregroundColor: UIColor.ksr_green_500])
let superscriptAttributes = checkoutCurrencySuperscriptAttributes()
guard
let attributedCurrency = Format.attributedCurrency(
amount,
country: project.country,
omitCurrencyCode: project.stats.omitUSCurrencyCode,
defaultAttributes: defaultAttributes,
superscriptAttributes: superscriptAttributes
) else { return nil }
return attributedCurrency
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer than my solution :)
superscriptAttributes: superscriptAttributes | ||
) else { return nil } | ||
|
||
let combinedAttributes = defaultAttributes.merging(superscriptAttributes) { _, new in new } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using .withAllValuesFrom(superscriptAttributes)
is a bit neater and does the same thing 👍
By the way, I noticed there's an autolayout warning when presenting the alert controller, it seems to be a UIKit bug: http://openradar.appspot.com/49289931 |
I think that we should use the |
.skipNil() | ||
|
||
self.shippingLocationText = backing.ignoreValues() | ||
.map { Strings.Shipping() + ": " + "Australia" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here Australia
is hardcoded because we will use a Backing property called locationName
. This is done in another branch (for the 2/2 PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think we want to add a new string here:
"Shipping: %{country_name}"
Although it seems very much like what you have, by including the :
in the string we give the translator the ability to move it around if they need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, before I implemented this, I checked out the Android codebase and that's how it was implemented. I can create a new string on the second part of this work, but I'm not sure if it would make a big difference.
cc @ginarovirosa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @Scollaco @justinswart. Indeed having the Shipping: %{country_name}
format makes it easier for the translators to work around country name prefixes. Fwiw, it does seem that the Shipping: %{country_name}
variable is an old one. We use %{country}
now. As you can see in this string for instance: en -> pledges -> checkout_summary -> Shipping_to_country
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ginarovirosa!
Will wait to hear back from @ginarovirosa on that string. What about this comment? Is there a max number of lines set? I'm surprised it doesn't wrap on space. |
It didn't have a number of lines set. I had set
Seeing the difference I'm leaning towards the lines = 0 solution, because then it won't compromise the font size too much depending on the text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, just the string to add in the next PR 👍
📲 What
ManageViewPledgeViewController
.Note:
JIRA ticket
🤔 Why
ManagePledge
feature. More to come.🛠 How
ManagePledgeSummaryView
classManageViewPledgeViewController
👀 See
♿️ Accessibility
✅ Acceptance criteria
With NativeCheckoutPledgeView feature enabled:
Profile
and choose a backed project.