mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various improvements
This commit is contained in:
@@ -25,3 +25,22 @@ public func shortStringForDistance(strings: PresentationStrings, distance: Int32
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user