mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-30 18:00:34 +00:00
Merge remote-tracking branch 'refs/remotes/origin/master'
This commit is contained in:
@@ -414,8 +414,7 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
||||
if let state = self.initialState {
|
||||
didSetScrollOffset = true
|
||||
contentOffset = CGPoint(x: 0.0, y: CGFloat(state.contentOffset))
|
||||
}
|
||||
else if let anchor = self.initialAnchor, !anchor.isEmpty {
|
||||
} else if let anchor = self.initialAnchor, !anchor.isEmpty {
|
||||
self.initialAnchor = nil
|
||||
if let items = self.currentLayout?.items {
|
||||
didSetScrollOffset = true
|
||||
@@ -1312,35 +1311,35 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
||||
}
|
||||
|
||||
private func presentReferenceView(item: InstantPageTextItem, referenceAnchor: String) {
|
||||
// guard let theme = self.theme, let webPage = self.webPage else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// var targetAnchor: InstantPageTextAnchorItem?
|
||||
// for (name, (line, _)) in item.anchors {
|
||||
// if name == referenceAnchor {
|
||||
// let anchors = item.lines[line].anchorItems
|
||||
// for anchor in anchors {
|
||||
// if anchor.name == referenceAnchor {
|
||||
// targetAnchor = anchor
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// guard let anchorText = targetAnchor?.anchorText else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let controller = InstantPageReferenceController(context: self.context, sourceLocation: self.sourceLocation, theme: theme, webPage: webPage, anchorText: anchorText, openUrl: { [weak self] url in
|
||||
// self?.openUrl(url)
|
||||
// }, openUrlIn: { [weak self] url in
|
||||
// self?.openUrlIn(url)
|
||||
// }, present: { [weak self] c, a in
|
||||
// self?.present(c, a)
|
||||
// })
|
||||
// self.present(controller, nil)
|
||||
guard let webPage = self.webPage else {
|
||||
return
|
||||
}
|
||||
|
||||
var targetAnchor: InstantPageTextAnchorItem?
|
||||
for (name, (line, _)) in item.anchors {
|
||||
if name == referenceAnchor {
|
||||
let anchors = item.lines[line].anchorItems
|
||||
for anchor in anchors {
|
||||
if anchor.name == referenceAnchor {
|
||||
targetAnchor = anchor
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard let anchorText = targetAnchor?.anchorText else {
|
||||
return
|
||||
}
|
||||
|
||||
let controller = InstantPageReferenceController(context: self.context, sourceLocation: self.sourceLocation, theme: theme, webPage: webPage, anchorText: anchorText, openUrl: { [weak self] url in
|
||||
self?.openUrl(url)
|
||||
}, openUrlIn: { [weak self] url in
|
||||
self?.openUrlIn(url)
|
||||
}, present: { [weak self] c, a in
|
||||
self?.present(c, a)
|
||||
})
|
||||
self.present(controller, nil)
|
||||
}
|
||||
|
||||
private func scrollToAnchor(_ anchor: String) {
|
||||
|
||||
@@ -251,6 +251,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
||||
|
||||
self.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||
self.webView.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||
self.webView.isOpaque = false
|
||||
|
||||
self.webView.allowsBackForwardNavigationGestures = true
|
||||
self.webView.scrollView.delegate = self
|
||||
|
||||
@@ -7,7 +7,7 @@ import SwiftSignalKit
|
||||
import AccountContext
|
||||
import TelegramUIPreferences
|
||||
|
||||
final class InstantPageReferenceController: ViewController {
|
||||
public final class InstantPageReferenceController: ViewController {
|
||||
private var controllerNode: InstantPageReferenceControllerNode {
|
||||
return self.displayNode as! InstantPageReferenceControllerNode
|
||||
}
|
||||
@@ -23,7 +23,7 @@ final class InstantPageReferenceController: ViewController {
|
||||
private let openUrlIn: (InstantPageUrlItem) -> Void
|
||||
private let present: (ViewController, Any?) -> Void
|
||||
|
||||
init(context: AccountContext, sourceLocation: InstantPageSourceLocation, theme: InstantPageTheme, webPage: TelegramMediaWebpage, anchorText: NSAttributedString, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlIn: @escaping (InstantPageUrlItem) -> Void, present: @escaping (ViewController, Any?) -> Void) {
|
||||
public init(context: AccountContext, sourceLocation: InstantPageSourceLocation, theme: InstantPageTheme, webPage: TelegramMediaWebpage, anchorText: NSAttributedString, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlIn: @escaping (InstantPageUrlItem) -> Void, present: @escaping (ViewController, Any?) -> Void) {
|
||||
self.context = context
|
||||
self.sourceLocation = sourceLocation
|
||||
self.theme = theme
|
||||
|
||||
@@ -38,10 +38,10 @@ struct InstantPageTextImageItem {
|
||||
let id: EngineMedia.Id
|
||||
}
|
||||
|
||||
struct InstantPageTextAnchorItem {
|
||||
let name: String
|
||||
let anchorText: NSAttributedString?
|
||||
let empty: Bool
|
||||
public struct InstantPageTextAnchorItem {
|
||||
public let name: String
|
||||
public let anchorText: NSAttributedString?
|
||||
public let empty: Bool
|
||||
}
|
||||
|
||||
public struct InstantPageTextRangeRectEdge: Equatable {
|
||||
@@ -63,7 +63,7 @@ public final class InstantPageTextLine {
|
||||
let strikethroughItems: [InstantPageTextStrikethroughItem]
|
||||
let markedItems: [InstantPageTextMarkedItem]
|
||||
let imageItems: [InstantPageTextImageItem]
|
||||
let anchorItems: [InstantPageTextAnchorItem]
|
||||
public let anchorItems: [InstantPageTextAnchorItem]
|
||||
let isRTL: Bool
|
||||
|
||||
init(line: CTLine, range: NSRange, frame: CGRect, strikethroughItems: [InstantPageTextStrikethroughItem], markedItems: [InstantPageTextMarkedItem], imageItems: [InstantPageTextImageItem], anchorItems: [InstantPageTextAnchorItem], isRTL: Bool) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import TelegramCore
|
||||
import UrlEscaping
|
||||
|
||||
public func decodeCodableDrawingEntities(data: Data) -> [CodableDrawingEntity] {
|
||||
if let codableEntities = try? JSONDecoder().decode([CodableDrawingEntity].self, from: data) {
|
||||
@@ -183,13 +184,9 @@ public enum CodableDrawingEntity: Equatable {
|
||||
return nil
|
||||
}
|
||||
case let .link(entity):
|
||||
var url = entity.url
|
||||
if !url.hasPrefix("http://") && !url.hasPrefix("https://") {
|
||||
url = "https://\(url)"
|
||||
}
|
||||
return .link(
|
||||
coordinates: coordinates,
|
||||
url: url
|
||||
url: explicitUrl(entity.url)
|
||||
)
|
||||
case let .weather(entity):
|
||||
let color: UInt32
|
||||
|
||||
Reference in New Issue
Block a user