mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Refactor PasswordSetupUI, PassportUI, GalleryUI and related modules
This commit is contained in:
35
submodules/WebUI/Sources/WebController.swift
Normal file
35
submodules/WebUI/Sources/WebController.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import SafariServices
|
||||
|
||||
public final class WebController: ViewController {
|
||||
private let url: URL
|
||||
|
||||
private var controllerNode: WebControllerNode {
|
||||
return self.displayNode as! WebControllerNode
|
||||
}
|
||||
|
||||
public init(url: URL) {
|
||||
self.url = url
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
||||
self.edgesForExtendedLayout = []
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = WebControllerNode(url: self.url)
|
||||
|
||||
self.displayNodeDidLoad()
|
||||
}
|
||||
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
self.controllerNode.containerLayoutUpdated(layout, transition: transition)
|
||||
}
|
||||
}
|
||||
35
submodules/WebUI/Sources/WebControllerNode.swift
Normal file
35
submodules/WebUI/Sources/WebControllerNode.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import WebKit
|
||||
|
||||
final class WebControllerNode: ViewControllerTracingNode {
|
||||
private let webView: WKWebView
|
||||
|
||||
init(url: URL) {
|
||||
let configuration = WKWebViewConfiguration()
|
||||
self.webView = WKWebView(frame: CGRect(), configuration: configuration)
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
self.webView.allowsLinkPreview = false
|
||||
}
|
||||
self.webView.allowsBackForwardNavigationGestures = true
|
||||
//webView.navigationDelegate = self
|
||||
|
||||
super.init()
|
||||
|
||||
self.view.addSubview(self.webView)
|
||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||
self.webView.scrollView.contentInsetAdjustmentBehavior = .never
|
||||
}
|
||||
self.webView.scrollView.contentInset = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
|
||||
|
||||
self.webView.load(URLRequest(url: url))
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
transition.animateView {
|
||||
self.webView.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: max(1.0, layout.size.height)))
|
||||
}
|
||||
}
|
||||
}
|
||||
19
submodules/WebUI/Sources/WebUI.h
Normal file
19
submodules/WebUI/Sources/WebUI.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// WebUI.h
|
||||
// WebUI
|
||||
//
|
||||
// Created by Peter on 8/11/19.
|
||||
// Copyright © 2019 Telegram Messenger LLP. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for WebUI.
|
||||
FOUNDATION_EXPORT double WebUIVersionNumber;
|
||||
|
||||
//! Project version string for WebUI.
|
||||
FOUNDATION_EXPORT const unsigned char WebUIVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <WebUI/PublicHeader.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user