-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ Impl: Add
RNIModalViewControllerWrapper
- Loading branch information
1 parent
c23dc7d
commit a6c17d0
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
ios/src_library/React Native/RNIModal/RNIModalViewControllerWrapper.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,105 @@ | ||
// | ||
// RNIModalViewControllerWrapper.swift | ||
// react-native-ios-modal | ||
// | ||
// Created by Dominic Go on 4/13/23. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Wraps a `UIViewController` so it can be used w/ `RNIModalManager` | ||
/// | ||
public class RNIModalViewControllerWrapper: | ||
RNIIdentifiable, RNIModalPresentationNotifying, RNIModalState, | ||
RNIModalPresentation { | ||
|
||
// MARK: - Properties - RNIIdentifiable | ||
// ------------------------------------ | ||
|
||
public static var synthesizedIdPrefix: String = "modal-wrapper-"; | ||
|
||
// MARK: - Properties - RNIModalPresentationNotifying | ||
// -------------------------------------------------- | ||
|
||
public var modalPresentationNotificationDelegate: RNIModalPresentationNotifiable! | ||
|
||
// MARK: - Properties - RNIModalState | ||
// ---------------------------------- | ||
|
||
public var modalIndexPrev: Int! | ||
public var modalIndex: Int! | ||
|
||
public lazy var modalPresentationState = RNIModalPresentationStateMachine(); | ||
|
||
public var modalFocusState = RNIModalFocusStateMachine(); | ||
|
||
// MARK: - Properties - RNIModalPresentation | ||
// ----------------------------------------- | ||
|
||
/// The modal that is being presented, or to be presented (i.e. | ||
/// `UIViewController.presentedViewController`). | ||
/// | ||
public weak var modalViewController: UIViewController?; | ||
|
||
/// The view controller that presented the modal (i.e. | ||
/// `modalViewController` or `UIViewController.presentingViewController`) | ||
/// | ||
public weak var presentingViewController: UIViewController?; | ||
|
||
public var window: UIWindow? { | ||
self.presentingViewController?.view.window | ||
}; | ||
|
||
// MARK: - | ||
// ------------------ | ||
|
||
|
||
public init(){ | ||
RNIModalManagerShared.register(modal: self); | ||
}; | ||
}; | ||
|
||
// MARK: - RNIModalRequestable | ||
// --------------------------- | ||
|
||
extension RNIModalViewControllerWrapper: RNIModalRequestable { | ||
|
||
public func requestModalToShow( | ||
sender: any RNIModal, | ||
onRequestApprovedBlock: () -> Void, | ||
onRequestDeniedBlock: (String) -> Void | ||
) { | ||
// TBA - no-op | ||
}; | ||
|
||
public func requestModalToHide( | ||
sender: any RNIModal, | ||
onRequestApprovedBlock: () -> Void, | ||
onRequestDeniedBlock: (String) -> Void | ||
) { | ||
// TBA - no-op | ||
}; | ||
}; | ||
|
||
// MARK: - RNIModalFocusNotifiable | ||
// ------------------------------- | ||
|
||
extension RNIModalViewControllerWrapper: RNIModalFocusNotifiable { | ||
public func onModalWillFocusNotification(sender: any RNIModal) { | ||
// no-op | ||
} | ||
|
||
public func onModalDidFocusNotification(sender: any RNIModal) { | ||
// no-op | ||
} | ||
|
||
public func onModalWillBlurNotification(sender: any RNIModal) { | ||
// no-op | ||
} | ||
|
||
public func onModalDidBlurNotification(sender: any RNIModal) { | ||
// no-op | ||
} | ||
}; | ||
|
||
|