1
1
mirror of https://github.com/qvacua/vimr.git synced 2025-01-08 06:58:50 +03:00
vimr/VimR/PreviewComponent.swift

56 lines
1.0 KiB
Swift
Raw Normal View History

2016-12-19 20:23:43 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import RxSwift
import PureLayout
import WebKit
struct PreviewPrefData: StandardPrefData {
static let `default` = PreviewPrefData()
init() {
}
init?(dict: [String: Any]) {
self.init()
}
func dict() -> [String: Any] {
return [:]
}
}
class PreviewComponent: ViewComponent {
fileprivate let previewService = PreviewService()
let webview = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(source: Observable<Any>) {
super.init(source: source)
2016-12-19 23:31:16 +03:00
webview.loadHTMLString(self.previewService.emptyPreview(), baseURL: nil)
2016-12-19 20:23:43 +03:00
}
override func addViews() {
let webview = self.webview
webview.configureForAutoLayout()
self.addSubview(webview)
webview.autoPinEdgesToSuperviewEdges()
}
override func subscription(source: Observable<Any>) -> Disposable {
return Disposables.create()
}
}