Skip to content

Commit

Permalink
💫 Update: RNIModalView
Browse files Browse the repository at this point in the history
Summary: Add `animated` param to `presentModal`, and `dismissModal` functions.
  • Loading branch information
dominicstop committed May 13, 2023
1 parent d92b3dc commit 5365fbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ios/src_library/React Native/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,10 @@ public class RNIModalView:
// MARK: - Functions - Public
// --------------------------

public func presentModal(completion: CompletionHandler? = nil) throws {
public func presentModal(
animated: Bool = true,
completion: CompletionHandler? = nil
) throws {
guard self.window != nil else {
throw RNIModalError(
code: .runtimeError,
Expand Down Expand Up @@ -860,7 +863,7 @@ public class RNIModalView:
self.synthesizedBaseEventData.synthesizedJSDictionary
);

topMostPresentedVC.present(modalVC, animated: true) { [unowned self] in
topMostPresentedVC.present(modalVC, animated: animated) { [unowned self] in

// Become the modal's presentation delegate after it has been presented
// in order to not override system-defined default modal behavior
Expand Down Expand Up @@ -888,7 +891,10 @@ public class RNIModalView:
};
};

public func dismissModal(completion: CompletionHandler? = nil) throws {
public func dismissModal(
animated: Bool = true,
completion: CompletionHandler? = nil
) throws {
guard self.computedIsModalPresented else {
throw RNIModalError(
code: .modalAlreadyHidden,
Expand Down Expand Up @@ -942,7 +948,7 @@ public class RNIModalView:
self.synthesizedBaseEventData.synthesizedJSDictionary
);

presentedVC.dismiss(animated: true){
presentedVC.dismiss(animated: animated){
self.modalPresentationState.set(state: .DISMISSED);

self.onModalDidDismiss?(
Expand Down Expand Up @@ -1102,15 +1108,15 @@ extension RNIModalView: RNIModalRequestable {
animated: Bool,
completion: @escaping () -> Void
) throws {
try self.presentModal(completion: completion);
try self.presentModal(animated: animated, completion: completion);
};

public func requestModalToHide(
sender: Any,
animated: Bool,
completion: @escaping () -> Void
) throws {
try self.dismissModal(completion: completion);
try self.dismissModal(animated: animated, completion: completion);
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class RNIModalViewModule: RCTEventEmitter {
: modalView.dismissModal;

do {
try modalAction() {
try modalAction(true) {
resolve([:]);
};

Expand Down

0 comments on commit 5365fbb

Please sign in to comment.