mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Update API
This commit is contained in:
@@ -20,5 +20,6 @@ static_library(
|
||||
],
|
||||
frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||
"$SDKROOT/System/Library/Frameworks/MapKit.framework",
|
||||
],
|
||||
)
|
||||
|
||||
27
submodules/TelegramStringFormatting/Sources/Geo.swift
Normal file
27
submodules/TelegramStringFormatting/Sources/Geo.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user