-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deep linking preventing subsequent event/news screen from being d…
…isplayed
- Loading branch information
Showing
5 changed files
with
93 additions
and
27 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
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
39 changes: 39 additions & 0 deletions
39
NOICommunityLib/Sources/CoreUI/UIWindow+topViewController.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,39 @@ | ||
// SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
// | ||
// UIWindow+topViewController.swift | ||
// NOICommunityLib | ||
// | ||
// Created by Matteo Matassoni on 06/12/24. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIWindow { | ||
|
||
var topViewController: UIViewController? { | ||
topMostViewController(from: rootViewController) | ||
} | ||
|
||
} | ||
|
||
private extension UIWindow { | ||
|
||
func topMostViewController( | ||
from viewController: UIViewController? | ||
) -> UIViewController? { | ||
if let presentedViewController = viewController?.presentedViewController { | ||
topMostViewController(from: presentedViewController) | ||
} else if let tabBarController = viewController as? UITabBarController { | ||
topMostViewController(from: tabBarController.selectedViewController) | ||
} else if let navigationController = viewController as? UINavigationController, | ||
let topViewController = navigationController.topViewController { | ||
topMostViewController(from: topViewController) | ||
} else { | ||
viewController | ||
} | ||
} | ||
|
||
} |