Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,58 @@
import Foundation
import MapKit
import TelegramPresentationData
private var sharedShortDistanceFormatter: MKDistanceFormatter?
public func shortStringForDistance(strings: PresentationStrings, distance: Int32) -> String {
let distanceFormatter: MKDistanceFormatter
if let currentDistanceFormatter = sharedShortDistanceFormatter {
distanceFormatter = currentDistanceFormatter
} else {
distanceFormatter = MKDistanceFormatter()
distanceFormatter.unitStyle = .abbreviated
sharedShortDistanceFormatter = distanceFormatter
}
let locale = localeWithStrings(strings)
if distanceFormatter.locale != locale {
distanceFormatter.locale = locale
}
let distance = max(1, distance)
var result = distanceFormatter.string(fromDistance: Double(distance))
if result.hasPrefix("0 ") {
result = result.replacingOccurrences(of: "0 ", with: "1 ")
}
return result
}
private var sharedDistanceFormatter: MKDistanceFormatter?
public func stringForDistance(strings: PresentationStrings, distance: CLLocationDistance) -> String {
let distanceFormatter: MKDistanceFormatter
if let currentDistanceFormatter = sharedDistanceFormatter {
distanceFormatter = currentDistanceFormatter
} else {
distanceFormatter = MKDistanceFormatter()
distanceFormatter.unitStyle = .full
sharedDistanceFormatter = distanceFormatter
}
let locale = localeWithStrings(strings)
if distanceFormatter.locale != locale {
distanceFormatter.locale = locale
}
return distanceFormatter.string(fromDistance: distance)
}
public func flagEmoji(countryCode: String) -> String {
if countryCode.uppercased() == "FT" {
return "🏴‍☠️"
}
let base : UInt32 = 127397
var flagString = ""
for v in countryCode.uppercased().unicodeScalars {
flagString.unicodeScalars.append(UnicodeScalar(base + v.value)!)
}
return flagString
}