Skip to content

Commit

Permalink
⭐️ Impl: RNIModalViewModule.requestModalInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Jan 6, 2023
1 parent 979396b commit e0bc5dd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ios/src_library/React Native/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ extension RNIModalView {
completion?(success, error);
};
};

public func requestModalInfo(
completion: CompletionHandler? = nil
){
let params = self.createModalNativeEventDict();

completion?(true, nil);
self.onRequestResult?(params);
};

// --------------------------------------
// MARK: Public Functions for ViewManager
// --------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ @interface RCT_EXTERN_MODULE(RNIModalViewModule, RCTEventEmitter)
resolve: (RCTPromiseResolveBlock *)resolve
reject : (RCTPromiseRejectBlock *)reject);

RCT_EXTERN_METHOD(requestModalInfo: (nonnull NSNumber) node
// promise blocks -----------------------
resolve: (RCTPromiseResolveBlock *)resolve
reject : (RCTPromiseRejectBlock *)reject);

@end
16 changes: 16 additions & 0 deletions ios/src_library/React Native/RNIModalView/RNIModalViewModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,20 @@ extension RNIModalViewModule {
};
};
};

@objc func requestModalInfo(
_ node: NSNumber,
// promise blocks ------------------------
resolve: @escaping RCTPromiseResolveBlock,
reject : @escaping RCTPromiseRejectBlock
){
DispatchQueue.main.async {
guard let modalView = self.getModalViewInstance(for: node) else {
reject(nil, "Unable to get the corresponding 'RNIModalView' instance for node: \(node)", nil);
return;
};

resolve(modalView.createModalNativeEventDict());
};
};
};
5 changes: 5 additions & 0 deletions src/native_modules/RNIModalViewModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ interface RNIModalViewModule {
node: number,
visibility: boolean
): Promise<RNIModalViewInfo>;

// prettier-ignore
requestModalInfo(
node: number,
): Promise<RNIModalViewInfo>;
}

export const RNIModalViewModule: RNIModalViewModule =
Expand Down

0 comments on commit e0bc5dd

Please sign in to comment.