-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[MBL-2120] PLOT - Fixing issue when device locate is ES #2297
Conversation
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 have a question about the expected server behavior before I can continue reviewing this code.
Library/Format.swift
Outdated
/// - Returns: An `NSAttributedString` where the currency symbol and decimals are displayed in a smaller font. | ||
/// If the amount cannot be parsed, it returns the amount as a plain attributed string. | ||
public static func attributedCurrency( | ||
amountString: String, |
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.
Question. amountString
will be set to the amountAsFloat
sent from the server, correct? Why would amountAsFloat
include any regional formatting, like comma separators? My assumption would be that the server should be sending a 'plain' string like "2499.75"
, not "2,499.75"
.
@lukert33 can you clarify the server's behavior here?
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.
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.
Huh, that's not what I would have expected. Surprising.
Library/Format.swift
Outdated
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.
Can you link the ticket that will address cleaning these format helpers up once the backend is updated to give us the correct formatted string as well?
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 seeing what's changed in these snapshots 🤔
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.
Good work. Looking forward to having the server handle this for us so we dont have to do so much formatting client side
…Currency` to represents the amounts in all of the PLOT stuff related
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.
PLOT UI now fully uses amountFormattedInProjectNativeCurrency
for amounts.
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.
Snapshots updated since the increments amounts are using a plain text instead of a attributed text
@@ -84,38 +84,12 @@ public struct PLOTPaymentScheduleItem: Equatable { | |||
timeStyle: .none | |||
) | |||
|
|||
self.amountString = increment.amount.amountFormattedInProjectNativeCurrency |
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.
Set amountFormattedInProjectNativeCurrency
directly to have a plain text in the UILabel
with: increments, | ||
project: project | ||
) | ||
.observeValues { [weak self] increments in |
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.
Removed project
since it is not more necessary
@@ -100,7 +100,7 @@ final class PledgeOverTimePaymentScheduleViewController: UIViewController { | |||
itemView.configure( | |||
with: item.dateString, | |||
badgeTitle: item.stateLabel, | |||
amountAttributedText: item.amountAttributedText, | |||
amountString: item.amountString, |
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.
Use a string instead of a attributedText due the UI is showing a plain 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.
Snapshots updated due the amount labels are using a plain text instead of a attributed text with currency symbols and decimals with smaller size and offset
@@ -1,6 +1,5 @@ | |||
fragment PaymentIncrementFragment on PaymentIncrement { | |||
amount { | |||
amountAsFloat |
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 don't need amountAsFloat
anymore
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.
LGTM! Thanks for reworking this.
There are two follow-up tickets from this PR:
https://kickstarter.atlassian.net/browse/PAY-3468
https://kickstarter.atlassian.net/browse/MBL-2123
* Fixing issue when device locate is ES * Fixing test * Removing `amountAsFloat` and only use `amountFormattedInProjectNativeCurrency` to represents the amounts in all of the PLOT stuff related * Remove unused Project reference
* marketing version to 5.23.0 * [MBL-2120] PLOT - Fixing issue when device locate is ES (#2297) * Fixing issue when device locate is ES * Fixing test * Removing `amountAsFloat` and only use `amountFormattedInProjectNativeCurrency` to represents the amounts in all of the PLOT stuff related * Remove unused Project reference --------- Co-authored-by: jovaniks <j.luna.c@kickstarter.com>
📲 What
This PR addresses the currency formatting issue in the Checkout Screen and Manage Pledge screens by using
amountFormattedInProjectNativeCurrency
for correctly formatted amounts and mappingamountAsFloat
to a new string-based field for accurate display in attributed text.🤔 Why
,
) instead of a dot (.
) for some locales, causing incorrect currency formatting.amountAsFloat
is inconsistent across different regional settings, leading to UI issues when displaying amounts.amountAsFloat
alone cannot handle.🛠 How
amountAsFloat
is mapped to a new field:PledgePaymentIncrementAmount.amountStringValue
(String type).amountFormattedInProjectNativeCurrency
to ensure the correct format without additional parsing.attributedCurrency
to handle attributed string formatting for currency values.parseAmountComponents
to extract integer, decimal separator, and decimal part fromamountStringValue
for proper UI display.👀 See
✅ Acceptance criteria
⏰ TODO