mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 08:36:22 +08:00
61 lines
1.7 KiB
Swift
61 lines
1.7 KiB
Swift
import Capacitor
|
|
import Intelligents
|
|
import UIKit
|
|
|
|
class AFFiNEViewController: CAPBridgeViewController {
|
|
var baseUrl: String? {
|
|
didSet { Intelligents.setUpstreamEndpoint(baseUrl ?? "") }
|
|
}
|
|
var documentID: String?
|
|
var workspaceID: String?
|
|
var documentContent: String?
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
webView?.allowsBackForwardNavigationGestures = true
|
|
navigationController?.navigationBar.isHidden = true
|
|
extendedLayoutIncludesOpaqueBars = false
|
|
edgesForExtendedLayout = []
|
|
let intelligentsButton = installIntelligentsButton()
|
|
intelligentsButton.delegate = self
|
|
dismissIntelligentsButton()
|
|
}
|
|
|
|
override func webViewConfiguration(for instanceConfiguration: InstanceConfiguration) -> WKWebViewConfiguration {
|
|
let configuration = super.webViewConfiguration(for: instanceConfiguration)
|
|
return configuration
|
|
}
|
|
|
|
override func webView(with frame: CGRect, configuration: WKWebViewConfiguration) -> WKWebView {
|
|
return super.webView(with: frame, configuration: configuration)
|
|
}
|
|
|
|
override func capacitorDidLoad() {
|
|
let plugins: [CAPPlugin] = [
|
|
AuthPlugin(),
|
|
CookiePlugin(),
|
|
HashcashPlugin(),
|
|
NavigationGesturePlugin(),
|
|
IntelligentsPlugin(representController: self),
|
|
NbStorePlugin(),
|
|
]
|
|
plugins.forEach { bridge?.registerPluginInstance($0) }
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
super.viewDidAppear(animated)
|
|
navigationController?.setNavigationBarHidden(false, animated: animated)
|
|
}
|
|
|
|
#if DEBUG
|
|
override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
|
|
super.motionEnded(motion, with: event)
|
|
if motion == .motionShake {
|
|
presentIntelligentsButton()
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
|