mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 14:53:35 +00:00
Various fixes
This commit is contained in:
parent
9975f939ce
commit
f6b2464ace
@ -46,6 +46,7 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
private var pendingAnchor: String?
|
private var pendingAnchor: String?
|
||||||
private var initialState: InstantPageStoredState?
|
private var initialState: InstantPageStoredState?
|
||||||
|
|
||||||
|
private let wrapperNode: ASDisplayNode
|
||||||
fileprivate let scrollNode: ASScrollNode
|
fileprivate let scrollNode: ASScrollNode
|
||||||
private let scrollNodeFooter: ASDisplayNode
|
private let scrollNodeFooter: ASDisplayNode
|
||||||
private var linkHighlightingNode: LinkHighlightingNode?
|
private var linkHighlightingNode: LinkHighlightingNode?
|
||||||
@ -109,6 +110,7 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
self._state = BrowserContentState(title: title, url: url, estimatedProgress: 0.0, readingProgress: 0.0, contentType: .instantPage)
|
self._state = BrowserContentState(title: title, url: url, estimatedProgress: 0.0, readingProgress: 0.0, contentType: .instantPage)
|
||||||
self.statePromise = Promise<BrowserContentState>(self._state)
|
self.statePromise = Promise<BrowserContentState>(self._state)
|
||||||
|
|
||||||
|
self.wrapperNode = ASDisplayNode()
|
||||||
self.scrollNode = ASScrollNode()
|
self.scrollNode = ASScrollNode()
|
||||||
self.scrollNode.backgroundColor = self.theme.pageBackgroundColor
|
self.scrollNode.backgroundColor = self.theme.pageBackgroundColor
|
||||||
|
|
||||||
@ -128,7 +130,8 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
self.addSubnode(self.scrollNode)
|
self.addSubnode(self.wrapperNode)
|
||||||
|
self.wrapperNode.addSubnode(self.scrollNode)
|
||||||
self.scrollNode.addSubnode(self.scrollNodeFooter)
|
self.scrollNode.addSubnode(self.scrollNodeFooter)
|
||||||
|
|
||||||
self.scrollNode.view.delaysContentTouches = false
|
self.scrollNode.view.delaysContentTouches = false
|
||||||
@ -392,6 +395,8 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
self.scrollNode.view.scrollIndicatorInsets = scrollInsets
|
self.scrollNode.view.scrollIndicatorInsets = scrollInsets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.wrapperNode.frame = CGRect(origin: .zero, size: size)
|
||||||
|
|
||||||
let scrollFrame = CGRect(origin: CGPoint(x: 0.0, y: insets.top), size: CGSize(width: size.width, height: size.height - insets.top))
|
let scrollFrame = CGRect(origin: CGPoint(x: 0.0, y: insets.top), size: CGSize(width: size.width, height: size.height - insets.top))
|
||||||
let scrollFrameUpdated = self.scrollNode.bounds.size != scrollFrame.size
|
let scrollFrameUpdated = self.scrollNode.bounds.size != scrollFrame.size
|
||||||
if scrollFrameUpdated {
|
if scrollFrameUpdated {
|
||||||
@ -1108,12 +1113,12 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
}
|
}
|
||||||
})], catchTapsOutside: true)
|
})], catchTapsOutside: true)
|
||||||
self.present(controller, ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
self.present(controller, ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
||||||
if let _ = self {
|
if let self {
|
||||||
// for (_, itemNode) in self.visibleItemsWithNodes {
|
for (_, itemNode) in self.visibleItemsWithNodes {
|
||||||
// if let (node, _, _) = itemNode.transitionNode(media: media) {
|
if let (node, _, _) = itemNode.transitionNode(media: media) {
|
||||||
// return (self.scrollNode, node.convert(node.bounds, to: self.scrollNode), self, self.bounds)
|
return (self.scrollNode, node.convert(node.bounds, to: self.scrollNode), self.wrapperNode, self.wrapperNode.bounds)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
@ -1201,84 +1206,84 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updateTextSelectionRects(_ rects: [CGRect], text: String?) {
|
private func updateTextSelectionRects(_ rects: [CGRect], text: String?) {
|
||||||
// if let text = text, !rects.isEmpty {
|
if let text = text, !rects.isEmpty {
|
||||||
// let textSelectionNode: LinkHighlightingNode
|
let textSelectionNode: LinkHighlightingNode
|
||||||
// if let current = self.textSelectionNode {
|
if let current = self.textSelectionNode {
|
||||||
// textSelectionNode = current
|
textSelectionNode = current
|
||||||
// } else {
|
} else {
|
||||||
// textSelectionNode = LinkHighlightingNode(color: UIColor.lightGray.withAlphaComponent(0.4))
|
textSelectionNode = LinkHighlightingNode(color: UIColor.lightGray.withAlphaComponent(0.4))
|
||||||
// textSelectionNode.isUserInteractionEnabled = false
|
textSelectionNode.isUserInteractionEnabled = false
|
||||||
// self.textSelectionNode = textSelectionNode
|
self.textSelectionNode = textSelectionNode
|
||||||
// self.scrollNode.addSubnode(textSelectionNode)
|
self.scrollNode.addSubnode(textSelectionNode)
|
||||||
// }
|
}
|
||||||
// textSelectionNode.frame = CGRect(origin: CGPoint(), size: self.scrollNode.bounds.size)
|
textSelectionNode.frame = CGRect(origin: CGPoint(), size: self.scrollNode.bounds.size)
|
||||||
// textSelectionNode.updateRects(rects)
|
textSelectionNode.updateRects(rects)
|
||||||
//
|
|
||||||
//// var coveringRect = rects[0]
|
var coveringRect = rects[0]
|
||||||
//// for i in 1 ..< rects.count {
|
for i in 1 ..< rects.count {
|
||||||
//// coveringRect = coveringRect.union(rects[i])
|
coveringRect = coveringRect.union(rects[i])
|
||||||
//// }
|
}
|
||||||
//
|
|
||||||
//// let context = self.context
|
let context = self.context
|
||||||
//// let strings = self.presentationData.strings
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
//// let _ = (context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.translationSettings])
|
let strings = self.presentationData.strings
|
||||||
//// |> take(1)
|
let _ = (context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.translationSettings])
|
||||||
//// |> deliverOnMainQueue).start(next: { [weak self] sharedData in
|
|> take(1)
|
||||||
//// let translationSettings: TranslationSettings
|
|> deliverOnMainQueue).start(next: { [weak self] sharedData in
|
||||||
//// if let current = sharedData.entries[ApplicationSpecificSharedDataKeys.translationSettings]?.get(TranslationSettings.self) {
|
let translationSettings: TranslationSettings
|
||||||
//// translationSettings = current
|
if let current = sharedData.entries[ApplicationSpecificSharedDataKeys.translationSettings]?.get(TranslationSettings.self) {
|
||||||
//// } else {
|
translationSettings = current
|
||||||
//// translationSettings = TranslationSettings.defaultSettings
|
} else {
|
||||||
//// }
|
translationSettings = TranslationSettings.defaultSettings
|
||||||
////
|
}
|
||||||
//// var actions: [ContextMenuAction] = [ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuCopy, accessibilityLabel: strings.Conversation_ContextMenuCopy), action: { [weak self] in
|
|
||||||
//// UIPasteboard.general.string = text
|
var actions: [ContextMenuAction] = [ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuCopy, accessibilityLabel: strings.Conversation_ContextMenuCopy), action: { [weak self] in
|
||||||
////
|
UIPasteboard.general.string = text
|
||||||
//// if let strongSelf = self {
|
|
||||||
//// let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
if let strongSelf = self {
|
||||||
//// strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil)
|
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil)
|
||||||
//// }
|
}
|
||||||
//// }), ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuShare, accessibilityLabel: strings.Conversation_ContextMenuShare), action: { [weak self] in
|
}), ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuShare, accessibilityLabel: strings.Conversation_ContextMenuShare), action: { [weak self] in
|
||||||
//// if let strongSelf = self, let webPage = strongSelf.webPage, case let .Loaded(content) = webPage.content {
|
if let strongSelf = self, let webPage = strongSelf.webPage, case let .Loaded(content) = webPage.content {
|
||||||
//// strongSelf.present(ShareController(context: strongSelf.context, subject: .quote(text: text, url: content.url)), nil)
|
strongSelf.present(ShareController(context: strongSelf.context, subject: .quote(text: text, url: content.url)), nil)
|
||||||
//// }
|
}
|
||||||
//// })]
|
})]
|
||||||
////
|
|
||||||
//// let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: false, ignoredLanguages: translationSettings.ignoredLanguages)
|
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: false, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||||
//// if canTranslate {
|
if canTranslate {
|
||||||
//// actions.append(ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuTranslate, accessibilityLabel: strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
actions.append(ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuTranslate, accessibilityLabel: strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
||||||
//// let controller = TranslateScreen(context: context, text: text, canCopy: true, fromLanguage: language)
|
let controller = TranslateScreen(context: context, text: text, canCopy: true, fromLanguage: language)
|
||||||
//// controller.pushController = { [weak self] c in
|
controller.pushController = { [weak self] c in
|
||||||
//// (self?.controller?.navigationController as? NavigationController)?._keepModalDismissProgress = true
|
self?.getNavigationController()?._keepModalDismissProgress = true
|
||||||
//// self?.controller?.push(c)
|
self?.push(c)
|
||||||
//// }
|
}
|
||||||
//// controller.presentController = { [weak self] c in
|
controller.presentController = { [weak self] c in
|
||||||
//// self?.controller?.present(c, in: .window(.root))
|
self?.present(c, nil)
|
||||||
//// }
|
}
|
||||||
//// self?.present(controller, nil)
|
self?.present(controller, nil)
|
||||||
//// }))
|
}))
|
||||||
//// }
|
}
|
||||||
////
|
|
||||||
//// let controller = makeContextMenuController(actions: actions)
|
let controller = makeContextMenuController(actions: actions)
|
||||||
//// controller.dismissed = { [weak self] in
|
controller.dismissed = { [weak self] in
|
||||||
//// self?.updateTextSelectionRects([], text: nil)
|
self?.updateTextSelectionRects([], text: nil)
|
||||||
//// }
|
}
|
||||||
//// self?.present(controller, ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
self?.present(controller, ContextMenuControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
||||||
//// if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
//// return (strongSelf.scrollNode, coveringRect.insetBy(dx: -3.0, dy: -3.0), strongSelf, strongSelf.bounds)
|
return (strongSelf.scrollNode, coveringRect.insetBy(dx: -3.0, dy: -3.0), strongSelf.wrapperNode, strongSelf.wrapperNode.bounds)
|
||||||
//// } else {
|
} else {
|
||||||
//// return nil
|
return nil
|
||||||
//// }
|
}
|
||||||
//// }))
|
}))
|
||||||
//// })
|
})
|
||||||
//
|
|
||||||
// textSelectionNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.18)
|
textSelectionNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.18)
|
||||||
// } else if let textSelectionNode = self.textSelectionNode {
|
} else if let textSelectionNode = self.textSelectionNode {
|
||||||
// self.textSelectionNode = nil
|
self.textSelectionNode = nil
|
||||||
// textSelectionNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.18, removeOnCompletion: false, completion: { [weak textSelectionNode] _ in
|
textSelectionNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.18, removeOnCompletion: false, completion: { [weak textSelectionNode] _ in
|
||||||
// textSelectionNode?.removeFromSupernode()
|
textSelectionNode?.removeFromSupernode()
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func findAnchorItem(_ anchor: String, items: [InstantPageItem]) -> (InstantPageItem, CGFloat, Bool, [InstantPageDetailsItem])? {
|
private func findAnchorItem(_ anchor: String, items: [InstantPageItem]) -> (InstantPageItem, CGFloat, Bool, [InstantPageDetailsItem])? {
|
||||||
|
|||||||
@ -6550,8 +6550,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return value - 1
|
return value - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hasBrowserOrAppInFront.set(.single(false))
|
|
||||||
|
|
||||||
let deallocate: () -> Void = {
|
let deallocate: () -> Void = {
|
||||||
self.historyStateDisposable?.dispose()
|
self.historyStateDisposable?.dispose()
|
||||||
self.messageIndexDisposable.dispose()
|
self.messageIndexDisposable.dispose()
|
||||||
@ -7137,7 +7135,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if case .standard(.default) = self.mode {
|
if case .standard(.default) = self.mode, !"".isEmpty {
|
||||||
let hasBrowserOrWebAppInFront: Signal<Bool, NoError> = .single([])
|
let hasBrowserOrWebAppInFront: Signal<Bool, NoError> = .single([])
|
||||||
|> then(
|
|> then(
|
||||||
self.effectiveNavigationController?.viewControllersSignal ?? .single([])
|
self.effectiveNavigationController?.viewControllersSignal ?? .single([])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user