Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewCont...

74 lines
2.6 KiB
Swift
Raw Normal View History

//
// MastodonResendEmailViewController.swift
// Mastodon
//
// Created by sxiaojian on 2021/2/24.
//
import Combine
import os.log
import UIKit
import WebKit
2021-02-26 11:27:47 +01:00
final class MastodonResendEmailViewController: UIViewController, NeedsDependency {
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
var disposeBag = Set<AnyCancellable>()
var viewModel: MastodonResendEmailViewModel!
let webView: WKWebView = {
let configuration = WKWebViewConfiguration()
configuration.processPool = WKProcessPool()
let webView = WKWebView(frame: .zero, configuration: configuration)
return webView
}()
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function)
// cleanup cookie
let httpCookieStore = webView.configuration.websiteDataStore.httpCookieStore
httpCookieStore.getAllCookies { cookies in
for cookie in cookies {
httpCookieStore.delete(cookie, completionHandler: nil)
}
}
}
2021-02-26 11:27:47 +01:00
}
extension MastodonResendEmailViewController {
2021-04-01 08:39:15 +02:00
override func viewDidLoad() {
super.viewDidLoad()
setupOnboardingAppearance()
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(MastodonResendEmailViewController.cancelBarButtonItemPressed(_:)))
webView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(webView)
NSLayoutConstraint.activate([
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
let request = URLRequest(url: viewModel.resendEmailURL)
2021-02-25 08:39:48 +01:00
webView.navigationDelegate = self.viewModel.navigationDelegate
webView.load(request)
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: resendEmail via: %s", (#file as NSString).lastPathComponent, #line, #function, viewModel.resendEmailURL.debugDescription)
}
2021-04-01 08:39:15 +02:00
}
extension MastodonResendEmailViewController {
@objc private func cancelBarButtonItemPressed(_ sender: UIBarButtonItem) {
dismiss(animated: true, completion: nil)
}
}
// MARK: - OnboardingViewControllerAppearance
extension MastodonResendEmailViewController: OnboardingViewControllerAppearance { }