-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add view controller support to hierarchy and layout
- Loading branch information
1 parent
dfba949
commit fa7a3e1
Showing
5 changed files
with
144 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
#if canImport(UIKit) | ||
import UIKit | ||
|
||
open class StandardViewController: UIViewController { | ||
private let realView: StandardView | ||
|
||
public init(realView: StandardView) { | ||
self.realView = realView | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
@available(*, unavailable) | ||
public required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public override func loadView() { | ||
view = realView | ||
} | ||
|
||
public override func viewDidLoad() { | ||
super.viewDidLoad() | ||
realView.hierarchy.install(on: self) | ||
} | ||
} | ||
|
||
#endif |
28 changes: 28 additions & 0 deletions
28
Sources/ViewKit/Standard/StandardViewController+macOS.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
#if canImport(AppKit) | ||
import AppKit | ||
|
||
open class StandardViewController: NSViewController { | ||
private let realView: StandardView | ||
|
||
public init(realView: StandardView) { | ||
self.realView = realView | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
@available(*, unavailable) | ||
public required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public override func loadView() { | ||
view = realView | ||
} | ||
|
||
public override func viewDidLoad() { | ||
super.viewDidLoad() | ||
realView.hierarchy.install(on: self) | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
public protocol NativeViewable { | ||
var asView: NativeView { get } | ||
} | ||
|
||
extension NativeView: NativeViewable { | ||
public var asView: NativeView { self } | ||
} | ||
|
||
extension NativeViewController: NativeViewable { | ||
public var asView: NativeView { view } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters