Location view fixes

This commit is contained in:
Ilya Laktyushin
2020-10-28 23:51:05 +04:00
parent c27ebb4787
commit 2f13d11224
10 changed files with 3969 additions and 3909 deletions

View File

@@ -5,6 +5,7 @@ import Display
import TelegramPresentationData
private let textFont = Font.with(size: 13.0, design: .round, traits: [.bold])
private let smallTextFont = Font.with(size: 11.0, design: .round, traits: [.bold])
private class ChatMessageLiveLocationTimerNodeParams: NSObject {
let backgroundColor: UIColor
@@ -119,10 +120,16 @@ public final class ChatMessageLiveLocationTimerNode: ASDisplayNode {
path.lineCapStyle = .round
path.stroke()
let attributes: [NSAttributedString.Key: Any] = [.font: textFont, .foregroundColor: parameters.foregroundColor]
let attributes: [NSAttributedString.Key: Any] = [.font: parameters.string.count > 2 ? smallTextFont : textFont, .foregroundColor: parameters.foregroundColor]
let nsString = parameters.string as NSString
let size = nsString.size(withAttributes: attributes)
nsString.draw(at: CGPoint(x: floor((bounds.size.width - size.width) / 2.0), y: floor((bounds.size.height - size.height) / 2.0)), withAttributes: attributes)
var offset: CGFloat = 0.0
if parameters.string.count > 2 {
offset = UIScreenPixel
}
nsString.draw(at: CGPoint(x: floor((bounds.size.width - size.width) / 2.0), y: floor((bounds.size.height - size.height) / 2.0) + offset), withAttributes: attributes)
}
}
}