Skip to content

Commit

Permalink
Remove comments and added assert
Browse files Browse the repository at this point in the history
  • Loading branch information
WanaldinoTelefonica committed Jul 22, 2024
1 parent 057c64c commit 5aec62c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public class CroutonController: NSObject {
public static let `default`: Closure = { UIApplication.shared.windows.filter(\.isKeyWindow).first?.rootViewController }
}

// public typealias RootViewControllerClosure = () -> UIViewController?
// public static let defaultRootViewControllerClosure = { UIApplication.shared.windows.filter(\.isKeyWindow).first?.rootViewController }

public typealias Token = UUID
public typealias ActionConfig = (text: String, accessibilityLabel: String?, handler: DidTapActionBlock)

Expand All @@ -40,27 +37,6 @@ public extension CroutonController {
/// - action: An optional action which will show a button with the given title and invoke the handler when the button is pressed
/// - style: The style of the crouton, `.info` by default
/// - dismissHandler: A handler which is called when the handler is removed from the screen
// @available(iOSApplicationExtension, unavailable)
// @discardableResult
// func showCrouton(
// config: SnackbarConfig,
// style: CroutonStyle = .info,
// dismissHandler: DismissHandlerBlock? = nil
// ) -> Token {
// showCrouton(
// config: config,
// style: style,
// dismissHandler: dismissHandler,
// rootViewController: UIApplication.shared.windows.filter(\.isKeyWindow).first?.rootViewController
// )
// }

/// Show a crouton (or enqueue one if there is already a crouton shown)
/// - Parameters:
/// - text: The text to display in the crouton
/// - action: An optional action which will show a button with the given title and invoke the handler when the button is pressed
/// - style: The style of the crouton, `.info` by default
/// - dismissHandler: A handler which is called when the handler is removed from the screen
/// - rootViewController: The root view controller that will show the crouton.
@discardableResult
func showCrouton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,11 @@ extension CroutonController {
} else if let rootViewController = rootViewController() {
return visibleViewController(from: rootViewController)
} else {
assertionFailure("Root view controller not found!")
return nil
}
}

// private func visibleViewController(_ rootViewController: () -> UIViewController?) -> UIViewController? {
// guard let rootViewController = rootViewController() else {
// assertionFailure("Root view controller not found!")
// return nil
// }
//
// let visibleVC = visibleViewController(from: rootViewController)
//
// if let rootVC = visibleVC as? UINavigationController {
// return visibleViewController(from: rootVC.topViewController!)
// } else if let homeVC = visibleVC.parent?.tabBarController,
// let selectedNavigationController = homeVC.selectedViewController as? UINavigationController {
// return visibleViewController(from: selectedNavigationController.topViewController!)
// } else {
// return visibleVC
// }
// }

private func visibleViewController(from viewController: UIViewController) -> UIViewController {
if let presentedViewController = viewController.presentedViewController {
if presentedViewController is UIAlertController {
Expand Down

0 comments on commit 5aec62c

Please sign in to comment.