mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
9ebff2dd6c
commit
965be89632
@ -589,7 +589,7 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
|
||||
let textFieldHeight: CGFloat
|
||||
if let textInputNode = self.textInputNode {
|
||||
let maxTextWidth = width - textFieldInsets.left - textFieldInsets.right - self.textInputViewInternalInsets.left - self.textInputViewInternalInsets.right
|
||||
let measuredHeight = textInputNode.textHeightForWidth(maxTextWidth)
|
||||
let measuredHeight = textInputNode.textHeightForWidth(maxTextWidth, rightInset: 0.0)
|
||||
let unboundTextFieldHeight = max(textFieldMinHeight, ceil(measuredHeight))
|
||||
|
||||
let maxNumberOfLines = min(12, (Int(fieldMaxHeight - 11.0) - 33) / 22)
|
||||
|
@ -2016,7 +2016,7 @@ public func chatWebpageSnippetFile(account: Account, userLocation: MediaResource
|
||||
}
|
||||
}
|
||||
|
||||
public func chatWebpageSnippetPhoto(account: Account, userLocation: MediaResourceUserLocation, photoReference: ImageMediaReference) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||
public func chatWebpageSnippetPhoto(account: Account, userLocation: MediaResourceUserLocation, photoReference: ImageMediaReference, placeholderColor: UIColor? = nil) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||
let signal = chatWebpageSnippetPhotoData(account: account, userLocation: userLocation, photoReference: photoReference)
|
||||
|
||||
return signal |> map { fullSizeData in
|
||||
@ -2053,6 +2053,22 @@ public func chatWebpageSnippetPhoto(account: Account, userLocation: MediaResourc
|
||||
|
||||
addCorners(context, arguments: arguments)
|
||||
|
||||
return context
|
||||
} else if let placeholderColor {
|
||||
guard let context = DrawingContext(size: arguments.drawingSize, scale: arguments.scale ?? 0.0, clear: true) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
context.withFlippedContext { c in
|
||||
c.setBlendMode(.copy)
|
||||
if arguments.corners.topLeft.radius != 0.0 {
|
||||
c.addPath(UIBezierPath(roundedRect: arguments.drawingRect, cornerRadius: arguments.corners.topLeft.radius).cgPath)
|
||||
c.clip()
|
||||
}
|
||||
c.setFillColor(placeholderColor.cgColor)
|
||||
c.fill(arguments.drawingRect)
|
||||
}
|
||||
|
||||
return context
|
||||
} else {
|
||||
return nil
|
||||
|
@ -130,8 +130,8 @@ open class ChatInputTextNode: ASDisplayNode, UITextViewDelegate {
|
||||
public func resetInitialPrimaryLanguage() {
|
||||
}
|
||||
|
||||
public func textHeightForWidth(_ width: CGFloat) -> CGFloat {
|
||||
return self.textView.textHeightForWidth(width)
|
||||
public func textHeightForWidth(_ width: CGFloat, rightInset: CGFloat) -> CGFloat {
|
||||
return self.textView.textHeightForWidth(width, rightInset: rightInset)
|
||||
}
|
||||
|
||||
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
||||
@ -463,10 +463,6 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
||||
horizontalInsetsUpdated = true
|
||||
self.customTextContainer.rightInset = result.right
|
||||
}
|
||||
if self.measurementTextContainer.rightInset != result.right {
|
||||
horizontalInsetsUpdated = true
|
||||
self.measurementTextContainer.rightInset = result.right
|
||||
}
|
||||
|
||||
result.left = 0.0
|
||||
result.right = 0.0
|
||||
@ -494,10 +490,11 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
||||
self.updateTextElements()
|
||||
}
|
||||
|
||||
public func textHeightForWidth(_ width: CGFloat) -> CGFloat {
|
||||
public func textHeightForWidth(_ width: CGFloat, rightInset: CGFloat) -> CGFloat {
|
||||
let measureSize = CGSize(width: width, height: 1000000.0)
|
||||
|
||||
if self.measurementTextStorage != self.attributedText || self.measurementTextContainer.size != measureSize {
|
||||
if self.measurementTextStorage != self.attributedText || self.measurementTextContainer.size != measureSize || self.measurementTextContainer.rightInset != rightInset {
|
||||
self.measurementTextContainer.rightInset = rightInset
|
||||
self.measurementTextStorage.setAttributedString(self.attributedText)
|
||||
self.measurementTextContainer.size = measureSize
|
||||
self.measurementLayoutManager.invalidateLayout(forCharacterRange: NSRange(location: 0, length: self.measurementTextStorage.length), actualCharacterRange: nil)
|
||||
|
@ -793,7 +793,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
self.inlineMediaValue = inlineMediaValue
|
||||
|
||||
if updateMedia {
|
||||
let updateInlineImageSignal = chatWebpageSnippetPhoto(account: context.account, userLocation: .peer(message.id.peerId), photoReference: .message(message: MessageReference(message), media: inlineMediaValue))
|
||||
let updateInlineImageSignal = chatWebpageSnippetPhoto(account: context.account, userLocation: .peer(message.id.peerId), photoReference: .message(message: MessageReference(message), media: inlineMediaValue), placeholderColor: mainColor.withMultipliedAlpha(0.1))
|
||||
inlineMedia.setSignal(updateInlineImageSignal)
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ import ChatMessageItemCommon
|
||||
import ChatMessageAnimatedStickerItemNode
|
||||
import ChatMessageBubbleItemNode
|
||||
import ChatNavigationButton
|
||||
import WebsiteType
|
||||
|
||||
public enum ChatControllerPeekActions {
|
||||
case standard
|
||||
@ -17939,9 +17940,19 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
func openUrl(_ url: String, concealed: Bool, forceExternal: Bool = false, skipUrlAuth: Bool = false, skipConcealedAlert: Bool = false, message: Message? = nil, commit: @escaping () -> Void = {}) {
|
||||
self.commitPurposefulAction()
|
||||
|
||||
if let message, let webpage = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content, content.url == url, content.instantPage != nil {
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
self.context.sharedContext.openChatInstantPage(context: self.context, message: message, sourcePeerType: nil, navigationController: navigationController)
|
||||
if let message, let webpage = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content, content.url == url {
|
||||
if content.instantPage != nil {
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
switch instantPageType(of: content) {
|
||||
case .album:
|
||||
break
|
||||
default:
|
||||
self.context.sharedContext.openChatInstantPage(context: self.context, message: message, sourcePeerType: nil, navigationController: navigationController)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if let embedUrl = content.embedUrl, !embedUrl.isEmpty {
|
||||
let _ = self.controllerInteraction?.openMessage(message, .default)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -1173,16 +1173,19 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
}
|
||||
|
||||
var textFieldMinHeight: CGFloat = 35.0
|
||||
var textInputViewRealInsets = UIEdgeInsets()
|
||||
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||
textFieldMinHeight = calclulateTextFieldMinHeight(presentationInterfaceState, metrics: metrics)
|
||||
}
|
||||
|
||||
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||
textInputViewRealInsets = calculateTextFieldRealInsets(presentationInterfaceState: presentationInterfaceState, accessoryButtonsWidth: accessoryButtonsWidth)
|
||||
}
|
||||
|
||||
let textFieldHeight: CGFloat
|
||||
if let textInputNode = self.textInputNode {
|
||||
let maxTextWidth = width - textFieldInsets.left - textFieldInsets.right - self.textInputViewInternalInsets.left - self.textInputViewInternalInsets.right
|
||||
|
||||
//let measuredHeight = textInputNode.measure(CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||
let measuredHeight = textInputNode.textHeightForWidth(maxTextWidth)
|
||||
let measuredHeight = textInputNode.textHeightForWidth(maxTextWidth, rightInset: textInputViewRealInsets.right)
|
||||
|
||||
let unboundTextFieldHeight = max(textFieldMinHeight, ceil(measuredHeight))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user