-
Notifications
You must be signed in to change notification settings - Fork 61
feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric #1236
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
base: main
Are you sure you want to change the base?
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 think we need to also move the FUIFormattedStringEditing protocol and its implementations FUINumberFormatter and FUIPhoneNumberFormatter to SwiftUI side as FormattedStringEditing, NumberFormatter, and PhoneNumberFormatter.
The GenericTextFormatter should also implement FormattedStringEditing.
Then in UIKit side use the SwiftUI implementation using the alias to link the old class name to new class name.
Issue: #1162 Should compatibility with the system API |
I added the related files, thank you! |
[HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric - added phoneNumber and CustomNumber formatters
// sourcery: defaultValue = false | ||
var isSecureEnabled: Bool? { get set } | ||
// sourcery: default.value = nil | ||
var formatter: GenericTextFormatter? { get set } |
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 think it is better to use FormattedStringEditing as the formatter type to allow PhoneNumberFormatter and CustomNumberFormatter.
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.
Hi @janhuachu,
Based on the initial discussion with David, we believed that the Generic Text Formatter could cover the functionalities of both PhoneNumberFormatter and CustomNumberFormatter, which is why I didn’t migrate PhoneNumberFormatter and CustomNumberFormatter initially. Now, it appears that these are needed for UIKit compatibility, so I’ve renamed and added them directly. Please correct me if my understanding is inaccurate.
To support PhoneNumberFormatter and CustomNumberFormatter in SwiftUI, implementation adjustments are required because SwiftUI’s TextField doesn’t natively support cursor manipulation. Currently, in SwiftUI, the Generic Text Formatter deletes characters from the middle by jumping to the end and deleting backward. If cursor positioning behavior (like in UIKit) is needed, additional extensions would be necessary, as both PhoneNumberFormatter and CustomNumberFormatter involve cursor operations during deletion.
Moreover, the timing of inserting spaces, hyphens, and other formatting characters differs between PhoneNumberFormatter/CustomNumberFormatter and the Generic Text Formatter.
I have fixed all "Force Unwrapping Violation" warning.
Thank you
cc: @dyongxu
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.
@leoxiao-sap I think it does not make sense if you just move FUINumberFormatter and FUIPhoneNumberFormatter to SwiftUI part without changing the formatter type to optional GenericTextFormatter.
I think it is better to make the formatter type to FormattedStringEdting and move the 2 formatters to the SwiftUI side.
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.
@janhuachu
Thank you for your answer, I will do this update.
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.
@leoxiao-sap I think it does not make sense if you just move FUINumberFormatter and FUIPhoneNumberFormatter to SwiftUI part without changing the formatter type to optional GenericTextFormatter. I think it is better to make the formatter type to FormattedStringEdting and move the 2 formatters to the SwiftUI side.
@janhuachu I have completed this update. Could you please review it? Thank you!
} | ||
|
||
let prefix = (isPositive ? self.positivePrefix : self.negativePrefix)! | ||
let suffix = (isPositive ? self.positiveSuffix : self.negativeSuffix)! |
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 fix all the "Force Unwrapping Violation" warnings.
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.
Overall, good implementation. Please change the formatter's type to FormattedStringEditing to allow developer use CustomNumberFormatter and PhoneNumberFormatter. Also, address the "Force Unwrapping Violation" warnings.
} | ||
|
||
func hasExactly(_ count: Int, consecutive character: Character) -> Bool { | ||
guard count > 0 else { return false } |
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.
Empty Count Violation: Prefer checking isEmpty
over comparing count
to zero. (empty_count)
Dev result

![Uploading Simulator Screenshot - iPhone 16e - 2025-10-17 at 10.40.17.png…]()
Simulator.Screen.Recording.-.iPhone.16.-.2025-08-25.at.18.14.04.mp4