mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
21 lines
558 B
Swift
21 lines
558 B
Swift
import Foundation
|
|
import libphonenumber
|
|
|
|
public final class InteractivePhoneFormatter {
|
|
private let formatter = NBAsYouTypeFormatter(regionCode: "US")!
|
|
|
|
public init() {
|
|
}
|
|
|
|
public func updateText(_ text: String) -> (String?, String) {
|
|
self.formatter.clear()
|
|
let string = self.formatter.inputString(text)
|
|
|
|
var regionPrefix = self.formatter.regionPrefix
|
|
if let string = string, string.hasPrefix("+383") {
|
|
regionPrefix = "+383"
|
|
}
|
|
return (regionPrefix, string ?? "")
|
|
}
|
|
}
|