mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
666b076867
commit
a605c7e31c
@ -108,6 +108,14 @@ private final class VoiceChatControllerTitleNode: ASDisplayNode {
|
|||||||
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tap)))
|
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tap)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||||
|
if point.y > 0.0 && point.y < self.frame.size.height && point.x > min(self.titleNode.frame.minX, self.infoNode.frame.minX) && point.x < max(self.recordingIconNode.frame.maxX, self.infoNode.frame.maxX) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc private func tap() {
|
@objc private func tap() {
|
||||||
self.tapped?()
|
self.tapped?()
|
||||||
}
|
}
|
||||||
@ -1676,9 +1684,21 @@ public final class VoiceChatController: ViewController {
|
|||||||
|
|
||||||
self.titleNode.tapped = { [weak self] in
|
self.titleNode.tapped = { [weak self] in
|
||||||
if let strongSelf = self, !strongSelf.titleNode.recordingIconNode.isHidden {
|
if let strongSelf = self, !strongSelf.titleNode.recordingIconNode.isHidden {
|
||||||
|
var ignore = false
|
||||||
|
strongSelf.controller?.forEachController { controller -> Bool in
|
||||||
|
if controller is TooltipScreen {
|
||||||
|
ignore = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
guard !ignore else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let location = strongSelf.titleNode.recordingIconNode.convert(strongSelf.titleNode.recordingIconNode.bounds, to: nil)
|
let location = strongSelf.titleNode.recordingIconNode.convert(strongSelf.titleNode.recordingIconNode.bounds, to: nil)
|
||||||
strongSelf.controller?.present(TooltipScreen(text: presentationData.strings.VoiceChat_RecordingInProgress, icon: nil, location: .point(location.offsetBy(dx: 1.0, dy: 0.0), .top), displayDuration: .custom(3.0), shouldDismissOnTouch: { _ in
|
strongSelf.controller?.present(TooltipScreen(text: presentationData.strings.VoiceChat_RecordingInProgress, icon: nil, location: .point(location.offsetBy(dx: 1.0, dy: 0.0), .top), displayDuration: .custom(3.0), shouldDismissOnTouch: { _ in
|
||||||
return .dismiss(consume: false)
|
return .dismiss(consume: true)
|
||||||
}), in: .window(.root))
|
}), in: .window(.root))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3418,6 +3438,9 @@ public final class VoiceChatController: ViewController {
|
|||||||
if let controller = controller as? UndoOverlayController {
|
if let controller = controller as? UndoOverlayController {
|
||||||
controller.dismissWithCommitAction()
|
controller.dismissWithCommitAction()
|
||||||
}
|
}
|
||||||
|
if let controller = controller as? TooltipScreen {
|
||||||
|
controller.dismiss()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,11 @@ private final class VoiceChatTitleEditInputFieldNode: ASDisplayNode, ASEditableT
|
|||||||
}
|
}
|
||||||
|
|
||||||
func editableTextNode(_ editableTextNode: ASEditableTextNode, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
func editableTextNode(_ editableTextNode: ASEditableTextNode, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
||||||
|
let updatedText = (editableTextNode.textView.text as NSString).replacingCharacters(in: range, with: text)
|
||||||
|
if updatedText.count > 40 {
|
||||||
|
self.textInputNode.layer.addShakeAnimation()
|
||||||
|
return false
|
||||||
|
}
|
||||||
if text == "\n" {
|
if text == "\n" {
|
||||||
self.complete?()
|
self.complete?()
|
||||||
return false
|
return false
|
||||||
|
@ -37,6 +37,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
private let displayDuration: TooltipScreen.DisplayDuration
|
private let displayDuration: TooltipScreen.DisplayDuration
|
||||||
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
|
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
|
||||||
private let requestDismiss: () -> Void
|
private let requestDismiss: () -> Void
|
||||||
|
private let openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)?
|
||||||
|
|
||||||
private let scrollingContainer: ASDisplayNode
|
private let scrollingContainer: ASDisplayNode
|
||||||
private let containerNode: ASDisplayNode
|
private let containerNode: ASDisplayNode
|
||||||
@ -53,7 +54,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
private var validLayout: ContainerViewLayout?
|
private var validLayout: ContainerViewLayout?
|
||||||
|
|
||||||
init(text: String, textEntities: [MessageTextEntity], style: TooltipScreen.Style, icon: TooltipScreen.Icon?, customContentNode: TooltipCustomContentNode? = nil, location: TooltipScreen.Location, displayDuration: TooltipScreen.DisplayDuration, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void) {
|
init(text: String, textEntities: [MessageTextEntity], style: TooltipScreen.Style, icon: TooltipScreen.Icon?, customContentNode: TooltipCustomContentNode? = nil, location: TooltipScreen.Location, displayDuration: TooltipScreen.DisplayDuration, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)?) {
|
||||||
self.tooltipStyle = style
|
self.tooltipStyle = style
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.customContentNode = customContentNode
|
self.customContentNode = customContentNode
|
||||||
@ -61,6 +62,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
self.displayDuration = displayDuration
|
self.displayDuration = displayDuration
|
||||||
self.shouldDismissOnTouch = shouldDismissOnTouch
|
self.shouldDismissOnTouch = shouldDismissOnTouch
|
||||||
self.requestDismiss = requestDismiss
|
self.requestDismiss = requestDismiss
|
||||||
|
self.openActiveTextItem = openActiveTextItem
|
||||||
|
|
||||||
self.containerNode = ASDisplayNode()
|
self.containerNode = ASDisplayNode()
|
||||||
self.backgroundContainerNode = ASDisplayNode()
|
self.backgroundContainerNode = ASDisplayNode()
|
||||||
@ -216,15 +218,15 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
|
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
|
||||||
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
|
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
|
||||||
}
|
}
|
||||||
openActiveTextItem(.url(url, concealed), .tap)
|
openActiveTextItem?(.url(url, concealed), .tap)
|
||||||
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
||||||
openActiveTextItem(.mention(mention.peerId, mention.mention), .tap)
|
openActiveTextItem?(.mention(mention.peerId, mention.mention), .tap)
|
||||||
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
||||||
openActiveTextItem(.textMention(mention), .tap)
|
openActiveTextItem?(.textMention(mention), .tap)
|
||||||
} else if let command = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand)] as? String {
|
} else if let command = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand)] as? String {
|
||||||
openActiveTextItem(.botCommand(command), .tap)
|
openActiveTextItem?(.botCommand(command), .tap)
|
||||||
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
|
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
|
||||||
openActiveTextItem(.hashtag(hashtag.hashtag), .tap)
|
openActiveTextItem?(.hashtag(hashtag.hashtag), .tap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,15 +239,15 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
|
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
|
||||||
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
|
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
|
||||||
}
|
}
|
||||||
openActiveTextItem(.url(url, concealed), .longTap)
|
openActiveTextItem?(.url(url, concealed), .longTap)
|
||||||
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
||||||
openActiveTextItem(.mention(mention.peerId, mention.mention), .longTap)
|
openActiveTextItem?(.mention(mention.peerId, mention.mention), .longTap)
|
||||||
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
||||||
openActiveTextItem(.textMention(mention), .longTap)
|
openActiveTextItem?(.textMention(mention), .longTap)
|
||||||
} else if let command = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand)] as? String {
|
} else if let command = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand)] as? String {
|
||||||
openActiveTextItem(.botCommand(command), .longTap)
|
openActiveTextItem?(.botCommand(command), .longTap)
|
||||||
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
|
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
|
||||||
openActiveTextItem(.hashtag(hashtag.hashtag), .longTap)
|
openActiveTextItem?(.hashtag(hashtag.hashtag), .longTap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +373,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
if let event = event {
|
if let event = event {
|
||||||
if let result = self.textNode.hitTest(self.view.convert(point, to: self.textNode.view), with: event) {
|
if let _ = self.openActiveTextItem, let result = self.textNode.hitTest(self.view.convert(point, to: self.textNode.view), with: event) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +518,7 @@ public final class TooltipScreen: ViewController {
|
|||||||
private let location: TooltipScreen.Location
|
private let location: TooltipScreen.Location
|
||||||
private let displayDuration: DisplayDuration
|
private let displayDuration: DisplayDuration
|
||||||
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
|
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
|
||||||
private let openActiveTextItem: (TooltipActiveTextItem, TooltipActiveTextAction) -> Void
|
private let openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)?
|
||||||
|
|
||||||
private var controllerNode: TooltipScreenNode {
|
private var controllerNode: TooltipScreenNode {
|
||||||
return self.displayNode as! TooltipScreenNode
|
return self.displayNode as! TooltipScreenNode
|
||||||
@ -530,7 +532,7 @@ public final class TooltipScreen: ViewController {
|
|||||||
|
|
||||||
private var dismissTimer: Foundation.Timer?
|
private var dismissTimer: Foundation.Timer?
|
||||||
|
|
||||||
public init(text: String, textEntities: [MessageTextEntity] = [], style: TooltipScreen.Style = .default, icon: TooltipScreen.Icon?, customContentNode: TooltipCustomContentNode? = nil, location: TooltipScreen.Location, displayDuration: DisplayDuration = .default, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void = { _, _ in }) {
|
public init(text: String, textEntities: [MessageTextEntity] = [], style: TooltipScreen.Style = .default, icon: TooltipScreen.Icon?, customContentNode: TooltipCustomContentNode? = nil, location: TooltipScreen.Location, displayDuration: DisplayDuration = .default, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)? = nil) {
|
||||||
self.text = text
|
self.text = text
|
||||||
self.textEntities = textEntities
|
self.textEntities = textEntities
|
||||||
self.style = style
|
self.style = style
|
||||||
|
Loading…
x
Reference in New Issue
Block a user