mastodon-ios/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewMode...

38 lines
996 B
Swift
Raw Normal View History

2021-02-25 08:39:48 +01:00
//
// MastodonResendEmailViewModelNavigationDelegateShim.swift
// Mastodon
//
// Created by sxiaojian on 2021/2/25.
//
import os.log
import Foundation
import WebKit
final class MastodonResendEmailViewModelNavigationDelegateShim: NSObject {
weak var viewModel: MastodonResendEmailViewModel?
init(viewModel: MastodonResendEmailViewModel) {
self.viewModel = viewModel
}
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
}
// MARK: - WKNavigationDelegate
extension MastodonResendEmailViewModelNavigationDelegateShim: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
guard let email = self.viewModel?.email else {
return
}
let scriptString = "document.getElementById('user_email').value = '\(email)';"
webView.evaluateJavaScript(scriptString)
2021-02-25 08:39:48 +01:00
}
}