mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +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)
|
||||
}
|
||||
|
||||
@@ -443,7 +443,8 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
case .phoneNumberRequest:
|
||||
attributedString = nil
|
||||
case let .geoProximityReached(distance):
|
||||
attributedString = NSAttributedString(string: "\(message.peers[message.id.peerId]?.compactDisplayTitle ?? "") is now within \(distance) m from you", font: titleFont, textColor: primaryTextColor)
|
||||
let distanceString = stringForDistance(strings: strings, distance: Double(distance))
|
||||
attributedString = addAttributesToStringWithRanges(strings.Notification_ProximityReached(authorName, distanceString), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
|
||||
case .unknown:
|
||||
attributedString = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user