Refactor PasswordSetupUI, PassportUI, GalleryUI and related modules

This commit is contained in:
Peter
2019-08-12 19:18:43 +03:00
parent aa366dee27
commit a49f04203e
311 changed files with 11406 additions and 1899 deletions

View 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)
}
}

View 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)))
}
}
}

View 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>