Skip to content

Commit

Permalink
extension CAViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Dec 17, 2023
1 parent 01b76bd commit e65001e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Sources/CommonAppleKit/CommonAppleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
}
}

public extension CAViewController {
func present(_ viewControllerToPresent: CAViewController) {
present(viewControllerToPresent, animated: true)
}

var presentedViewControllers: [CAViewController]? {
presentedViewController.map { [$0] }
}

func dismiss(_ viewController: CAViewController) {
viewController.dismiss(animated: true)
}
}
#elseif canImport(AppKit)
import AppKit

Expand Down Expand Up @@ -155,15 +168,15 @@
}

public extension CATabBarController {
var viewControllers: [CAViewController] {
var viewControllers: [CAViewController]? {
get {
tabViewItems.compactMap(\.viewController)
}

set {
tabViewItems = newValue.map {
tabViewItems = newValue?.map {
.init(viewController: $0)
}
} ?? []
}
}
}
Expand Down Expand Up @@ -193,6 +206,12 @@
}
}
}

public extension CAViewController {
func present(_ viewControllerToPresent: CAViewController) {
presentAsModalWindow(viewControllerToPresent)
}
}
#endif

public extension CAButton {
Expand Down

0 comments on commit e65001e

Please sign in to comment.